I am writing a code for matrix multiplication using multi-threading.
The code works fine without multiple-threads. The code works when i add the line t.join()
,but doing this won't parallelise the code.
All the threads will wait for their predecessor to finish.I want to execute them in parallel.
Run-time Error :
libc++abi.dylib: terminating
Abort trap: 6
When i looked up the error in SO mirrors,almost all of them where facing segmentation faults which gave this errror.
Note : I am using a mac machine with gcc(clang).
Here's my code:
void multiply (int a[][N],int b[][N],int n,int m,int p,int result[][N])
{
int i,j,k;
for (i=0;i<n;i++)
{
for (j=0;j<p;j++)
{
thread t(multiplyParallely,a,b,m,i,j,result);
// t.join(); // Works When i add this line.But that doesnt parallelise.
//multiplyParallely(a,b,m,i,j,result); // Obviously This Works
}
}
}
Aucun commentaire:
Enregistrer un commentaire