Skip to content

Commit

Permalink
Feature #2724 mode_openmp (#2726)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Nov 7, 2023
1 parent 14f482b commit 46cf0db
Show file tree
Hide file tree
Showing 9 changed files with 490 additions and 658 deletions.
12 changes: 10 additions & 2 deletions docs/Users_Guide/config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,20 @@ Regions of parallelized code are:

* :code:`fractional_coverage (data_plane_util.cc)`

* Called by `gen_ens_prod` to compute NMEP outputs.
* Called by `grid_stat` when applying neighborhood verification methods.

* :code:`ShapeData::conv_filter_circ() (shapedata.cc)`

* Called by `mode` to apply a convolution smoothing operation when
defining objects.

Only the following top-level executables can presently benefit from OpenMP
parallelization:

* :code:`grid_stat`
* :code:`ensemble_stat`
* :code:`grid_ens_prod`
* :code:`mode`

**Thread Binding**

Expand All @@ -474,7 +482,7 @@ guarantees that threads remain evenly distributed across the available cores.
Otherwise, the operating system may migrate threads between cores during a run.

OpenMP provides some environment variables to handle this: :code:`OMP_PLACES`
and :code:`OMP_PROC_BIND`. We anticipate that the effect of setting only
and :code:`OMP_PROC_BIND`. We anticipate that the effect of setting only
:code:`OMP_PROC_BIND=true` would be neutral-to-positive.

However, there are sometimes compiler-specific environment variables. Instead,
Expand Down
77 changes: 39 additions & 38 deletions src/basic/vx_util/data_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using namespace std;

#include <algorithm>
#include <map>

#include "data_plane.h"

Expand Down Expand Up @@ -230,57 +231,57 @@ void DataPlane::dump(ostream & out, int depth) const {

void DataPlane::debug_examine(bool show_all_values) const {

vector<double> values;
vector<int> count;
// Nothing to print if verbosity level is below 4
if(mlog.verbosity_level() < 4) return;

map<double,int> value_count_map;
int total_count = 0;

for (int x=0; x<Nx; ++x) {
for (int y=0; y<Ny; ++y) {
double v = get(x,y);
if (v <= 0) {
continue;
}
++total_count;
if (show_all_values) {
vector<double>::iterator vi;
vi = find(values.begin(), values.end(), v);
if (vi == values.end()) {
values.push_back(v);
count.push_back(1);
} else {
int ii = vi - values.begin();
count[ii] = count[ii] + 1;
}

for(int i=0; i<Data.size(); i++) {

// Count positive values
if(Data[i] > 0) total_count++;

if (show_all_values) {

// Add a new map entry
if(value_count_map.count(Data[i]) == 0) {
value_count_map[Data[i]] = 0;
}

// Increment count
value_count_map[Data[i]] += 1;
}
}
if (show_all_values) {
for (size_t i=0; i<values.size(); ++i) {
mlog << Debug(4) << " data value=" << values[i] << " count=" << count[i] << "\n";

if(show_all_values) {
for(auto it = value_count_map.begin();
it != value_count_map.end(); it++) {
mlog << Debug(4) << " data value=" << it->first
<< " count=" << it->second << "\n";
}
}
mlog << Debug(4) << "Total count = " << total_count << "\n";

mlog << Debug(4) << "Total count > 0 = " << total_count
<< " of " << Data.size() << "\n";

return;
}

///////////////////////////////////////////////////////////////////////////////

string DataPlane::sdebug_examine() const{
ConcatString cs;
int n = 0;

int total_count = 0;

for (int x=0; x<Nx; ++x) {
for (int y=0; y<Ny; ++y) {
double v = get(x,y);
if (v <= 0) {
continue;
}
++total_count;
}
// Count positive values
for(auto it = Data.begin(); it != Data.end(); it++) {
if(*it > 0) n++;
}
char buf[1000];
sprintf(buf, "Total count = %d", total_count);
string retval = buf;
return retval;

cs << "Total count > 0 = " << n << " of " << (int) Data.size();

return cs;
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_util/vx_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "fix_float.h"
#include "get_filenames.h"
#include "grib_constants.h"
#include "GridTemplate.h"
#include "int_array.h"
#include "interp_mthd.h"
#include "interp_util.h"
Expand Down
Loading

0 comments on commit 46cf0db

Please sign in to comment.