...
 
Commits (3)
    https://gitcode.net/csdn/skill_tree_cuda/-/commit/9ecac3322bbf2d8fde0b3568e10952cb3aad6de3 Ken He 2022-04-06T05:09:47+08:00 Ken He kun.he.love.u@gmail.com https://gitcode.net/csdn/skill_tree_cuda/-/commit/aa253ffa8fd5e4c0aa74bb2a2e544258b878401c Ken He 2022-04-06T21:33:16+08:00 Ken He kun.he.love.u@gmail.com https://gitcode.net/csdn/skill_tree_cuda/-/commit/5d6c3e036735302ab27d49e7a71799787d8a96ef Ken He 2022-04-06T22:53:05+08:00 Ken He kun.he.love.u@gmail.com
{
"type": "code_options",
"author": null,
"source": "GPU_arch.md",
"notebook_enable": false,
"exercise_id": ""
}
\ No newline at end of file
# GPU异构计算
* 下面关于GPU异构计算 ***错误*** 的是?
## 答案
在GPU异构计算体系中,更高效的是GPU负责更多逻辑控制运算,而CPU负责更多的计算密集型的向量运算.
## 选项
### A
GPU可以更出色的完成计算密集型的矢量运算
### B
GPU有更多的计算核心来并行完成计算
......@@ -3,7 +3,7 @@
"keywords": [],
"children": [],
"export": [
"helloworld.json"
"GPU_arch.json"
],
"keywords_must": [],
"keywords_forbid": []
......
# GPU硬件平台
以下介绍GPU硬件平台 ***错误*** 的是?
## 答案
GPU(Graphics Processing Unit)最多可以同时执行几十个线程.
## 选项
### A
GPU(Graphics Processing Unit) 专门用于高度并行计算,因此设计时更多的晶体管用于数据处理.
### B
GPU(Graphics Processing Unit)可以通过计算隐藏内存访问延迟,而不是依靠大数据缓存和复杂的流控制来避免长时间的内存访问延迟.
### C
GPU(Graphics Processing Unit)在相同的价格和功率范围内,比CPU提供更高的指令吞吐量和内存带宽.
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-8acef8aa3f7b479d90b7eaf77ff752eb",
"keywords": [],
"children": [],
"export": [],
"export": [
"GPU_Platform.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 环境安装配置
以下介绍关于GPU环境安装配置 ***错误***的是?
## 答案
我可以在没有NVIDIA GPU的系统上使用CUDA
## 选项
### A
CUDA可以安装在Windows操作系统中.
### B
CUDA可以安装在Linux系统中.
### C
CUDA可以安装在Jetson系统上
......@@ -2,7 +2,9 @@
"node_id": "cuda-f15df586747c4e648b6c6824c6b9b3e1",
"keywords": [],
"children": [],
"export": [],
"export": [
"Install.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA编译
以下哪个编译器可以用来编译CUDA程序?
## 答案
nvcc
## 选项
### A
gcc
### B
g++
......@@ -2,7 +2,9 @@
"node_id": "cuda-25c9eacb75e64d00bff3d14ffdec7ea7",
"keywords": [],
"children": [],
"export": [],
"export": [
"CUDA_compiler.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA线程
在以下形式代码中调用kernel函数方式正确的是?
## 答案
```C++
kernel<<<gridDim, blockDim>>>(a,b,c)
```
## 选项
### A
```C++
kernel(a,b,c)
```
### B
```C++
kernel<<<gridDim>>>(a,b,c)
```
### C
```C++
kernel(a,b,c)<<<gridDim, blockDim>>>
```
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-4756f243773643fd8064aa5b4ffdb789",
"keywords": [],
"children": [],
"export": [],
"export": [
"CUDA_thread.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CPU和GPU的通讯
以下说法中错误的是
## 答案
\_\_device\_\_标注的函数可以在host端调用,并在host上执行
## 选项
### A
\_\_global\_\_标注的函数可以在host端调用,并在device上执行
### B
\_\_device\_\_标注的函数可以在device端调用,并在device上执行
### C
在最新的GPU架构上, \_\_global\_\_标注的函数可以在device端调用,并在device上执行.
......@@ -2,7 +2,9 @@
"node_id": "cuda-bf38379916ce44978c6bfa3ef3487c71",
"keywords": [],
"children": [],
"export": [],
"export": [
"communication.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-8c79c6a5e3ca441a9cee430f312407bf",
"keywords": [],
"children": [],
"export": [],
"export": [
"multi_thread.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 使用多个线程的核函数
以下说法错误的是?
## 答案
每个block内可以设置无限多个thread.
## 选项
### A
核函数会被你设置的每一个线程执行.
### B
CUDA中的grid和block可以是一维, 二维或者三维.
### C
在host端代码中需要通常需要显示或者隐式的设置同步命令, 让CPU知道GPU中的线程执行完毕.
......@@ -2,7 +2,9 @@
"node_id": "cuda-b7fb5b2b91234dd89968918460ae506f",
"keywords": [],
"children": [],
"export": [],
"export": [
"thread_index.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA线程
在以下形式代码中调用kernel函数的前提下, 那每个线程的全局索引正确的是?
```C++
dim3 gridDim = blocksPerGrid;
dim3 blockDim = threadsPerBlock;
....
kernel<<<gridDim, blockDim>>>(a,b,c)
....
```
## 答案
```C++
index = threadIdx.x + blockIdx.x * blockDim;
```
## 选项
### A
```C++
index = threadIdx.x + blockDim;
```
### B
```C++
index = threadIdx.x * threadDim;
```
### C
```C++
index = blockIdx.x * blockDim;
```
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-ec664e92f8e2410b88226408d9bb9a9f",
"keywords": [],
"children": [],
"export": [],
"export": [
"multi_dim.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 多维网格
以下代码调用kernel函数, 对于多维Grid中每个线程在***全局***中的索引(x, y)正确的是?
```C++
dim3 gridDim = (blocksPerGrid, blocksPerGrid);
dim3 blockDim = (threadsPerBlock, threadsPerBlock);
....
kernel<<<gridDim, blockDim>>>(a,b,c)
....
```
## 答案
```C++
x = threadIdx.x + blockIdx.x * blockDim.x;
y = threadIdx.y + blockIdx.y * blockDim.y;
```
## 选项
### A
```C++
x = threadIdx.x + blockIdx.x ;
y = threadIdx.y + blockIdx.y ;
```
### B
```C++
x = threadIdx.x * blockDim.x ;
y = threadIdx.y * blockDim.y ;
```
### C
```C++
x = threadIdx.x ;
y = threadIdx.y ;
```
......@@ -2,7 +2,9 @@
"node_id": "cuda-70b301e021ef435f92c0f07b22adaa09",
"keywords": [],
"children": [],
"export": [],
"export": [
"grid_block.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 网格和线程块
以下说法不正确的是?
## 答案
一个kernel调用的所有线程肯定运行在同一个GPU上
## 选项
### A
同一个Block中的线程一定会运行在同一个SM中
### B
一个Grid可以包含多个线程block
......@@ -2,7 +2,9 @@
"node_id": "cuda-5f99fc5469cf4907ba3ebe615287a6e9",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem1.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# GPU 存储单元
以下关于GPU存储单元说法正确的是?
## 答案
在CPU上初始化的数据需要显式或者隐式的传输到GPU存储单元, 然后才能被CUDA线程读取.
## 选项
### A
CUDA线程可以直接访问CPU中的内存设备.
### B
CPU不可以对GPU中的Global Memory读写.
### C
GPU内存读写带宽只与CUDA版本有关.
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-f336472c4c244a68b4a2ee80dac8fdd0",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem2.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# GPU的存储单元
下面关于GPU存储单元说法错误的是?
## 答案
CUDA线程有对所有类型的存储类型的读写权限
## 选项
### A
同一个Block内的线程可以通过 shared memory来进行协作
### B
CPU可以对GPU中的global memory, constant memory 和 texture memory进行读写
......@@ -2,7 +2,9 @@
"node_id": "cuda-3443edc2ea5140b0a39f690382bf91e2",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem3.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# GPU存储单元的分配与释放
下面关于GPU存储单元的分配与释放的说法错误的是?
## 答案
可以使用`cudaMemcpy(d_m, h_m, sizeof(int)*m*m, cudaMemcpyHostToDevice)` 的形式将数据从GPU传输给CPU
## 选项
### A
可是使用`cudaMalloc()`函数来分配GPU存储空间
### B
可以使用`cudaFree()`函数来释放显存
......@@ -2,7 +2,9 @@
"node_id": "cuda-2244dd4b61cc478094ba7013770f1f29",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem4.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 数据传输
对于CUDA中的数据传输函数`cudaMemcpy(void *dst, const void *src, size_t count, cudaMemcpyKind kind)
`,以下说法错误的是?
## 答案
count可以无限大
## 选项
### A
dst可以是由cudaMalloc()分配的,指向GPU内存的地址.
### B
dst也可以是指向CPU内存的地址
### C
kind指的是数据传输方向
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-3fa4ca2a53d74b9d92a11ba6a7f23306",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem5.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 数据存储单元与线程之间的对应关系
以下说法正确的是?
## 答案
所有的线程都可以访问global memory
## 选项
### A
每个线程都有自己的寄存器, 其他线程无法访问.
### B
所有的线程都可以访问一个shared memory
......@@ -2,7 +2,9 @@
"node_id": "cuda-73f87372510e4546a282aea26e371e53",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem6.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA中的多种存储单元类型
下面关于CUDA中的多种存储单元说法错误的是?
## 答案
Register和Shared memory有很多, 每个线程更多的占用它们,可以让更多的block驻留在SM中
## 选项
### A
GPU上有onchip和onboard的存储单元类型
### B
Onchip的存储单元包括Register 和 Shared memory
......@@ -2,7 +2,9 @@
"node_id": "cuda-3347d61cb34745a4adbe216f6eca305c",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem7.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA中的多种存储单元
下面关于GPU中多种存储单元的说法错误的是?
## 答案
内核无法使用多于可用寄存器数量的任何变量(这也称为寄存器溢出)
## 选项
### A
寄存器变量是每个线程私有的,一旦thread执行结束,寄存器变量就会失效
### B
同一个Block中的线程共享一块Shared Memory
### C
在同一个编译单元,constant对所有kernel可见
......@@ -2,7 +2,9 @@
"node_id": "cuda-73179a76ecd34f5dbf8e53b3a1e84228",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem8.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA中的多种存储单元
下面对于CUDA中的多种存储单元说法错误的是?
## 答案
Texture Memory驻留在onchip Memory中,并且使用一个只读cache.
## 选项
### A
当一个warp中所有thread都从同一个Constant Memory地址读取数据时,Constant Memory表现会非常好,会触发广播机制.
### B
Texture Mmeory是专门为那些在内存访问模式中存在大量空间局部性(Spatial Locality)的图形应用程序而设计的.
### C
Global Memory驻留在Device memory中.
......@@ -2,7 +2,9 @@
"node_id": "cuda-8965afc1396c4aad8fa3eaa203b6e3ac",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem8.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 共享内存
下面关于共享内存的说法错误的是?
## 答案
Shared Memory可以被设置成512KB,1024KB ,2048KB…剩下的给L1缓存
## 选项
### A
有可能会出现同时有很多线程访问Shared Memory上的数据
### B
为了克服这个同时访问的瓶颈,Shared Memory被分成32个逻辑块(banks)
......@@ -2,7 +2,9 @@
"node_id": "cuda-3c183e532dcd44d88311a778f6958916",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem9.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 共享内存
下面关于共享内存说法错误的是?
## 答案
同一个warp 内多个线程访问同一个bank的同一个地址时,会出现bank冲突.
## 选项
### A
同常量内存一样,当一个 warp 中的所有线程访问同一地址的共享内存时,会触发一个广播(broadcast)机制到 warp 中所有线程.
### B
同一个warp 内多个线程访问同一个bank的不同地址时,会出现bank冲突.
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-6560fcc5a5c9465b84aa0f15b9576b79",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem10.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 利用共享存储单元优化程序
下面关于共享存储单元的说法错误的是?
## 答案
驻留在一个SM中的block中的线程如果shared memory不够用, 可以利用其他SM中的shared memory
## 选项
### A
在优化矩阵乘的过程中, 我们可以利用shared memory减少从global memory中数据的读取次数.
### B
同一Block中的线程可以利用shared memory进行协作.
......@@ -2,7 +2,9 @@
"node_id": "cuda-e2ec9573577d42fdbed66392ffc835d3",
"keywords": [],
"children": [],
"export": [],
"export": [
"mem11.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 统一内存的基本概念
以下关于统一内存的说法错误的是?
## 答案
申请的统一内存不需要进行数据传输,所以不受硬件带宽限制(如: PCIE等).
## 选项
### A
不需要手动拷贝数据.
### B
可以利用cudaMallocManaged() 函数分配统一内存.
......@@ -2,7 +2,9 @@
"node_id": "cuda-634b3d9492044bafb7a089431c878879",
"keywords": [],
"children": [],
"export": [],
"export": [
"error.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA 错误检测
下面关于CUDA错误检测错误的是?
## 答案
当异步函数发生错误的时候, 会马上终止并报告错误代码.
## 选项
### A
运行时函数会返回错误代码.
### B
内核启动不返回任何错误代码,因此必须在内核启动后立即调用 `cudaPeekAtLastError()``cudaGetLastError()` 以检索任何启动前错误.
......@@ -2,7 +2,9 @@
"node_id": "cuda-5a542af3254b49a8ab5266364d421e47",
"keywords": [],
"children": [],
"export": [],
"export": [
"event.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 事件
下面关于CUDA编程模型中的event说法错误的是?
## 答案
CUDA运行时提供了一种密切监视设备进度以及执行准确计时的方法,方法是让应用程序同步记录程序中任何点的事件
## 选项
### A
以下代码示例创建`start`, `stop`两个事件:
```C++
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
```
### B
可以利用以下代码销毁event:
```C++
cudaEventDestroy(start);
cudaEventDestroy(stop);
```
# 原子操作
下面关于CUDA中原子操作错误的是?
## 答案
原子函数可以在GPU或者CPU上执行
## 选项
### A
原子函数对驻留在全局或共享内存中的一个 32 位或 64 位字执行读-修改-写原子操作.
### B
原子操作保证在不受其他线程干扰的情况下执行。 换句话说,在操作完成之前,没有其他线程可以访问它处理数据的地址。
......@@ -2,7 +2,9 @@
"node_id": "cuda-10a7cead25f14eeaaf0730ff2468cb90",
"keywords": [],
"children": [],
"export": [],
"export": [
"atom.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# 原子操作
下面关于原子操作的说法正确的是?
## 答案
原子操作可以处理CPU内存的数据
## 选项
### A
原子操作可以处理GPU中global memory的数据.
### B
原子操作可以处理GPU中shared memory的数据.
......@@ -2,7 +2,9 @@
"node_id": "cuda-9e74b1fb163e46bb8cc2e72b3c9990a9",
"keywords": [],
"children": [],
"export": [],
"export": [
"atom1.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
......@@ -2,7 +2,9 @@
"node_id": "cuda-a95b22ce131e42979daabc1f2ec82886",
"keywords": [],
"children": [],
"export": [],
"export": [
"stream.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA流
下面关于CUDA流的说法错误的是?
## 答案
CUDA流只能在设备代码中调用执行.
## 选项
### A
流是按顺序执行的命令序列(可能由不同的主机线程发出).
### B
不同的流可能会彼此乱序或同时执行它们的命令.
......@@ -2,7 +2,9 @@
"node_id": "cuda-93c84af94c154430b93094befb70f5c8",
"keywords": [],
"children": [],
"export": [],
"export": [
"stream1.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA流
下面关于CUDA流的说法是错误的是?
## 答案
调用`cudaStreamSynchronize()` 函数, 程序会一直等待,直到所有主机线程的所有流中的所有先前命令都完成.
## 选项
### A
未指定任何流参数或等效地将流参数设置为零的内核启动和主机 <-> 设备内存拷贝将发布到默认流.
### B
调用`cudaDeviceSynchronize()`函数, 程序会一直等待,直到所有主机线程的所有流中的所有先前命令都完成.
......@@ -2,7 +2,9 @@
"node_id": "cuda-24b5313252644192b40894d9d677a40f",
"keywords": [],
"children": [],
"export": [],
"export": [
"stream2.md"
],
"keywords_must": [],
"keywords_forbid": []
}
\ No newline at end of file
# CUDA流
下面关于CUDA流的说法错误的是?
## 答案
以下设备操作对主机不是异步的:
* 内核启动;
* 内存复制在单个设备的内存中;
* 从主机到设备内存拷贝的内存块大小不超过64kb的;
* 由带有Async后缀的函数执行的内存拷贝;
* 内存设置函数调用。
## 选项
### A
如果主机线程在它们之间发出以下任一操作,则来自不同流的两个命令不能同时运行:
* 页面锁定的主机内存分配,
* 设备内存分配,
* 设备内存设置,
* 两个地址之间的内存拷贝到同一设备内存,
* 对 NULL 流的任何 CUDA 命令,
* 计算能力 3.x 和计算能力 7.x 中描述的 L1/共享内存配置之间的切换。
### B
CUDA 将以下操作公开为可以彼此同时操作的独立任务:
* 在主机上计算;
* 设备上的计算;
* 从主机到设备的内存传输;
* 从设备到主机的内存传输;
* 在给定设备的内存中进行内存传输;
* 设备之间的内存传输。
\ No newline at end of file