TOTO HARYANTO

Sedikit goresan menebar manfaat …..

Archive for February, 2018

Paper dengan author banyak

Posted by totoharyanto on 22nd February 2018

Membaca paper dengan penulisĀ 5 s. 10 orang masih sering. Tetapi membaca paper dengan penulis yang berjumlah lebih dari 70 orang adalah luar biasa..

Author

Posted in Ilmu Komputer | 2 Comments »

Cuda Programming Tutorial : First

Posted by totoharyanto on 16th February 2018

Posted in Bahasa Pemrograman | No Comments »

Deep Learning

Posted by totoharyanto on 16th February 2018

Posted in IPB | No Comments »

Generate id of thread on GPU

Posted by totoharyanto on 16th February 2018

#include <stdio.h>
 #include <cuda.h>

#define LENGTH_OF_ARRAY 500
 #define THREADS 5
 #define BLOCKS 100
 // MAKE KERNEL FUNCTION

__global__ void print_real(int *a){
 int idx = blockIdx.x * blockDim.x + threadIdx.x;
 a[idx] = idx;
 }

__global__ void print_constant(int *a){
 int idx = blockIdx.x * blockDim.x + threadIdx.x;
 a[idx] = 7;
 }

__global__ void print_blockid(int *a){
 int idx = blockIdx.x * blockDim.x + threadIdx.x;
 a[idx] = blockIdx.x;
 }

__global__ void print_threadid(int *a){
 int idx = blockIdx.x * blockDim.x + threadIdx.x;
 a[idx] = threadIdx.x;
 }

int main()
 {
 int size = LENGTH_OF_ARRAY*sizeof(int); //DEFINE
 int i=0;
 // printf("Print constant\n");
 // printf("Print blockid\n");
 printf("Print threadid\n");
 int *a_h, *a_d;
 //memory allocation on host
 a_h = (int*)malloc(size);
 //memory allocation on device
 cudaMalloc((void**)&a_d, size);
 //call the kernel

// print_constant<<<BLOCKS,THREADS>>>(a_d);
 // print_blockid<<<BLOCKS,THREADS>>>(a_d);
 // print_threadid<<<BLOCKS,THREADS>>>(a_d);
 print_real<<<BLOCKS,THREADS>>>(a_d);

//copy from devie to host
 cudaMemcpy(a_h,a_d,size,cudaMemcpyDeviceToHost);

//print from host
 for(i=0;i<LENGTH_OF_ARRAY;i++)
 printf("%d ", a_h[i]);
 printf("\n\n");

cudaFree(a_d);

}

Posted in Bahasa Pemrograman | No Comments »