2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
// =================================================================================================
|
|
|
|
// This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This
|
|
|
|
// project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max-
|
|
|
|
// width of 100 characters per line.
|
|
|
|
//
|
|
|
|
// Author(s):
|
|
|
|
// Cedric Nugteren <www.cedricnugteren.nl>
|
|
|
|
//
|
|
|
|
// This file implements the Database class, providing a static variable holding the actual database
|
|
|
|
// information. The class also provides utility functions to search the database and to access a
|
|
|
|
// found entry by parameter-key. The database itself is filled in the corresponding source-file and
|
|
|
|
// partially also by the database/xxxxx.h files, in which kernel-specific parameters are found.
|
|
|
|
//
|
|
|
|
// =================================================================================================
|
|
|
|
|
|
|
|
#ifndef CLBLAST_DATABASE_H_
|
|
|
|
#define CLBLAST_DATABASE_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "internal/utilities.h"
|
|
|
|
|
|
|
|
namespace clblast {
|
|
|
|
// =================================================================================================
|
|
|
|
|
|
|
|
// See comment at top of file for a description of the class
|
|
|
|
class Database {
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Type alias for the database parameters
|
|
|
|
using Parameters = std::unordered_map<std::string,size_t>;
|
|
|
|
|
|
|
|
// Structures for content inside the database
|
|
|
|
struct DatabaseDevice {
|
|
|
|
const std::string name;
|
|
|
|
const Parameters parameters;
|
|
|
|
};
|
|
|
|
struct DatabaseVendor {
|
2015-07-27 07:18:06 +02:00
|
|
|
const std::string type;
|
2015-05-30 12:30:43 +02:00
|
|
|
const std::string name;
|
|
|
|
const std::vector<DatabaseDevice> devices;
|
|
|
|
};
|
|
|
|
struct DatabaseEntry {
|
|
|
|
const std::string kernel;
|
|
|
|
const Precision precision;
|
|
|
|
const std::vector<DatabaseVendor> vendors;
|
|
|
|
};
|
|
|
|
|
2015-07-27 07:18:06 +02:00
|
|
|
// The OpenCL device types
|
|
|
|
static constexpr auto kDeviceTypeCPU = "CPU";
|
|
|
|
static constexpr auto kDeviceTypeGPU = "GPU";
|
|
|
|
static constexpr auto kDeviceTypeAccelerator = "accelerator";
|
|
|
|
static constexpr auto kDeviceTypeAll = "default";
|
|
|
|
|
|
|
|
// The OpenCL device vendors
|
|
|
|
static constexpr auto kDeviceVendorNVIDIA = "NVIDIA Corporation";
|
|
|
|
static constexpr auto kDeviceVendorAMD = "Advanced Micro Devices, Inc.";
|
|
|
|
static constexpr auto kDeviceVendorIntel = "Intel";
|
|
|
|
static constexpr auto kDeviceVendorAll = "default";
|
|
|
|
|
|
|
|
// The OpenCL device names
|
|
|
|
static constexpr auto kDefaultDevice = "default";
|
|
|
|
|
2015-05-30 12:30:43 +02:00
|
|
|
|
|
|
|
// The database consists of separate database entries, stored together in a vector
|
|
|
|
static const DatabaseEntry XaxpySingle, XaxpyDouble, XaxpyComplexSingle, XaxpyComplexDouble;
|
2015-09-14 16:57:00 +02:00
|
|
|
static const DatabaseEntry XdotSingle, XdotDouble, XdotComplexSingle, XdotComplexDouble;
|
2015-06-13 11:01:20 +02:00
|
|
|
static const DatabaseEntry XgemvSingle, XgemvDouble, XgemvComplexSingle, XgemvComplexDouble;
|
2015-05-30 12:30:43 +02:00
|
|
|
static const DatabaseEntry XgemmSingle, XgemmDouble, XgemmComplexSingle, XgemmComplexDouble;
|
|
|
|
static const DatabaseEntry CopySingle, CopyDouble, CopyComplexSingle, CopyComplexDouble;
|
|
|
|
static const DatabaseEntry PadSingle, PadDouble, PadComplexSingle, PadComplexDouble;
|
|
|
|
static const DatabaseEntry TraSingle, TraDouble, TraComplexSingle, TraComplexDouble;
|
|
|
|
static const DatabaseEntry PadTraSingle, PadTraDouble, PadTraComplexSingle, PadTraComplexDouble;
|
|
|
|
static const std::vector<DatabaseEntry> database;
|
|
|
|
|
|
|
|
// The constructor
|
2015-07-27 07:18:06 +02:00
|
|
|
explicit Database(const Queue &queue, const std::vector<std::string> &routines,
|
2015-05-30 12:30:43 +02:00
|
|
|
const Precision precision);
|
|
|
|
|
|
|
|
// Accessor of values by key
|
|
|
|
size_t operator[](const std::string key) const { return parameters_.find(key)->second; }
|
|
|
|
|
|
|
|
// Obtain a list of OpenCL pre-processor defines based on the parameters
|
|
|
|
std::string GetDefines() const;
|
|
|
|
|
|
|
|
private:
|
2015-07-27 07:18:06 +02:00
|
|
|
Parameters Search(const std::string &this_kernel, const std::string &this_type,
|
2015-05-30 12:30:43 +02:00
|
|
|
const std::string &this_vendor, const std::string &this_device,
|
|
|
|
const Precision this_precision) const;
|
|
|
|
|
|
|
|
// Found parameters suitable for this device/kernel
|
|
|
|
Parameters parameters_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// =================================================================================================
|
|
|
|
} // namespace clblast
|
|
|
|
|
|
|
|
// CLBLAST_DATABASE_H_
|
|
|
|
#endif
|