Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple GPU Calc

a simple c code, that loop of print a calculation from cuda cpu

Goal

We’ll do this:

result[i] = rand(i) * i

on the GPU, and print it from the CPU.

Requirement

  • NVIDIA GPU

  • CUDA Toolkit installed

  • Compile with: nvcc gpu_calc.cu -o gpu_calc

What This Does:

Generates a simple random float on GPU using a seed and the index.

Multiplies it by the index (r * i).

Copies results back to CPU.

Prints the first 10 results.

Why It's Faster:

Each index calculation runs in its own GPU thread, in parallel.

Best for large N (e.g., millions of items).

Avoids slow printf() inside GPU.

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages