#Need help with parallelising code

34 messages · Page 1 of 1 (latest)

limber locustBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

patent surge
#

so where does it fail atm?

red garden
#

there is no error, however i cant iterate the columns. Basically i need another loop or some other logic i suppose to iterate columns

#

ill print result

#

The statements with (comma) indicate diagonal and x

basically the rows are ok but columns are most often than not incorrect 6x7 matrix

patent surge
#

can't you just calculate the start column? and then go one row and column up until you hit the end?

#

or down, whichever direction you wanna do it in

red garden
#

ye thats the problem, i dont know how to get the start column of submatrices

patent surge
#

well, the submatrices are 2×2 if i understand correctly?

red garden
#

nope, the submatrices vary in size

#

i just picked 2x2 for simplicity

patent surge
#

well, are they all the same size at least?

red garden
#

yes

#

well

#

the last submatrices probably not

#

the ones closest to cols or rows, they are limited by the number of cols and rows thus min(x + block, row or col)

patent surge
#

well then you can just think of it as a matrix of submatrices. and forget they are submatrices at first. just calcumate the start row/col in the matrix of submatrices. and then multiply by the submatrix size to get the actual index in the full matrix.

red garden
#

hmmmmm

#

I dont get it

  1. I seperate the matrix into submatrices using the antidiagonal
  2. calculate the start col and row of these submatrices (not sure i understand this)
  3. then just multiply the index by submatrix size
#

i pass in a function row + block, col + block until it reaches row + block > rows and col + block > cols?

#

and even if i did that, how would they be differentiated between each other? If i just multiply them by size of block it wont give me much.

lets say submatrix 0 has 200 rows, i multiply any index by 200.
submatrix 1 has 200 rows again, i multiply any index by 200 i wont get anything in the big matrix.

patent surge
#

i'm not following

#

you take the index of the submatrix and multiply it by 200. and you get the index where that submatrix begins in the big matrix?

red garden
#

but u cant differentiate between rows like that no?

#

or im confused

#

ah hmm index of submatrix, which would mean we index all the submatrices

#

you mean smth like this

lets say we have 6x7 blocks of size 2. First i find how many submatrices i have so in this case 12? 4 per row.

for (int d = 0; d < submatriceSize(12); d++)
  function(matrixS, blockSize, id)


function(matrixS, blockSize, id)
{
  //iterate rows
    //iterate cols
}

#

only question i have is how do i get the id so i know which matrix goes first or rather how many submatrices to do at the same time

patent surge
#

if you want to parallelize, ideally, you'd have each thread process the same number of blocks, no?

#

you could do this

#

i.e., have the shorter diagonals wrap around to process the other half of the corresponding diagonal on the other side of the matrix

#

that way, all diagonals have the same number of elements on them

limber locustBOT
#

@red garden

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

red garden
#

!solved