Skip to content

Commit

Permalink
Bugfix for max reduction + visibility for Spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
BDoignies committed Nov 9, 2023
1 parent 9b36d6a commit 7f178d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/utk/utils/Omp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
template<typename T>
T omp_parallel_max(const T* data, uint32_t size)
{
T max_val = std::numeric_limits<T>::max();
T max_val = std::numeric_limits<T>::min();

#pragma omp parallel
{
Expand All @@ -74,7 +74,7 @@
template<typename T>
T omp_parallel_max(const T* data, uint32_t size)
{
T maxval = std::numeric_limits<T>::max();
T maxval = std::numeric_limits<T>::min();

#pragma omp parallel for reduction(max: maxval)
for (OPENMP_UINT i = 0; i < size; i++)
Expand Down
5 changes: 3 additions & 2 deletions src/metrics/Spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char** argv)
}

unsigned char* data = new unsigned char[res * res];
double maxval = omp_parallel_max(rslts.data(), rslts.size());
const double maxval = omp_parallel_max(rslts.data(), rslts.size());

// Copy data to unsigned char buffer
#pragma omp parallel for
Expand All @@ -87,7 +87,8 @@ int main(int argc, char** argv)
{
const OPENMP_UINT idx = x + y * res;

double value = rslts[idx] / maxval;
// Common scaling to enhance visibility
double value = std::sqrt(rslts[idx] / maxval);
data[idx] = static_cast<unsigned char>(255 * value);
}
}
Expand Down

0 comments on commit 7f178d7

Please sign in to comment.