Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "module_hamilt_pw/hamilt_pwdft/kernels/force_op.h"
#include "module_psi/kernels/device.h"

#include <complex>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "module_hamilt_pw/hamilt_pwdft/kernels/stress_op.h"
#include "module_psi/kernels/device.h"

#include <complex>
#include <thrust/complex.h>
Expand Down
15 changes: 15 additions & 0 deletions source/module_psi/kernels/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
#include <complex>
#include <iostream>

#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600
static __inline__ __device__ double atomicAdd(double *address, double val) {
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)));
// Note: uses integer comparison to avoid hang in case of NaN (since NaN !=
// NaN) } while (assumed != old);
} while (assumed != old);
return __longlong_as_double(old);
}
#endif

namespace psi {
namespace device {

Expand Down