CUDA 커널을 템플릿으로 만들려고합니다. 아니요, 특히 SO이 아닙니다. 이 커널 내에서 typename에 의존하는 typedef를 갖고 싶습니다. 나는 다음과 같이 (가정/기대) C++와 비슷하게 작동 할 것이지만 시도하지는 않았다.CUDA 커널에서 std :: conditional을 사용할 수 있습니까?
#include <type_traits> // for std::conditional. Not sure if it's necessary
#include <cuda_runtime.h>
#include <cuComplex.h>
template <typename fType>
__global__ void DummyKernel() {
typedef std::conditional<sizeof(fType) == sizeof(double), cuDoubleComplex, cuFloatComplex>::type cfType;
}
이 내가 원하는 것을 할 수있는 방법이 있나요 오류
nontype "std::conditional<_Test, _Ty1, _Ty2>::type [with _Test=<expression>, _Ty1=cuDoubleComplex, _Ty2=cuFloatComplex]" is not a type name
생산? CUDA 5.5 및 VS2012를 사용하고 있습니다.
'typedef '뒤에'typename' 키워드가 없습니다. – catscradle
@catscradle 나는 VS를 사용하고 있으며 Nvidia 컴파일러가 분리되어 있다는 것을 깨달았을 때 표준을 따르지 않는다고 말하려고했습니다. 나는 어리석은 게으른 습관을 깨야한다. 게시하면 답변으로 받아 들일 것입니다. –