Advertisement
Guest User

Untitled

a guest
May 5th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. void *compute_gauss(void *threadid){
  2.  
  3. int local_row, local_norm, col;
  4. float multiplier;
  5. long tid;
  6. tid = (long)threadid;
  7.  
  8. fprintf(stdout, "Thread %ld has startedn", tid);
  9.  
  10. while (global_norm < N){
  11.  
  12. while (global_row < N) {
  13. pthread_mutex_lock(&global_row_lock);
  14. local_row = global_row;
  15. global_row++;
  16. pthread_mutex_unlock(&global_row_lock);
  17.  
  18. print_inputs();
  19. multiplier = A[local_row][global_norm] / A[global_norm][global_norm];
  20.  
  21. for (col = global_norm; col < N; col++) {
  22. A[local_row][col] -= A[global_norm][col] * multiplier;
  23. }
  24.  
  25. B[local_row] -= B[global_norm] * multiplier;
  26.  
  27. }
  28.  
  29. pthread_barrier_wait(&barrier);
  30. if (tid == 0){
  31. global_norm++;
  32. global_row=global_norm+1;
  33. }
  34. pthread_barrier_wait(&barrier); // wait until all threads arrive
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement