环境变量 OMP_NUM_THREADS以控制执行线程的数量。即由4线程来执行
However, the problem is that the program 'test' only use 4 cores when running in parallel part (total CPU usage is only 80%), I noticed that when set I_MPI_PIN_DOMAIN=omp, every process 'test' will use all 24 cores. I have tested the program 'test' on one node by mpiexec -wdir...
int main() { // 显式设置线程数 omp_set_num_threads(4); // 并行区域 #pragma omp parallel { int thread_id = omp_get_thread_num(); // 获取当前线程的 ID int num_threads = omp_get_num_threads(); // 获取当前并行区域的>线程数 printf("Hello from thread %d out of %d threads\n",...
针对你遇到的“undefined reference to omp_get_num_threads'”问题,这通常是由于编译器在链接阶段未能找到omp_get_num_threads`函数的定义。该函数是OpenMP库的一部分,用于获取当前使用的线程数。以下是根据你的提示,逐步分析和解决问题的建议: 确认omp_get_num_threads函数所属的库: omp_get_num_threads函数属于...