Add padding callback examples demonstrating load and store callbacks - #361
Add padding callback examples demonstrating load and store callbacks#361ThibaultGH wants to merge 7 commits into
Conversation
Greptile SummaryThis PR adds zero-padding examples to the existing cuFFT callback sample directory, demonstrating both load and store callbacks together (forward R2C zero-pads the input; inverse C2R truncates and normalises the output). It also renames the existing windowing files to carry a
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Host
participant GPU as GPU (device_signals)
participant CUFFT as cuFFT Engine
participant LoadCB as Load Callback (R2C)
participant StoreCB as Store Callback (C2R)
participant Complex as device_complex
Host->>GPU: cudaMemcpy input_signals[0..signal_size)
Host->>CUFFT: cufftExecR2C(forward_plan, device_signals, device_complex)
loop for each index 0..padded_signal_size-1
CUFFT->>LoadCB: read index
alt "index < signal_size"
LoadCB-->>CUFFT: return device_signals[index]
else "index >= signal_size"
LoadCB-->>CUFFT: return 0.0f (zero-pad)
end
end
CUFFT->>Complex: write R2C output
Host->>CUFFT: cufftExecC2R(inverse_plan, device_complex, device_signals)
loop for each index 0..padded_signal_size-1
CUFFT->>StoreCB: write index, value
alt "index < signal_size"
StoreCB->>GPU: "out[index] = value / padded_signal_size"
else "index >= signal_size"
StoreCB->>GPU: "out[index] = 0.0f"
end
end
Host->>GPU: cudaMemcpy output_signals[0..signal_size)
Reviews (4): Last reviewed commit: "fix(Makefile): update targets to match w..." | Re-trigger Greptile |
- Rename all windowing example files to include 'windowing' in their names: - r2c_c2r_legacy_callback_example.cu -> r2c_c2r_windowing_legacy_callback_example.cu - r2c_c2r_lto_callback_example.cpp -> r2c_c2r_windowing_lto_callback_example.cpp - r2c_c2r_lto_nvrtc_callback_example.cpp -> r2c_c2r_windowing_lto_nvrtc_callback_example.cpp - r2c_c2r_lto_callback_device.cu -> r2c_c2r_windowing_lto_callback_device.cu - r2c_c2r_reference.* -> r2c_c2r_windowing_reference.* - Update CMakeLists.txt, README.md, and includes to use new names - Rename executables to include windowing prefix Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
- Add compute_error_windowing for complex buffer layout (windowing) - Add compute_error_padding for real buffer layout (padding) - Update windowing examples to use compute_error_windowing - Update common.h with both error computation functions Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
New files: - r2c_c2r_padding_legacy_callback_example.cu: Legacy API with load/store callbacks - r2c_c2r_padding_lto_callback_example.cpp: LTO API with load/store callbacks - r2c_c2r_padding_lto_load_callback_device.cu: LTO load callback device code - r2c_c2r_padding_lto_store_callback_device.cu: LTO store callback device code - r2c_c2r_padding_reference.cu/h: Reference implementation without callbacks Modified files: - CMakeLists.txt: Add padding targets and fatbin generation - README.md: Document padding examples - callback_params.h: Add padding parameters - common.h: Add compute_error_padding function Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
In the error path when reference_r2c_padding_c2r() fails, the code was only freeing host memory but not CUDA resources. This adds the missing: - cufftDestroy() for both forward and inverse plans - cudaFree() for device_signals, device_complex, and device_params Files: - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_legacy_callback_example.cu - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_lto_callback_example.cpp Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
The PaddingCallbackParams struct was duplicated in 4 files. This consolidates it into callback_params.h and updates all files to include the header. Files: - cuFFT/lto_callback_window_1d/src/callback_params.h (added struct) - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_legacy_callback_example.cu - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_lto_callback_example.cpp - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_lto_load_callback_device.cu - cuFFT/lto_callback_window_1d/src/r2c_c2r_padding_lto_store_callback_device.cu Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
The init_input_signals_padding function was never called in any example and had a hidden bug (used += without zeroing the buffer first). This removes the unused function and its declaration. Files: - cuFFT/lto_callback_window_1d/src/common.cpp - cuFFT/lto_callback_window_1d/src/common.h Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
8ab079b to
522914b
Compare
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Could the Makefile be updated together with the CMake build?
This PR renames the existing sources/targets to r2c_c2r_windowing_*, but the Makefile still builds r2c_c2r_lto_callback_example, r2c_c2r_lto_nvrtc_callback_example, r2c_c2r_legacy_callback_example and the old r2c_c2r_reference objects.
Since those source names are being replaced in this PR, the documented make build path will no longer work even though the CMake path does. The Makefile should follow the windowing renames and probably add the new padding targets as well.
…ing examples Update Makefile to reflect the file renames from the windowing examples and add build rules for the new padding examples. Changes: - Rename all windowing targets to include 'windowing_' prefix - Add build rules for padding LTO and legacy callback examples - Add fatbin generation for padding load/store callbacks - Update references to use new filenames This ensures the make build path works alongside the CMake path. Signed-off-by: Thibault Cimic <thibault.cimic@cea.fr>
Add padding callback examples demonstrating load and store callbacks
This PR adds new examples to demonstrate the use of both load and store callbacks with cuFFT, complementing the existing windowing examples that only show load callbacks.
New Examples
r2c_c2r_padding_legacy_callback_example.cu: Legacy API with load/store callbacksr2c_c2r_padding_lto_callback_example.cpp: LTO API with load/store callbacksr2c_c2r_padding_reference.cu: Reference implementation without callbacksKey Differences from Windowing Examples
Implementation Notes
Testing