int main()
{
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
time1 = caa_get_cycles();
loop_sleep(NR_LOOPS);
int main(int argc, char **argv)
{
unsigned long i;
- cycles_t time1, time2;
- cycles_t time_tot = 0;
+ caa_cycles_t time1, time2;
+ caa_cycles_t time_tot = 0;
double cpl;
for (i = 0; i < TESTS; i++) {
#define NR_READ num_read
#define NR_WRITE num_write
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
void *thr_reader(void *arg)
{
int i, j;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
long tidx = (long)arg;
printf("thread_begin %s, tid %lu\n",
{
int i, j;
long tidx;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"writer", urcu_get_thread_id());
pthread_t *tid_reader, *tid_writer;
void *tret;
int i;
- cycles_t tot_rtime = 0;
- cycles_t tot_wtime = 0;
+ caa_cycles_t tot_rtime = 0;
+ caa_cycles_t tot_wtime = 0;
if (argc < 2) {
printf("Usage : %s nr_readers nr_writers\n", argv[0]);
#define NR_READ num_read
#define NR_WRITE num_write
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
void *thr_reader(void *arg)
{
int i, j;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"reader", urcu_get_thread_id());
void *thr_writer(void *arg)
{
int i, j;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"writer", urcu_get_thread_id());
pthread_t *tid_reader, *tid_writer;
void *tret;
int i;
- cycles_t tot_rtime = 0;
- cycles_t tot_wtime = 0;
+ caa_cycles_t tot_rtime = 0;
+ caa_cycles_t tot_wtime = 0;
if (argc < 2) {
printf("Usage : %s nr_readers nr_writers\n", argv[0]);
#define NR_READ num_read
#define NR_WRITE num_write
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
void *thr_reader(void *arg)
{
int i, j;
struct test_array *local_ptr;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"reader", urcu_get_thread_id());
{
int i, j;
struct test_array *new, *old;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"writer", urcu_get_thread_id());
pthread_t *tid_reader, *tid_writer;
void *tret;
int i;
- cycles_t tot_rtime = 0;
- cycles_t tot_wtime = 0;
+ caa_cycles_t tot_rtime = 0;
+ caa_cycles_t tot_wtime = 0;
if (argc < 2) {
printf("Usage : %s nr_readers nr_writers\n", argv[0]);
#define NR_READ num_read
#define NR_WRITE num_write
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
-static cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *reader_time;
+static caa_cycles_t __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *writer_time;
void *thr_reader(void *arg)
{
int i, j;
struct test_array *local_ptr;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"reader", urcu_get_thread_id());
{
int i, j;
struct test_array *new, *old;
- cycles_t time1, time2;
+ caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
"writer", urcu_get_thread_id());
pthread_t *tid_reader, *tid_writer;
void *tret;
int i;
- cycles_t tot_rtime = 0;
- cycles_t tot_wtime = 0;
+ caa_cycles_t tot_rtime = 0;
+ caa_cycles_t tot_wtime = 0;
if (argc < 2) {
printf("Usage : %s nr_readers nr_writers\n", argv[0]);
#ifndef HAS_CAA_GET_CYCLES
#define HAS_CAA_GET_CYCLES
-typedef unsigned long long cycles_t;
-static inline cycles_t caa_get_cycles (void)
+#include <time.h>
+#include <stdint.h>
+
+typedef uint64_t caa_cycles_t;
+
+static inline caa_cycles_t caa_get_cycles (void)
{
- cycles_t thetime;
- struct timeval tv;
+ struct timespec ts;
- if (gettimeofday(&tv, NULL) != 0)
- return 0;
- thetime = ((cycles_t)tv.tv_sec) * 1000000ULL + ((cycles_t)tv.tv_usec);
- return (cycles_t)thetime;
+ if (caa_unlikely(clock_gettime(CLOCK_MONOTONIC, &ts)))
+ return -1ULL;
+ return ((uint64_t) ts.tv_sec * 1000000000ULL) + ts.tv_nsec;
}
#endif /* HAS_CAA_GET_CYCLES */
#include <sys/time.h>
#define HAS_CAA_GET_CYCLES
-typedef unsigned long cycles_t;
+typedef unsigned long caa_cycles_t;
-static inline cycles_t caa_get_cycles(void)
+static inline caa_cycles_t caa_get_cycles(void)
{
- cycles_t cycles;
+ caa_cycles_t cycles;
asm volatile("mfctl 16, %0" : "=r" (cycles));
return cycles;
#include <urcu/compiler.h>
#include <urcu/config.h>
#include <urcu/syscall-compat.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#define HAS_CAA_GET_CYCLES
-typedef unsigned long long cycles_t;
+typedef uint64_t caa_cycles_t;
#ifdef __powerpc64__
-static inline cycles_t caa_get_cycles(void)
+static inline caa_cycles_t caa_get_cycles(void)
{
- return (cycles_t) mftb();
+ return (caa_cycles_t) mftb();
}
#else
-static inline cycles_t caa_get_cycles(void)
+static inline caa_cycles_t caa_get_cycles(void)
{
unsigned long h, l;
l = mftbl();
cmm_barrier();
if (mftbu() == h)
- return (((cycles_t) h) << 32) + l;
+ return (((caa_cycles_t) h) << 32) + l;
}
}
#endif
#include <urcu/compiler.h>
#include <urcu/config.h>
#include <urcu/syscall-compat.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#define HAS_CAA_GET_CYCLES
-typedef unsigned long long cycles_t;
+typedef uint64_t caa_cycles_t;
-static inline cycles_t caa_get_cycles (void)
+static inline caa_cycles_t caa_get_cycles (void)
{
- cycles_t cycles;
+ caa_cycles_t cycles;
__asm__ __volatile__("stck %0" : "=m" (cycles) : : "cc", "memory" );
#include <urcu/compiler.h>
#include <urcu/config.h>
#include <urcu/syscall-compat.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
| (((unsigned long long)__d) << 32); \
} while(0)
-typedef unsigned long long cycles_t;
+typedef uint64_t caa_cycles_t;
-static inline cycles_t caa_get_cycles(void)
+static inline caa_cycles_t caa_get_cycles(void)
{
- cycles_t ret = 0;
+ caa_cycles_t ret = 0;
rdtscll(ret);
return ret;