Created
January 14, 2012 17:30
-
-
Save aprell/1612190 to your computer and use it in GitHub Desktop.
Writing single bytes to MPBs 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 WORKER(i) if (ID == (i)) | |
#define PRINT(...) { printf(__VA_ARGS__); fflush(stdout); } | |
int RCCE_APP(int argc, char *argv[]) | |
{ | |
int ID, offset; | |
t_vcharp p; | |
dup2(STDOUT_FILENO, STDERR_FILENO); | |
RCCE_init(&argc, &argv); | |
ID = RCCE_ue(); | |
if (RCCE_num_ues() != 3) { | |
WORKER(0) PRINT("Run with 3 cores!\n"); | |
goto exit; | |
} | |
p = RCCE_malloc(RCCE_LINE_SIZE); | |
WORKER(0) { | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
RC_cache_invalidate(); | |
char byte1 = *(char *)p; | |
char byte2 = *(char *)(p + 1); | |
PRINT("Core %d reads %c %c\n", ID, byte1, byte2); | |
} | |
// RCCE_comm_buffer[ID] marks the starting address of core ID's MPB | |
WORKER(1) { | |
char byte = 'A'; | |
offset = (long)p - (long)RCCE_comm_buffer[ID]; | |
RC_cache_invalidate(); | |
*(char *)(RCCE_comm_buffer[0] + offset) = byte; | |
*(char *)(RCCE_comm_buffer[0] + offset + 64) = 'x'; | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
} | |
WORKER(2) { | |
char byte = '$'; | |
offset = (long)p - (long)RCCE_comm_buffer[ID]; | |
RC_cache_invalidate(); | |
*(char *)(RCCE_comm_buffer[0] + offset + 1) = byte; | |
*(char *)(RCCE_comm_buffer[0] + offset + 65) = 'x'; | |
RCCE_barrier(&RCCE_COMM_WORLD); | |
} | |
exit: | |
RCCE_finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment