Skip to content
Snippets Groups Projects
Commit 276b8405 authored by Rafael Ravedutti's avatar Rafael Ravedutti
Browse files

Add device functions to header

parent 446868a3
Branches
Tags
No related merge requests found
...@@ -41,15 +41,4 @@ __host__ void copy_static_symbol_to_host(void *d_ptr, const void *h_ptr, size_t ...@@ -41,15 +41,4 @@ __host__ void copy_static_symbol_to_host(void *d_ptr, const void *h_ptr, size_t
//CUDA_ASSERT(cudaMemcpyFromSymbol(h_ptr, d_ptr, count)); //CUDA_ASSERT(cudaMemcpyFromSymbol(h_ptr, d_ptr, count));
} }
__device__ int atomic_add(int *addr, int val) { return atomicAdd(addr, val); }
__device__ int atomic_add_resize_check(int *addr, int val, int *resize, int capacity) {
const int add_res = *addr + val;
if(add_res >= capacity) {
*resize = add_res;
return *addr;
}
return atomic_add(addr, val);
}
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef PAIRS_TARGET_CUDA #ifndef PAIRS_TARGET_CUDA
# define __host__ # define __host__
# define __device__
typedef int cudaError_t; typedef int cudaError_t;
#endif #endif
...@@ -18,7 +17,21 @@ __host__ void copy_to_device(const void *h_ptr, void *d_ptr, size_t count); ...@@ -18,7 +17,21 @@ __host__ void copy_to_device(const void *h_ptr, void *d_ptr, size_t count);
__host__ void copy_to_host(const void *d_ptr, void *h_ptr, size_t count); __host__ void copy_to_host(const void *d_ptr, void *h_ptr, size_t count);
__host__ void copy_static_symbol_to_device(void *h_ptr, const void *d_ptr, size_t count); __host__ void copy_static_symbol_to_device(void *h_ptr, const void *d_ptr, size_t count);
__host__ void copy_static_symbol_to_host(void *d_ptr, const void *h_ptr, size_t count); __host__ void copy_static_symbol_to_host(void *d_ptr, const void *h_ptr, size_t count);
__device__ int atomic_add(int *addr, int val);
__device__ int atomic_add_resize_check(int *addr, int val, int *resize, int capacity); #ifdef PAIRS_TARGET_CUDA
__device__ int atomic_add(int *addr, int val) { return atomicAdd(addr, val); }
__device__ int atomic_add_resize_check(int *addr, int val, int *resize, int capacity) {
const int add_res = *addr + val;
if(add_res >= capacity) {
*resize = add_res;
return *addr;
}
return atomic_add(addr, val);
}
#else
int atomic_add(int *addr, int val);
int atomic_add_resize_check(int *addr, int val, int *resize, int capacity);
#endif
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment