Simple loopy test, plus gitignore cleanup

This commit is contained in:
Charlie Curtsinger 2014-07-08 17:13:36 -04:00
parent 3ea479fd4e
commit 095bfae9b9
12 changed files with 170 additions and 58 deletions

74
.gitignore vendored
View File

@ -13,50 +13,54 @@ lib/support/release
tools/inspect/debug
tools/inspect/release
tests/*/profile.log
tests/*/results.csv
tests/*/Rplots.pdf
tests/loopy/debug
tests/loopy/release
tests/loopy/profile.log
tests/histogram/debug
tests/histogram/release
tests/histogram/histogram_datafiles
benchmarks/*/profile.log
benchmarks/*/results.csv
benchmarks/*/Rplots.pdf
tests/kmeans/debug
tests/kmeans/release
benchmarks/histogram/debug
benchmarks/histogram/release
benchmarks/histogram/histogram_datafiles
tests/linear_regression/debug
tests/libear_regression/release
tests/linear_regression/linear_regression_datafiles
benchmarks/kmeans/debug
benchmarks/kmeans/release
tests/matrix_multiply/debug
tests/matrix_multiply/release
tests/matrix_multiply/matrix_file_A.txt
tests/matrix_multiply/matrix_file_B.txt
tests/matrix_multiply/matrix_file_out_pthreads.txt
benchmarks/linear_regression/debug
benchmarks/libear_regression/release
benchmarks/linear_regression/linear_regression_datafiles
tests/pbzip2/debug
tests/pbzip2/release
tests/pbzip2/data/input.txt
tests/pbzip2/data/output.txt
tests/pbzip2/bzip2-1.0.6
benchmarks/matrix_multiply/debug
benchmarks/matrix_multiply/release
benchmarks/matrix_multiply/matrix_file_A.txt
benchmarks/matrix_multiply/matrix_file_B.txt
benchmarks/matrix_multiply/matrix_file_out_pthreads.txt
tests/pca/debug
tests/pca/release
benchmarks/pbzip2/debug
benchmarks/pbzip2/release
benchmarks/pbzip2/data/input.txt
benchmarks/pbzip2/data/output.txt
benchmarks/pbzip2/bzip2-1.0.6
tests/producer_consumer/debug
tests/producer_consumer/release
benchmarks/pca/debug
benchmarks/pca/release
tests/string_match/debug
tests/string_match/release
tests/string_match/string_match_datafiles
benchmarks/producer_consumer/debug
benchmarks/producer_consumer/release
tests/unbalanced/debug
tests/unbalanced/release
benchmarks/string_match/debug
benchmarks/string_match/release
benchmarks/string_match/string_match_datafiles
tests/word_count/debug
tests/word_count/release
tests/word_count/word_count_datafiles
benchmarks/unbalanced/debug
benchmarks/unbalanced/release
tests/work_queue/debug
tests/work_queue/release
benchmarks/word_count/debug
benchmarks/word_count/release
benchmarks/word_count/word_count_datafiles
benchmarks/work_queue/debug
benchmarks/work_queue/release

View File

@ -1,5 +1,5 @@
ROOT = .
DIRS = lib tools
DIRS = lib tools benchmarks tests
include $(ROOT)/common.mk

View File

@ -4,5 +4,3 @@ DIRS = histogram kmeans linear_regression matrix_multiply \
RECURSIVE_TARGETS = debug release bench
include $(ROOT)/common.mk
DIRS = histogram linear_regression matrix_multiply \
pbzip2 pca producer_consumer string_match word_count

View File

@ -80,8 +80,7 @@ void matrixmult_splitter(void *data_in)
assert(data->matrix_B);
assert(data->output);
//CHECK_ERROR((num_procs = sysconf(_SC_NPROCESSORS_ONLN)) <= 0);
num_procs = 4;
CHECK_ERROR((num_procs = sysconf(_SC_NPROCESSORS_ONLN)) <= 0);
dprintf("THe number of processors is %d\n", num_procs);
tid = (pthread_t *)MALLOC(num_procs * sizeof(pthread_t));
@ -148,9 +147,7 @@ void *matrixmult_map(void *args_in)
value = 0;
for(j=0;j<data->matrix_len ; j++)
{
for(int k = 0; k <= 8 - SKIP_COUNT; k++) {
value += ( a_ptr[j] * (*b_ptr));
}
value += ( a_ptr[j] * (*b_ptr));
b_ptr+= data->matrix_len;
}
x_loc = (data->row_num + row_count);
@ -286,14 +283,14 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "runtime = %f\n", (usec / 1000000));
/*for(i=0;i<matrix_len*matrix_len;i++)
for(i=0;i<matrix_len*matrix_len;i++)
{
if(i%matrix_len == 0)
dprintf("\n");
dprintf("%d ",mm_data.output[i]);
//write(fd_out,&(mm_data.output[i]),sizeof(int));
write(fd_out,&(mm_data.output[i]),sizeof(int));
}
dprintf("\n");
@ -307,7 +304,7 @@ int main(int argc, char *argv[]) {
CHECK_ERROR(munmap(fdata_B, file_size + 1) < 0);
CHECK_ERROR(close(fd_B) < 0);
CHECK_ERROR(close(fd_out) < 0);*/
CHECK_ERROR(close(fd_out) < 0);
return 0;
}

View File

@ -18,9 +18,11 @@ static void __init_counter(int kind, size_t* ctr, const char* name) {
#define CAUSAL_INCREMENT_COUNTER(kind, name) \
if(1) { \
static unsigned char __causal_counter_initialized = 0; \
static size_t __causal_counter = 0; \
if(__atomic_exchange_n(&__causal_counter_initialized, 1, __ATOMIC_SEQ_CST) == 0) { \
static unsigned int __causal_counter_initialized; \
static size_t __causal_counter; \
if(__causal_counter_initialized != 0xDEADBEEF && \
__atomic_exchange_n(&__causal_counter_initialized, 0xDEADBEEF, __ATOMIC_SEQ_CST) != 0xDEADBEEF) { \
__causal_counter = 0; \
__init_counter(kind, &__causal_counter, name); \
} \
__atomic_fetch_add(&__causal_counter, 1, __ATOMIC_SEQ_CST); \
@ -33,9 +35,9 @@ static void __init_counter(int kind, size_t* ctr, const char* name) {
#define STR2(x) #x
#define STR(x) STR2(x)
#define CAUSAL_PROGRESS CAUSAL_INCREMENT_COUNTER(PROGRESS_COUNTER, __FILE__ " line " STR(__LINE__))
#define CAUSAL_BEGIN CAUSAL_INCREMENT_COUNTER(BEGIN_COUNTER, __FILE__ " line " STR(__LINE__))
#define CAUSAL_END CAUSAL_INCREMENT_COUNTER(END_COUNTER, __FILE__ " line " STR(__LINE__))
#define CAUSAL_PROGRESS CAUSAL_INCREMENT_COUNTER(PROGRESS_COUNTER, __FILE__ ":" STR(__LINE__))
#define CAUSAL_BEGIN CAUSAL_INCREMENT_COUNTER(BEGIN_COUNTER, __FILE__ ":" STR(__LINE__))
#define CAUSAL_END CAUSAL_INCREMENT_COUNTER(END_COUNTER, __FILE__ ":" STR(__LINE__))
#if defined(__cplusplus)
}

View File

@ -9,4 +9,8 @@ CFLAGS =
include $(ROOT)/common.mk
debug:: $(ROOT)/debug/lib/libcausal_support.a
release:: $(ROOT)/release/lib/libcausal_support.a
CXXFLAGS += --std=c++11 -fPIC

View File

@ -10,7 +10,7 @@
enum {
PauseSignal = 42,
SamplePeriod = 1000000, // 1ms
SamplePeriod = 2100000, // 1ms
SampleWakeupCount = 1,
MinRoundSamples = 1000
};

View File

@ -187,8 +187,8 @@ namespace profiler {
/// The perf event configuration
struct perf_event_attr pe = {
.type = PERF_TYPE_SOFTWARE,
.config = PERF_COUNT_SW_TASK_CLOCK,
.type = PERF_TYPE_HARDWARE,
.config = PERF_COUNT_HW_CPU_CYCLES,
.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME | PERF_SAMPLE_CALLCHAIN,
.sample_period = SamplePeriod,
.wakeup_events = SampleWakeupCount
@ -207,7 +207,11 @@ namespace profiler {
// If the baseline round has run long enough and we're in a known line,
// use this line for the next speedup round
if(roundSamples >= MinRoundSamples) {
selectedLine = l;
if(fixed_line) {
selectedLine = fixed_line;
} else {
selectedLine = l;
}
}
} else if(mode == Speedup) {
// Check if the sample is in the selected line

View File

@ -254,8 +254,19 @@ namespace causal_support {
}
shared_ptr<line> memory_map::find_line(const string& name) {
WARNING << "Line name searches are not yet implemented!";
return shared_ptr<line>();
string::size_type colon_pos = name.find_first_of(':');
if(colon_pos == string::npos) {
WARNING << "Could not identify file name in input " << name;
return shared_ptr<line>();
}
string filename = name.substr(0, colon_pos);
string line_no_str = name.substr(colon_pos + 1);
size_t line_no;
stringstream(line_no_str) >> line_no;
return memory_map::get_file(filename)->get_line(line_no);
}
shared_ptr<line> memory_map::find_line(uintptr_t addr) {

5
tests/Makefile Normal file
View File

@ -0,0 +1,5 @@
ROOT = ..
DIRS = loopy
RECURSIVE_TARGETS = debug release test
include $(ROOT)/common.mk

8
tests/loopy/Makefile Normal file
View File

@ -0,0 +1,8 @@
ROOT = ../..
TARGETS = loopy
LIBS = pthread dl
include $(ROOT)/common.mk
test:: debug/bin/loopy
debug/bin/loopy

79
tests/loopy/loopy.cpp Normal file
View File

@ -0,0 +1,79 @@
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <causal.h>
#define WIDTH 40000
#define HEIGHT 40000
#define MAX_SKIP_COUNT 8
struct thread_arg {
size_t index;
size_t thread_count;
size_t skip_count;
int* data;
thread_arg(size_t i, size_t t, size_t s, int* d) :
index(i), thread_count(t), skip_count(s), data(d) {}
};
void* thread_fn(void* arg) {
thread_arg* a = reinterpret_cast<thread_arg*>(arg);
for(size_t i = a->index; i < HEIGHT; i += a->thread_count) {
for(size_t k = 0; k < MAX_SKIP_COUNT; k++) {
if(k >= a->skip_count) {
for(size_t j = 0; j < WIDTH; j++) {
a->data[i * HEIGHT + j] *= 2;
}
}
}
CAUSAL_PROGRESS;
}
delete a;
return NULL;
}
size_t get_nanos() {
struct timespec ts;
if(clock_gettime(CLOCK_REALTIME, &ts)) {
fprintf(stderr, "Failed to get start time\n");
exit(2);
}
return ts.tv_sec * 1000000000 + ts.tv_nsec;
}
int main(int argc, char** argv) {
if(argc != 3) {
fprintf(stderr, "Must specify thread count and skip count on command line\n");
exit(1);
}
size_t num_threads = atoi(argv[1]);
size_t skip_count = atoi(argv[2]);
int* data = new int[WIDTH * HEIGHT];
size_t start_nanos = get_nanos();
pthread_t threads[num_threads];
for(size_t i = 0; i < num_threads; i++) {
thread_arg* arg = new thread_arg(i, num_threads, skip_count, data);
pthread_create(&threads[i], NULL, thread_fn, arg);
}
for(size_t i = 0; i < num_threads; i++) {
while(pthread_tryjoin_np(threads[i], NULL)) {}
}
size_t nanos = get_nanos() - start_nanos;
delete[] data;
fprintf(stderr, "runtime: %lu\n", nanos);
return 0;
}