From fcac81bfef1ebe460a99dc0465a0768ede525f1a Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Mon, 10 Oct 2016 20:37:45 +0200 Subject: First fixes towards compilation on Visual Studio 2013 --- src/database/database.cpp | 17 +++++++++++++++++ src/database/database.hpp | 17 ++++++----------- src/msvc.hpp | 39 +++++++++++++++++++++++++++++++++++++++ src/utilities.hpp | 4 ++++ 4 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 src/msvc.hpp (limited to 'src') diff --git a/src/database/database.cpp b/src/database/database.cpp index df9ac373..1198cefb 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -48,6 +48,23 @@ const std::vector Database::database = { KernelSelectionHalf, KernelSelectionSingle, KernelSelectionDouble, KernelSelectionComplexSingle, KernelSelectionComplexDouble }; +// The OpenCL device types +const std::string Database::kDeviceTypeCPU = "CPU"; +const std::string Database::kDeviceTypeGPU = "GPU"; +const std::string Database::kDeviceTypeAccelerator = "accelerator"; +const std::string Database::kDeviceTypeAll = "default"; + +// The OpenCL device vendors +const std::string Database::kDeviceVendorAll = "default"; + +// Alternative names for some OpenCL vendors +const std::unordered_map Database::kVendorNames{ + { "Intel(R) Corporation", "Intel" }, + { "GenuineIntel", "Intel" }, + { "Advanced Micro Devices, Inc.", "AMD" }, + { "NVIDIA Corporation", "NVIDIA" }, +}; + // ================================================================================================= // Constructor, computing device properties and populating the parameter-vector from the database. diff --git a/src/database/database.hpp b/src/database/database.hpp index 912f0f15..d56ed40b 100644 --- a/src/database/database.hpp +++ b/src/database/database.hpp @@ -51,21 +51,16 @@ class Database { }; // The OpenCL device types - static constexpr auto kDeviceTypeCPU = "CPU"; - static constexpr auto kDeviceTypeGPU = "GPU"; - static constexpr auto kDeviceTypeAccelerator = "accelerator"; - static constexpr auto kDeviceTypeAll = "default"; + static const std::string kDeviceTypeCPU; + static const std::string kDeviceTypeGPU; + static const std::string kDeviceTypeAccelerator; + static const std::string kDeviceTypeAll; // The OpenCL device vendors - static constexpr auto kDeviceVendorAll = "default"; + static const std::string kDeviceVendorAll; // Alternative names for some OpenCL vendors - const std::unordered_map kVendorNames { - {"Intel(R) Corporation", "Intel"}, - {"GenuineIntel", "Intel"}, - {"Advanced Micro Devices, Inc.", "AMD"}, - {"NVIDIA Corporation", "NVIDIA"}, - }; + static const std::unordered_map kVendorNames; // The database consists of separate database entries, stored together in a vector static const DatabaseEntry XaxpyHalf, XaxpySingle, XaxpyDouble, XaxpyComplexSingle, XaxpyComplexDouble; diff --git a/src/msvc.hpp b/src/msvc.hpp new file mode 100644 index 00000000..2de93371 --- /dev/null +++ b/src/msvc.hpp @@ -0,0 +1,39 @@ + +// ================================================================================================= +// 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 +// +// This file provides macro's and definitions to make compilation work on Microsoft Visual Studio, +// in particular for versions older than 2015 with limited C++11 support. +// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) +// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) +// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) +// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) +// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) +// +// ================================================================================================= + +#ifndef CLBLAST_MSVC_HPP_ +#define CLBLAST_MSVC_HPP_ + +namespace clblast { +// ================================================================================================= +#ifdef _MSC_VER + +// No support for constexpr prior to 2015. Note that this only works with constants, not with +// constexpr functions (unused in this project). +#if _MSC_VER < 1900 +#define constexpr const +#endif + +// _MSC_VER +#endif +// ================================================================================================= +} // namespace clblast + +// CLBLAST_MSVC_HPP_ +#endif \ No newline at end of file diff --git a/src/utilities.hpp b/src/utilities.hpp index 71bfc1af..02dda069 100644 --- a/src/utilities.hpp +++ b/src/utilities.hpp @@ -25,6 +25,10 @@ #include "clblast_half.h" #include "clpp11.hpp" +#ifdef _MSC_VER + #include "msvc.hpp" +#endif + namespace clblast { // ================================================================================================= -- cgit v1.2.3