Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

parallelizing kruskal algo

ktrfrk
Beginner
453 Views
hii all. iam a student. i implemented the parallel version of kruskal using tbb as a project. iam attaching the code files. now the problem i hav is wen the number of nodes is greater than 300 the the edges and weights of the edges are changing to 1. i.e., after calling parallel_sort function in kruskalApply function. i donno the reason :( it works fine for small number of nodes. iam intrested in any suggestions as well. thankyou
0 Kudos
3 Replies
ninhngt
Beginner
453 Views
Quoting - ktrfrk
hii all. iam a student. i implemented the parallel version of kruskal using tbb as a project. iam attaching the code files. now the problem i hav is wen the number of nodes is greater than 300 the the edges and weights of the edges are changing to 1. i.e., after calling parallel_sort function in kruskalApply function. i donno the reason :( it works fine for small number of nodes. iam intrested in any suggestions as well. thankyou

You only use parallel_sort from TBB . Try replacing it with std::sort and see if there is any problem with the serial version. Have it working and make it parallel later.
0 Kudos
ktrfrk
Beginner
453 Views
Quoting - ninhngt

You only use parallel_sort from TBB . Try replacing it with std::sort and see if there is any problem with the serial version. Have it working and make it parallel later.
yea i got the same output for serial version also. the weights of the edges are changing after the sort function
0 Kudos
ozang
Beginner
453 Views
I think you used the map in a wrong way. In maps, you have to use pairs but you use the weights as key. It seems wrong. please review this:http://www.cplusplus.com/reference/stl/map/.
Another point, you call "ed.push_back(e);" but what is ed? it is not declared.

You can give a try with TBB 3.
0 Kudos
Reply