-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from nkallima/v3.1.0-dev
Releasing v3.1.0
- Loading branch information
Showing
16 changed files
with
716 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
#include <config.h> | ||
#include <primitives.h> | ||
#include <fastrand.h> | ||
#include <threadtools.h> | ||
#include <fc.h> | ||
#include <barrier.h> | ||
#include <bench_args.h> | ||
#include <fam.h> | ||
|
||
ObjectState *object CACHE_ALIGN; | ||
FCStruct *object_combiner; | ||
int64_t d1, d2; | ||
SynchBarrier bar CACHE_ALIGN; | ||
SynchBenchArgs bench_args CACHE_ALIGN; | ||
|
||
inline static void *Execute(void *Arg) { | ||
FCThreadState *th_state; | ||
long i, rnum; | ||
volatile long j; | ||
long id = (long)Arg; | ||
|
||
synchFastRandomSetSeed(id + 1); | ||
th_state = synchGetAlignedMemory(CACHE_LINE_SIZE, sizeof(FCThreadState)); | ||
FCThreadStateInit(object_combiner, th_state, (int)id); | ||
synchBarrierWait(&bar); | ||
if (id == 0) d1 = synchGetTimeMillis(); | ||
|
||
for (i = 0; i < bench_args.runs; i++) { | ||
// perform a fetchAndMultiply operation | ||
FCApplyOp(object_combiner, th_state, fetchAndMultiply, (void *)object, (ArgVal)id, id); | ||
rnum = synchFastRandomRange(1, bench_args.max_work); | ||
for (j = 0; j < rnum; j++) | ||
; | ||
} | ||
synchBarrierWait(&bar); | ||
if (id == 0) d2 = synchGetTimeMillis(); | ||
|
||
return NULL; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
synchParseArguments(&bench_args, argc, argv); | ||
object_combiner = synchGetAlignedMemory(S_CACHE_LINE_SIZE, sizeof(FCStruct)); | ||
object = synchGetAlignedMemory(CACHE_LINE_SIZE, sizeof(ObjectState)); | ||
object->state_f = 1.0; | ||
FCStructInit(object_combiner, bench_args.nthreads); | ||
|
||
synchBarrierSet(&bar, bench_args.nthreads); | ||
synchStartThreadsN(bench_args.nthreads, Execute, bench_args.fibers_per_thread); | ||
synchJoinThreadsN(bench_args.nthreads - 1); | ||
|
||
printf("time: %d (ms)\tthroughput: %.2f (millions ops/sec)\t", (int)(d2 - d1), bench_args.runs * bench_args.nthreads / (1000.0 * (d2 - d1))); | ||
synchPrintStats(bench_args.nthreads, bench_args.total_runs); | ||
|
||
#ifdef DEBUG | ||
fprintf(stderr, "DEBUG: Object float state: %f\n", object->state_f); | ||
fprintf(stderr, "DEBUG: Object state: %ld\n", object_combiner->counter); | ||
fprintf(stderr, "DEBUG: rounds: %ld\n", object_combiner->rounds); | ||
fprintf(stderr, "DEBUG: Average helping: %.2f\n", (float)object_combiner->counter / object_combiner->rounds); | ||
fprintf(stderr, "\n"); | ||
#endif | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
#include <sched.h> | ||
|
||
#include <config.h> | ||
#include <primitives.h> | ||
#include <fastrand.h> | ||
#include <threadtools.h> | ||
#include <fcqueue.h> | ||
#include <barrier.h> | ||
#include <bench_args.h> | ||
|
||
FCQueueStruct *queue_object CACHE_ALIGN; | ||
int64_t d1 CACHE_ALIGN, d2; | ||
SynchBarrier bar CACHE_ALIGN; | ||
SynchBenchArgs bench_args CACHE_ALIGN; | ||
|
||
inline static void *Execute(void *Arg) { | ||
FCQueueThreadState *th_state; | ||
long i, rnum; | ||
volatile int j; | ||
long id = (long)Arg; | ||
|
||
synchFastRandomSetSeed(id + 1); | ||
th_state = synchGetAlignedMemory(CACHE_LINE_SIZE, sizeof(FCQueueThreadState)); | ||
FCQueueThreadStateInit(queue_object, th_state, (int)id); | ||
|
||
synchBarrierWait(&bar); | ||
if (id == 0) d1 = synchGetTimeMillis(); | ||
|
||
for (i = 0; i < bench_args.runs; i++) { | ||
// perform an enqueue operation | ||
FCQueueApplyEnqueue(queue_object, th_state, (ArgVal)id, id); | ||
rnum = synchFastRandomRange(1, bench_args.max_work); | ||
for (j = 0; j < rnum; j++) | ||
; | ||
// perform a dequeue operation | ||
FCQueueApplyDequeue(queue_object, th_state, id); | ||
rnum = synchFastRandomRange(1, bench_args.max_work); | ||
for (j = 0; j < rnum; j++) | ||
; | ||
} | ||
synchBarrierWait(&bar); | ||
if (id == 0) d2 = synchGetTimeMillis(); | ||
|
||
return NULL; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
synchParseArguments(&bench_args, argc, argv); | ||
queue_object = synchGetAlignedMemory(S_CACHE_LINE_SIZE, sizeof(FCQueueStruct)); | ||
FCQueueStructInit(queue_object, bench_args.nthreads); | ||
|
||
synchBarrierSet(&bar, bench_args.nthreads); | ||
synchStartThreadsN(bench_args.nthreads, Execute, bench_args.fibers_per_thread); | ||
synchJoinThreadsN(bench_args.nthreads - 1); | ||
|
||
printf("time: %d (ms)\tthroughput: %.2f (millions ops/sec)\t", (int)(d2 - d1), 2 * bench_args.runs * bench_args.nthreads / (1000.0 * (d2 - d1))); | ||
synchPrintStats(bench_args.nthreads, bench_args.total_runs); | ||
#ifdef DEBUG | ||
fprintf(stderr, "DEBUG: Enqueue: Object state: %ld\n", queue_object->enqueue_struct.counter); | ||
fprintf(stderr, "DEBUG: Enqueue: rounds: %ld\n", queue_object->enqueue_struct.rounds); | ||
fprintf(stderr, "DEBUG: Dequeue: Object state: %ld\n", queue_object->dequeue_struct.counter); | ||
fprintf(stderr, "DEBUG: Dequeue: rounds: %ld\n", queue_object->dequeue_struct.rounds); | ||
volatile Node *first = (Node *)queue_object->first; | ||
long counter = 0; | ||
|
||
while (first->next != NULL) { | ||
first = first->next; | ||
counter++; | ||
} | ||
fprintf(stderr, "DEBUG: %ld nodes were left in the queue\n", counter); | ||
#endif | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <string.h> | ||
#include <stdint.h> | ||
|
||
#include <config.h> | ||
#include <primitives.h> | ||
#include <fastrand.h> | ||
#include <threadtools.h> | ||
#include <fcstack.h> | ||
#include <barrier.h> | ||
#include <bench_args.h> | ||
|
||
FCStackStruct *object_struct CACHE_ALIGN; | ||
int64_t d1 CACHE_ALIGN, d2; | ||
SynchBarrier bar CACHE_ALIGN; | ||
SynchBenchArgs bench_args CACHE_ALIGN; | ||
|
||
inline static void *Execute(void *Arg) { | ||
FCStackThreadState *th_state; | ||
long i, rnum; | ||
volatile int j; | ||
long id = (long)Arg; | ||
|
||
synchFastRandomSetSeed(id + 1); | ||
th_state = synchGetAlignedMemory(CACHE_LINE_SIZE, sizeof(FCStackThreadState)); | ||
FCStackThreadStateInit(object_struct, th_state, (int)id); | ||
synchBarrierWait(&bar); | ||
if (id == 0) d1 = synchGetTimeMillis(); | ||
|
||
for (i = 0; i < bench_args.runs; i++) { | ||
// perform a push operation | ||
FCStackPush(object_struct, th_state, id, id); | ||
rnum = synchFastRandomRange(1, bench_args.max_work); | ||
for (j = 0; j < rnum; j++) | ||
; | ||
// perform a pop operation | ||
FCStackPop(object_struct, th_state, id); | ||
rnum = synchFastRandomRange(1, bench_args.max_work); | ||
for (j = 0; j < rnum; j++) | ||
; | ||
} | ||
synchBarrierWait(&bar); | ||
if (id == 0) d2 = synchGetTimeMillis(); | ||
|
||
return NULL; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
synchParseArguments(&bench_args, argc, argv); | ||
object_struct = synchGetAlignedMemory(S_CACHE_LINE_SIZE, sizeof(FCStackStruct)); | ||
FCStackInit(object_struct, bench_args.nthreads); | ||
synchBarrierSet(&bar, bench_args.nthreads); | ||
synchStartThreadsN(bench_args.nthreads, Execute, bench_args.fibers_per_thread); | ||
synchJoinThreadsN(bench_args.nthreads - 1); | ||
|
||
printf("time: %d (ms)\tthroughput: %.2f (millions ops/sec)\t", (int)(d2 - d1), 2 * bench_args.runs * bench_args.nthreads / (1000.0 * (d2 - d1))); | ||
synchPrintStats(bench_args.nthreads, bench_args.total_runs); | ||
|
||
#ifdef DEBUG | ||
fprintf(stderr, "DEBUG: Object state: %ld\n", object_struct->object_struct.counter); | ||
fprintf(stderr, "DEBUG: rounds: %ld\n", object_struct->object_struct.rounds); | ||
volatile Node *top = object_struct->top; | ||
long counter = 0; | ||
|
||
while (top != NULL) { | ||
top = top->next; | ||
counter++; | ||
} | ||
fprintf(stderr, "DEBUG: %ld nodes left in the queue\n", counter); | ||
#endif | ||
|
||
return 0; | ||
} |
Oops, something went wrong.