This file declares a function adapting the stack size of the threads of the device to a CUDA or HIP kernel, used by the generic-parallel interface for material properties. This file must be compiled by a CUDA or a HIP compiler. The HIP runtime is used if the hip/hip_runtime.h header has been included before this file or if the HIP language is enabled, the CUDA runtime otherwise.
More...
#include <mutex>
#include <string>
#include <cstddef>
#include <cuda_runtime.h>
#include "MFront/GenericParallel/DeviceStackSize.hxx"
|
|
using | mfront::generic_parallel::gpu::Error = MFRONT_GENERIC_PARALLEL_GPU_API(Error_t) |
| | error code of the runtime
|
|
| template<auto kernel> |
| StackSizeCheck | mfront::generic_parallel::gpu::ensureStackSize (const bool preserve) noexcept |
| | increase the stack size of the threads of the current device if the given kernel requires it. The default stack size (1024 bytes with CUDA) is too small for some kernels, and the increase performed by the runtime at kernel launch does not account for the internal routines of the compilers (see setMinimalCUDAStackSize), hence the margin added below to the static estimate of the local memory of the kernel.
|
This file declares a function adapting the stack size of the threads of the device to a CUDA or HIP kernel, used by the generic-parallel interface for material properties. This file must be compiled by a CUDA or a HIP compiler. The HIP runtime is used if the hip/hip_runtime.h header has been included before this file or if the HIP language is enabled, the CUDA runtime otherwise.
- Date
- 08/10/2026
- Copyright
- Copyright (C) 2006-2025 CEA/DEN, EDF R&D. All rights reserved. This project is publicly released under either the GNU GPL Licence with linking exception or the CECILL-A licence. A copy of thoses licences are delivered with the sources of TFEL. CEA or EDF may also distribute this project under specific licensing conditions.
◆ MFRONT_GENERIC_PARALLEL_GPU_API
| #define MFRONT_GENERIC_PARALLEL_GPU_API |
( |
| f | ) |
|
◆ ensureStackSize()
template<auto kernel>
| StackSizeCheck mfront::generic_parallel::gpu::ensureStackSize |
( |
const bool | preserve | ) |
|
|
noexcept |
increase the stack size of the threads of the current device if the given kernel requires it. The default stack size (1024 bytes with CUDA) is too small for some kernels, and the increase performed by the runtime at kernel launch does not account for the internal routines of the compilers (see setMinimalCUDAStackSize), hence the margin added below to the static estimate of the local memory of the kernel.
The kernel is a template argument, so that this function is instantiated in the library defining the kernel. The CUDA runtime is linked statically by default: each library has its own instance of the runtime, which only knows the kernels of this library. A function shared by several libraries, for instance a function taking the kernel as argument, would be resolved to the instance of one library by the dynamic linker.
- Template Parameters
-
- Parameters
-
| [in] | preserve | if true, the stack size is not modified, and the required stack size is returned if the current one is too small |