-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/more_fft_utils'
- Loading branch information
Showing
16 changed files
with
956 additions
and
173 deletions.
There are no files selected for viewing
Submodule examples_tests
updated
5 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#ifndef _NBL_BUILTIN_HLSL_BITREVERSE_INCLUDED_ | ||
#define _NBL_BUILTIN_HLSL_BITREVERSE_INCLUDED_ | ||
|
||
|
||
#include <nbl/builtin/hlsl/cpp_compat.hlsl> | ||
|
||
namespace nbl | ||
{ | ||
namespace hlsl | ||
{ | ||
|
||
template<typename T, uint16_t Bits NBL_FUNC_REQUIRES(is_unsigned_v<T>&& Bits <= sizeof(T) * 8) | ||
/** | ||
* @brief Takes the binary representation of `value` as a string of `Bits` bits and returns a value of the same type resulting from reversing the string | ||
* | ||
* @tparam T Type of the value to operate on. | ||
* @tparam Bits The length of the string of bits used to represent `value`. | ||
* | ||
* @param [in] value The value to bitreverse. | ||
*/ | ||
T bitReverseAs(T value) | ||
{ | ||
return bitReverse<T>(value) >> promote<T, scalar_type_t<T> >(scalar_type_t <T>(sizeof(T) * 8 - Bits)); | ||
} | ||
|
||
template<typename T NBL_FUNC_REQUIRES(is_unsigned_v<T>) | ||
/** | ||
* @brief Takes the binary representation of `value` and returns a value of the same type resulting from reversing the string of bits as if it was `bits` long. | ||
* Keep in mind `bits` cannot exceed `8 * sizeof(T)`. | ||
* | ||
* @tparam T type of the value to operate on. | ||
* | ||
* @param [in] value The value to bitreverse. | ||
* @param [in] bits The length of the string of bits used to represent `value`. | ||
*/ | ||
T bitReverseAs(T value, uint16_t bits) | ||
{ | ||
return bitReverse<T>(value) >> promote<T, scalar_type_t<T> >(scalar_type_t <T>(sizeof(T) * 8 - bits)); | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#ifndef _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_FFT_INCLUDED_ | ||
#define _NBL_BUILTIN_HLSL_CONCEPTS_ACCESSORS_FFT_INCLUDED_ | ||
|
||
#include "nbl/builtin/hlsl/concepts.hlsl" | ||
#include "nbl/builtin/hlsl/fft/common.hlsl" | ||
|
||
namespace nbl | ||
{ | ||
namespace hlsl | ||
{ | ||
namespace workgroup | ||
{ | ||
namespace fft | ||
{ | ||
// The SharedMemoryAccessor MUST provide the following methods: | ||
// * void get(uint32_t index, inout uint32_t value); | ||
// * void set(uint32_t index, in uint32_t value); | ||
// * void workgroupExecutionAndMemoryBarrier(); | ||
|
||
#define NBL_CONCEPT_NAME FFTSharedMemoryAccessor | ||
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename) | ||
#define NBL_CONCEPT_TPLT_PRM_NAMES (T) | ||
#define NBL_CONCEPT_PARAM_0 (accessor, T) | ||
#define NBL_CONCEPT_PARAM_1 (index, uint32_t) | ||
#define NBL_CONCEPT_PARAM_2 (val, uint32_t) | ||
NBL_CONCEPT_BEGIN(3) | ||
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2 | ||
NBL_CONCEPT_END( | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template set<uint32_t, uint32_t>(index, val)), is_same_v, void)) | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.template get<uint32_t, uint32_t>(index, val)), is_same_v, void)) | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.workgroupExecutionAndMemoryBarrier()), is_same_v, void)) | ||
); | ||
#undef val | ||
#undef index | ||
#undef accessor | ||
#include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
||
|
||
// The Accessor (for a small FFT) MUST provide the following methods: | ||
// * void get(uint32_t index, inout complex_t<Scalar> value); | ||
// * void set(uint32_t index, in complex_t<Scalar> value); | ||
|
||
#define NBL_CONCEPT_NAME SmallFFTAccessor | ||
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename) | ||
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(Scalar) | ||
#define NBL_CONCEPT_PARAM_0 (accessor, T) | ||
#define NBL_CONCEPT_PARAM_1 (index, uint32_t) | ||
#define NBL_CONCEPT_PARAM_2 (val, complex_t<Scalar>) | ||
NBL_CONCEPT_BEGIN(3) | ||
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
#define index NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_1 | ||
#define val NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_2 | ||
NBL_CONCEPT_END( | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.set(index, val)), is_same_v, void)) | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.get(index, val)), is_same_v, void)) | ||
); | ||
#undef val | ||
#undef index | ||
#undef accessor | ||
#include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
||
|
||
// The Accessor MUST provide the following methods: | ||
// * void get(uint32_t index, inout complex_t<Scalar> value); | ||
// * void set(uint32_t index, in complex_t<Scalar> value); | ||
// * void memoryBarrier(); | ||
|
||
#define NBL_CONCEPT_NAME FFTAccessor | ||
#define NBL_CONCEPT_TPLT_PRM_KINDS (typename)(typename) | ||
#define NBL_CONCEPT_TPLT_PRM_NAMES (T)(Scalar) | ||
#define NBL_CONCEPT_PARAM_0 (accessor, T) | ||
NBL_CONCEPT_BEGIN(1) | ||
#define accessor NBL_CONCEPT_PARAM_T NBL_CONCEPT_PARAM_0 | ||
NBL_CONCEPT_END( | ||
((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((accessor.memoryBarrier()), is_same_v, void)) | ||
) && SmallFFTAccessor<T, Scalar>; | ||
#undef accessor | ||
#include <nbl/builtin/hlsl/concepts/__end.hlsl> | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.