33 #ifdef __INTEL_COMPILER
34 #include <ia32intrin.h>
77 #if defined(NVBIO_DEVICE_COMPILATION)
78 return atomicAdd( value, op );
87 #if defined(NVBIO_DEVICE_COMPILATION)
88 return atomicAdd( value, op );
97 #if defined(NVBIO_DEVICE_COMPILATION)
98 return atomicAdd( value, op );
107 #if defined(NVBIO_DEVICE_COMPILATION)
108 return atomicSub( value, op );
117 #if defined(NVBIO_DEVICE_COMPILATION)
118 return atomicSub( value, op );
127 #if defined(NVBIO_DEVICE_COMPILATION)
128 return atomicOr( value, op );
137 #if defined(NVBIO_DEVICE_COMPILATION)
138 return atomicOr( value, op );
146 int32 atomic_increment(
int32 volatile *value);
147 int64 atomic_increment(
int64 volatile *value);
149 int32 atomic_decrement(
int32 volatile *value);
150 int64 atomic_decrement(
int64 volatile *value);
154 template<
typename intT>
158 AtomicInt() : m_value(0) {}
161 AtomicInt(
const intT value) : m_value(value) {}
166 return atomic_increment( &m_value );
172 return atomic_decrement( &m_value );
176 intT
operator++(
int) {
return increment()-1u; }
179 intT
operator--(
int) {
return decrement()+1u; }
188 intT
operator+=(
const intT v) {
return m_value += v; }
190 intT
operator-=(
const intT v) {
return m_value -= v; }
193 bool operator==(
const intT value) {
return m_value == value; }
194 bool operator!=(
const intT value) {
return m_value != value; }
195 bool operator>=(
const intT value) {
return m_value >= value; }
196 bool operator<=(
const intT value) {
return m_value <= value; }
197 bool operator>(
const intT value) {
return m_value > value; }
198 bool operator<(
const intT value) {
return m_value < value; }
200 volatile intT m_value;
203 typedef AtomicInt<int> AtomicInt32;
204 typedef AtomicInt<int64> AtomicInt64;
219 #if defined(PLATFORM_X86) && defined(ASM_ATOMICS)
227 __asm__ __volatile__ (
"lock; xaddl %0, %1"
238 __asm__ __volatile__ (
"lock; xaddl %0, %1"
249 __asm__ __volatile__ (
"lock; xaddl %0, %1"
260 __asm__ __volatile__ (
"lock; xaddl %0, %1"
269 register int v
asm (
"eax") = value;
271 __asm__ __volatile__ (
"lock; xaddl %0, %1"
280 register int v
asm (
"eax") = -value;
282 __asm__ __volatile__ (
"lock; xaddl %0, %1"
288 #elif defined(__INTEL_COMPILER)
345 #if defined(PLATFORM_X86) && defined(ASM_ATOMICS)
351 register long v
asm (
"eax");
353 __asm__ __volatile__ (
"lock; xaddq %0, %1"
362 register long v
asm (
"eax");
364 __asm__ __volatile__ (
"lock; xaddq %0, %1"
373 register long v
asm (
"eax");
375 __asm__ __volatile__ (
"lock; xaddq %0, %1"
384 register long v
asm (
"eax");
386 __asm__ __volatile__ (
"lock; xaddq %0, %1"
395 register long v
asm (
"eax") = value;
397 __asm__ __volatile__ (
"lock; xaddq %0, %1"
406 register long v
asm (
"eax") = -value;
408 __asm__ __volatile__ (
"lock; xaddq %0, %1"
414 #elif defined(__INTEL_COMPILER)