Created
July 4, 2012 09:50
-
-
Save aprell/3046434 to your computer and use it in GitHub Desktop.
RCCE: measuring round-trip latency between two cores
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <RCCE.h> | |
#include "timer.h" | |
#define PRINT(...) { printf(__VA_ARGS__); fflush(stdout); } | |
#define CORE(i) if (RCCE_ue() == (i)) | |
#define MSG_SIZE 32 | |
#define ROUNDS 1000 | |
extern double RC_REFCLOCKGHZ; | |
int RCCE_APP(int argc, char *argv[]) | |
{ | |
mytimer_t timer; | |
char buf[MSG_SIZE]; | |
int ME = 0, YOU = 1, i; | |
dup2(STDOUT_FILENO, STDERR_FILENO); | |
RCCE_init(&argc, &argv); | |
timer_new(&timer, RC_REFCLOCKGHZ); | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
CORE(ME) { | |
timer_start(&timer); | |
for (i = 0; i < ROUNDS; i++) { | |
RCCE_send(buf, MSG_SIZE, YOU); | |
RCCE_recv(buf, MSG_SIZE, YOU); | |
} | |
timer_end(&timer); | |
} | |
CORE(YOU) { | |
for (i = 0; i < ROUNDS; i++) { | |
RCCE_recv(buf, MSG_SIZE, ME); | |
RCCE_send(buf, MSG_SIZE, ME); | |
} | |
} | |
CORE(ME) PRINT("Round-trip latency: %.2lf\n", timer_elapsed(&timer, timer_us) / ROUNDS); | |
RCCE_finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment