Commit 6b5fa721 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

MACOSX: call omp_set_num_threads only in master thread

parent 3e502500
......@@ -31,7 +31,7 @@ case "${HOSTNAME}" in
--with-hdf5=/opt/local \
--with-szlib=/opt/local \
--with-proj=/opt/local \
CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2"
CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2 -fopenmp"
;;
# ia64-xxx-linux
ds*)
......
......@@ -955,7 +955,7 @@ int main(int argc, char *argv[])
omp_set_num_threads(numThreads);
ompNumThreads = omp_get_max_threads();
if ( omp_get_max_threads() > omp_get_num_procs() )
fprintf(stderr, " Number of threads is greater than number of CPUs=%d!\n", omp_get_num_procs());
fprintf(stderr, "Warning: Number of OMP threads is greater than number of CPUs=%d!\n", omp_get_num_procs());
if ( cdoVerbose )
fprintf(stderr, " OpenMP: num_procs = %d max_threads = %d\n",
omp_get_num_procs(), omp_get_max_threads());
......
......@@ -332,6 +332,7 @@ int pstreamOpenRead(const char *argument)
int rval;
pthread_t thrID;
pthread_attr_t attr;
struct sched_param param;
size_t len;
size_t stacksize;
int status;
......@@ -359,7 +360,11 @@ int pstreamOpenRead(const char *argument)
if ( status ) SysError(func, "pthread_attr_init failed for '%s'\n", newarg+1);
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
if ( status ) SysError(func, "pthread_attr_setdetachstate failed for '%s'\n", newarg+1);
/*
param.sched_priority = 0;
status = pthread_attr_setschedparam(&attr, &param);
if ( status ) SysError(func, "pthread_attr_setschedparam failed for '%s'\n", newarg+1);
*/
/* status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); */
/* if ( status ) SysError(func, "pthread_attr_setinheritsched failed for '%s'\n", newarg+1); */
......@@ -1355,7 +1360,9 @@ void cdoInitialize(void *argument)
int processID;
#if defined (_OPENMP)
#if !(defined __APPLE__ && defined __MACH__)
omp_set_num_threads(ompNumThreads); /* Have to be called for every module (pthread)! */
#endif
#endif
processID = processCreate();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment