{"id":19348240,"url":"https://github.com/lintenn/cudaaddvectors-explicit-vs-unified-memory","last_synced_at":"2026-05-17T19:02:07.535Z","repository":{"id":107936383,"uuid":"413191516","full_name":"lintenn/cudaAddVectors-explicit-vs-unified-memory","owner":"lintenn","description":"Performance comparison of two different forms of memory management in CUDA","archived":false,"fork":false,"pushed_at":"2021-10-03T21:01:57.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-06T14:48:50.941Z","etag":null,"topics":["c","cuda","explicit","memory","memory-management","performance","unified-memory"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lintenn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-03T20:38:06.000Z","updated_at":"2024-10-30T16:51:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"bd641568-ed69-4a07-bfd2-ecb5b9c234a1","html_url":"https://github.com/lintenn/cudaAddVectors-explicit-vs-unified-memory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintenn%2FcudaAddVectors-explicit-vs-unified-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintenn%2FcudaAddVectors-explicit-vs-unified-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintenn%2FcudaAddVectors-explicit-vs-unified-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lintenn%2FcudaAddVectors-explicit-vs-unified-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lintenn","download_url":"https://codeload.github.com/lintenn/cudaAddVectors-explicit-vs-unified-memory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240457995,"owners_count":19804489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cuda","explicit","memory","memory-management","performance","unified-memory"],"created_at":"2024-11-10T04:19:29.770Z","updated_at":"2025-11-14T20:04:48.402Z","avatar_url":"https://github.com/lintenn.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cudaAddVectors-explicit-vs-unified-memory\n## Performance comparison of two different forms of memory management in CUDA\n### By Luis Miguel García Marín\n\nI 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.\n\nAfter 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: \n\n### Unified memory version\n![Visual Profiler de la versión unified memory](https://user-images.githubusercontent.com/74145538/135771280-66aead40-eeb0-48e8-95fe-f783979d23b0.png)\n\n### Explicit memory version with cudaMemcpy transactions\n![Visual Profiler de la versión explicit memory](https://user-images.githubusercontent.com/74145538/135771317-108a3001-50c3-40e3-9c17-22fefcf28691.png)\n\nWe see that both memory allocations (Malloc) and a transaction are made from the device (GPU) to the host (CPU) with the resulting vector (c).\n\nWe 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.\n\nHowever, 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:\n\n### Unified memory version\n![nsys de unified-memory](https://user-images.githubusercontent.com/74145538/135771355-46938946-1418-421f-8a01-c3d960df758a.png)\n\n### Explicit memory version with cudaMemcpy transactions\n![nsys de explicit-memory](https://user-images.githubusercontent.com/74145538/135771360-6f330e9d-67ce-468d-8dc4-67ea86357dc1.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintenn%2Fcudaaddvectors-explicit-vs-unified-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flintenn%2Fcudaaddvectors-explicit-vs-unified-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flintenn%2Fcudaaddvectors-explicit-vs-unified-memory/lists"}