Advertisement
Guest User

comebackkkk

a guest
Dec 8th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. include <stdio.h>
  2. #include <stdlib.h>
  3. #include <pthread.h>
  4. #define SIZE 1024
  5. #define NUMTHREAD 1024
  6.  
  7. static double a[SIZE][SIZE];
  8. static double b[SIZE][SIZE];
  9. static double c[SIZE][SIZE];
  10.  
  11.  
  12. //The thread will begin control in this function
  13. /*void *runner1(void *param) {
  14. int data1 = *((int *) param);
  15. free(param);
  16. int i,j,range ,k = 0; //the counter and sum
  17. range = data1;
  18. for (i = data1 - 128; i < SIZE; i = i +128) {
  19. for(j = 0; j < SIZE; j++){
  20. a[data1][j] = 1.0;
  21. b[data1][j] = 1.0;
  22. }
  23. }
  24. printf("init");
  25. //Exit the thread
  26. pthread_exit(0);
  27. }
  28. */
  29. static void
  30. init_matrix(void)
  31. {
  32.  
  33. int i,j,k;
  34. /* pthread_t p_threads1[NUMTHREAD];
  35. for (i = 128; i < SIZE; i = i +128) {
  36.  
  37. int *data = malloc(sizeof(*data));
  38. *data = i;
  39. pthread_create(&p_threads1[i],NULL,runner1,(void *) data);
  40. //Make sure the parent waits for all thread to complete
  41. k++;
  42. }
  43. for (i=0; i< NUMTHREAD; i++) {
  44. pthread_join(p_threads1[i], NULL);
  45. }
  46. */
  47. for (i = 0; i < SIZE; i++){
  48. for (j = 0; j < SIZE; j++) {
  49. a[i][j] = 1.0;
  50. b[i][j] = 1.0;
  51. }
  52. }
  53. }
  54. include <stdio.h>
  55. #include <stdlib.h>
  56. #include <pthread.h>
  57. #define SIZE 1024
  58. #define NUMTHREAD 1024
  59.  
  60. static double a[SIZE][SIZE];
  61. static double b[SIZE][SIZE];
  62. static double c[SIZE][SIZE];
  63.  
  64.  
  65. //The thread will begin control in this function
  66. /*void *runner1(void *param) {
  67. int data1 = *((int *) param);
  68. free(param);
  69. int i,j,range ,k = 0; //the counter and sum
  70. range = data1;
  71. for (i = data1 - 128; i < SIZE; i = i +128) {
  72. for(j = 0; j < SIZE; j++){
  73. a[data1][j] = 1.0;
  74. b[data1][j] = 1.0;
  75. }
  76. }
  77. printf("init");
  78. //Exit the thread
  79. pthread_exit(0);
  80. }
  81. */
  82. static void
  83. init_matrix(void)
  84. {
  85.  
  86. int i,j,k;
  87. /* pthread_t p_threads1[NUMTHREAD];
  88. for (i = 128; i < SIZE; i = i +128) {
  89.  
  90. int *data = malloc(sizeof(*data));
  91. *data = i;
  92. pthread_create(&p_threads1[i],NULL,runner1,(void *) data);
  93. //Make sure the parent waits for all thread to complete
  94. k++;
  95. }
  96. for (i=0; i< NUMTHREAD; i++) {
  97. pthread_join(p_threads1[i], NULL);
  98. }
  99. */
  100. for (i = 0; i < SIZE; i++){
  101. for (j = 0; j < SIZE; j++) {
  102. a[i][j] = 1.0;
  103. b[i][j] = 1.0;
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement