-
1. Re: Using "#pragma omp flush" in emulator
tedk Apr 27, 2011 10:43 AM (in response to omid)Yes, please post the code. Are you putting a pragma in the middle of your executing code?
-
2. Re: Using "#pragma omp flush" in emulator
omid Apr 28, 2011 12:03 PM (in response to tedk)Yes Ted, I am using pragma in the middle of the code. A simple test code is attached. You will see that a variable called 'size'
in core B is incremented by core A, but sometimes it is not visible by core A in its future access. Test the code with 4 cores.
Omid
-
test1.c.zip 676 bytes
-
-
3. Re: Using "#pragma omp flush" in emulator
omid May 3, 2011 7:05 AM (in response to omid)Any ideas? Plus is there anything wrong with using 'pragma' in the middle of executing code?
Omid
-
4. Re: Using "#pragma omp flush" in emulator
aprell May 3, 2011 8:18 AM (in response to omid)1 of 1 people found this helpfulI guess it's pointer related... The following example is adapted from your code. Could you check it?
char *p;
int ID, next, prev;
RCCE_init(&argc, &argv);
ID = RCCE_ue();
next = (ID + 1) % RCCE_num_ues();
prev = (ID - 1 >= 0) ? ID - 1 : RCCE_num_ues() - 1;
p = RCCE_malloc(32);
*(int *)p = 0;
RCCE_barrier(&RCCE_COMM_WORLD);
RCCE_acquire_lock(0);
printf("Core %d writes to the MPB of core %d\n", ID, next);
*(int *)(p - (char *)RCCE_comm_buffer[ID] + (char *)RCCE_comm_buffer[next]) = ID;
RCCE_release_lock(0);
RCCE_barrier(&RCCE_COMM_WORLD);
assert(*(int *)p == prev);
RCCE_finalize();
-
5. Re: Using "#pragma omp flush" in emulator
omid May 9, 2011 8:14 AM (in response to aprell)Thanks for the modified code. Executing the above code on emulator leads to 3 possible results:
(1) it works as we expect (each code copy its id to its right hand nieghbor in a round robin manner)
(2) Sometimes just one core copy its ID to the nieghbor core and then Assert statement will be false. (this behaviour is not expected)
(3) Sometimes it crashes in the middle of execution. (this is also unexpected)
Could anyone test the above code on SCC platform, since we haven't got the platform yet? I want to understand whether the emulator is guilty or RCCE library (or maybe the code itself !).
Thanks,
Omid
-
6. Re: Using "#pragma omp flush" in emulator
aprell May 9, 2011 10:03 AM (in response to omid)1 of 1 people found this helpfulHmm, it seems to work. No problems when I run it on the emulator (older, revision 90)...
I will test a version of the code on the actual hardware.
-
7. Re: Using "#pragma omp flush" in emulator
aprell May 9, 2011 10:48 AM (in response to omid)Also no problems on the hardware... The code is slightly different, with puts and gets to avoid caching and write-combining issues.
Could you post your code again?
-
8. Re: Using "#pragma omp flush" in emulator
omid May 10, 2011 3:02 AM (in response to aprell)This is exactly my code which runs on emulator:
#include <stdio.h>
#include <stdlib.h>
#include "../../include/RCCE_lib.h"
#include "../../include/RCCE.h"
#include<assert.h>int RCCE_APP(int argc, char** argv) {
char *p;
int ID, next, prev;
RCCE_init(&argc, &argv);
ID = RCCE_ue();
next = (ID + 1) % RCCE_num_ues();
prev = (ID - 1 >= 0) ? ID - 1 : RCCE_num_ues() - 1;
p = (char *)RCCE_malloc(32);
*(int *)p = 0;
RCCE_barrier(&RCCE_COMM_WORLD);
RCCE_acquire_lock(0);
printf("Core %d writes ' %d ' to the MPB of core %d\n", ID, ID, next);
*(int *)(p - (char *)RCCE_comm_buffer[ID] + (char *)RCCE_comm_buffer[next]) = ID;
RCCE_release_lock(0);
RCCE_barrier(&RCCE_COMM_WORLD);
assert(*(int *)p == prev);
RCCE_finalize();
}And RCCE version is : "1.0.13.x" and I am using the trunc revision.
I still have the same strange behaviour. Are you sure no "#pragma omp flush " is needed (befroe reads or after writes) in order to make changes made by one thread to shared variables be visible to others threads too?
Omid
-
9. Re: Using "#pragma omp flush" in emulator
aprell May 10, 2011 5:50 AM (in response to omid)I can't get it to fail... I've also checked it against the latest revision of RCCE. Note that I am using gcc to build the RCCE emulator (default is icc).
-
10. Re: Using "#pragma omp flush" in emulator
omid May 10, 2011 8:34 AM (in response to aprell)Strange. I also build emulator with gcc.
App behaves in this way:
Sometimes it crashes -> Here I suspect the RCCE_barrier on emulator.
Sometimes Assert statement is false -> Here I am not sure how it can be explained. Maybe some coherence issues between omp threads.
And sometimes it works as it should.
Could you please send me the code that you already run on actual hardware?
Thanks,
Omid
-
11. Re: Using "#pragma omp flush" in emulator
aprell May 11, 2011 3:13 AM (in response to omid)Of course, here it is. Haven't seen it fail once, both on hardware and on emulator...
The address arithmetic is now done by RCCE_put.
-
test.c.zip 600 bytes
-