From aa07ebd83b172ffec5a18e1b36ee728adf39b3db Mon Sep 17 00:00:00 2001 From: Dmitry Baryshev Date: Thu, 16 Nov 2023 16:29:40 +0300 Subject: [PATCH] SAIL: Added SAIL_OPENMP_SCHEDULE build option with the default value of 'dynamic' --- BUILDING.md | 1 + CMakeLists.txt | 1 + src/config.h.in | 3 +++ src/sail-manip/convert.c | 32 ++++++++++++++++---------------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index f72d1800..088afed8 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -24,6 +24,7 @@ vcpkg install sail - `SAIL_THIRD_PARTY_CODECS_PATH=ON|OFF` - Enable loading custom codecs from the ';'-separated paths specified in the `SAIL_THIRD_PARTY_CODECS_PATH` environment variable. Default: `ON` - `SAIL_THREAD_SAFE=ON|OFF` - Enable working in multi-threaded environments by locking the internal context with a mutex. Default: `ON` - `SAIL_ONLY_CODECS="a;b;c"` - Forcefully enable only the codecs specified in this ';'-separated list and disable the rest. If an enabled codec fails to find its dependencies, the configuration process fails. One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm. Default: empty list +- `SAIL_OPENMP_SCHEDULE="dynamic"` - OpenMP scheduling algorithm. Default: dynamic ### Windows diff --git a/CMakeLists.txt b/CMakeLists.txt index f56da3ec..3db3c9fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ option(SAIL_INSTALL_PDB "Install PDB files along with libraries." ON) set(SAIL_ONLY_CODECS "" CACHE STRING "Forcefully enable only the codecs specified in this ';'-separated list and disable the rest. \ If an enabled codec fails to find its dependencies, the configuration process fails. \ One can also specify not just individual codecs but codec groups by their priority like that: highest-priority;xbm.") +set(SAIL_OPENMP_SCHEDULE "dynamic" CACHE STRING "OpenMP scheduling algorithm.") option(BUILD_SHARED_LIBS "Build shared libs. When disabled, sets SAIL_COMBINE_CODECS to ON automatically." ON) cmake_dependent_option(SAIL_COMBINE_CODECS "Combine all codecs into a single library. When disabled, all codecs are implemented as \ dynamically loaded plugins." OFF "BUILD_SHARED_LIBS" ON) diff --git a/src/config.h.in b/src/config.h.in index 33cf0d4b..6a51a8d2 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -87,4 +87,7 @@ /* Enabled built-in codecs. */ @SAIL_HAVE_CODEC_DEFINES@ +/* OpenMP scheduling algorithm. */ +#cmakedefine SAIL_OPENMP_SCHEDULE @SAIL_OPENMP_SCHEDULE@ + #endif diff --git a/src/sail-manip/convert.c b/src/sail-manip/convert.c index ef54ff96..03c260ae 100644 --- a/src/sail-manip/convert.c +++ b/src/sail-manip/convert.c @@ -195,7 +195,7 @@ static sail_status_t convert_from_indexed(const struct sail_image *image, sail_status_t status = SAIL_OK; unsigned row; - #pragma omp parallel for shared(status) + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) shared(status) for (row = 0; row < image->height; row++) { #pragma omp flush(status) if (status == SAIL_OK) { @@ -264,7 +264,7 @@ static sail_status_t convert_from_grayscale_up_to_bpp8(const struct sail_image * unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -324,7 +324,7 @@ static sail_status_t convert_from_bpp16_grayscale(const struct sail_image *image unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -344,7 +344,7 @@ static sail_status_t convert_from_bpp16_grayscale_alpha(const struct sail_image unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -366,7 +366,7 @@ static sail_status_t convert_from_bpp32_grayscale_alpha(const struct sail_image unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -388,7 +388,7 @@ static sail_status_t convert_from_bpp16_rgb555(const struct sail_image *image, p unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -409,7 +409,7 @@ static sail_status_t convert_from_bpp16_bgr555(const struct sail_image *image, p unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -430,7 +430,7 @@ static sail_status_t convert_from_bpp16_rgb565(const struct sail_image *image, p unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -451,7 +451,7 @@ static sail_status_t convert_from_bpp16_bgr565(const struct sail_image *image, p unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -472,7 +472,7 @@ static sail_status_t convert_from_bpp24_rgb_kind(const struct sail_image *image, unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -493,7 +493,7 @@ static sail_status_t convert_from_bpp48_rgb_kind(const struct sail_image *image, unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -514,7 +514,7 @@ static sail_status_t convert_from_bpp32_rgba_kind(const struct sail_image *image unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -535,7 +535,7 @@ static sail_status_t convert_from_bpp64_rgba_kind(const struct sail_image *image unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint16_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -556,7 +556,7 @@ static sail_status_t convert_from_bpp32_cmyk(const struct sail_image *image, pix unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -578,7 +578,7 @@ static sail_status_t convert_from_bpp24_ycbcr(const struct sail_image *image, pi unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row); @@ -600,7 +600,7 @@ static sail_status_t convert_from_bpp32_ycck(const struct sail_image *image, pix unsigned row; - #pragma omp parallel for + #pragma omp parallel for schedule(SAIL_OPENMP_SCHEDULE) for (row = 0; row < image->height; row++) { const uint8_t *scan_input = sail_scan_line(image, row); uint8_t *scan_output8 = sail_scan_line(output_context->image, row);