mirror of
				https://github.com/OPM/opm-simulators.git
				synced 2025-02-25 18:55:30 -06:00 
			
		
		
		
	flow: default to 2 threads if OpenMP is available
I still think it is better to specify `--threads-per-process` explicitly, but this patch is better than the current machinery...
This commit is contained in:
		| @@ -78,6 +78,11 @@ SET_SCALAR_PROP(FlowModelParameters, MaxPressureChangeMsWells, 2.0 *1e5); | ||||
| SET_BOOL_PROP(FlowModelParameters, UseInnerIterationsMsWells, true); | ||||
| SET_INT_PROP(FlowModelParameters, MaxInnerIterMsWells, 10); | ||||
|  | ||||
| // if openMP is available, determine the number threads per process automatically. | ||||
| #if _OPENMP | ||||
| SET_INT_PROP(FlowModelParameters, ThreadsPerProcess, -1); | ||||
| #endif | ||||
|  | ||||
| END_PROPERTIES | ||||
|  | ||||
| namespace Opm | ||||
|   | ||||
| @@ -255,6 +255,13 @@ namespace Opm | ||||
|             mpi_rank_ = 0; | ||||
|             mpi_size_ = 1; | ||||
| #endif | ||||
|  | ||||
| #if _OPENMP | ||||
|             // if openMP is available, default to 2 threads per process. | ||||
|             if (!getenv("OMP_NUM_THREADS")) | ||||
|                 omp_set_num_threads(std::min(2, omp_get_num_procs())); | ||||
| #endif | ||||
|  | ||||
|             typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager; | ||||
|             ThreadManager::init(); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user