Skip to content

Commit

Permalink
Changed PAUSE macro to avoid conflicts with other frameworks with the…
Browse files Browse the repository at this point in the history
… same definitions.
  • Loading branch information
nicolotonci committed Feb 13, 2024
1 parent d951af2 commit fbd8aa9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion include/mtcl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace MTCL {


#if defined(ENABLE_MPI)
const bool MPI_ENABLED = true;
#define MTCL_ENABLE_MPI
Expand Down
12 changes: 6 additions & 6 deletions include/protocols/shm_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class shmBuffer {
pthread_spin_lock(&shmp->spinlock);
if (shmp->guard==0) break;
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(1);
shmp->data.size=sz;
shmp->guard=(void*)data;
Expand All @@ -144,7 +144,7 @@ class shmBuffer {
pthread_spin_lock(&shmp->spinlock);
if (shmp->guard==0) break;
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(1);
shmp->data.size=sz;
s = std::min(size, (size_t)SHM_SMALL_MSG_SIZE);
Expand All @@ -170,7 +170,7 @@ class shmBuffer {
break;
}
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(true);

size_t size = shmp->data.size;
Expand All @@ -191,7 +191,7 @@ class shmBuffer {
pthread_spin_lock(&shmp->spinlock);
if (shmp->guard!=0) break;
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(true);
}
posix_madvise(data, sz, POSIX_MADV_NORMAL);
Expand All @@ -211,7 +211,7 @@ class shmBuffer {
break;
}
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(true);
size_t size = shmp->data.size;
pthread_spin_unlock(&shmp->spinlock);
Expand Down Expand Up @@ -250,7 +250,7 @@ class shmBuffer {
pthread_spin_lock(&shmp->spinlock);
if (shmp->guard!=0) break;
pthread_spin_unlock(&shmp->spinlock);
cpu_relax();
mtcl_cpu_relax();
} while(true);
}
posix_madvise(data, sz, POSIX_MADV_NORMAL);
Expand Down
13 changes: 7 additions & 6 deletions include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,25 @@ static inline int internal_connect(const std::string& address, int retry, unsign


#if defined(__i386__) || defined(__x86_64__)
#define PAUSE() __asm__ __volatile__ ("rep; nop" ::: "memory")
#define MTCL_PAUSE() __asm__ __volatile__ ("rep; nop" ::: "memory")
#endif // __i386

#if defined (__riscv)
#define PAUSE() /* ?? */
#define MTCL_PAUSE() /* ?? */
#endif // __riscv

#if defined(__powerpc__) || defined(__ppc__)
// yield == or 27, 27, 27
#define PAUSE() asm volatile ("or 27,27,27" ::: "memory");
#define MTCL_PAUSE() asm volatile ("or 27,27,27" ::: "memory");
#endif // __powerpc

#if defined(__arm__) || defined(__aarch64__)
#define PAUSE() asm volatile("yield" ::: "memory")
#define MTCL_PAUSE() asm volatile("yield" ::: "memory")
#endif //__arm

static inline void cpu_relax(void) {
PAUSE();

static inline void mtcl_cpu_relax(void) {
MTCL_PAUSE();
}

#endif

0 comments on commit fbd8aa9

Please sign in to comment.