Giter Site home page Giter Site logo

lintenn / cudaaddvectors-explicit-vs-unified-memory Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 5 KB

Performance comparison of two different forms of memory management in CUDA

Cuda 100.00%
cuda c performance memory-management unified-memory explicit memory

cudaaddvectors-explicit-vs-unified-memory's Introduction

cudaAddVectors-explicit-vs-unified-memory

Performance comparison of two different forms of memory management in CUDA

By Luis Miguel García Marín

I have made two kernel implementations for vector addition (AddVectorsInto), one in which I use unified memory (cudaMallocManaged, cudaMemPrefetchAsync ...) and another in which I explicitly declare the vectors in CPU and GPU (malloc, cudaMalloc) and perform the same transfers manually with cudaMemcpy.

After the implementation of both (both codes can be seen within the repository), I have decided to compare their performance, with the help of the Visual Profiler. So let's take a look:

Unified memory version

Visual Profiler de la versión unified memory

Explicit memory version with cudaMemcpy transactions

Visual Profiler de la versión explicit memory

We see that both memory allocations (Malloc) and a transaction are made from the device (GPU) to the host (CPU) with the resulting vector (c).

We can see that both versions have similar total execution times (395 ms for unified memory and 420 ms for explicit memory), but that of unified memory is a little lower than that of explicit memory, even manually controlling the allocations of memory and transactions on CPU and GPU. The efficiency of Nvidia's unified memory usage (with the help of prefetches) is quite surprising, as it is comparable (and slightly better) to my manual implementation of memory allocation and transactions with cudaMemcpy.

However, we see that the unified memory version uses more main threads (5) than the explicit memory version (3). And not only that, but we also see that the unified memory version performs many more memory operations (64) than the explicit memory version (1), we can corroborate this by consulting the output of the nsys profiler command:

Unified memory version

nsys de unified-memory

Explicit memory version with cudaMemcpy transactions

nsys de explicit-memory

cudaaddvectors-explicit-vs-unified-memory's People

Contributors

lintenn avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.