/* fig3.10-mxv-omp.cvl: CIVL model of fig3.10-mxv-omp.c * Translated by Stephen Siegel. */ #include #include #include #define THREAD_MAX 4 /* Does thread t own iteration i in loop with n iterations? */ #define CIVL_owns(t, n, i) ((i)%(n)==(t)) void mxv(int m, int n, double * restrict a, double * restrict b, double * restrict c); void perror(char *s) { printf("%s\n", s); exit(1); } int main(int argc, char *argv[]) { double *a,*b,*c; int i, j, m, n; printf("Please give m and n: "); scanf("%d %d",&m,&n); printf("\n"); if ( (a=(double *)malloc(m*sizeof(double))) == NULL ) perror("memory allocation for a"); if ( (b=(double *)malloc(m*n*sizeof(double))) == NULL ) perror("memory allocation for b"); if ( (c=(double *)malloc(n*sizeof(double))) == NULL ) perror("memory allocation for c"); printf("Initializing matrix B and vector c\n"); for (j=0; j