【发布时间】:2022-01-01 23:03:13
【问题描述】:
当我打算使用ldmatrix 和mma 指令时,我从以下代码中得到了错误。 PTX Docu 说 PTX 6.5 中引入了“ldmatrix”。所以我怀疑 PTX 版本可能是原因之一。我想知道我们如何找出我们使用的是哪个 PTX 版本?这些错误的原因还有哪些其他可能性?
__device__ void
runldmatrix(typet & D, unsigned addr){
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 750))
int x, y, z, w;
asm volatile (
"ldmatrix.sync.aligned.x4.m8n8.shared.b16 {%0, %1, %2, %3}, [%4];"
: "=r"(x), "=r"(y), "=r"(z), "=r"(w)
: "r"(addr));
reinterpret_cast<int4 &>(D) = make_int4(x, y, z, w);
#else
assert(0);
#endif
}
__device__ void
runmma(typet & d, typet const & a,
typet const & b,typet const & c ){
#if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 750))
unsigned const *A = reinterpret_cast<unsigned const *>(&a);
unsigned const & B = reinterpret_cast<unsigned const &>(b);
unsigned const *C = reinterpret_cast<unsigned const *>(&c);
unsigned *D = reinterpret_cast<unsigned *>(&d);
asm volatile(
"mma.sync.aligned.m16n8k8.row.col.f16.f16.f16.f16 {%0,%1}, {%2,%3}, {%4}, {%5,%6};\n"
: "=r"(D[0]), "=r"(D[1])
: "r"(A[0]), "r"(A[1]), "r"(B), "r"(C[0]), "r"(C[1]));
#endif
}
/tmp/tmpxft_00002eb6_00000000-5_test_gemm.ptx,第 2637 行;错误 : 未知修饰符 '.x4' ptxas
/tmp/tmpxft_00002eb6_00000000-5_test_gemm.ptx,第 2637 行;错误 : 未知修饰符 '.m8n8' ptxas
/tmp/tmpxft_00002eb6_00000000-5_test_gemm.ptx,第 2637 行;错误 : 不是任何已知指令的名称:'ldmatrix'
ptxas /tmp/tmpxft_000
02ee1_00000000-5_test_gemm.ptx,第 2611 行;错误:未知修饰符 '.m16n8k8' ptxas /tmp/tmpxft_00002ee1_00000000-5_test_gemm.ptx,线 2611;错误:指令“mma”需要形状修饰符
更新:
我用的是2080 Ti和CUDA 10.1,下面的cmake保证7.5的计算能力
cmake_minimum_required(VERSION 3.18)
project(Hello)
enable_language(CUDA)
add_executable(gunne test_gemm.cu)
target_include_directories(gunne PRIVATE include)
set_property(TARGET gunne PROPERTY CUDA_ARCHITECTURES 75)
【问题讨论】:
-
你需要为你希望编译器使用的特性指定一个合适的架构