Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- #define SIZE 1024
- #define NUMTHREAD 1024
- static double a[SIZE][SIZE];
- static double b[SIZE][SIZE];
- static double c[SIZE][SIZE];
- //The thread will begin control in this function
- /*void *runner1(void *param) {
- int data1 = *((int *) param);
- free(param);
- int i,j,range ,k = 0; //the counter and sum
- range = data1;
- for (i = data1 - 128; i < SIZE; i = i +128) {
- for(j = 0; j < SIZE; j++){
- a[data1][j] = 1.0;
- b[data1][j] = 1.0;
- }
- }
- printf("init");
- //Exit the thread
- pthread_exit(0);
- }
- */
- static void
- init_matrix(void)
- {
- int i,j,k;
- /* pthread_t p_threads1[NUMTHREAD];
- for (i = 128; i < SIZE; i = i +128) {
- int *data = malloc(sizeof(*data));
- *data = i;
- pthread_create(&p_threads1[i],NULL,runner1,(void *) data);
- //Make sure the parent waits for all thread to complete
- k++;
- }
- for (i=0; i< NUMTHREAD; i++) {
- pthread_join(p_threads1[i], NULL);
- }
- */
- for (i = 0; i < SIZE; i++){
- for (j = 0; j < SIZE; j++) {
- a[i][j] = 1.0;
- b[i][j] = 1.0;
- }
- }
- }
- include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- #define SIZE 1024
- #define NUMTHREAD 1024
- static double a[SIZE][SIZE];
- static double b[SIZE][SIZE];
- static double c[SIZE][SIZE];
- //The thread will begin control in this function
- /*void *runner1(void *param) {
- int data1 = *((int *) param);
- free(param);
- int i,j,range ,k = 0; //the counter and sum
- range = data1;
- for (i = data1 - 128; i < SIZE; i = i +128) {
- for(j = 0; j < SIZE; j++){
- a[data1][j] = 1.0;
- b[data1][j] = 1.0;
- }
- }
- printf("init");
- //Exit the thread
- pthread_exit(0);
- }
- */
- static void
- init_matrix(void)
- {
- int i,j,k;
- /* pthread_t p_threads1[NUMTHREAD];
- for (i = 128; i < SIZE; i = i +128) {
- int *data = malloc(sizeof(*data));
- *data = i;
- pthread_create(&p_threads1[i],NULL,runner1,(void *) data);
- //Make sure the parent waits for all thread to complete
- k++;
- }
- for (i=0; i< NUMTHREAD; i++) {
- pthread_join(p_threads1[i], NULL);
- }
- */
- for (i = 0; i < SIZE; i++){
- for (j = 0; j < SIZE; j++) {
- a[i][j] = 1.0;
- b[i][j] = 1.0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement