void strassenMM(int perfectMatrix) { pthread_t ids[7]; // Has to be 7 int i; makeParts(perfectMatrix); pthread_create(&ids[0], NULL, calcM1, NULL); // calcM1(NULL) pthread_create(&ids[1], NULL, calcM2, NULL); // calcM2(NULL) pthread_create(&ids[2], NULL, calcM3, NULL); // calcM3(NULL) pthread_create(&ids[3], NULL, calcM4, NULL); // calcM4(NULL) pthread_create(&ids[4], NULL, calcM5, NULL); // calcM5(NULL) pthread_create(&ids[5], NULL, calcM6, NULL); // calcM6(NULL) pthread_create(&ids[6], NULL, calcM7, NULL); // calcM7(NULL) for (i = 0; i < 7; i++) { pthread_join(ids[i], NULL); } pthread_create(&ids[0], NULL, calcC11, NULL); // calcC11(NULL) pthread_create(&ids[1], NULL, calcC12, NULL); // calcC12(NULL) pthread_create(&ids[2], NULL, calcC21, NULL); // calcC21(NULL) pthread_create(&ids[3], NULL, calcC22, NULL); // calcC22(NULL) for (i = 0; i < 4; i++) { pthread_join(ids[i], NULL); } copyC(perfectMatrix); }
// WRITE YOUR CODE HERE, you will need to also add functions for each // of the sub-matrixes you will need to calculate but you can create your // threads in this fucntion. void strassenMM(int N) { pthread_t ids[NUM_THREADS]; int i_s[NUM_THREADS]; makeParts(N); pthread_create(&ids[0], NULL, calcM1, NULL); // calcM1(NULL) pthread_create(&ids[1], NULL, calcM2, NULL); // calcM2(NULL) pthread_create(&ids[2], NULL, calcM3, NULL); // calcM3(NULL) pthread_create(&ids[3], NULL, calcM4, NULL); // calcM4(NULL) pthread_create(&ids[4], NULL, calcM5, NULL); // calcM5(NULL) pthread_create(&ids[5], NULL, calcM6, NULL); // calcM6(NULL) pthread_create(&ids[6], NULL, calcM7, NULL); // calcM7(NULL) for (int i = 0; i < 7; i++) pthread_join(ids[i], NULL); pthread_create(&ids[0], NULL, calcC11, NULL); // calcC11(NULL) pthread_create(&ids[1], NULL, calcC12, NULL); // calcC12(NULL) pthread_create(&ids[2], NULL, calcC21, NULL); // calcC21(NULL) pthread_create(&ids[3], NULL, calcC22, NULL); // calcC22(NULL) for (int i = 0; i < 4; i++) pthread_join(ids[i], NULL); copyC(N); }