aboutsummaryrefslogtreecommitdiff
path: root/nerv/lib/matrix/cukernel.cu
diff options
context:
space:
mode:
Diffstat (limited to 'nerv/lib/matrix/cukernel.cu')
-rw-r--r--nerv/lib/matrix/cukernel.cu16
1 files changed, 16 insertions, 0 deletions
diff --git a/nerv/lib/matrix/cukernel.cu b/nerv/lib/matrix/cukernel.cu
index a19030a..6fb78f0 100644
--- a/nerv/lib/matrix/cukernel.cu
+++ b/nerv/lib/matrix/cukernel.cu
@@ -1,5 +1,21 @@
#define NERV_GENERIC_CUKERNEL
+#include "cumatrix.h"
+
+__device__ double atomicAdd(double* address, double val) {
+ //atmoicAdd is not included in CUDA for double
+ unsigned long long int* address_as_ull =
+ (unsigned long long int*)address;
+ unsigned long long int old = *address_as_ull, assumed;
+ do {
+ assumed = old;
+ old = atomicCAS(address_as_ull, assumed,
+ __double_as_longlong(val +
+ __longlong_as_double(assumed)));
+ } while (assumed != old);
+ return __longlong_as_double(old);
+}
+
#define cudak_(NAME) cudak_float_ ## NAME
#define MATRIX_USE_FLOAT
#include "generic/elem_type.h"