30 #include <cugar/basic/types.h> 32 #if defined(__CUDACC__) 33 #include <cuda_runtime.h> 37 #ifdef __INTEL_COMPILER 38 #include <ia32intrin.h> 72 CUGAR_API
void host_release_fence();
73 CUGAR_API
void host_acquire_fence();
75 CUGAR_API int32 host_atomic_add( int32* value,
const int32 op);
76 CUGAR_API uint32 host_atomic_add(uint32* value,
const uint32 op);
77 CUGAR_API int64 host_atomic_add( int64* value,
const int64 op);
78 CUGAR_API uint64 host_atomic_add(uint64* value,
const uint64 op);
80 CUGAR_API int32 host_atomic_sub( int32* value,
const int32 op);
81 CUGAR_API uint32 host_atomic_sub(uint32* value,
const uint32 op);
82 CUGAR_API int64 host_atomic_sub( int64* value,
const int64 op);
83 CUGAR_API uint64 host_atomic_sub(uint64* value,
const uint64 op);
85 CUGAR_API uint32 host_atomic_or(uint32* value,
const uint32 op);
86 CUGAR_API uint64 host_atomic_or(uint64* value,
const uint64 op);
88 CUGAR_API int32 host_atomic_increment(int32* value);
89 CUGAR_API int64 host_atomic_increment(int64* value);
91 CUGAR_API int32 host_atomic_decrement(int32* value);
92 CUGAR_API int64 host_atomic_decrement(int64* value);
94 CUGAR_API
float host_atomic_add(
float* value,
const float op);
99 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
102 #if defined(CUGAR_DEVICE_COMPILATION) 103 return atomicAdd(value, op);
105 return host_atomic_add(value, op);
111 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
114 #if defined(CUGAR_DEVICE_COMPILATION) 115 return atomicAdd( value, op );
117 return host_atomic_add( value, op );
123 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
126 #if defined(CUGAR_DEVICE_COMPILATION) 127 return atomicAdd( value, op );
129 return host_atomic_add( value, op );
135 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
138 #if defined(CUGAR_DEVICE_COMPILATION) 139 return atomicAdd( (
unsigned long long int*)value, (
unsigned long long int)op );
141 return host_atomic_add( value, op );
147 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
150 #if defined(CUGAR_DEVICE_COMPILATION) 151 return atomicSub( value, op );
153 return host_atomic_sub( value, op );
159 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
162 #if defined(CUGAR_DEVICE_COMPILATION) 163 return atomicSub( value, op );
165 return host_atomic_sub( value, op );
171 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
174 #if defined(CUGAR_DEVICE_COMPILATION) 175 return atomicOr( value, op );
177 return host_atomic_or( value, op );
183 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
186 #if defined(CUGAR_DEVICE_COMPILATION) 187 return atomicOr( (
unsigned long long int*)value, (
unsigned long long int)op );
189 return host_atomic_or( value, op );
195 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
198 #if defined(CUGAR_DEVICE_COMPILATION) 199 return atomicAdd( value, int32(1) );
201 return host_atomic_increment( value );
206 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
209 #if defined(CUGAR_DEVICE_COMPILATION) 210 return (int64)atomicAdd( (
unsigned long long int*)value, (
unsigned long long int)(1) );
212 return host_atomic_increment( value );
218 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
221 #if defined(CUGAR_DEVICE_COMPILATION) 222 return atomicSub( value, int32(1) );
224 return host_atomic_decrement( value );
229 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
232 #if defined(CUGAR_DEVICE_COMPILATION) 233 return (int64)atomicAdd( (
unsigned long long int*)value, (
unsigned long long int)(-1) );
235 return host_atomic_decrement( value );
241 template<
typename intT>
280 bool operator==(
const intT value) {
return m_value == value; }
281 bool operator!=(
const intT value) {
return m_value != value; }
282 bool operator>=(
const intT value) {
return m_value >= value; }
283 bool operator<=(
const intT value) {
return m_value <= value; }
284 bool operator>(
const intT value) {
return m_value > value; }
285 bool operator<(
const intT value) {
return m_value < value; }
287 volatile intT m_value;
bool operator==(const intT value)
compare
Definition: atomics.h:280
intT operator-=(const intT v)
decrement by v
Definition: atomics.h:277
intT operator++()
increment by one
Definition: atomics.h:269
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE int32 atomic_increment(int32 *value)
Definition: atomics.h:196
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float atomic_add(float *value, const float op)
Definition: atomics.h:100
AtomicInt()
constructor
Definition: atomics.h:245
intT increment()
increment by one
Definition: atomics.h:251
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE int32 atomic_sub(int32 *value, const int32 op)
Definition: atomics.h:148
Definition: atomics.h:242
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
intT operator++(int)
increment by one
Definition: atomics.h:263
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 atomic_or(uint32 *value, const uint32 op)
Definition: atomics.h:172
AtomicInt(const intT value)
destructor
Definition: atomics.h:248
intT operator+=(const intT v)
increment by v
Definition: atomics.h:275
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE int32 atomic_decrement(int32 *value)
Definition: atomics.h:219
intT operator--()
decrement by one
Definition: atomics.h:272
intT operator--(int)
decrement by one
Definition: atomics.h:266
intT decrement()
decrement by one
Definition: atomics.h:257