Parallel programming: simd and multicore in Ala7
Parallel programming support in Ala7 consists of SIMD and multicore support.
SIMD instructions are used in for loops
for row=1 to m1.rows for col=1 to m1.cols simd #!!!!!!!!!!!!!!!!! m1[row,col]=m0[row,col]*3.0
Multicore support contains parallel for in loop and parallel for loop
As far as for in loop in concrened at the beginning procedure is called for first list element and processed on first processor core, second list element is processed on next core and so on to last available core. Now program waits all cores to finish their tasks and everything starts again.
initMT() # at the beginning multicore support must be started for e in mainList parallel #!!!!!!!!!!!!!!!! test(e)
Second instruction resulting in parallel code is for instruction where subinstructions are called parallely.
for row=1 to matrix.rows parallel #!!!!!!!!!!!!!!!! for col=1 to matrix.cols x=0;sx=0 for k=1 to 100 x=x+1; sx=sx+x sx=sx/100;sx=reminder matrix[row,col]=toFloat(row*5)+toFloat(col*2)+toFloat(sx)
To use parallel multicore instructions option multithreading must be set and name.ala will be compiled to name_mt.exe.