blender/intern/cycles/util
Sergey Sharybin 30b962b3d8 Cycles: Optimize 3d and 4d noise
The goal is to reduce the affect of the fmod() used in the noise code,
which was initially reported in the comment:

    https://projects.blender.org/blender/blender/pulls/119884#issuecomment-1258902

Basic idea is to benefit from SIMD vectorization on CPU.

Tested on Linux i9-11900K and macOS on M2 Ultra, in both cases performance
after this change is very close to what it could be with the fmod() commented
out (the call itself, `p = p + precision_correction`).

On macOS the penalty of fmod() was about 10%, on Linux it was closer to 30%
when built with GCC-13. With Linux builds from the buildbot it is more like 18%.

The optimization is only done for 3d and 4d noise. It might be possible to
gain some performance improvement for 1d and 2d cases, but the approach would
need to be different: we'd need to optimize scalar version fmodf(). Maybe
tricks with integer cast will be faster (since we are a bit optimistic in the
kernel and do not guarantee exact behavior in extreme cases such as NaN inputs).

Pull Request: https://projects.blender.org/blender/blender/pulls/137109
2025-04-09 13:40:10 +02:00
..
algorithm.h Refactor: Cycles: Make math and type headers work by themselves 2025-01-03 10:22:47 +01:00
aligned_malloc.cpp Refactor: Cycles: Simplify util_guarded_mem_alloc/free calls 2025-01-29 14:11:47 +01:00
aligned_malloc.h Refactor: Cycles: Simplify util_guarded_mem_alloc/free calls 2025-01-29 14:11:47 +01:00
args.h Refactor: Cycles: Stop using entire OIIO namespace 2025-01-03 10:22:52 +01:00
array.h Refactor: Cycles: Add concurrent vector, concurrent set from TBB 2025-03-24 09:42:25 +01:00
atomic.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
boundbox.h Fix #130829: Incorrect render result with light trees 2025-02-18 13:11:46 +01:00
CMakeLists.txt Refactor: Cycles: Add concurrent vector, concurrent set from TBB 2025-03-24 09:42:25 +01:00
color.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
concurrent_set.h Refactor: Cycles: Add concurrent vector, concurrent set from TBB 2025-03-24 09:42:25 +01:00
concurrent_vector.h Refactor: Cycles: Add concurrent vector, concurrent set from TBB 2025-03-24 09:42:25 +01:00
debug.cpp Cycles: Support Decomposed MetalRT motion interpolation 2025-04-03 16:24:04 +02:00
debug.h Cycles: Support Decomposed MetalRT motion interpolation 2025-04-03 16:24:04 +02:00
defines.h Cleanup: Cycles: Deduplicate kernel attribute code using templating 2025-02-20 19:28:45 +01:00
deque.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
disjoint_set.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
guarded_allocator.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
guarded_allocator.h Refactor: Cycles: Sync various build fixes from the standalone repository 2025-03-27 22:07:50 +01:00
guiding.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
half.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
hash.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
ies.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
ies.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
image.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
image_impl.h Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
list.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
log.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
log.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
map.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
math.h Refactor: Cycles: Make math and type headers work by themselves 2025-01-03 10:22:47 +01:00
math_base.h Cycles: Perform attribute subdivision on the host side 2025-03-11 20:58:07 +01:00
math_cdf.cpp Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
math_cdf.h Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
math_fast.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
math_float2.h Cycles: Optimize 3d and 4d noise 2025-04-09 13:40:10 +02:00
math_float3.h Cycles: Optimize 3d and 4d noise 2025-04-09 13:40:10 +02:00
math_float4.h Cycles: Optimize 3d and 4d noise 2025-04-09 13:40:10 +02:00
math_float8.h Refactor: Cycles: Rename rcp to reciprocal 2025-02-04 18:59:24 +01:00
math_int2.h Refactor: Cycles: Make math and type headers work by themselves 2025-01-03 10:22:47 +01:00
math_int3.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
math_int4.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
math_int8.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
math_intersect.h Refactor: Cycles: Rename rcp to reciprocal 2025-02-04 18:59:24 +01:00
md5.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
md5.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
murmurhash.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
murmurhash.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
openimagedenoise.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
openvdb.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
optimization.h Cleanup: Cycles: Remove unnecessary SSE4.2 CPU kernel 2025-01-13 10:07:37 +01:00
param.h Cycles: Perform attribute subdivision on the host side 2025-03-11 20:58:07 +01:00
path.cpp Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
path.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
profiling.cpp Fix: Build error with latest MSVC 2022 2025-02-12 17:18:55 +01:00
profiling.h Cleanup: Fix warnings about comparing int and size_t 2025-03-27 22:07:50 +01:00
progress.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
projection.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
projection_inverse.h Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
queue.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
rect.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
semaphore.h Refactor: Cycles: Add const keyword where possible, using clang-tidy 2025-01-03 10:23:20 +01:00
set.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
simd.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
stack_allocator.h MEM_guardedalloc: Refactor to add more type-safety. 2025-02-20 10:37:10 +01:00
static_assert.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
stats.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
string.cpp OpenImageIO: Compatibility with version 3.0 2025-01-06 17:21:11 +01:00
string.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
system.cpp Refactor: Cycles: Stop using entire OIIO namespace 2025-01-03 10:22:52 +01:00
system.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
task.cpp Refactor: Cycles: Replace new/delete by unique_ptr, in simple cases 2025-01-03 10:23:30 +01:00
task.h Refactor: Cycles: Replace new/delete by unique_ptr, in simple cases 2025-01-03 10:23:30 +01:00
tbb.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
texture.h Refactor: Cycles: Avoid unsafe memcpy and memcmp 2025-01-03 10:23:15 +01:00
thread.cpp Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
thread.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
time.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
time.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
transform.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
transform.h Cleanup: Cycles: Remove unnecessary SSE4.2 CPU kernel 2025-01-13 10:07:37 +01:00
transform_avx2.cpp License headers: use SPDX-FileCopyrightText in intern/cycles 2023-06-14 16:53:23 +10:00
types.h Refactor: Cycles: Make math and type headers work by themselves 2025-01-03 10:22:47 +01:00
types_base.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_float2.h Cycles: Optimize 3d and 4d noise 2025-04-09 13:40:10 +02:00
types_float3.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_float4.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_float8.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_int2.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_int3.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_int4.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_int8.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_spectrum.h Refactor: Cycles: Make math and type headers work by themselves 2025-01-03 10:22:47 +01:00
types_uchar2.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_uchar3.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_uchar4.h Cycles: Perform attribute subdivision on the host side 2025-03-11 20:58:07 +01:00
types_uint2.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_uint3.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_uint4.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
types_ushort4.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
unique_ptr.h Refactor: Cycles: Use #pragma once 2025-01-03 10:22:45 +01:00
unique_ptr_vector.h Cleanup: Fix warnings about comparing int and size_t 2025-03-27 22:07:50 +01:00
vector.h Refactor: Cycles: Automated clang-tidy fixups in Cycles 2025-01-03 10:22:55 +01:00
version.h Refactor: Cycles: Sync various build fixes from the standalone repository 2025-03-27 22:07:50 +01:00
windows.cpp Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
windows.h Refactor: Cycles: Add const keyword to more function parameters 2025-01-03 10:23:24 +01:00
xml.h Fix: Cycles lite build failure without Pugixml 2024-12-31 00:50:44 +01:00