我有一个
multimap<key1,pair<key2, value2>>
Run Code Online (Sandbox Code Playgroud)
我想在这个多图中更改 value2。
typedef std::pair<int, int> comp_buf_pair; //pair<comp_t, dij>
typedef std::pair<int, comp_buf_pair> node_buf_pair;
typedef std::multimap<int, comp_buf_pair> buf_map; //key=PE, value = pair<comp_t, dij>
typedef buf_map::iterator It_buf;
buf_map bufsz_map;
bufsz_map.insert(node_buf_pair(target(*ei,g), comp_buf_pair(comp_t[target(*ei,g)], dij)));
for(It_buf it = bufsz_map.equal_range(*u_iter).first; it!= bufsz_map.equal_range(*u_iter).second;)
{
comp_buf_pair it1 = it->second;
if(it1.first < c_i)
{
std::cout << it1.first << " : " << it1.second << std::endl;
old_c_i = it1.first;
old_dij = it1.second;
updated_dij = (c_i-old_c_i) + old_dij;
// I would like to erase the it1.second value and add …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 FFT 与使用加窗方法比较互相关。
我的 Matlab 代码是:
isize = 20;
n = 7;
for i = 1:n %%7x7 xcorr
for j = 1:n
xcout(i,j) = sum(sum(ffcorr1 .* ref(i:i+isize-1,j:j+isize-1))); %%ref is 676 element array and ffcorr1 is a 400 element array
end
end
Run Code Online (Sandbox Code Playgroud)
类似的CUDA内核:
__global__ void xc_corr(double* in_im, double* ref_im, int pix3, int isize, int n, double* out1, double* temp1, double* sum_temp1)
{
int p = blockIdx.x * blockDim.x + threadIdx.x;
int q = 0;
int i = 0;
int j = …
Run Code Online (Sandbox Code Playgroud) 串行代码片段如下所示:
int i, j;
for(j=0; j<ny; j++)
{
for(i=0; i<nx; i++)
{
x[i + j*nx] *= y[i];
}
}
Run Code Online (Sandbox Code Playgroud)
我使用这个内核将其转换为CUDA:
int tid = blockIdx.x * blockDim.x + threadIdx.x;
int i,j;
for(tid = 0; tid <nx*ny; tid++)
{
j = tid/nx;
i = tid - j*nx;
x[tid] *= y[i];
}
Run Code Online (Sandbox Code Playgroud)
但是GPU内核没有提供任何加速改进?关于更好解决方案的任何建议?提前致谢