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 ...@@ -31,7 +31,7 @@ case "${HOSTNAME}" in
--with-hdf5=/opt/local \ --with-hdf5=/opt/local \
--with-szlib=/opt/local \ --with-szlib=/opt/local \
--with-proj=/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 # ia64-xxx-linux
ds*) ds*)
......
...@@ -955,7 +955,7 @@ int main(int argc, char *argv[]) ...@@ -955,7 +955,7 @@ int main(int argc, char *argv[])
omp_set_num_threads(numThreads); omp_set_num_threads(numThreads);
ompNumThreads = omp_get_max_threads(); ompNumThreads = omp_get_max_threads();
if ( omp_get_max_threads() > omp_get_num_procs() ) 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 ) if ( cdoVerbose )
fprintf(stderr, " OpenMP: num_procs = %d max_threads = %d\n", fprintf(stderr, " OpenMP: num_procs = %d max_threads = %d\n",
omp_get_num_procs(), omp_get_max_threads()); omp_get_num_procs(), omp_get_max_threads());
......
...@@ -332,6 +332,7 @@ int pstreamOpenRead(const char *argument) ...@@ -332,6 +332,7 @@ int pstreamOpenRead(const char *argument)
int rval; int rval;
pthread_t thrID; pthread_t thrID;
pthread_attr_t attr; pthread_attr_t attr;
struct sched_param param;
size_t len; size_t len;
size_t stacksize; size_t stacksize;
int status; int status;
...@@ -359,7 +360,11 @@ int pstreamOpenRead(const char *argument) ...@@ -359,7 +360,11 @@ int pstreamOpenRead(const char *argument)
if ( status ) SysError(func, "pthread_attr_init failed for '%s'\n", newarg+1); if ( status ) SysError(func, "pthread_attr_init failed for '%s'\n", newarg+1);
status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
if ( status ) SysError(func, "pthread_attr_setdetachstate failed for '%s'\n", newarg+1); 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); */ /* status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); */
/* if ( status ) SysError(func, "pthread_attr_setinheritsched failed for '%s'\n", newarg+1); */ /* if ( status ) SysError(func, "pthread_attr_setinheritsched failed for '%s'\n", newarg+1); */
...@@ -1355,7 +1360,9 @@ void cdoInitialize(void *argument) ...@@ -1355,7 +1360,9 @@ void cdoInitialize(void *argument)
int processID; int processID;
#if defined (_OPENMP) #if defined (_OPENMP)
#if !(defined __APPLE__ && defined __MACH__)
omp_set_num_threads(ompNumThreads); /* Have to be called for every module (pthread)! */ omp_set_num_threads(ompNumThreads); /* Have to be called for every module (pthread)! */
#endif
#endif #endif
processID = processCreate(); 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