Skip to content

Opencl / cpu maths part 5#20752

Merged
TurboGit merged 3 commits intodarktable-org:masterfrom
jenshannoschwalm:opencl_cpu_maths_5
Apr 6, 2026
Merged

Opencl / cpu maths part 5#20752
TurboGit merged 3 commits intodarktable-org:masterfrom
jenshannoschwalm:opencl_cpu_maths_5

Conversation

@jenshannoschwalm
Copy link
Copy Markdown
Collaborator

Make some more use of fast-maths switch

  1. We make use of the FAST_MATH (cpu) and FAST_RELAXED_MATH (OpenCL) switches delivered by compiler options to switch between code paths performance vs precision.
  2. deduplicated scharr operator code in OpenCL
  3. made Y0 mask generation identical for OpenCL and CPU (slightly better performance here).
  4. removed two unused functions in colorspace inline conversions

Code maintenance using predefined math defines

  1. Instead of calculating 2*PI, PI/2 and PI/4 we use existing defines M_PI_2f M_PI_4f and introduce DT_2PI_F.
  2. root(2.0) is replaced by M_SQRT2_F

Color equalizer simplifications
Don't interpolate/mix where simpler maths will do it.


Nothing relevant while testing integration suite, here is the current (commented) status

Analysis.log

1. We make use of the __FAST_MATH__ (cpu) and __FAST_RELAXED_MATH__ (OpenCL) switches
   delivered by compiler options to switch between code paths performance vs precision.
2. deduplicated scharr operator code in OpenCL
3. made Y0 mask generation identical for OpenCL and CPU (slightly better performance here).
4. removed two unused functions in colorspace inline conversions
1. Instead of calculating 2*PI, PI/2 and PI/4 we use existing defines M_PI_2f M_PI_4f
   and introduce DT_2PI_F.
2. root(2.0) is replaced by M_SQRT2_F
@jenshannoschwalm jenshannoschwalm added this to the 5.6 milestone Apr 5, 2026
@jenshannoschwalm jenshannoschwalm added scope: image processing correcting pixels scope: codebase making darktable source code easier to manage OpenCL Related to darktable OpenCL code labels Apr 5, 2026
Don't interpolate/mix where simpler maths will do it.
Copy link
Copy Markdown
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to me, thanks!

@TurboGit TurboGit merged commit 791cf93 into darktable-org:master Apr 6, 2026
5 checks passed
case DT_IOP_COLORZONES_h:
select = h;
blend = pow(1.0f - C/128.0f, 2.0f);
blend = dtcl_pow(1.0f - C/128.0f, 2.0f);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pow(x,2.0f) -> x*x, or sqf(x) in CPU path.

@jenshannoschwalm jenshannoschwalm deleted the opencl_cpu_maths_5 branch April 8, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OpenCL Related to darktable OpenCL code scope: codebase making darktable source code easier to manage scope: image processing correcting pixels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants