Question: Parallelize a double for-loop using Grid

Hi, I would like to parallelize the double for loop. I am computing pairwise SPolynomials like so

for i from 1 to n-1 do

for j from i+1 to ndo

spol:=Spol(poly[i],poly[j], tdeg(op(vars))):

...

od:

od: 

I would like to parallelize this code, here is what I have done:

at_node:=proc(p1,p2,vars, polynomials)

spol:=SPolynomial(p1,p2,tdeg(op(vars))):

if NormalForm(spol, polynomials, tdeg(op(vars)))=0

return [1,0]:

fi:

end proc:

Grid[Setup]("local", num_nodes=4):

Grid[Set](at_node): # below is the main loop that fails

for idx from 1 to n-1 do

out:=Grid[Seq](at_node(polynomials[idx], polynomials[j], vars, polynomials) j=idx+1, n):

od:

The loop above fails due to the error when calling normal form. It seems that the at_node function accepts an incorrect input for p1, a list of polynomials instead of a single polynomial. Is there a way to parallelize double for-loop with Grid like that? I am not sure where my error is.

 

 

 

 

 

 

Please Wait...