Strange Programm Output (OpenMP)

General OpenMP discussion

Strange Programm Output (OpenMP)

Postby nguaze » Fri Jul 26, 2013 1:17 am

Hi Guys , I am learningto programm a multithreading application using OpenMP with aTexas Instruments DSP Board.
this is the piece of that I run :
#include "SorterProcessing.h"
// global variable
int shared_inputdata[ELEMENTS_to_SORTED * NUMBER_of_LINES];
int private_inputdata[NUMBER_of_Lines_pro_Thread * ELEMENTS_to_SORTED];
int private_Buffer[LENGHT];
void main()
{
// init the shared_inputdata array
int i, j;
int nthreads, tid;
unsigned int start , stop = 0;
unsigned int begin, end , total = 0;
TSCL = 0;
for(i = 0; i<(ELEMENTS_to_SORTED * NUMBER_of_LINES); i++){
shared_inputdata[i] = i * 2;
}

nthreads = NTHREADS;
omp_set_num_threads(NTHREADS);
begin = TSCL ;
/* Fork a team of threads giving them their own copies of variables*/
#pragma omp parallel private(tid ,j,start,stop,private_inputdata) shared (shared_inputdata)
{
/* Obtain thread number*/
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);

/* Only master thread does this*/
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\n", nthreads);
}
// distributes block data for each Thread*/
start = TSCL;
memcpy(private_inputdata, &shared_inputdata[tid*NUMBER_of_Lines_pro_Thread*ELEMENTS_to_SORTED], sizeof(int)*NUMBER_of_Lines_pro_Thread*ELEMENTS_to_SORTED); // run for all threads
stop = TSCL;
printf("CFAR TIME#OMP= [%u] cycles \n", (stop - start));
}
end = TSCL;
// all Threads join the Master
printf("OMP TIME =[%u] cycles \n", (end - begin));

}
and the Output see like this:
[C66xx_0] Hello World from thread = 0
[C66xx_1] Hello World from thread = 1
[C66xx_0] Number of threads = 2
[C66xx_1] CFAR TIME#OMP= [0] cycles
[C66xx_0] CFAR TIME#OMP= [15138] cycles
OMP TIME =[106820] cycles

I started 2 threads (Core 0 and Core 1) but it look like only the Core 0 run the memcpy() instruction ( see Output : Core 0 -> 15138 cycles and Core 1-> 0 cycles)
I don´t understand why the cycles time for Core 1 is 0.
Can anybody explain me the problem on this piece Code

Thank you for Reply

Lopez
nguaze
 
Posts: 4
Joined: Thu Jul 25, 2013 1:48 am

Re: Strange Programm Output (OpenMP)

Postby MarkB » Fri Jul 26, 2013 2:47 am

Hi there,

I see nothing wrong with your OpenMP code. Does private_inputdata on thread 1 contain the correct values after the memcpy?
If so, then the problem is likely to be with the timer. The standard OpenMP timer omp_get_wtime() should be supported, so you could try
using that instead.

Hope that helps,
Mark.
MarkB
 
Posts: 487
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: Strange Programm Output (OpenMP)

Postby nguaze » Mon Jul 29, 2013 12:10 am

Hello Mark ,
thank you for your Suggestion , I am going to try this

Best Regards
Lopez
nguaze
 
Posts: 4
Joined: Thu Jul 25, 2013 1:48 am


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 11 guests