Skip to content

Instantly share code, notes, and snippets.

@aprell
Created July 4, 2012 09:50
Show Gist options
  • Save aprell/3046434 to your computer and use it in GitHub Desktop.
Save aprell/3046434 to your computer and use it in GitHub Desktop.
RCCE: measuring round-trip latency between two cores
#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