Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'openbsd'

  • Loading branch information...
commit 2d4e04394efe20e668ff6e35cc182ff3ae8bc494 2 parents 5effb73 + 0f42a3e
@avsm authored
View
2  .gitignore
@@ -2,3 +2,5 @@
*_thr
*_lat
results
+summarise_tsc_counters
+.*.swp
View
48 Makefile
@@ -1,21 +1,51 @@
+all_target := posix
+uname := $(shell uname -s)
+ifeq ($(uname),Linux)
+all_target := linux
+endif
+ifeq ($(uname),OpenBSD)
+all_target := openbsd
+endif
+ifeq ($(uname),Darwin)
+all_target := darwin
+endif
+
CFLAGS = -g -Wall -O3 -D_GNU_SOURCE -DNDEBUG -std=gnu99
LDLIBS+=-lm
.PHONY: all clean run
-TARGETS=pipe_thr tcp_thr tcp_nodelay_thr unix_thr mempipe_thr mempipe_spin_thr
-TARGETS+=vmsplice_pipe_thr vmsplice_hugepages_pipe_thr vmsplice_hugepages_coop_pipe_thr vmsplice_coop_pipe_thr
-TARGETS+=shmem_pipe_thr futex_lat
-TARGETS+=pipe_lat unix_lat tcp_lat tcp_nodelay_lat mempipe_lat
-TARGETS+=summarise_tsc_counters
+CFLAGS_Linux = -DUSE_INLINE_ASM
+CFLAGS_OpenBSD = -DUSE_INLINE_ASM
+CFLAGS += -g -Wall -O3 -D_GNU_SOURCE -DNDEBUG -std=gnu99 $(CFLAGS_$(uname))
+
+LDFLAGS_Linux := -lrt -lnuma
+LDFLAGS += -lm $(LDFLAGS_$(uname))
+
+TARGETS_POSIX := pipe_thr tcp_thr tcp_nodelay_thr unix_thr mempipe_spin_thr
+TARGETS_Linux += mempipe_thr vmsplice_pipe_thr vmsplice_hugepages_pipe_thr vmsplice_hugepages_coop_pipe_thr vmsplice_coop_pipe_thr
+
+TARGETS_POSIX += pipe_lat unix_lat tcp_lat tcp_nodelay_lat mempipe_lat
+TARGETS_Linux += shmem_pipe_thr futex_lat
+
+TARGETS_POSIX += summarise_tsc_counters
+
+TARGETS_OpenBSD :=
+TARGETS_Darwin :=
+
+TARGETS := $(TARGETS_POSIX) $(TARGETS_$(uname))
+
+x-%:
+ echo $($*)
all: $(TARGETS)
+ @ :
-%_lat: atomicio.o test.o xutil.o stats.o %_lat.o
- $(CC) $(CFLAGS) -o $@ $^ -lrt -lnuma -lm
+%_lat: atomicio.o test.o xutil.o %_lat.o stats.o
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
-%_thr: atomicio.o test.o xutil.o stats.o %_thr.o
- $(CC) $(CFLAGS) -o $@ $^ -lrt -lnuma -lm
+%_thr: atomicio.o test.o xutil.o %_thr.o stats.o
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
tcp_nodelay_thr.o: tcp_thr.c
$(CC) $(CFLAGS) $^ -c -DUSE_NODELAY -o $@
View
6 mempipe_thr.c
@@ -43,7 +43,6 @@
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
-#include <linux/futex.h>
#include <assert.h>
#include <err.h>
#include <errno.h>
@@ -53,6 +52,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/uio.h>
#undef USE_MWAIT
#ifndef NO_FUTEX
@@ -61,7 +61,11 @@
#include "test.h"
#include "xutil.h"
+
+#ifdef Linux
+#include <linux/futex.h>
#include "futex.h"
+#endif
#define PAGE_SIZE 4096
#define CACHE_LINE_SIZE 64
View
1  pipe_thr.c
@@ -36,6 +36,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/uio.h>
#include <errno.h>
#include <assert.h>
View
2  tcp_lat.c
@@ -37,6 +37,8 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
+
+#include <netinet/in.h>
#include <netinet/tcp.h>
#include "test.h"
View
6 tcp_thr.c
@@ -34,12 +34,16 @@
#include <inttypes.h>
#include <netdb.h>
#include <assert.h>
-#include <netinet/tcp.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
#include <errno.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+
#include "test.h"
#include "xutil.h"
View
13 test.c
@@ -38,6 +38,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/uio.h>
#include <errno.h>
#include "test.h"
@@ -70,6 +71,7 @@ wait_for_children_to_finish(void)
}
static void stosmemset(void* buf, int byte, size_t count) {
+#ifdef USE_INLINE_ASM
int clobber;
assert(count % 8 == 0);
asm volatile ("rep stosq\n"
@@ -78,10 +80,13 @@ static void stosmemset(void* buf, int byte, size_t count) {
"D" (buf),
"0" (count / 8)
: "memory");
+#else
+ errx(1, "stosmemset: not implemented");
+#endif
}
static int repmemcmp(void* buf, int byte, size_t count) {
-
+#ifdef USE_INLINE_ASM
unsigned long clobber;
void* clobber2;
char result;
@@ -96,7 +101,9 @@ static int repmemcmp(void* buf, int byte, size_t count) {
"D" (buf)
);
return result;
-
+#else
+ errx(1, "repmemcmp: not implemented");
+#endif
}
void parent_main(test_t* test, test_data* td, int is_latency_test) {
@@ -185,7 +192,7 @@ void parent_main(test_t* test, test_data* td, int is_latency_test) {
if (is_latency_test)
logmsg(td,
"headline",
- "%s %d %" PRId64 " %fs\n", td->name, td->size, td->count,
+ "%s %d %" PRIu64 " %fs\n", td->name, td->size, td->count,
delta / (td->count * 1e6));
else
logmsg(td,
View
1  unix_thr.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/uio.h>
#include <errno.h>
#include "test.h"
View
15 xutil.c
@@ -29,7 +29,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
-#include <numa.h>
#include <sched.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -251,7 +250,7 @@ parse_args(int argc, char *argv[], bool *per_iter_timings, int *size, size_t *co
}
}
- fprintf(stderr, "size %d count %" PRId64 " first_cpu %d second_cpu %d parallel %d tsc %d produce-method %d %s %s numa_node %d output_dir %s\n",
+ fprintf(stderr, "size %d count %" PRIu64 " first_cpu %d second_cpu %d parallel %d tsc %d produce-method %d %s %s numa_node %d output_dir %s\n",
*size, *count, *first_cpu, *second_cpu, *parallel, *per_iter_timings, *produce_method, *read_in_place ? "read-in-place" : "copy-read", *write_in_place ? "write-in-place" : "copy-write",
*numa_node,
*output_dir);
@@ -260,6 +259,7 @@ parse_args(int argc, char *argv[], bool *per_iter_timings, int *size, size_t *co
void
setaffinity(int cpunum)
{
+#ifdef Linux
cpu_set_t *mask;
size_t size;
int i;
@@ -274,11 +274,19 @@ setaffinity(int cpunum)
if (i == -1)
err(1, "sched_setaffinity");
CPU_FREE(mask);
+#else
+ fprintf(stderr, "setaffinity: skipping\n");
+#endif
}
+#ifdef Linux
+#include <numa.h>
+#endif
+
void *
establish_shm_segment(int nr_pages, int numa_node)
{
+#ifdef Linux
int fd;
void *addr;
@@ -299,6 +307,9 @@ establish_shm_segment(int nr_pages, int numa_node)
close(fd);
return addr;
+#else
+ errx(1, "establish_shm_segment not implemented\n");
+#endif
}
void
View
2  xutil.h
@@ -39,4 +39,6 @@ void *establish_shm_segment(int nr_pages, int numa_node);
/* Doesn't really belong here, but doesn't really belong anywhere. */
void summarise_samples(FILE *f, double *data, int nr_samples);
+#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.