In many parallel programming books and tutorials there are examples of this "forall" construsct but I haven't seen any C compilers capable of doing that. What it does is simply create n separate parallel processes executed at the same time - for example if we have:
Code:
forall (i=0; i<=10; i++)
..it means that for every single i there is going to be a separate process. This would greately simplify loop parallelization on numerically intensive computations on multiprocessor systems and you wouldn't have to go through all that threads, forks, MPI, OMP, ..you name it.. simply just add "forall" and thatt's it.
I don't know, that's why I'm asking, the book I have - "Parallel programming (Wilkinson, Allen), Prentice/Hall 1999" uses those "forall" constructs all over the book just as if it was a normal C construct without including any libraries !!!???
It does say on one page that sometimes C compilers use "parfor" instead "forall". After I googled around I came across this page:
http://www.cs.nyu.edu/milan/publications/sd97/
Code:
par {
parfor (int i=0; i<N; i++) {
statment_1; statment_1;
: : : :
statement_n; statement_n;
}
}
..hmm, looks like C languege to me, ..and another example from the above link:
Code:
#include "chime.h"
#include <stdlib.h>
#include <iostream.h>
const int N=500;
float A[N][N], B[N][N], C[N][N];
void RandomFill(float mat[N][N], int size){
for(int i=0; i<size; i++)
for(int j=0; j<size; j++)
mat[i][j] = rand();
} /* RandomFill */
void main(int argc, char *argv[]){
int numOfSubDiv;
cout << "Input num of sub divisions: ";
cin >> numOfSubDiv ;
RandomFill(A,N);
RandomFill(B,N);
parfor(int division=0; division < numOfSubDiv; division++){
int from = division * (N/numOfSubDiv);
int to = from + (N/numOfSubDiv);
for(int i=from; i<to; i++)
for(int j=0; j<N; j++){
C[i][j] = 0;
for (int k=0; k<N; k++)
C[i][j] += A[i][k] * B[k][j];
}
} /* parfor */
} /* main */
So, "parfor" should be for C ?
Which compilers? Is this "chime.h" needed for this? "forall" also seems to be standard construct in Fortarn 95, but all free/GNU Fortran compilers available on the web failed to build on my machine so I can't try this "magical" construct..
c.