0

私はcuda-gdbにいます。使用できます((@global float *)array)[0]

しかし、 gdb で定数メモリを使用する方法は?

私は試します((@parameter float *)const_array)

私は次のように宣言しconst_arrayました: __constant__ float const_array[1 << 14]

で試しましたが1 << 5、同じ問題です。

4

2 に答える 2

2

私はそれに問題があるようには見えません。デバイス メモリを出力するには、デバイス コードのブレークポイントで停止する必要があります

例:

$ cat t1973.cu
const int cs = 1 << 14;
__constant__ int cdata[cs];
__global__ void k(int *gdata){

  gdata[0] = cdata[0];
}

int main(){

  int *hdata = new int[cs];
  for (int i = 0; i < cs; i++) hdata[i] = i+1;
  cudaMemcpyToSymbol(cdata, hdata, cs*sizeof(cdata[0]));
  int *gdata;
  cudaMalloc(&gdata, sizeof(gdata[0]));
  cudaMemset(gdata, 0, sizeof(gdata[0]));
  k<<<1,1>>>(gdata);
  cudaDeviceSynchronize();
}
$ nvcc -o t1973 t1973.cu -g -G -arch=sm_70
$ cuda-gdb ./t1973
sh: python3: command not found
Unable to determine python3 interpreter version. Python integration disabled.
NVIDIA (R) CUDA Debugger
11.4 release
Portions Copyright (C) 2007-2021 NVIDIA Corporation
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./t1973...
(cuda-gdb) b 5
Breakpoint 1 at 0x403b0c: file t1973.cu, line 6.
(cuda-gdb) run
Starting program: /home/user2/misc/t1973
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Detaching after fork from child process 22872]
[New Thread 0x7fffef475700 (LWP 22879)]
[New Thread 0x7fffeec74700 (LWP 22880)]
[Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (0,0,0), device 0, sm 0, warp 0, lane 0]

Thread 1 "t1973" hit Breakpoint 1, k<<<(1,1,1),(1,1,1)>>> (
    gdata=0x7fffcdc00000) at t1973.cu:5
5         gdata[0] = cdata[0];
(cuda-gdb) print gdata[0]
$1 = 0
(cuda-gdb) print cdata[0]
$2 = 1
(cuda-gdb) s
6       }
(cuda-gdb) print gdata[0]
$3 = 1
(cuda-gdb) print cdata[0]
$4 = 1
(cuda-gdb) print cdata[1]
$5 = 2
(cuda-gdb)
于 2022-03-01T23:16:32.657 に答える