合并内存访问时的全局加载事务计数

时间:2016-06-15 06:44:52

标签: cuda nvprof

我创建了一个简单的内核,通过观察nvidia gtx980卡中的事务计数来测试合并的内存访问。内核是,

__global__
void copy_coalesced(float * d_in, float * d_out)
{
    int tid = threadIdx.x + blockIdx.x*blockDim.x;

    d_out[tid] = d_in[tid];
}

当我使用以下内核配置

运行时
#define BLOCKSIZE 32   

int data_size  = 10240;                  //always a multiply of the BLOCKSIZE
int gridSize   = data_size / BLOCKSIZE;

copy_coalesced<<<gridSize, BLOCKSIZE>>>(d_in, d_out);

由于内核中的数据访问是完全合并的,并且由于数据类型是float(4个字节),因此可以找到预期的加载/存储事务数,

加载事务大小= 32字节

每个事务可以加载的浮点数= 32个字节/ 4个字节= 8

加载10240个数据所需的交易数量= 10240/8 = 1280个交易

预计写入数据的交易量也相同。

但是在观察nvprof指标时,以下是结果

gld_transactions    2560
gst_transactions    1280

gld_transactions_per_request    8.0
gst_transactions_per_request    4.0

我无法弄清楚为什么它需要两倍于加载数据所需的事务。但是,当涉及到加载/存储效率时,两个指标都给出了100%

我错过了什么?

1 个答案:

答案 0 :(得分:1)

我在linux上重现了你的结果,

1  gld_transactions             Global Load Transactions               2560
1  gst_transactions             Global Store Transactions              1280
1  l2_tex_read_transactions     L2 Transactions (Texture Reads)        1280
1  l2_tex_write_transactions    L2 Transactions (Texture Writes)       1280 

但是,在使用NSIGHT Visual Studio版本的Windows上,我得到的值看起来更好:

Snapshot of NSIGHT Visual Studio edition

您可能希望与NVIDIA联系,因为它可能只是nvprof中的显示问题。