I am using parallel and collect functions from the multi-core R package to parallelize a simple matrix multiplication code. The answer is correct but the parallelized version seems to take the same time as the serial version.
I doubt that it is performing on only one core (instead of 8 available on my machine!). Is there a way to detect this and ensure usage of more than 1 cores?
Here is my code:
library("multicore")
A = read.table("matrixA.txt")
B = read.table("matrixB.txt")
A = as.matrix(A)
B = as.matrix(B)
rows = dim(A)[1]
columns = dim(B)[2]
C <- mcparallel(A%*%B)
C <- collect(list(C))
C <- as.matrix(C[[1]])
write.table(C,"matrixC_mc.txt",row.names=FALSE, col.names=FALSE)