How to programmatically detect the number of cores and run an MPI program using all cores

前端 未结 2 1813
再見小時候
再見小時候 2021-01-06 07:24

I do not want to use mpiexec -n 4 ./a.out to run my program on my core i7 processor (with 4 cores). Instead, I want to run ./a.out, have it detect

2条回答
  •  抹茶落季
    2021-01-06 08:09

    You can get number of CPUs by using for example this solution, and then start the MPI process by calling MPI_comm_spawn. But you will need to have a separate executable file.

提交回复
热议问题