Announcement

Collapse
No announcement yet.

A simple Sum

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A simple Sum

    PHP Code:
    #include <iostream>

    __global__ void sum (int aint *bintc){

        *
    = (*+ *b);
    }


    int mainvoid ) {

        
    int a,b,c;
        
    a=10;
        
    b=20;

        
    int d_a_pointer;
        
    int d_b_pointer;
        
    int d_c_pointer;

        
    cudaMalloc ((void **)&d_a_pointersizeof(int));
        
    cudaMalloc ((void **)&d_b_pointersizeof(int));
        
    cudaMalloc ((void **)&d_c_pointersizeof(int));


        
    cudaMemcpyd_a_pointer, &asizeof(int), cudaMemcpyHostToDevice);
        
    cudaMemcpyd_b_pointer, &bsizeof(int), cudaMemcpyHostToDevice);

        
    sum<<<1,1>>>(d_a_pointerd_b_pointerd_c_pointer);
        
    cudaMemcpy( &cd_c_pointer sizeof(int), cudaMemcpyDeviceToHost);


        
    std::cout << c;

        
    std::cin.get();


    return 
    0;

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia