0

my problem is following:

I have a handle class with many objects and I want to link them to each other. So my vertex(1) from my class vertex needs to be linked to vertex(2) and vertex(3), so that my vertex(1) has the properties vertex(1).neighboor_vertex=vertex(2) (and vertex(3)).

This is just one thing that has to be done (actually I need to link and relink different classes to each other and because its millions of objects and want to do it in parrallel and the fact that linking is not working in parallel stops me from following steps).

So while worker 1 links vertex(1) to vertex(2), no other worker should be able to change the properties of both, they can lets say link 5 to 7 or so, and when the linking is done the new link of vertex(1) to vertex(2) and vertex(2) to vertex(1), needs to be updates to all other workers, so that when another worker wants to link vertex(3) to vertex(1), it has to know that it is alreay linked to vertex(1), otherwise there would be 2 different versions of vertex(1), one linked to vertex(2) and one linked to vertex(3).

So for the blocking that multiple workers cant change the the vertex I would need something like a mutex within the spmd, otherwise it wouldnt be threatsave...

What would be the best way to do this in Matlab?

Many Thanks in advance Best regards

Marc Laub
  • 11
  • 1
  • in MPI, each task has its own address space, so long story short, each hask has its own copy of the vertices and you do not have to worry about thread safety. If you think shared memory would be a better fit, you can for example use OpenMP or pthreads, and both libraries handle mutex. – Gilles Gouaillardet Jun 14 '20 at 23:50
  • I think shared memory is the only way to go, since when each worker has its own copy and worker 1 changes the link from A to B and worker 2 changes the link from A to C, I will end up with 2 different versions of A on both workers, not knowing which to take when assembing them back together...shared memory will also be better since I dont have to copy millions of objects to each worker. Where can I read some more detailed information about openMP and pthreads uner MatLab, because most MatLab documentary for parrallel programming is relativ scanty – Marc Laub Jun 15 '20 at 09:27
  • if you do not need massive scalability and one node is enough, then keep it simple and go with shared memory! – Gilles Gouaillardet Jun 15 '20 at 09:30
  • ok, Just a huge step for me from single core to shared memory and that within MatLab, will take a while I guess... – Marc Laub Jun 15 '20 at 09:36

0 Answers0