任何人都可以描述之间的差异__global__
和__device__
?
我应该何时使用__device__
,何时使用__global__
?
举例来说,这是cuda的第一个并行代码。
谁能形容我有关内核调用的信息:<<< N,1 >>>
这是重要的代码:
#define N 10
__global__ void add( int *a, int *b, int *c ) {
int tid = blockIdx.x; // this thread handles the data at its thread id
if (tid < N)
c[tid] = a[tid] + b[tid];
}
int main( void ) {
int a[N], b[N], c[N];
int *dev_a, *dev_b, *dev_c;
// allocate the memory on the GPU
// fill the arrays 'a' and 'b' on the CPU
// copy the arrays …
Run Code Online (Sandbox Code Playgroud) AES算法最重要的问题是速度慢.
是否可以使用CUDA实现其算法?我知道这是可能的,但我知道我可以提高它的速度吗?我想立即替换列表中的一些元素.
假设我们有这些列表:
list = [1, 2, 3, 4, 5, 6]
idx = [1, 3, 4]
new = [100, 200, 300]
Run Code Online (Sandbox Code Playgroud)
我想list
用new
值替换元素1,3,4.例如 :
list[idx] = new
Run Code Online (Sandbox Code Playgroud)
所以最后的清单是=> [1, 100, 3, 200, 300, 6]
我知道你可以在Matlab中以这种方式使用它,但想知道我应该在Python中做什么?
注意:我知道可以使用循环并执行此操作.
编辑:我想使用纯python解决方案.