Skip to content

Commit

Permalink
Add NVCC only static assert
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbowen42 committed Nov 2, 2023
1 parent a1d55a8 commit 9be83ae
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/serac/physics/heat_transfer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,16 @@ class HeatTransfer<order, dim, Parameters<parameter_space...>, std::integer_sequ
* @param[in] material A functor representing the material model. Should be a functor, or a class/struct with
* public operator() method. Must NOT be a generic lambda, or serac will not compile due to static asserts below.
*/
ThermalMaterialIntegrand(MaterialType material) : material_(material) {}

// Due to nvcc's lack of support for extended generic lambdas (i.e. functions of the form
// auto lambda = [] __host__ __device__ (auto) {}; ), MaterialType cannot be an extended
// generic lambda. The static asserts below check this.
private:
class DummyArgumentType {
};
static_assert(!std::is_invocable<MaterialType, DummyArgumentType&>::value);
static_assert(!std::is_invocable<MaterialType, DummyArgumentType*>::value);
static_assert(!std::is_invocable<MaterialType, DummyArgumentType>::value);
ThermalMaterialIntegrand(MaterialType material) : material_(material)
{
// Due to nvcc's lack of support for extended generic lambdas (i.e. functions of the form
// auto lambda = [] __host__ __device__ (auto) {}; ), MaterialType cannot be an extended
// generic lambda. The static asserts below check this.
#ifdef __CUDACC__
static_assert(!__nv_is_extended_host_device_lambda_closure_type(MaterialType),
"NVCC does not support host device lambdas");
#endif
}

public:
/**
Expand Down

0 comments on commit 9be83ae

Please sign in to comment.