Method: BOAST::CKernel#fill_code

Defined in:
lib/BOAST/CKernel.rb

#fill_code(source_file) ⇒ Object



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/BOAST/CKernel.rb', line 438

def fill_code(source_file)
  @code.rewind
  source_file.puts "#include <inttypes.h>" if @lang == BOAST::C or @lang == BOAST::CUDA
  source_file.puts "#include <cuda.h>" if @lang == BOAST::CUDA
  source_file.write @code.read
  if @lang == BOAST::CUDA then
    source_file.write <<EOF
extern "C" {
  #{@procedure.header(BOAST::CUDA,false)}{
dim3 dimBlock(block_size[0], block_size[1], block_size[2]);
dim3 dimGrid(block_number[0], block_number[1], block_number[2]);
cudaEvent_t __start, __stop;
float __time;
cudaEventCreate(&__start);
cudaEventCreate(&__stop);
cudaEventRecord(__start, 0);
#{@procedure.name}<<<dimGrid,dimBlock>>>(#{@procedure.parameters.join(", ")});
cudaEventRecord(__stop, 0);
cudaEventSynchronize(__stop);
cudaEventElapsedTime(&__time, __start, __stop);
return (unsigned long long int)((double)__time*(double)1e6);
  }
}
EOF
  end
  @code.rewind
end