PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

pthread proram will not compile

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
THX 1138



Joined: 30 Jun 2011
Posts: 103

PostPosted: Wed Nov 20, 2013 12:08 pm    Post subject: pthread proram will not compile Reply with quote

I am trying to compile a program to trigger false sharing (I have a second program that can detect and fix false sharing). I believe that so far I am correct, but it still refuses to compile. I know that you cannot send a thread function anything, but a sinlge argument, and the way to send more than one argument is by using a struct.

I did use an struct and it still does not compile. I am only trying to fill up two vectors with numbers simultaneously and I am struggling. What am I doing wrong.

The source and out are shown below.

Code:

 pgcc example2.c -o exam -lpthread
PGC-W-0095-Type cast required for this conversion (example2.c: 43)
PGC-S-0037-Syntax error: Recovery attempted by deleting ')' (example2.c: 47)
PGC-W-0095-Type cast required for this conversion (example2.c: 47)
PGC-S-0037-Syntax error: Recovery attempted by deleting ')' (example2.c: 48)
PGC-W-0095-Type cast required for this conversion (example2.c: 48)
PGC/x86-64 Linux 13.6-0: compilation completed with severe errors
[james@james Desktop]$ cat example2.c

#include<pthread.h>

int sum1;
int sum2;

struct arg_struct  {
   int arg1;
   int arg2;
};


void *thread1(int v[], int v_count) {
   
     struct arg_struct *args = (struct arg_struct *)args;
     sum1 = 0;
     int i;
     for (i = 0; i < v_count; i++) {
//   printf ( "%d ", i );
     sum1 += v[i];
   }
     return NULL;
}
void *thread2(int v[], int v_count) {

     struct arg_struct *args = (struct arg_struct *)args;
     sum2 = 0;
     int i;
     for (i = 0; i < v_count; i++) {
//   printf ( "%d ", i );
     sum2 += v[i];
   }
     return NULL;
}


int main ( int argc, char** argv )
{
   pthread_t t1, t2;
   int N = 5000;
   int array1[N];
   struct arg_struct args;
   args.arg1 = array1;
   args.arg2 = N;

   
   pthread_create(&t1,NULL,&thread1,(void *)&args));
   pthread_create(&t2,NULL,&thread2,(void *)&args));
   pthread_join(t1,NULL);

   return 0;
}

.

I am trying to send to thread1 and thread2 and vector and a integer number. For some reson it is not taking it.

Any help appreciated. Thnks in advance.


Respectfully,


THX 1138
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6134
Location: The Portland Group Inc.

PostPosted: Thu Nov 21, 2013 9:31 am    Post subject: Reply with quote

Hi THX 1138,

As the error message suggests, you have an extra ")" at the end of the pthread_create functions.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group