Hands-On GPU Computing with Python by Avimanyu Bandyopadhyay

Hands-On GPU Computing with Python by Avimanyu Bandyopadhyay

Author:Avimanyu Bandyopadhyay
Language: eng
Format: epub, mobi, pdf
Tags: COM087020 - COMPUTERS / Desktop Applications / Design and Graphics, COM051240 - COMPUTERS / Software Development and Engineering / Systems Analysis and Design, COM051220 - COMPUTERS / Programming / Parallel
Publisher: Packt Publishing
Published: 2019-05-14T03:19:35+00:00


// Setup input values

for (i = 0; i < N - 1; ++i) {

p[i] = 24.0;

q[i] = 12.0;

}

// Copy inputs to device

hipMemcpy(gpu_p, p, size, hipMemcpyHostToDevice);

hipMemcpy(gpu_q, q, size, hipMemcpyHostToDevice);

Note that only the following comment has been modified manually for HIP:

//INITIALIZE HIP EVENTS

hipEvent_t start, stop;

float elapsedTime;

//CREATING EVENTS

hipEventCreate(&start);

hipEventCreate(&stop);

hipEventRecord(start, 0);

//HIP KERNEL STUFF HERE...

// Launch multiply() kernel on GPU with N threads

hipLaunchKernelGGL(multiply, dim3((N + THREADS_PER_BLOCK - 1) / THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, 0, gpu_p, gpu_q, N);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.