summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Nugteren <web@cedricnugteren.nl>2016-10-13 08:34:07 +0200
committerGitHub <noreply@github.com>2016-10-13 08:34:07 +0200
commit541415374fa47b328aed9b927a5be97914e75e8d (patch)
tree7e39659250f739d16de813501d50e3a6f98cbfe2
parent39afc9543b5d255ac140fb2529a0332813bab39a (diff)
parentc60f6715f8f420333912d6be33ed64191dbf8aae (diff)
Merge pull request #108 from CNugteren/msvc2013
Support for Visual Studio 2013
-rw-r--r--CHANGELOG1
-rw-r--r--README.md2
-rw-r--r--include/clblast_half.h5
-rw-r--r--src/database/database.cpp17
-rw-r--r--src/database/database.hpp33
-rw-r--r--src/msvc.hpp39
-rw-r--r--src/routines/level3/xgemm.cpp9
-rw-r--r--src/utilities.hpp4
8 files changed, 86 insertions, 24 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 87ecccce..34e1736b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ Development version (next release)
- Updated to version 8.0 of the CLCudaAPI C++11 OpenCL header
- Improved performance of GEMM kernels for small sizes by using a direct single-kernel implementation
- Fixed a bug in the tests and samples related to waiting for an invalid event
+- Added support for compilation under Visual Studio 2013 (MSVC++ 12.0)
- Added an option to set OpenCL compiler options through the env variable CLBLAST_BUILD_OPTIONS
- Added an option to run tuned kernels multiple times to average execution times
- Various minor fixes and enhancements
diff --git a/README.md b/README.md
index f53b4dda..a8e79c39 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ The pre-requisites for compilation of CLBlast are:
- Clang 3.3 or newer
- AppleClang 5.0 or newer
- ICC 14.0 or newer
- - MSVC (Visual Studio) 2015 or newer
+ - MSVC (Visual Studio) 2013 or newer
* An OpenCL 1.1 or newer library, for example:
- Apple OpenCL
- NVIDIA CUDA SDK
diff --git a/include/clblast_half.h b/include/clblast_half.h
index 269a520e..05d96f9f 100644
--- a/include/clblast_half.h
+++ b/include/clblast_half.h
@@ -25,6 +25,11 @@
#include <CL/opencl.h>
#endif
+// MSVC 2013 doesn't fully support C99
+#ifdef _MSC_VER
+ #define inline __inline
+#endif
+
// =================================================================================================
// Host data-type for half-precision floating-point (16-bit). This is based on the OpenCL type,
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::DatabaseEntry> 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<std::string, std::string> 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..346fe089 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -36,36 +36,31 @@ class Database {
// Structures for content inside the database
struct DatabaseDevice {
- const std::string name;
- const Parameters parameters;
+ std::string name;
+ Parameters parameters;
};
struct DatabaseVendor {
- const std::string type;
- const std::string name;
- const std::vector<DatabaseDevice> devices;
+ std::string type;
+ std::string name;
+ std::vector<DatabaseDevice> devices;
};
struct DatabaseEntry {
- const std::string kernel;
- const Precision precision;
- const std::vector<DatabaseVendor> vendors;
+ std::string kernel;
+ Precision precision;
+ std::vector<DatabaseVendor> vendors;
};
// 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<std::string,std::string> kVendorNames {
- {"Intel(R) Corporation", "Intel"},
- {"GenuineIntel", "Intel"},
- {"Advanced Micro Devices, Inc.", "AMD"},
- {"NVIDIA Corporation", "NVIDIA"},
- };
+ static const std::unordered_map<std::string, std::string> 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..a45105df
--- /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 <www.cedricnugteren.nl>
+//
+// 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
diff --git a/src/routines/level3/xgemm.cpp b/src/routines/level3/xgemm.cpp
index 9d912374..1602c69f 100644
--- a/src/routines/level3/xgemm.cpp
+++ b/src/routines/level3/xgemm.cpp
@@ -34,13 +34,16 @@ Xgemm<T>::Xgemm(Queue &queue, EventPointer event, const std::string &name):
#include "../../kernels/level3/convert_symmetric.opencl"
#include "../../kernels/level3/convert_triangular.opencl"
#include "../../kernels/level3/convert_hermitian.opencl"
- #include "../../kernels/level3/xgemm_part1.opencl"
- #include "../../kernels/level3/xgemm_part2.opencl"
- #include "../../kernels/level3/xgemm_part3.opencl"
#include "../../kernels/level3/xgemm_direct_part1.opencl"
#include "../../kernels/level3/xgemm_direct_part2.opencl"
#include "../../kernels/level3/xgemm_direct_part3.opencl"
;
+ auto source_string_part_2 = // separated in two parts to prevent C1091 in MSVC 2013
+ #include "../../kernels/level3/xgemm_part1.opencl"
+ #include "../../kernels/level3/xgemm_part2.opencl"
+ #include "../../kernels/level3/xgemm_part3.opencl"
+ ;
+ source_string_ += source_string_part_2;
}
// =================================================================================================
diff --git a/src/utilities.hpp b/src/utilities.hpp
index 71bfc1af..038a8a96 100644
--- a/src/utilities.hpp
+++ b/src/utilities.hpp
@@ -25,6 +25,8 @@
#include "clblast_half.h"
#include "clpp11.hpp"
+#include "msvc.hpp"
+
namespace clblast {
// =================================================================================================
@@ -206,7 +208,7 @@ bool CheckArgument(const int argc, char *argv[], std::string &help, const std::s
// =================================================================================================
// Helper function to check for errors in the status code
-constexpr bool ErrorIn(const StatusCode s) { return (s != StatusCode::kSuccess); }
+inline bool ErrorIn(const StatusCode s) { return (s != StatusCode::kSuccess); }
// =================================================================================================