mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
30 lines
522 B
C
30 lines
522 B
C
/*
|
|
* @@name: set_dynamic_nthrs.1c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: no
|
|
* @@expect: success
|
|
*/
|
|
#include <omp.h>
|
|
#include <stdlib.h>
|
|
|
|
void do_by_16(float *x, int iam, int ipoints) {}
|
|
|
|
void dynthreads(float *x, int npoints)
|
|
{
|
|
int iam, ipoints;
|
|
|
|
omp_set_dynamic(0);
|
|
omp_set_num_threads(16);
|
|
|
|
#pragma omp parallel shared(x, npoints) private(iam, ipoints)
|
|
{
|
|
if (omp_get_num_threads() != 16)
|
|
abort();
|
|
|
|
iam = omp_get_thread_num();
|
|
ipoints = npoints/16;
|
|
do_by_16(x, iam, ipoints);
|
|
}
|
|
}
|