benchmark makefile updates

This commit is contained in:
Charlie Curtsinger 2014-07-07 11:40:23 -04:00
parent d1c592b097
commit 3ea479fd4e
14 changed files with 22 additions and 205 deletions

View File

@ -1,15 +1,8 @@
ROOT = ..
DIRS = histogram kmeans linear_regression matrix_multiply pbzip2 pca \
producer_consumer string_match unbalanced word_count work_queue
RECURSIVE_TARGETS = debug release test
DIRS = histogram kmeans linear_regression matrix_multiply \
pbzip2 pca producer_consumer string_match word_count
RECURSIVE_TARGETS = debug release bench
include $(ROOT)/common.mk
DIRS = histogram linear_regression matrix_multiply \
pbzip2 pca producer_consumer string_match \
unbalanced word_count work_queue
experiment:
@for dir in $(DIRS); do \
echo "$(INDENT)[$@] Entering $$dir"; \
$(MAKE) -C $$dir $@ DEBUG=$(DEBUG); \
done
pbzip2 pca producer_consumer string_match word_count

View File

@ -12,6 +12,6 @@ histogram_datafiles/%:
tar xvzf histogram.tar.gz
rm histogram.tar.gz
test:: debug/bin/histogram setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/histogram $(ARGS)
bench:: debug/bin/histogram setup
causal --- debug/bin/histogram $(ARGS)

View File

@ -5,5 +5,5 @@ ARGS =
include $(ROOT)/common.mk
test:: debug/bin/kmeans
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/kmeans $(ARGS)
bench:: debug/bin/kmeans
causal --- debug/bin/kmeans $(ARGS)

View File

@ -12,5 +12,5 @@ linear_regression_datafiles/%:
tar xvzf linear_regression.tar.gz
rm linear_regression.tar.gz
test:: debug/bin/linear_regression setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/linear_regression $(ARGS)
bench:: debug/bin/linear_regression setup
causal --- debug/bin/linear_regression $(ARGS)

View File

@ -11,5 +11,5 @@ setup: matrix_file_A.txt matrix_file_B.txt
matrix_file_A.txt matrix_file_B.txt: debug/bin/matrix_multiply
./debug/bin/matrix_multiply $(MATRIX_SIZE) $(MATRIX_SIZE) > /dev/null
test:: debug/bin/matrix_multiply setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/matrix_multiply $(ARGS)
bench:: debug/bin/matrix_multiply setup
causal --- debug/bin/matrix_multiply $(ARGS)

View File

@ -31,5 +31,5 @@ data/input.txt:
mkdir -p data
cp ../linear_regression/linear_regression_datafiles/key_file_500MB.txt data/input.txt
test:: debug/bin/pbzip2 setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/pbzip2 --causal-profile libbz2 $(ARGS)
bench:: debug/bin/pbzip2 setup
causal -i libbz2 --- debug/bin/pbzip2 $(ARGS)

View File

@ -5,5 +5,5 @@ ARGS = > /dev/null
include $(ROOT)/common.mk
test:: debug/bin/pca
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/pca $(ARGS)
bench:: debug/bin/pca
causal --- debug/bin/pca $(ARGS)

View File

@ -5,5 +5,5 @@ ARGS =
include $(ROOT)/common.mk
test:: debug/bin/producer_consumer
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/producer_consumer $(ARGS)
bench:: debug/bin/producer_consumer
causal --- debug/bin/producer_consumer $(ARGS)

View File

@ -12,5 +12,5 @@ string_match_datafiles/%:
tar xvzf string_match.tar.gz
rm string_match.tar.gz
test:: debug/bin/string_match setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/string_match $(ARGS)
bench:: debug/bin/string_match setup
causal --- debug/bin/string_match $(ARGS)

View File

@ -1,9 +0,0 @@
ROOT = ../..
TARGETS = unbalanced
LIBS = pthread dl
ARGS =
include $(ROOT)/common.mk
test:: debug/bin/unbalanced
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/unbalanced $(ARGS)

View File

@ -1,58 +0,0 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <pthread.h>
#include <queue>
#include <time.h>
#include <list>
using namespace std;
enum { N = 5000 };
static void wait(size_t ns) {
struct timespec ts;
ts.tv_nsec = ns % (1000 * 1000 * 1000);
ts.tv_sec = (ns - ts.tv_nsec) / (1000 * 1000 * 1000);
while(nanosleep(&ts, &ts) != 0) {}
}
void foo() {
static int x = 0;
for(int i=0; i<N; i++) {
x++;
}
}
void bar() {
static int y = 0;
for(int i=0; i<N; i++) {
wait(250);
y++;
}
}
void* thread1(void* arg) {
foo();
return NULL;
}
void* thread2(void* arg) {
bar();
return NULL;
}
int main(int argc, char** argv) {
pthread_t t1, t2;
pthread_create(&t1, NULL, thread1, NULL);
pthread_create(&t2, NULL, thread2, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
return 0;
}

View File

@ -12,5 +12,5 @@ word_count_datafiles/%:
tar xvzf word_count.tar.gz
rm word_count.tar.gz
test:: debug/bin/word_count setup
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/word_count $(ARGS)
bench:: debug/bin/word_count setup
causal --- debug/bin/word_count $(ARGS)

View File

@ -1,11 +0,0 @@
ROOT = ../..
TARGETS = work_queue
LIBS = pthread dl
#ARGS = --causal-select-block _Z11work_item_Av 0
CFLAGS = -O3
include $(ROOT)/common.mk
test:: debug/bin/work_queue
LD_PRELOAD=$(ROOT)/debug/lib/libcausal.so ./debug/bin/work_queue $(ARGS)

View File

@ -1,98 +0,0 @@
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <pthread.h>
#include <queue>
#include <time.h>
#include <causal.h>
using namespace std;
enum {
WorkerCount = 8,
WorkItemCount = 10000000,
WeightA = 3,
WeightB = 2,
WeightC = 1
};
void work_item_A();
void work_item_B();
void work_item_C();
int a = 0;
int b = 0;
int c = 0;
typedef void (*work_item_t)();
queue<work_item_t> work_queue;
pthread_mutex_t work_queue_lock = PTHREAD_MUTEX_INITIALIZER;
void* worker(void* arg) {
while(true) {
pthread_mutex_lock(&work_queue_lock);
// Exit if the work queue is empty
if(work_queue.empty()) {
pthread_mutex_unlock(&work_queue_lock);
return NULL;
}
// Take an item off the queue and unlock it
work_item_t item = work_queue.front();
work_queue.pop();
pthread_mutex_unlock(&work_queue_lock);
// Do work
item();
CAUSAL_PROGRESS;
}
}
void work_item_A() {
a++;
}
void work_item_B() {
b++;
}
void work_item_C() {
c++;
}
void fill_work_queue() {
for(size_t i=0; i<WorkItemCount; i++) {
int r = rand() % (WeightA + WeightB + WeightC);
if(r < WeightA) {
work_queue.push(work_item_A);
} else if(r < WeightA + WeightB) {
work_queue.push(work_item_B);
} else {
work_queue.push(work_item_C);
}
}
}
int main(int argc, char** argv) {
for(int i=0; i<argc; i++) {
fprintf(stderr, "%d: %s\n", i, argv[i]);
}
fill_work_queue();
pthread_t workers[WorkerCount];
for(size_t i=0; i<WorkerCount; i++) {
pthread_create(&workers[i], NULL, worker, NULL);
}
for(size_t i=0; i<WorkerCount; i++) {
pthread_join(workers[i], NULL);
}
fprintf(stderr, "A: %d\n", a);
fprintf(stderr, "B: %d\n", b);
fprintf(stderr, "C: %d\n", c);
return 0;
}