Can anyone tell me what is wrong with this code?
I found it on Wikipedia
When I compile it it gives me a lot of errors
void parallel(int num_threads,int matrix_demention)
int i;
for(i=0;i<num_threads;i++)
create_thread(&threads[i],i);
pthread_attr_destroy(&attr); // Free attribute and wait for the other threads
for(i=0;i<p;i++)
pthread_join(threads[i],NULL);
void *gauss(int thread_id)
int i,k,j;
for(k=0;k<matrix_demention-1;k++)
if(thread_id==(k%num_thread)) //interleaved-row work distribution
for(j=k+1;j<matrix_demention;j++)
M[k][j]=M[k][j]/M[k][k];
M[k][k]=1;
barrier(num_thread,&mybarrier); //wait for other thread finishing this round
for(i=k+1;i<matrix_demention;i=i+1)
if(i%p==thread_id)
for(j=k+1;j<matrix_demention;j++)
M[i][j]=M[i][j]-M[i][k]*M[k][j];
M[i][k]=0;}
barrier(num_thread,&mybarrier);
return NULL;
void barrier(int num_thread, barrier_t * mybarrier)
pthread_mutex_lock(&(mybarrier->barrier_mutex));
mybarrier->cur_count++;
if(mybarrier->cur_count!=num_thread)
pthread_cond_wait(&(mybarrier->barrier_cond),&(mybarrier->barrier_mutex));
else
mybarrier->cur_count=0;
pthread_cond_broadcast(&(mybarrier->barrier_cond));
pthread_mutex_unlock(&(mybarrier->barrier_mutex));