papi error when starting event sets in an array

papi error when starting event sets in an array

Postby zoompapi » Mon Mar 24, 2014 12:57 pm

Hi,
I want to have an array of papi event sets so I each thread operates with its own set. The problem comes when from the master thread I try to call to the PAPI_start(sys.eventsets[i] ) method.

The first iteration goes well however, at the second iteration I get an error -10, which is "Event Set is currently running". I don't know why this is happening, the event sets are in different positions of the vector. I also have tried to define different counter types for the second iteration but I get the same error.

Somebody knows what is happening below this papi call?


I attach you the code, ( sorry bout having so many comments)

if (not PAPI_is_initialized()) {

if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT ){
std::cout<<"PAPI ERROR init (master): " << retval << "\n";
}else{ std::cout<<"PAPI ERROR no error init (master): " << retval << "\n"; }
if((retval = PAPI_thread_init(pthread_self)) != PAPI_OK){
std::cout<<"PAPI ERROR thread init (master): " << retval << "\n";
}else{
std::cout<<"PAPI ERROR no errorno error thread init (master): " << retval << "\n";
}

}else{
std::cout<<"PAPI ERROR already initialized (master): \n";
}

for(int i=0; i< sys.getNumThreads(); i++){
std::cout << "one thread" << "\n";
if ((retval=PAPI_create_eventset(&sys.eventsets[i])) != PAPI_OK){
std::cout<<"PAPI ERROR create set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error create (master): " <<i<< "\n"; }
if ((retval=PAPI_add_events(sys.eventsets[i], (int*)Events, numevents)) != PAPI_OK){
std::cout<<"PAPI ERROR adding event to set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error add (master): " <<i<< "\n"; }
if((retval=PAPI_start(sys.eventsets[i] )) != PAPI_OK){
std::cout<<"PAPI ERROR starting set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error start (master): " <<i<< "\n"; }
Events[0]= PAPI_L1_TCM;
Events[1]= PAPI_L2_TCM;
Events[2]= PAPI_L3_TCM;
}

the error is in the last call to PAPI_start as I have mentioned

Thank you,
David
zoompapi
 
Posts: 2
Joined: Mon Mar 24, 2014 12:16 pm

Re: papi error when starting event sets in an array

Postby James Ralph » Mon Mar 24, 2014 1:59 pm

David,

A thread is only allowed to have one event set running at a time. By having the main thread
create and try to start several event sets you run afoul of this.

You're going to want to have each thread call PAPI_create_eventset and PAPI_start

Some of our 'ctests' test code are good examples of how to use PAPI with threads.
See ctests/pthrtough.c

James
James Ralph
 
Posts: 20
Joined: Tue Aug 25, 2009 2:43 pm

Re: papi error when starting event sets in an array

Postby zoompapi » Tue Mar 25, 2014 7:27 am

I made the changes but the error still persists

I attach you the codes

////////master thread code
if (not PAPI_is_initialized()) {

if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT ){
std::cout<<"PAPI ERROR init (master): " << retval << "\n";
}else{ std::cout<<"PAPI ERROR no error init (master): " << retval << "\n"; }
if((retval = PAPI_thread_init(pthread_self)) != PAPI_OK){
std::cout<<"PAPI ERROR thread init (master): " << retval << "\n";
}else{
std::cout<<"PAPI ERROR no errorno error thread init (master): " << retval << "\n";
}

}else{
std::cout<<"PAPI ERROR already initialized (master): \n";
}
if ((retval = PAPI_register_thread() ) != PAPI_OK){
std::cout<<"PAPI ERROR register (thread): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error register (thread): " <<getId()<< "\n"; }

if ((retval=PAPI_create_eventset(&(myThread->eventse))) != PAPI_OK){
std::cout<<"PAPI ERROR create set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error create (master): " <<getId()<< "\n"; }
if ((retval=PAPI_add_events(myThread->eventse, (int*)Events, numevents)) != PAPI_OK){
std::cout<<"PAPI ERROR adding event to set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error add (master): " <<getId()<< "\n"; }
if((retval=PAPI_start(myThread->eventse )) != PAPI_OK){
std::cout<<"PAPI ERROR starting set (master): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error start (master): " <<getId()<< "\n"; }


///////auxiliar threads code

if ((retval = PAPI_register_thread() ) != PAPI_OK){
std::cout<<"PAPI ERROR register (thread): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error register (thread): " <<getId()<< "\n"; }

if ((retval=PAPI_create_eventset(&eventse)) != PAPI_OK){
std::cout<<"PAPI ERROR create set (thread): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error create (thread): " <<getId()<< "\n"; }
if ((retval=PAPI_add_events(eventse, Events, numevents)) != PAPI_OK){
std::cout<<"PAPI ERROR adding event to set (thread): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error add (thread): " <<getId()<< "\n"; }
if((retval=PAPI_start(eventse )) != PAPI_OK){
std::cout<<"PAPI ERROR starting set (thread): " << retval << "\n";
}else{std::cout<<"PAPI ERROR no error start (thread): " <<getId()<< "\n"; }


////eventse is a local variable of each thread, it is located in another class, which should be instantiated as many times as threads has the system has
////the same happens if instead of having it locally, I declare a <vector> with length equals to the number of threads, and each position has a int for the eventset variable. Having this varible in a singleton class in the system


////////Otuput
PAPI ERROR no error init (master): 84017152
PAPI ERROR no errorno error thread init (master): 0
PAPI ERROR no error register (thread): 0
PAPI ERROR no error create (master): 0
PAPI ERROR no error add (master): 0
PAPI ERROR no error start (master): 0
PAPI ERROR no error register (thread): 1
PAPI ERROR no error create (thread): 1
PAPI ERROR no error add (thread): 1
PAPI ERROR starting set (thread): -10
PAPI ERROR no error register (thread): 2
PAPI ERROR no error create (thread): 2
PAPI ERROR no error add (thread): 2
PAPI ERROR starting set (thread): -10
PAPI ERROR no error register (thread): 3
PAPI ERROR no error create (thread): 3
PAPI ERROR no error add (thread): 3
PAPI ERROR starting set (thread): -10

thanks,
David
zoompapi
 
Posts: 2
Joined: Mon Mar 24, 2014 12:16 pm


Return to Classic PAPI (read-only)

Who is online

Users browsing this forum: No registered users and 1 guest