Skip to content

Commit

Permalink
Clean up OpenMP usage and make it required
Browse files Browse the repository at this point in the history
  • Loading branch information
r-barnes committed Apr 9, 2022
1 parent 7b995a5 commit d30231e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(richdem
)

find_package(GDAL)
find_package(OpenMP)
find_package(OpenMP REQUIRED)
find_package(MPI)

set(CMAKE_MACOSX_RPATH 1)
Expand Down Expand Up @@ -43,10 +43,6 @@ add_library(richdem
src/terrain_generation/PerlinNoise.cpp
)

if(NOT OpenMP_CXX_FOUND)
message(WARNING "Compiling without OpenMP!")
endif()

# set_target_properties(richdem PROPERTIES VERSION ${PROJECT_VERSION})
# set_target_properties(richdem PROPERTIES SOVERSION 2)

Expand Down
15 changes: 6 additions & 9 deletions include/richdem/common/ProgressBar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@
#ifndef _richdem_progress_bar_hpp_
#define _richdem_progress_bar_hpp_

#include <string>
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <richdem/common/timer.hpp>

namespace richdem {
#include <iomanip>
#include <iostream>
#include <stdexcept>
#include <string>

///Macros used to disguise the fact that we do not have multithreading enabled.
#ifdef _OPENMP
#include <omp.h>
#else
#define omp_get_thread_num() 0
#define omp_get_num_threads() 1
#endif

namespace richdem {

///@brief Manages a console-based progress bar to keep the user entertained.
///
///Defining the global `RICHDEM_NO_PROGRESS` will
Expand Down
12 changes: 4 additions & 8 deletions include/richdem/common/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@
#include <random>
#include <string>

#ifdef _OPENMP
#include <omp.h>
#endif

namespace richdem {

///Maximum number of threads this class should deal with
#define PRNG_THREAD_MAX 32

#ifdef _OPENMP
#include <omp.h>
#else
#define omp_get_thread_num() 0
#define omp_get_num_threads() 1
#define omp_get_max_threads() 1
#endif

typedef std::string RandomEngineState;

typedef std::mt19937 our_random_engine;
Expand Down

0 comments on commit d30231e

Please sign in to comment.