1 2 // ================================================================================================= 3 // This file is part of the CLBlast project. The project is licensed under Apache Version 2.0. This 4 // project loosely follows the Google C++ styleguide and uses a tab-size of two spaces and a max- 5 // width of 100 characters per line. 6 // 7 // Author(s): 8 // Cedric Nugteren <www.cedricnugteren.nl> 9 // 10 // This file describes the database storage structures. 11 // 12 // ================================================================================================= 13 14 #ifndef CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ 15 #define CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ 16 17 #include <string> 18 #include <array> 19 #include <vector> 20 #include <unordered_map> 21 22 namespace clblast { 23 // A special namespace to hold all the global constant variables (including the database entries) 24 namespace database { 25 26 // ================================================================================================= 27 28 // Type alias for the database storage (arrays for fast compilation/efficiency) 29 using Name = std::array<char, 51>; // name as stored in database (50 chars + string terminator) 30 using Params = std::array<size_t, 14>; // parameters as stored in database 31 32 // Type alias after extracting from the database (map for improved code readability) 33 using Parameters = std::unordered_map<std::string, size_t>; // parameters after reading from DB 34 35 // The OpenCL device types 36 const std::string kDeviceTypeCPU = "CPU"; 37 const std::string kDeviceTypeGPU = "GPU"; 38 const std::string kDeviceTypeAccelerator = "accelerator"; 39 const std::string kDeviceTypeAll = "default"; 40 const Name kDeviceNameDefault = {"default "}; 41 42 struct DatabaseDevice { 43 Name name; 44 Params parameters; // parameter values 45 46 }; 47 struct DatabaseArchitecture { 48 std::string name; 49 std::vector<DatabaseDevice> devices; 50 }; 51 struct DatabaseVendor { 52 std::string type; 53 std::string name; 54 std::vector<DatabaseArchitecture> architectures; 55 }; 56 struct DatabaseEntry { 57 std::string kernel; 58 Precision precision; 59 std::vector<std::string> parameter_names; 60 std::vector<DatabaseVendor> vendors; 61 }; 62 63 // ================================================================================================= 64 } // namespace database 65 } // namespace clblast 66 67 // CLBLAST_DATABASE_DATABASE_STRUCTURE_H_ 68 #endif 69