Question: Write a C program in dot.c which takes an integer as a command line argument and computes the following dot product: . Your program should

Write a C program in dot.c which takes an integer as a command line argument and computes the following dot product: .

Your program should utilize two threads and evenly split the work of computing the dot product between them. The output of your program should be as shown in the example program interaction provided below.

Write a C program in dot.c which takes an integer as a

#include #include #include *This structure stores al1 of the variables that are shared between the two threads. Handle with care.* typedef struct int idx; /* index of this thread * long long *a, *b; /* vectors to dot product* int dim; dimensionality of vectors long long psum partial dot product* thread data; This is the function each thread will call to do the work of computing the partial dot product.* void' Worker(void* arg) { thread_data* dat; int idx, dim; long long a, *b; Get thread arquments* dat (thread_data) arg; idx dat->idx ; a dat-a; b dat->b; dim - dat->dim; TODO compute partial dot product and safely exit the thread... * int mainCint argc, char* argv) int dim; *Parse program arguments* if(argc != 2) { printfC"usage: ./dot "); exit(2); dim atoi(argv[1]); TODO initialize thread data structure, create threads, wait for them to terminate, add the partial sums together, then print!* Be sure not to have any memory errors/leaks!! #include #include #include *This structure stores al1 of the variables that are shared between the two threads. Handle with care.* typedef struct int idx; /* index of this thread * long long *a, *b; /* vectors to dot product* int dim; dimensionality of vectors long long psum partial dot product* thread data; This is the function each thread will call to do the work of computing the partial dot product.* void' Worker(void* arg) { thread_data* dat; int idx, dim; long long a, *b; Get thread arquments* dat (thread_data) arg; idx dat->idx ; a dat-a; b dat->b; dim - dat->dim; TODO compute partial dot product and safely exit the thread... * int mainCint argc, char* argv) int dim; *Parse program arguments* if(argc != 2) { printfC"usage: ./dot "); exit(2); dim atoi(argv[1]); TODO initialize thread data structure, create threads, wait for them to terminate, add the partial sums together, then print!* Be sure not to have any memory errors/leaks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!