From 12929c457104dd86d9e627396461422f0f48ff66 Mon Sep 17 00:00:00 2001 From: scribam Date: Mon, 16 May 2022 11:15:11 +0200 Subject: [PATCH] openmp: use _OPENMP preprocessor, search openmp pkg unconditionally if enabled --- CMakeLists.txt | 26 +++---- core/rend/TexCache.cpp | 6 +- core/rend/gui.cpp | 2 +- shell/libretro/libretro.cpp | 6 +- shell/libretro/libretro_core_options.h | 2 +- shell/libretro/libretro_core_options_intl.h | 78 ++++++++++----------- 6 files changed, 60 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08dfaea7b..706d0be0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,20 +201,20 @@ if(NOT LIBRETRO) endif() endif() -find_package(OpenMP) -if(OpenMP_CXX_FOUND AND NOT APPLE AND USE_OPENMP) - if(MINGW) - target_link_libraries(${PROJECT_NAME} PRIVATE "-static -lgomp -lpthread") - target_compile_options(${PROJECT_NAME} PRIVATE -fopenmp) - elseif(ANDROID) - # Reference: https://android.googlesource.com/platform/ndk/+/refs/heads/master/tests/device/openmp/CMakeLists.txt - set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_OPTIONS -fopenmp) - target_link_libraries(${PROJECT_NAME} PRIVATE -fopenmp -static-openmp) - else() - target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX) +if(USE_OPENMP) + find_package(OpenMP) + if(OpenMP_CXX_FOUND) + if(MINGW) + target_link_libraries(${PROJECT_NAME} PRIVATE "-static -lgomp -lpthread") + target_compile_options(${PROJECT_NAME} PRIVATE -fopenmp) + elseif(ANDROID) + # Reference: https://android.googlesource.com/platform/ndk/+/refs/heads/master/tests/device/openmp/CMakeLists.txt + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_OPTIONS -fopenmp) + target_link_libraries(${PROJECT_NAME} PRIVATE -fopenmp -static-openmp) + else() + target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX) + endif() endif() -else() - target_compile_definitions(${PROJECT_NAME} PRIVATE TARGET_NO_OPENMP) endif() option(BUILD_SHARED_LIBS "Build shared library" OFF) diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp index 3c1e8f645..d8034abfb 100644 --- a/core/rend/TexCache.cpp +++ b/core/rend/TexCache.cpp @@ -9,7 +9,7 @@ #include #include -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP #include #endif @@ -295,7 +295,7 @@ static void libCore_vramlock_Unlock_block_wb(vram_block* block) delete block; } -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP static inline int getThreadCount() { int tcount = omp_get_num_procs() - 1; @@ -324,7 +324,7 @@ static struct xbrz::ScalerCfg xbrz_cfg; void UpscalexBRZ(int factor, u32* source, u32* dest, int width, int height, bool has_alpha) { -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP parallelize([=](int start, int end) { xbrz::scale(factor, source, dest, width, height, has_alpha ? xbrz::ColorFormat::ARGB : xbrz::ColorFormat::RGB, xbrz_cfg, start, end); diff --git a/core/rend/gui.cpp b/core/rend/gui.cpp index d6b5e0366..0e37a491f 100644 --- a/core/rend/gui.cpp +++ b/core/rend/gui.cpp @@ -1903,7 +1903,7 @@ static void gui_display_settings() ImGui::Spacing(); header("Texture Upscaling"); { -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP OptionArrowButtons("Texture Upscaling", config::TextureUpscale, 1, 8, "Upscale textures with the xBRZ algorithm. Only on fast platforms and for certain 2D games"); OptionSlider("Texture Max Size", config::MaxFilteredTextureSize, 8, 1024, diff --git a/shell/libretro/libretro.cpp b/shell/libretro/libretro.cpp index 375efddfc..4cab3d839 100644 --- a/shell/libretro/libretro.cpp +++ b/shell/libretro/libretro.cpp @@ -121,7 +121,7 @@ static bool platformIsArcade = false; static bool threadedRenderingEnabled = true; static bool oitEnabled = false; static bool autoSkipFrameEnabled = false; -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP static bool textureUpscaleEnabled = false; #endif static bool vmuScreenSettingsShown = true; @@ -363,7 +363,7 @@ void retro_deinit() threadedRenderingEnabled = true; oitEnabled = false; autoSkipFrameEnabled = false; -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP textureUpscaleEnabled = false; #endif vmuScreenSettingsShown = true; @@ -491,7 +491,7 @@ static bool set_variable_visibility(void) } #endif -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP // Only if texture upscaling is enabled bool textureUpscaleWasEnabled = textureUpscaleEnabled; textureUpscaleEnabled = false; diff --git a/shell/libretro/libretro_core_options.h b/shell/libretro/libretro_core_options.h index 455e105cd..7d479efc4 100644 --- a/shell/libretro/libretro_core_options.h +++ b/shell/libretro/libretro_core_options.h @@ -501,7 +501,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", "Texture Upscaling (xBRZ)", diff --git a/shell/libretro/libretro_core_options_intl.h b/shell/libretro/libretro_core_options_intl.h index 67a8742e9..155270ee7 100644 --- a/shell/libretro/libretro_core_options_intl.h +++ b/shell/libretro/libretro_core_options_intl.h @@ -643,7 +643,7 @@ struct retro_core_option_v2_definition option_defs_ar[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_AR, @@ -2178,7 +2178,7 @@ struct retro_core_option_v2_definition option_defs_ast[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_AST, @@ -3713,7 +3713,7 @@ struct retro_core_option_v2_definition option_defs_ca[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_CA, @@ -5248,7 +5248,7 @@ struct retro_core_option_v2_definition option_defs_chs[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_CHS, @@ -6783,7 +6783,7 @@ struct retro_core_option_v2_definition option_defs_cht[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_CHT, @@ -8318,7 +8318,7 @@ struct retro_core_option_v2_definition option_defs_cs[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_CS, @@ -9853,7 +9853,7 @@ struct retro_core_option_v2_definition option_defs_cy[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_CY, @@ -11388,7 +11388,7 @@ struct retro_core_option_v2_definition option_defs_da[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_DA, @@ -12923,7 +12923,7 @@ struct retro_core_option_v2_definition option_defs_de[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_DE, @@ -14458,7 +14458,7 @@ struct retro_core_option_v2_definition option_defs_el[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_EL, @@ -15993,7 +15993,7 @@ struct retro_core_option_v2_definition option_defs_eo[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_EO, @@ -17528,7 +17528,7 @@ struct retro_core_option_v2_definition option_defs_es[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_ES, @@ -19063,7 +19063,7 @@ struct retro_core_option_v2_definition option_defs_fa[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_FA, @@ -20598,7 +20598,7 @@ struct retro_core_option_v2_definition option_defs_fi[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_FI, @@ -22133,7 +22133,7 @@ struct retro_core_option_v2_definition option_defs_fr[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_FR, @@ -23668,7 +23668,7 @@ struct retro_core_option_v2_definition option_defs_gl[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_GL, @@ -25203,7 +25203,7 @@ struct retro_core_option_v2_definition option_defs_he[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_HE, @@ -26738,7 +26738,7 @@ struct retro_core_option_v2_definition option_defs_hu[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_HU, @@ -28273,7 +28273,7 @@ struct retro_core_option_v2_definition option_defs_id[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_ID, @@ -29808,7 +29808,7 @@ struct retro_core_option_v2_definition option_defs_it[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_IT, @@ -31343,7 +31343,7 @@ struct retro_core_option_v2_definition option_defs_ja[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_JA, @@ -32878,7 +32878,7 @@ struct retro_core_option_v2_definition option_defs_ko[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_KO, @@ -34413,7 +34413,7 @@ struct retro_core_option_v2_definition option_defs_mt[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_MT, @@ -35948,7 +35948,7 @@ struct retro_core_option_v2_definition option_defs_nl[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_NL, @@ -37483,7 +37483,7 @@ struct retro_core_option_v2_definition option_defs_no[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_NO, @@ -39018,7 +39018,7 @@ struct retro_core_option_v2_definition option_defs_oc[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_OC, @@ -40553,7 +40553,7 @@ struct retro_core_option_v2_definition option_defs_pl[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_PL, @@ -42088,7 +42088,7 @@ struct retro_core_option_v2_definition option_defs_pt_br[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_PT_BR, @@ -43623,7 +43623,7 @@ struct retro_core_option_v2_definition option_defs_pt_pt[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_PT_PT, @@ -45158,7 +45158,7 @@ struct retro_core_option_v2_definition option_defs_ro[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_RO, @@ -46693,7 +46693,7 @@ struct retro_core_option_v2_definition option_defs_ru[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_RU, @@ -48228,7 +48228,7 @@ struct retro_core_option_v2_definition option_defs_si[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_SI, @@ -49763,7 +49763,7 @@ struct retro_core_option_v2_definition option_defs_sk[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_SK, @@ -51298,7 +51298,7 @@ struct retro_core_option_v2_definition option_defs_sr[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_SR, @@ -52833,7 +52833,7 @@ struct retro_core_option_v2_definition option_defs_sv[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_SV, @@ -54368,7 +54368,7 @@ struct retro_core_option_v2_definition option_defs_tr[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_TR, @@ -55903,7 +55903,7 @@ struct retro_core_option_v2_definition option_defs_uk[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_UK, @@ -57438,7 +57438,7 @@ struct retro_core_option_v2_definition option_defs_val[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_VAL, @@ -58973,7 +58973,7 @@ struct retro_core_option_v2_definition option_defs_vn[] = { }, "disabled", }, -#ifndef TARGET_NO_OPENMP +#ifdef _OPENMP { CORE_OPTION_NAME "_texupscale", CORE_OPTION_NAME_TEXUPSCALE_LABEL_VN,