From 1a47fc8e309b3473641a2b4f39161c2ef3275d83 Mon Sep 17 00:00:00 2001 From: Shanigen Date: Wed, 5 Sep 2018 13:02:57 +0200 Subject: [PATCH] Moved omp pragmas declaration to seperate file Definition of omp pragmas have nothing to do with Scale_vars, for that reason pragmas.h was created with all of the definitions. --- src/CMakeLists.txt | 2 +- src/kcf.h | 1 + src/piotr_fhog/fhog.hpp | 1 + src/pragmas.h | 21 +++++++++++++++++++++ src/scale_vars.hpp | 17 ----------------- 5 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 src/pragmas.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d403299..4bdff1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8) -set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp scale_vars.hpp) +set(KCF_LIB_SRC kcf.cpp kcf.h fft.cpp scale_vars.hpp pragmas.h) find_package(PkgConfig) diff --git a/src/kcf.h b/src/kcf.h index 4205921..afd90a5 100644 --- a/src/kcf.h +++ b/src/kcf.h @@ -18,6 +18,7 @@ #include "cnfeat.hpp" #include "fft.h" #include "scale_vars.hpp" +#include "pragmas.h" struct BBox_c { diff --git a/src/piotr_fhog/fhog.hpp b/src/piotr_fhog/fhog.hpp index db7912a..3b5c0cd 100644 --- a/src/piotr_fhog/fhog.hpp +++ b/src/piotr_fhog/fhog.hpp @@ -12,6 +12,7 @@ #include "gradientMex.h" #include "scale_vars.hpp" +#include "pragmas.h" struct Scale_vars; diff --git a/src/pragmas.h b/src/pragmas.h new file mode 100644 index 0000000..7342cfd --- /dev/null +++ b/src/pragmas.h @@ -0,0 +1,21 @@ +#ifndef PRAGMAS_H +#define PRAGMAS_H + +#if defined(BIG_BATCH) && defined(OPENMP) +#define BIG_BATCH_OMP_PARALLEL_FOR _Pragma("omp parallel for ordered") +#define BIG_BATCH_OMP_ORDERED _Pragma("omp ordered") +#define NORMAL_OMP_PARALLEL_FOR +#define NORMAL_OMP_CRITICAL +#elif defined(OPENMP) +#define BIG_BATCH_OMP_PARALLEL_FOR +#define BIG_BATCH_OMP_ORDERED +#define NORMAL_OMP_PARALLEL_FOR _Pragma("omp parallel for schedule(dynamic)") +#define NORMAL_OMP_CRITICAL _Pragma("omp critical") +#else +#define BIG_BATCH_OMP_PARALLEL_FOR +#define BIG_BATCH_OMP_ORDERED +#define NORMAL_OMP_PARALLEL_FOR +#define NORMAL_OMP_CRITICAL +#endif + +#endif // PRAGMAS_H diff --git a/src/scale_vars.hpp b/src/scale_vars.hpp index e550bc8..75d0b8c 100644 --- a/src/scale_vars.hpp +++ b/src/scale_vars.hpp @@ -13,23 +13,6 @@ typedef int *cudaStream_t; #endif #endif -#if defined(BIG_BATCH) && defined(OPENMP) -#define BIG_BATCH_OMP_PARALLEL_FOR _Pragma("omp parallel for ordered") -#define BIG_BATCH_OMP_ORDERED _Pragma("omp ordered") -#define NORMAL_OMP_PARALLEL_FOR -#define NORMAL_OMP_CRITICAL -#elif defined(OPENMP) -#define BIG_BATCH_OMP_PARALLEL_FOR -#define BIG_BATCH_OMP_ORDERED -#define NORMAL_OMP_PARALLEL_FOR _Pragma("omp parallel for schedule(dynamic)") -#define NORMAL_OMP_CRITICAL _Pragma("omp critical") -#else -#define BIG_BATCH_OMP_PARALLEL_FOR -#define BIG_BATCH_OMP_ORDERED -#define NORMAL_OMP_PARALLEL_FOR -#define NORMAL_OMP_CRITICAL -#endif - struct Scale_vars { public: Scale_vars(int windows_size[2], int cell_size, int num_of_feats, int num_of_scales = 1, -- 2.39.2