Computer Engineering15 [cuda] udacity atomic add 관련 코드 #include #include "gputimer.h" #define NUM_THREADS 10000000#define ARRAY_SIZE 100 #define BLOCK_WIDTH 1000 void print_array(int *array, int size){ printf("{ "); for (int i = 0; i < size; i++) { printf("%d ", array[i]); } printf("}\n");} __global__ void increment_naive(int *g){// which thread is this?int i = blockIdx.x * blockDim.x + threadIdx.x; // each thread to increment consecutive elements, .. 2015. 6. 14. [cuda] udacity 첫 숙제 // Homework 1// Color to Greyscale Conversion //A common way to represent color images is known as RGBA - the color//is specified by how much Red, Green, and Blue is in it.//The 'A' stands for Alpha and is used for transparency; it will be//ignored in this homework. //Each channel Red, Blue, Green, and Alpha is represented by one byte.//Since we are using one byte for each color there are 256 di.. 2015. 6. 13. [cuda] 개별 thread 색인 번호 각 차원별 접근법 다음 내용의 출처는 martinpeniak 이다. 1차원 블록의 1차원 그리드 __device__ int getGlobalIdx_1D_1D(){return blockIdx.x *blockDim.x + threadIdx.x;} 2차원 블록의 1차원 그리드 __device__ int getGlobalIdx_1D_2D(){return blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;} 3차원 블록의 1차원 그리드 __device__ int getGlobalIdx_1D_3D(){return blockIdx.x * blockDim.x * blockDim.y * blockDim.z + threadIdx.z * blockDim.. 2015. 6. 13. 이전 1 2 3 4 다음