Skip to content

Instantly share code, notes, and snippets.

@aprell
Created July 4, 2012 10:08
Show Gist options
  • Save aprell/3046526 to your computer and use it in GitHub Desktop.
Save aprell/3046526 to your computer and use it in GitHub Desktop.
RCCE: measuring round-trip latency between one core and all the other 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, i, j;
dup2(STDOUT_FILENO, STDERR_FILENO);
RCCE_init(&argc, &argv);
timer_new(&timer, RC_REFCLOCKGHZ);
for (i = 0; i < RCCE_num_ues(); i++) {
RCCE_barrier(&RCCE_COMM_WORLD);
YOU = i;
if (ME == YOU)
continue;
CORE(ME) {
timer_reset(&timer, RC_REFCLOCKGHZ);
timer_start(&timer);
for (j = 0; j < ROUNDS; j++) {
RCCE_send(buf, MSG_SIZE, YOU);
RCCE_recv(buf, MSG_SIZE, YOU);
}
timer_end(&timer);
}
CORE(YOU) {
for (j = 0; j < ROUNDS; j++) {
RCCE_recv(buf, MSG_SIZE, ME);
RCCE_send(buf, MSG_SIZE, ME);
}
}
CORE(ME) PRINT("Round-trip latency %d <--> %d: %.2lf\n", ME, YOU,
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