[clblas] 24/75: proposed fix for gemm thread safety; using thread-local storage for kernel map using pre-C++-11 syntax
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jan 24 23:30:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/master
in repository clblas.
commit 3e2c8264bbd83058b5ad5e1df60aaab64fee011b
Author: David Tanner <guacamoleo at gmail.com>
Date: Mon Feb 29 15:20:16 2016 -0600
proposed fix for gemm thread safety; using thread-local storage for kernel map using pre-C++-11 syntax
---
src/library/blas/xgemm.cc | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/library/blas/xgemm.cc b/src/library/blas/xgemm.cc
index 71165dd..67e2e50 100644
--- a/src/library/blas/xgemm.cc
+++ b/src/library/blas/xgemm.cc
@@ -17,6 +17,7 @@
#include <map>
#include <string>
#include <sstream>
+#include <thread>
#include <stdio.h>
#include <string.h>
#include <clBLAS.h>
@@ -135,7 +136,17 @@ void makeGemmKernel(
{
//TODO: This will need to be converted to thread local when making clBLAS thread safe
typedef std::map<std::string, cl_kernel> kernel_map_t;
- static kernel_map_t kernel_map;
+
+#if defined( _WIN32 )
+ __declspec( thread ) static kernel_map_t *kernel_map = 0;
+
+
+#else
+ __thread static kernel_map_t *kernel_map = 0;
+#endif
+ if (!kernel_map) {
+ kernel_map = new kernel_map_t();
+ }
cl_context clContext;
cl_device_id clDevice;
@@ -159,11 +170,11 @@ void makeGemmKernel(
// Check if kernel exists for this device
std::string key = prefix + "_" + kernelName;
- kernel_map_t::iterator idx = kernel_map.find(key);
+ kernel_map_t::iterator idx = kernel_map->find(key);
// If kernel not found for this device, set to NULL
- if (idx == kernel_map.end()) {
+ if (idx == kernel_map->end()) {
*clKernel = NULL;
} else {
*clKernel = idx->second;
@@ -251,7 +262,7 @@ void makeGemmKernel(
#endif
std::string key = prefix + "_" + kernelName;
- kernel_map[key] = *clKernel;
+ (*kernel_map)[key] = *clKernel;
delete[] kernelName;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clblas.git
More information about the debian-science-commits
mailing list