Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include "omp.h"
#include "cblas.h"
#include "utils/options.h"
using namespace std;
/*
* Interrogate and print out the number of threads used by OpenMP, and the
* number of threads used by OpenBLAS.
*
* The utils/fslStartup.cc file contains some global initialisation logic
* which controls the number of threads used by OpenBLAS. All we need to do
* to induce the fslStartup.cc code is link against libfsl-utils.so.
*/
int main(int argc, char *argv[]) {
// Use something from libfsl-utils.so
// to ensure that it gets linked.
Utilities::OptionParser opts("test", "test");
int omp_threads;
int blas_threads;
int sum = 0;
// omp num threads should not be
// affected by the FSL startup logic.
// Sum should be equal to omp num threads.
#pragma omp parallel
{
sum += 1;
omp_threads = omp_get_num_threads();
}
// blas num threads should be controlled
// by FSL startup logic.
blas_threads = openblas_get_num_threads();
cout << omp_threads << " " << blas_threads << " " << sum << endl;
}