diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2017-09-16 20:37:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-16 20:37:09 +0200 |
commit | 7d0ef8e10d05ee3a18360295c021ab6a6ef32c2d (patch) | |
tree | 55d795f06769134601f017f50d505a6c8904d398 /src/database/database_structure.hpp | |
parent | bb947890dec90712c92028c20234eafd48e6fa3e (diff) | |
parent | bcf39eb79a8252b9f9b0c31311c7951abc8520ee (diff) |
Merge pull request #191 from CNugteren/database_improvements
Database improvements
Diffstat (limited to 'src/database/database_structure.hpp')
-rw-r--r-- | src/database/database_structure.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/database/database_structure.hpp b/src/database/database_structure.hpp new file mode 100644 index 00000000..d592d7ac --- /dev/null +++ b/src/database/database_structure.hpp @@ -0,0 +1,67 @@ + +// ================================================================================================= +// 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 describes the database storage structures. +// +// ================================================================================================= + +#ifndef CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ +#define CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ + +#include <string> +#include <array> +#include <vector> +#include <unordered_map> + +namespace clblast { +// A special namespace to hold all the global constant variables (including the database entries) +namespace database { + +// ================================================================================================= + +// Type alias for the database storage (arrays for fast compilation/efficiency) +using Name = std::array<char, 51>; // name as stored in database (50 chars + string terminator) +using Params = std::array<size_t, 14>; // parameters as stored in database + +// Type alias after extracting from the database (map for improved code readability) +using Parameters = std::unordered_map<std::string, size_t>; // parameters after reading from DB + +// The OpenCL device types +const std::string kDeviceTypeCPU = "CPU"; +const std::string kDeviceTypeGPU = "GPU"; +const std::string kDeviceTypeAccelerator = "accelerator"; +const std::string kDeviceTypeAll = "default"; +const Name kDeviceNameDefault = {"default "}; + +struct DatabaseDevice { + const Name name; + const Params parameters; // parameter values +}; +struct DatabaseArchitecture { + const std::string name; + const std::vector<DatabaseDevice> devices; +}; +struct DatabaseVendor { + const std::string type; + const std::string name; + const std::vector<DatabaseArchitecture> architectures; +}; +struct DatabaseEntry { + const std::string kernel; + const Precision precision; + const std::vector<std::string> parameter_names; + const std::vector<DatabaseVendor> vendors; +}; + +// ================================================================================================= +} // namespace database +} // namespace clblast + +// CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ +#endif |