Created
January 14, 2012 17:25
-
-
Save aprell/1612177 to your computer and use it in GitHub Desktop.
One-sided communication in RCCE
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 <assert.h> | |
#include <unistd.h> | |
#include "RCCE.h" | |
#include "RCCE_lib.h" | |
#define PRINT(...) { printf(__VA_ARGS__); fflush(stdout); } | |
int RCCE_APP(int argc, char *argv[]) | |
{ | |
int ID, nprocs, next, prev; | |
int buf[8]; | |
t_vcharp p; | |
dup2(STDOUT_FILENO, STDERR_FILENO); | |
RCCE_init(&argc, &argv); | |
ID = RCCE_ue(); | |
nprocs = RCCE_num_ues(); | |
next = (ID + 1) % nprocs; | |
prev = (ID - 1 + nprocs) % nprocs; | |
p = RCCE_malloc(RCCE_LINE_SIZE); | |
// RCCE_put() and RCCE_get() copy data in cache line chunks | |
buf[0] = 0; | |
RCCE_put(p, (t_vcharp)buf, sizeof(buf), ID); | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
buf[0] = ID; | |
RCCE_put(p, (t_vcharp)buf, sizeof(buf), next); | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
RCCE_get((t_vcharp)buf, p, sizeof(buf), ID); | |
assert(buf[0] == prev); | |
PRINT("Core %d reads a value of %d\n", ID, buf[0]); | |
// Alternatively, with explicit MPBT cache line invalidations | |
//RC_cache_invalidate(); | |
//assert(*(int *)p == prev); | |
//PRINT("Core %d reads a value of %d\n", ID, *(int *)p); | |
RCCE_finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment