Question: I have the following C * ( cstar ) code: / * Parallel Numerical Integration Program * / #include #include #define numproc 4 0 #define

I have the following C*(cstar) code:
/* Parallel Numerical Integration Program */
#include
#include
#define numproc 40
#define numpoints 30
#define N 6
#define MESH_DIM sqrt(numproc)
float a =0.0, b =2.0, w, globalsum =0.0, answer;
spinlock L;
float local_sums[N][N];
int i, j, row, col;
float f(float t){
return sqrt(4- t * t);
}
void Integrate(int myrow, int mycol){
float localsum =0.0;
float t;
int j;
int myindex = myrow * MESH_DIM + mycol;
t = a + myindex *(b - a)/ numproc;
for (j =1; j <= numpoints; j++){
localsum += f(t);
t += w;
}
localsum = w * localsum;
local_sums[myrow][mycol]= localsum;
}
void meshReduceSum(){
for (row =0; row < MESH_DIM; row++){
for (col =1; col < MESH_DIM; col++){
local_sums[row][0]+= local_sums[row][col];
}
}
for (row =1; row < MESH_DIM; row++){
local_sums[0][0]+= local_sums[row][0];
}
globalsum = local_sums[0][0];
}
main(){
w =(b - a)/(numproc * numpoints);
forall i =0 to MESH_DIM do
forall j =0 to MESH_DIM do
Integrate(i, j);
meshReduceSum();
answer = globalsum + w /2*(f(b)- f(a));
cout << "Approximation to the value of pi: %f
"<< answer;
return 0;
}
and its giving me the following error when I try to compile it:
*OPEN numIntegration.c
7 #define MESH_DIM sqrt(numproc)
****^25
9 float a =0.0, b =2.0, w, globalsum =0.0, answer;
****^14
11 float local_sums[N][N];
****^29
14 float f(float t){
****^29
19 float localsum =0.0;
****^14
20 float t;
****^14
24 t = a + myindex *(b - a)/ numproc;
****^0
27 localsum += f(t);
****^0
28 t += w;
****^0
30 localsum = w * localsum;
****^0
32 local_sums[myrow][mycol]= localsum;
****^0
36 for (row =0; row < MESH_DIM; row++){
****^35
37 for (col =1; col < MESH_DIM; col++){
****^35
42 for (row =1; row < MESH_DIM; row++){
****^35
52 forall i =0 to MESH_DIM do
****^19
53 forall j =0 to MESH_DIM do
****^19
COMPILATION ERRORS
ERROR CODES
0 Undefined Identifier
14 ;
19 Wrong Type
25 Invalid constant defn
29 Type Identifier Expected
35 Types
PROGRAM SOURCE FILE IS NOW CLOSED TO ALLOW EDITING

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 Programming Questions!