CUDA螺纹块尺寸1024';t工作(cc=20,sm=21)

CUDA螺纹块尺寸1024';t工作(cc=20,sm=21),cuda,Cuda,我的运行配置: -CUDA工具包5.5 -NVidia Nsight Eclipse版 -Ubuntu 12.04 x64 -CUDA设备是NVidia GeForce GTX 560:cc=20,sm=21(正如您所看到的,我可以使用最多1024个线程的块) 我在iGPU(英特尔高清图形)上渲染显示器,因此可以使用Nsight调试器 然而,当我设置threads>960时,我遇到了一些奇怪的行为 代码: 当我添加-keep键时,编译器会生成.cubin文件,但我无法读取它来找出smem和reg

我的运行配置: -CUDA工具包5.5 -NVidia Nsight Eclipse版 -Ubuntu 12.04 x64 -CUDA设备是NVidia GeForce GTX 560:cc=20,sm=21(正如您所看到的,我可以使用最多1024个线程的块)

我在iGPU(英特尔高清图形)上渲染显示器,因此可以使用Nsight调试器

然而,当我设置threads>960时,我遇到了一些奇怪的行为

代码:

当我添加-keep键时,编译器会生成.cubin文件,但我无法读取它来找出smem和reg的值,请遵循本主题。至少现在这个文件必须有一些不同的格式

因此,我被迫每个块使用256个线程,考虑到这一点,这可能不是一个坏主意。xls:


无论如何。任何帮助都将不胜感激。

我在CUDA入住率计算器文件中填写了当前信息:

  • 计算能力:2.1
  • 每个区块的线程数:961
  • 每个线程的寄存器数:34
  • 共享内存:0
受寄存器计数限制,我的占用率0%
如果将线程数设置为960,则占用率为63%,这解释了它的工作原理

尝试将寄存器计数限制为32,并将线程数设置为1024,以使占用率达到67%

要限制寄存器的计数,请使用以下选项:
nvcc[…]--maxrregcount=32

我设置了--maxrregcount=32,得到了这样的结果:“ptxas信息:使用了20个寄存器,16个字节的累积堆栈大小,32个字节的cmem[0]”,它反映了实际的数据,与我限制它们的数量超过32的情况不同。这个节目很有魅力!但是根据您的建议,我将使用--maxrregcount=16,因为在我的例子中,它在占用率方面似乎是最佳的。@vitrums,有时您会得到(当内核是内存带绑定的时候)。
#include <stdio.h>
#include <cuda_runtime.h>

__global__ void mytest() {
    float a, b;
    b = 1.0F;
    a = b / 1.0F;
}

int main(void) {

    // Error code to check return values for CUDA calls
    cudaError_t err = cudaSuccess;

    // Here I run my kernel
    mytest<<<1, 961>>>();

    err = cudaGetLastError();

    if (err != cudaSuccess) {
        fprintf(stderr, "error=%s\n", cudaGetErrorString(err));
        exit (EXIT_FAILURE);
    }

    // Reset the device and exit
    err = cudaDeviceReset();

    if (err != cudaSuccess) {
        fprintf(stderr, "Failed to deinitialize the device! error=%s\n",
                cudaGetErrorString(err));
        exit (EXIT_FAILURE);
    }

    printf("Done\n");
    return 0;
}
12:57:39 **** Incremental Build of configuration Debug for project block_size_test ****
make all 
Building file: ../src/vectorAdd.cu
Invoking: NVCC Compiler
/usr/local/cuda-5.5/bin/nvcc -I"/usr/local/cuda-5.5/samples/0_Simple" -I"/usr/local/cuda-5.5/samples/common/inc" -G -g -O0 -m64 -keep -keep-dir /home/vitrums/cuda-workspace-trashcan -optf /home/vitrums/cuda-workspace/block_size_test/options.txt -gencode arch=compute_20,code=sm_20 -gencode arch=compute_20,code=sm_21 -odir "src" -M -o "src/vectorAdd.d" "../src/vectorAdd.cu"
/usr/local/cuda-5.5/bin/nvcc --compile -G -I"/usr/local/cuda-5.5/samples/0_Simple" -I"/usr/local/cuda-5.5/samples/common/inc" -O0 -g -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_21 -keep -keep-dir /home/vitrums/cuda-workspace-trashcan -m64 -optf /home/vitrums/cuda-workspace/block_size_test/options.txt  -x cu -o  "src/vectorAdd.o" "../src/vectorAdd.cu"
../src/vectorAdd.cu(7): warning: variable "a" was set but never used

../src/vectorAdd.cu(7): warning: variable "a" was set but never used

ptxas info    : 4 bytes gmem, 8 bytes cmem[14]
ptxas info    : Function properties for _ZN4dim3C1Ejjj
    0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info    : Compiling entry function '_Z6mytestv' for 'sm_21'
ptxas info    : Function properties for _Z6mytestv
    8 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info    : Used 34 registers, 8 bytes cumulative stack size, 32 bytes cmem[0]
ptxas info    : Function properties for _ZN4dim3C2Ejjj
    0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
Finished building: ../src/vectorAdd.cu

Building target: block_size_test
Invoking: NVCC Linker
/usr/local/cuda-5.5/bin/nvcc --cudart static -m64 -link -o  "block_size_test"  ./src/vectorAdd.o   
Finished building target: block_size_test


12:57:41 Build Finished (took 1s.659ms)