This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma opname sample_merge | |
#pragma oplabel "SampleMerge" | |
#pragma opmaxinputs 4 | |
#pragma inputlabel 1 "R" | |
#pragma inputlabel 2 "G" | |
#pragma inputlabel 3 "B" | |
#pragma inputlabel 4 "A" | |
#pragma label useChannelOfR "Use channel of R" | |
#pragma choice useChannelOfR "0" "R" | |
#pragma choice useChannelOfR "1" "G" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CUDA プログラミング実践講座 演習6.3の解答 */ | |
/* 図6.2の改良版 */ | |
__global__ void reduction_kernel0602(float *array) | |
{ | |
extern __shared__ float partialSum[]; | |
unsigned int tid = threadIdx.x; | |
unsigned int bid = blockIdx.x; | |
unsigned int arrayIdx = bid * blockDim.x + (2*tid); /* (2) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 図6.2の改良 | |
* テキストと同様にグローバルメモリと共有メモリの間のコピーは除いている | |
*/ | |
__global__ void reduction_kernel(float *array) | |
{ | |
extern __shared__ float partialSum[]; | |
unsigned int t = 2*threadIdx.x; | |
for (unsigned int stride = 1; stride <= blockDim.x; stride *= 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 図6.4の改良 | |
* テキストと同様にグローバルメモリとshared memoryの間のコピーは省略 | |
*/ | |
__global__ reduction_kernel(float *array) | |
{ | |
extern __shared__ float patrialSum[]; | |
unsigned int t = threadIdx.x; | |
for (unsigned int stride = blockDim.x; stride > 0; stride >>= 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__global__ void kernel(...) | |
{ | |
__shared__ int candidates[32], candidateSize; | |
int customer = threadIdx.x; | |
candidateSize = 0; | |
if (customer < 32 && !isVisited(customer)) | |
{ | |
int old = atomicAdd(&candidateSize, 1); | |
candidate[old] = customer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__global__ void kernel(...) | |
{ | |
__shared__ int candidates[32], candidateSize; | |
int customer = threadIdx.x; | |
candidateSize = 0; | |
if (customer < 32 && !isVisited(customer)) | |
{ | |
atomicAdd(&candidate[candidateSize], customer); | |
atomicAdd(&candidateSize, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct distnce | |
{ | |
int *cost; | |
} distance; | |
typedef struct problem | |
{ | |
distance dist; | |
} problem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cstdarg> | |
template<typename T> | |
T sumN(unsigned int n, ...) | |
{ | |
va_list vl; | |
va_start(vl, n); | |
T sum = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:count_if(list, string) abort | |
let copy = deepcopy(a:list) | |
call filter(copy, a:string) | |
return len(copy) | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:foo(second) abort | |
let l:start = reltime() | |
while str2float(reltimestr(reltime(l:start))) < float(a:second) | |
execute 'normal! r ' | |
endwhile | |
endfunction | |
tabnew Sample | |
call setline(1, 'Please any keys for 2 seconds.') |
NewerOlder