egi-megi / porr-pso

2 stars 0 forks source link

Dependency on the number of CPUs #5

Closed mpiku closed 3 years ago

mpiku commented 3 years ago

Dependency on omp_get_num_procs() might be a problem when a user force the OpenMP to create more threads than CPUs available https://www.openmp.org/spec-html/5.0/openmpsu114.html.

I guess the following function might be usefull (after lurking SO): https://www.openmp.org/spec-html/5.0/openmpsu112.html#x149-6510003.2.3

https://github.com/egi-megi/rojCzastek_Szczepanski_Jurkiewicz_Pikulinski/blob/83e6a109c0b1c8cecd8bcf53c0e89a6207918eb8/src/Swarm.cpp#L50

https://github.com/egi-megi/rojCzastek_Szczepanski_Jurkiewicz_Pikulinski/blob/83e6a109c0b1c8cecd8bcf53c0e89a6207918eb8/src/Swarm.cpp#L105

mpiku commented 3 years ago

Solution is working now with any given number of threads. Threads number might be changed with, e.g. OMP_NUM_THREADS environment variable or omp_set_num_threads(int) routine.

https://www.openmp.org/spec-html/5.0/openmpse50.html