Skip to content

Commit

Permalink
add cuda arch 3.5 compilation support for ABACUS (#2794)
Browse files Browse the repository at this point in the history
  • Loading branch information
denghuilu authored Aug 4, 2023
1 parent ce14dcc commit cf1270f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
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

0 comments on commit cf1270f

Please sign in to comment.