Skip to content

Commit

Permalink
split most shared OMP task keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Aug 2, 2023
1 parent a3ba8e6 commit 175255f
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 115 deletions.
58 changes: 53 additions & 5 deletions EidosScribe/EidosHelpFunctions.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -5928,7 +5928,13 @@ The task keys recognized, and the tasks they govern, are:\
"MAX_INT" max(integer x)\uc0\u8232 "MAX_FLOAT" max(float x)\u8232 "MIN_INT" min(integer x)\u8232 "MIN_FLOAT" min(float x)\u8232 "PMAX_INT_1" pmax(i$ x, i y) / pmax(i x, i$ y)\u8232 "PMAX_INT_2" pmax(integer x, integer y)\u8232 "PMAX_FLOAT_1" pmax(f$ x, f y) / pmax(f x, f$ y)\u8232 "PMAX_FLOAT_2" pmax(float x, float y)\u8232 "PMIN_INT_1" pmin(i$ x, i y) / pmax(i x, i$ y)\u8232 "PMIN_INT_2" pmin(integer x, integer y)\u8232 "PMIN_FLOAT_1" pmin(f$ x, f y) / pmin(f x, f$ y)\u8232 "PMIN_FLOAT_2" pmin(float x, float y)\
"MATCH_INT" match(integer x, integer table)\uc0\u8232 "MATCH_FLOAT" match(float x, float table)\u8232 "MATCH_STRING" match(string x, string table)\u8232 "MATCH_OBJECT" match(object x, object table)\u8232 "SAMPLE_INDEX" sample()
\f3\fs20 index buffer generation (internal)
\f1\fs18 \uc0\u8232 "SAMPLE_R_INT" sample(integer x, weights=NULL)\u8232 "SAMPLE_R_FLOAT" sample(float x, weights=NULL)\u8232 "SAMPLE_R_OBJECT" sample(object x, weights=NULL)\u8232 "SAMPLE_WR_INT" sample(integer x, if weights)\u8232 "SAMPLE_WR_FLOAT" sample(float x, if weights)\u8232 "SAMPLE_WR_OBJECT" sample(object x, if weights)\u8232 "TABULATE" tabulate()\
\f1\fs18 \uc0\u8232 "SAMPLE_R_INT" sample(integer x, weights=NULL)\u8232 "SAMPLE_R_FLOAT" sample(float x, weights=NULL)\u8232 "SAMPLE_R_OBJECT" sample(object x, weights=NULL)\u8232 "SAMPLE_WR_INT" sample(integer x, if weights)\u8232 "SAMPLE_WR_FLOAT" sample(float x, if weights)\u8232 "SAMPLE_WR_OBJECT" sample(object x, if weights)\u8232 "TABULATE_MAXBIN" tabulate()
\f3\fs20 determination of
\f1\fs18 maxbin
\f3\fs20 (if not supplied)
\f1\fs18 \uc0\u8232 "TABULATE" tabulate()
\f3\fs20 main loop
\f1\fs18 \
"DNORM_1" dnorm(numeric$ mean, numeric$ sd)\uc0\u8232 "DNORM_2" dnorm()
\f3\fs20 other cases
\f1\fs18 \uc0\u8232 "RBINOM_1" rbinom(i$ size = 1, f$ prob = 0.5)\u8232 "RBINOM_2" rbinom(i$ size, f$ prob)
Expand All @@ -5953,12 +5959,54 @@ The task keys recognized, and the tasks they govern, are:\
\f3\fs20 other cases
\f1\fs18 \
"CLIPPEDINTEGRAL_1" clippedIntegral() "x"\uc0\u8232 "CLIPPEDINTEGRAL_2" clippedIntegral() "y"\u8232 "CLIPPEDINTEGRAL_3" clippedIntegral() "z"\u8232 "CLIPPEDINTEGRAL_4" clippedIntegral() "xy"\u8232 "CLIPPEDINTEGRAL_5" clippedIntegral() "xz"\u8232 "CLIPPEDINTEGRAL_6" clippedIntegral() "yz"\u8232 "DRAWBYSTRENGTH" drawByStrength(returnDict=T)\u8232 "INTNEIGHCOUNT" interactingNeighborSount()\u8232 "LOCALPOPDENSITY" localPopulationDensity()\u8232 "NEARESTINTNEIGH" nearestInteractingNeighbors(returnDict=T)\u8232 "NEARESTNEIGH" nearestNeighbors(returnDict=T)\u8232 "NEIGHCOUNT" neighborCount()\u8232 "TOTNEIGHSTRENGTH" totalOfNeighborsStrengths()\
"POINT_IN_BOUNDS" pointInBounds()\uc0\u8232 "POINT_PERIODIC" pointPeriodic()\u8232 "POINT_REFLECTED" pointReflected()\u8232 "POINT_STOPPED" pointStopped()\u8232 "POINT_UNIFORM" pointUniform()\u8232 "SET_SPATIAL_POS_1" setSpatialPosition()
\f3\fs20 with one point
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_2" setSpatialPosition()
"POINT_IN_BOUNDS_1D" pointInBounds()
\f3\fs20 , 1D case
\f1\fs18 \uc0\u8232 "POINT_IN_BOUNDS_2D" pointInBounds()
\f3\fs20 , 2D case
\f1\fs18 \uc0\u8232 "POINT_IN_BOUNDS_3D" pointInBounds()
\f3\fs20 , 3D case
\f1\fs18 \uc0\u8232 "POINT_PERIODIC_1D" pointPeriodic()
\f3\fs20 , 1D case
\f1\fs18 \uc0\u8232 "POINT_PERIODIC_2D" pointPeriodic()
\f3\fs20 , 2D case
\f1\fs18 \uc0\u8232 "POINT_PERIODIC_3D" pointPeriodic()
\f3\fs20 , 3D case
\f1\fs18 \uc0\u8232 "POINT_REFLECTED_1D" pointReflected()
\f3\fs20 , 1D case
\f1\fs18 \uc0\u8232 "POINT_REFLECTED_2D" pointReflected()
\f3\fs20 , 2D case
\f1\fs18 \uc0\u8232 "POINT_REFLECTED_3D" pointReflected()
\f3\fs20 , 3D case
\f1\fs18 \uc0\u8232 "POINT_STOPPED_1D" pointStopped()
\f3\fs20 , 1D case
\f1\fs18 \uc0\u8232 "POINT_STOPPED_2D" pointStopped()
\f3\fs20 , 2D case
\f1\fs18 \uc0\u8232 "POINT_STOPPED_3D" pointStopped()
\f3\fs20 , 3D case
\f1\fs18 \uc0\u8232 "POINT_UNIFORM_1D" pointUniform()
\f3\fs20 , 1D case
\f1\fs18 \uc0\u8232 "POINT_UNIFORM_2D" pointUniform()
\f3\fs20 , 2D case
\f1\fs18 \uc0\u8232 "POINT_UNIFORM_3D" pointUniform()
\f3\fs20 , 3D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_1_1D" setSpatialPosition()
\f3\fs20 with one point, 1D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_1_2D" setSpatialPosition()
\f3\fs20 with one point, 2D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_1_3D" setSpatialPosition()
\f3\fs20 with one point, 3D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_2_1D" setSpatialPosition()
\f3\fs20 with
\f7\i N
\f3\i0 points, 1D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_2_2D" setSpatialPosition()
\f3\fs20 with
\f7\i N
\f3\i0 points, 2D case
\f1\fs18 \uc0\u8232 "SET_SPATIAL_POS_2_3D" setSpatialPosition()
\f3\fs20 with
\f7\i N
\f3\i0 points
\f3\i0 points, 3D case
\f1\fs18 \uc0\u8232 "SPATIAL_MAP_VALUE" spatialMapValue()\
"CONTAINS_MARKER_MUT" containsMarkerMutation(returnMutation = F)\uc0\u8232 "I_COUNT_OF_MUTS_OF_TYPE" countOfMutationsOfType() (Individual)\u8232 "G_COUNT_OF_MUTS_OF_TYPE" countOfMutationsOfType() (Genome)\u8232 "INDS_W_PEDIGREE_IDS" individualsWithPedigreeIDs()\u8232 "RELATEDNESS" relatedness()\u8232 "SAMPLE_INDIVIDUALS_1" sampleIndividuals()
\f3\fs20 simple case with replace=T
Expand Down
31 changes: 23 additions & 8 deletions QtSLiM/help/EidosHelpFunctions.html
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@
"SAMPLE_WR_INT"<span class="Apple-tab-span"> </span>sample(integer x, if weights)<br>
"SAMPLE_WR_FLOAT"<span class="Apple-tab-span"> </span>sample(float x, if weights)<br>
"SAMPLE_WR_OBJECT"<span class="Apple-tab-span"> </span>sample(object x, if weights)<br>
"TABULATE"<span class="Apple-tab-span"> </span>tabulate()</p>
"TABULATE_MAXBIN"<span class="Apple-tab-span"> </span>tabulate()<span class="s19"> determination of </span>maxbin<span class="s19"> (if not supplied)</span><br>
"TABULATE"<span class="Apple-tab-span"> </span>tabulate()<span class="s19"> main loop</span></p>
<p class="p10">"DNORM_1"<span class="Apple-tab-span"> </span>dnorm(numeric$ mean, numeric$ sd)<br>
"DNORM_2"<span class="Apple-tab-span"> </span>dnorm()<span class="s19"> other cases</span><br>
"RBINOM_1"<span class="Apple-tab-span"> </span>rbinom(i$ size = 1, f$ prob = 0.5)<br>
Expand Down Expand Up @@ -563,13 +564,27 @@
"NEARESTNEIGH"<span class="Apple-tab-span"> </span>nearestNeighbors(returnDict=T)<br>
"NEIGHCOUNT"<span class="Apple-tab-span"> </span>neighborCount()<br>
"TOTNEIGHSTRENGTH"<span class="Apple-tab-span"> </span>totalOfNeighborsStrengths()</p>
<p class="p10">"POINT_IN_BOUNDS"<span class="Apple-tab-span"> </span>pointInBounds()<br>
"POINT_PERIODIC"<span class="Apple-tab-span"> </span>pointPeriodic()<br>
"POINT_REFLECTED"<span class="Apple-tab-span"> </span>pointReflected()<br>
"POINT_STOPPED"<span class="Apple-tab-span"> </span>pointStopped()<br>
"POINT_UNIFORM"<span class="Apple-tab-span"> </span>pointUniform()<br>
"SET_SPATIAL_POS_1"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with one point</span><br>
"SET_SPATIAL_POS_2"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with <i>N</i> points</span><br>
<p class="p10">"POINT_IN_BOUNDS_1D"<span class="Apple-tab-span"> </span>pointInBounds()<span class="s19">, 1D case</span><br>
"POINT_IN_BOUNDS_2D"<span class="Apple-tab-span"> </span>pointInBounds()<span class="s19">, 2D case</span><br>
"POINT_IN_BOUNDS_3D"<span class="Apple-tab-span"> </span>pointInBounds()<span class="s19">, 3D case</span><br>
"POINT_PERIODIC_1D"<span class="Apple-tab-span"> </span>pointPeriodic()<span class="s19">, 1D case</span><br>
"POINT_PERIODIC_2D"<span class="Apple-tab-span"> </span>pointPeriodic()<span class="s19">, 2D case</span><br>
"POINT_PERIODIC_3D"<span class="Apple-tab-span"> </span>pointPeriodic()<span class="s19">, 3D case</span><br>
"POINT_REFLECTED_1D"<span class="Apple-tab-span"> </span>pointReflected()<span class="s19">, 1D case</span><br>
"POINT_REFLECTED_2D"<span class="Apple-tab-span"> </span>pointReflected()<span class="s19">, 2D case</span><br>
"POINT_REFLECTED_3D"<span class="Apple-tab-span"> </span>pointReflected()<span class="s19">, 3D case</span><br>
"POINT_STOPPED_1D"<span class="Apple-tab-span"> </span>pointStopped()<span class="s19">, 1D case</span><br>
"POINT_STOPPED_2D"<span class="Apple-tab-span"> </span>pointStopped()<span class="s19">, 2D case</span><br>
"POINT_STOPPED_3D"<span class="Apple-tab-span"> </span>pointStopped()<span class="s19">, 3D case</span><br>
"POINT_UNIFORM_1D"<span class="Apple-tab-span"> </span>pointUniform()<span class="s19">, 1D case</span><br>
"POINT_UNIFORM_2D"<span class="Apple-tab-span"> </span>pointUniform()<span class="s19">, 2D case</span><br>
"POINT_UNIFORM_3D"<span class="Apple-tab-span"> </span>pointUniform()<span class="s19">, 3D case</span><br>
"SET_SPATIAL_POS_1_1D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with one point, 1D case</span><br>
"SET_SPATIAL_POS_1_2D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with one point, 2D case</span><br>
"SET_SPATIAL_POS_1_3D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with one point, 3D case</span><br>
"SET_SPATIAL_POS_2_1D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with <i>N</i> points, 1D case</span><br>
"SET_SPATIAL_POS_2_2D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with <i>N</i> points, 2D case</span><br>
"SET_SPATIAL_POS_2_3D"<span class="Apple-tab-span"> </span>setSpatialPosition()<span class="s19"> with <i>N</i> points, 3D case</span><br>
"SPATIAL_MAP_VALUE"<span class="Apple-tab-span"> </span>spatialMapValue()</p>
<p class="p10">"CONTAINS_MARKER_MUT"<span class="Apple-tab-span"> </span>containsMarkerMutation(returnMutation = F)<br>
"I_COUNT_OF_MUTS_OF_TYPE"<span class="Apple-tab-span"> </span>countOfMutationsOfType() (Individual)<br>
Expand Down
28 changes: 15 additions & 13 deletions core/individual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
{
double x = position_value->FloatAtIndex(0, nullptr);

EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1) num_threads(thread_count)
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_1D);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_1D) num_threads(thread_count)
for (int target_index = 0; target_index < target_size; ++target_index)
{
Individual *target = targets[target_index];
Expand All @@ -1920,8 +1920,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
double x = position_value->FloatAtIndex(0, nullptr);
double y = position_value->FloatAtIndex(1, nullptr);

EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1) num_threads(thread_count)
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_2D);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_2D) num_threads(thread_count)
for (int target_index = 0; target_index < target_size; ++target_index)
{
Individual *target = targets[target_index];
Expand All @@ -1936,8 +1936,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
double y = position_value->FloatAtIndex(1, nullptr);
double z = position_value->FloatAtIndex(2, nullptr);

EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y, z) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1) num_threads(thread_count)
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_1_3D);
#pragma omp parallel for simd schedule(simd:static) default(none) shared(target_size) firstprivate(targets, x, y, z) if(target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_1_3D) num_threads(thread_count)
for (int target_index = 0; target_index < target_size; ++target_index)
{
Individual *target = targets[target_index];
Expand All @@ -1959,14 +1959,16 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
const double *positions = position_vec->data();

#ifdef _OPENMP
if (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2)
if (((dimensionality == 1) && (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2_1D)) ||
((dimensionality == 2) && (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2_2D)) ||
((dimensionality == 3) && (target_size >= EIDOS_OMPMIN_SET_SPATIAL_POS_2_3D)))
{
switch (dimensionality)
{
case 1:
{
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2) is above
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2_1D);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2_1D) is above
for (int target_index = 0; target_index < target_size; ++target_index)
{
targets[target_index]->spatial_x_ = positions[target_index];
Expand All @@ -1975,8 +1977,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
}
case 2:
{
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2) is above
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2_2D);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2_2D) is above
for (int target_index = 0; target_index < target_size; ++target_index)
{
Individual *target = targets[target_index];
Expand All @@ -1989,8 +1991,8 @@ EidosValue_SP Individual_Class::ExecuteMethod_setSpatialPosition(EidosGlobalStri
}
case 3:
{
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2) is above
EIDOS_THREAD_COUNT(gEidos_OMP_threads_SET_SPATIAL_POS_2_3D);
#pragma omp parallel for schedule(static) default(none) shared(target_size) firstprivate(targets, positions) num_threads(thread_count) // if(EIDOS_OMPMIN_SET_SPATIAL_POS_2_3D) is above
for (int target_index = 0; target_index < target_size; ++target_index)
{
Individual *target = targets[target_index];
Expand Down
2 changes: 1 addition & 1 deletion core/population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ void Population::DoDeferredReproduction(void)
}
}

//EIDOS_THREAD_COUNT(gEidos_OMP_threads_DEFERRED_REPRO);
//EIDOS_THREAD_COUNT(gEidos_OMP_threads_DEFERRED_REPRO); // this loop shares the same key
#pragma omp parallel for schedule(dynamic, 1) default(none) shared(deferred_count_recombinant) if(deferred_count_recombinant >= EIDOS_OMPMIN_DEFERRED_REPRO) num_threads(thread_count)
for (size_t deferred_index = 0; deferred_index < deferred_count_recombinant; ++deferred_index)
{
Expand Down
Loading

0 comments on commit 175255f

Please sign in to comment.