cuda.live
  • Home
    • CUDA C++
    • Triton
  • Playground
  • Challenges
  • Gallery
  • Pricing

Explore Snippets

26 public snippets shared by the community.

Sort:RecentPopular
Language:AllCUDAC++Python

Shared Code

CUDA
#include<iostream>
#include<chrono>
#include<cuda_runtime.h>

using namespace std;
using namespace chrono;

__global__ void GPU_Vector_Addition(int* a, int* b, int* c, int n){
  int i = blockDim.x * blockIdx.x + threadIdx.x;

  if (i < n){
    c[i] = a[i] + b[i];
  }
}

void CPU_Vector_Addition(int*
...
by harrypotterck1990
15 views·May 7, 2026

Shared CUDA Code

CUDA
#include <stdio.h>

__global__ void vecAdd(float *a, float *b, float *c, int n) {
    int i = blockIdx.x * blockDim.x + threadIdx.x;
    if (i < n) {
        c[i] = a[i] + b[i];
    }
}

int main() {
    int n = 1024;
    size_t bytes = n * sizeof(float);

    float *h_a = (float*)malloc(bytes);
   
...
by anan.gupt.1994
20 views·Apr 14, 2026
← PreviousPage 2 of 2Next →

⚠️ NVIDIA has not reviewed, approved, or authorized the content on this website. cuda.live is an independent educational resource and is not affiliated with, endorsed by, or sponsored by NVIDIA Corporation. CUDA® is used here solely for descriptive/reference purposes to identify the technology being taught. This use is not intended to suggest any affiliation with or endorsement by NVIDIA Corporation. The use of "CUDA" in this domain name is for nominative fair use purposes — to describe the subject matter of these educational tutorials, not to imply sponsorship. CUDA® and NVIDIA® are registered trademarks of NVIDIA Corporation. All other trademarks are the property of their respective owners. Full legal notice →

© 2026 cuda.live. Content is for educational purposes only.
LegalPrivacyTerms