fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #define N 1000
  5. float A[N][N], B[N][N], C[N][N]; // declaring matrices of NxN size
  6. int main ()
  7. {
  8. /* DECLARING VARIABLES */
  9. int i, j, m; // indices for matrix multiplication
  10. float t_1; // Execution time measures
  11. clock_t c_1, c_2;
  12. /* FILLING MATRICES WITH RANDOM NUMBERS */
  13. srand ( time(NULL) );
  14. for(i=0;i<N;i++) {
  15. for(j=0;j<N;j++) {
  16. A[i][j]= (rand()%10);
  17. B[i][j]= (rand()%10);
  18. }
  19. }
  20. /* MATRIX MULTIPLICATION */
  21. printf("Max number of threads: %i \n",omp_get_max_threads());
  22. #pragma omp parallel
  23. printf("Number of threads: %i \n",omp_get_num_threads());
  24. c_1=time(NULL); // time measure: start mm
  25. #pragma omp parallel for private(m,j)
  26. // #pragma omp_set_num_threads(8)
  27. for(i=0;i<N;i++) {
  28. for(j=0;j<N;j++) {
  29. C[i][j]=0.; // set initial value of resulting matrix C = 0
  30. for(m=0;m<N;m++) {
  31. C[i][j]=A[i][m]*B[m][j]+C[i][j];
  32. }
  33. // printf("C: %f \n",C[i][j]);
  34. }
  35. }
  36. /* TIME MEASURE + OUTPUT */
  37. c_2=time(NULL); // time measure: end mm
  38. t_1 = (float)(c_2-c_1); // time elapsed for job row-wise
  39. printf("Execution time: %f \n",t_1);
  40. /* TERMINATE PROGRAM */
  41. return 0;
  42. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:21:39: warning: implicit declaration of function 'omp_get_max_threads' [-Wimplicit-function-declaration]
 printf("Max number of threads: %i \n",omp_get_max_threads());
                                       ^
prog.c:22:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
 #pragma omp parallel
 ^
prog.c:23:35: warning: implicit declaration of function 'omp_get_num_threads' [-Wimplicit-function-declaration]
 printf("Number of threads: %i \n",omp_get_num_threads());
                                   ^
prog.c:25:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
 #pragma omp parallel for private(m,j)
 ^
/home/fsIf4M/ccE326GI.o: In function `main':
prog.c:(.text.startup+0x98): undefined reference to `omp_get_max_threads'
prog.c:(.text.startup+0xb0): undefined reference to `omp_get_num_threads'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty