Cuda-GPU-fibonacci-Parallel-Programming-project

所属分类:GPU/显卡
开发工具:Cuda
文件大小:0KB
下载次数:0
上传日期:2023-07-28 18:50:35
上 传 者sh-1993
说明:  Cuda GPU fibonacci并行编程项目,,
(Cuda-GPU-fibonacci-Parallel-Programming-project,,)

文件列表:
Makefile (93, 2023-07-28)
simpleKernel.cu (9306, 2023-07-28)
simpleKernel.sh (270, 2023-07-28)

# Cuda GPU fibonacci Sequence Sorting project This project is written in C++ on Cuda. The general Idea of this project is to generate a Fibonacci Sequence and sort it by **Manual Sorting Algorithms** Such as (_Bubble Sort, Quick Sort, Merge Sort, and Heap Sort_) And Also **Sorting Algorithms by Thrust Library** such as _('thrust::sort' and 'thrust::transform')_ at the same time. We'll see also why a Fibonacci sequence leads to the creation of a - (minus) digit and how will handle this.

## Table of Contents - [What is CUDA parallel programming](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#what-is-cuda) - [Why we used C++ ](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#why-we-used-c-) - [What is Fibonacci?](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#what-is-fibonacci) - [The Main Idea](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#the-main-idea) - [ Where did I run this project?](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#where-did-i-run-this-project) - [Some Technical points](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#some-technical-points) - [Why minus numbers will be generated?](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#why-minus-numbers-will-be-generated) - [How to Run](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#how-to-run) - [My test](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#my-test) - [Result Compare](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#compare-runtime-results-) - [Conclution](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/#conclution)

## What is CUDA? CUDA simplifies GPU Parallel programming, allowing developers to utilize the power of NVIDIA GPUs for parallel computing tasks. It provides a programming model, libraries, and tools for efficient GPU acceleration.

### Why we used C++ ? C++ is used with CUDA in this project to take advantage of the rich features and libraries provided by C++. CUDA is an extension of the C++ programming language, allowing developers to write parallel code for GPUs. By using C++, the project can leverage object-oriented programming capabilities, standard template libraries, and other features provided by C++, making the code more expressive, modular, and easier to develop and maintain. CUDA C is an extension of C specifically designed for GPU programming. While standard C focuses on general-purpose computing, CUDA C is optimized for utilizing the parallel processing capabilities of NVIDIA GPUs. ![image](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://github.com/pouyasattari/Cuda-GPU-fibonacci-project/assets/60811552/edaef585-e043-4497-8efe-2b29196fd65f)

## What is Fibonacci? The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones.
It starts with 0 and 1, and the subsequent numbers are generated by adding the two previous numbers together.
The sequence begins as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on.
The Fibonacci sequence has many interesting properties and is found in various areas of mathematics, nature, and computer science.


## The Main Idea * At first, we Generate a Fibonacci sequence, The 'N' is the maximum number of the sequence.
* Then Is goes to a - (minus) number and - (minus) numbers will generate on the sequence because of the summing of 2 past digits. [Why minus numbers will be generated? ](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://github.com/pouyasattari/Cuda-GPU-fibonacci-project/edit/main/README.md#why-minus-numbers-will-be-generated)
* After ending the generation process, Sorting Algorithms will be run on the CPU and GPU.
* After measuring runtime, the output will be shown.


## Where did I run this project? IBISCO Clusters (_Infrastructure for Big Data and Scientific Computing_) of the University of Naples Federico II. [IBiSCo](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://ibiscohpc-wiki.scope.unina.it/wiki:startdoc) ![image](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://github.com/pouyasattari/Cuda-GPU-fibonacci-project/assets/60811552/9f4f1d1b-a63a-44ab-a266-216afd65d006) Figure: We have 32 Nodes(servers) on the Data Center, Each nodes(servers) has 4 GPUs which are connected by [nVLink](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://www.nvidia.com/en-us/data-center/nvlink/).
These 32 Servers are connected by [InfiniBand : _Complex workloads demand ultra-fast processing of high-resolution simulations, extreme-size datasets, and highly parallelized algorithms._](https://github.com/pouyasattari/Cuda-GPU-fibonacci-Parallel-Programming-project/blob/master/https://www.nvidia.com/en-us/networking/products/infiniband/)


## Some Technical points - Manual Sorting algorithms are running on CPUs - Thrust library sorting algorithms are running on GPU. - This code will be run on a single GPU. You can modify it to run on more GPUs.

## Why minus numbers will be generated?
Look at the output of generated sequence: ```C++ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 -1323752223 512559680 -811192543 -298632863 -1109825406 -1408458269 1776683621 368225352 2144908973 -1781832971 ```
At this section of the output above: ```C++ ... 1134903170 1836311903 -1323752223 ... ```
result of 1134903170 + 1836311903 = **2,971,215,073** Which is Bigger than the Intiger size. As a result, an **integer overflow** occurs, and the next number becomes a negative number, -1323752223.
**From that point on, the generated sequence continues with negative numbers due to the integer overflow caused by adding the previous two numbers.** Then after: ```C++ ... ... 1836311903 -1323752223 512559680 ... ``` And So on: ```C++ ... ... ... -1323752223 512559680 -811192543 ... ```

# How to Run 1. You need to implement all 3 files in one directory. ### Makefile ### simpleKernel.cu - This file contents the main C++ CUDA parallel programming code. ### simpleKernel.sh - This file is the executer of the project 2. use terminal to go to the project path example: ``` cd CUDA/Fibonacci/ ``` 3. run the code: ``` ./simpleKernel.sh 2 ``` "2" is the number of threads. You can use 4,8,...


# My Test: N = 1000 _(Number of Fibonacci sequence)_ ```C++ 'Generated Fibonacci Sequence': 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 -1323752223 512559680 -811192543 -298632863 -1109825406 -1408458269 1776683621 368225352 2144908973 -1781832971 363076002 -1418756969 -1055680967 1820529360 764848393 -1709589543 -944741150 1640636603 695895453 -1958435240 -1262539787 1073992269 -188547518 885444751 696897233 1582341984 -2015728079 -433386095 1845853122 1412467027 -1036647147 375819880 -660827267 -285007387 -945834654 -1230842041 2118290601 887448560 -1289228135 -401779575 -1691007710 -2092787285 511172301 -1581614984 -1070442683 1642909629 572466946 -2079590721 -1507123775 708252800 -798870975 -90618175 -889489150 -980107325 -1869596475 1445263496 -424332979 1020930517 596597538 1617528055 -2080841703 -463313648 1750811945 1287498297 -1256657054 30841243 -1225815811 -1194974568 1874176917 679202349 -1741588030 -1062385681 1490993585 428607904 1919601489 -1946757903 -27156414 -1973914317 -2001070731 319982248 -1681088483 -1361106235 1252772578 -108333657 1144438921 1036105264 -2114423111 -1078317847 1102226338 23908491 1126134829 1150043320 -2018789147 -868745827 1407432322 538686495 1946118817 -1810161984 135956833 -1674205151 -1538248318 1082513827 -455734491 626779336 171044845 797824181 968869026 1766693207 -1559405063 207288144 -1352116919 -1144828775 1798021602 653192827 -1843752867 -1190560040 1260654389 70094349 1330748738 1400843087 -1563375471 -162532384 -1725907855 -1888440239 680619202 -1207821037 -527201835 -1735022872 2032742589 297719717 -1964504990 -1666785273 663677033 -1003108240 -339431207 -1342539447 -1681970654 1270457195 -411513459 858943736 447430277 1306374013 1753804290 -1234788993 519015297 -715773696 -196758399 -912532095 -1109290494 -2021822589 1163854213 -857968376 305885837 -552082539 -246196702 -798279241 -1044475943 -1842755184 1407736169 -435019015 972717154 537698139 1510415293 2048113432 -736438571 1311674861 575236290 1886911151 -1832819855 54091296 -1778728559 -1724637263 791601474 -933035789 -141434315 -1074470104 -1215904419 2004592773 788688354 -1501686169 -712997815 2080283312 1367285497 -847398487 519887010 -327511477 192375533 -135135944 57239589 -77896355 -20656766 -98553121 -119209887 -217763008 -336972895 -554735903 -891708798 -1446444701 1956813797 510369096 -1827784403 -1317415307 1149767586 -167647721 982119865 814472144 1796592009 -1683903143 112688866 -1571214277 -1458525411 1265227608 -193297803 1071929805 878632002 1950561807 -1465773487 484788320 -980985167 -496196847 -1477182014 -1973378861 844406421 -1128972440 -284566019 -1413538459 -1698104478 1183324359 -514780119 668544240 153764121 822308361 976072482 1798380843 -1520513971 277866872 -1242647099 -964780227 2087539970 1122759743 -1084667583 38092160 -1046575423 -1008483263 -2055058686 1231425347 -823633339 407792008 -415841331 -8049323 -423890654 -431939977 -855830631 -1287770608 -2143601239 863595449 -1280005790 -416410341 -1696416131 -2112826472 485724693 -1627101779 -1141377086 1526488431 385111345 1911599776 -1998256175 -86656399 -2084912574 2123398323 38485749 -2133083224 -2094597475 67286597 -2027310878 -1960024281 307632137 -1652392144 -1344760007 1297815145 -46944862 1250870283 1203925421 -1840171592 -636246171 1818549533 1182303362 -1294114401 -111811039 -1405925440 -1517736479 1371305377 -146431102 1224874275 1078443173 -1991649848 -913206675 1390110773 476904098 1867014871 -1951048327 -84033456 -2035081783 -2119115239 140770274 -1978344965 -1837574691 479047640 -1358527051 -879479411 2056960834 1177481423 -1060525039 116956384 -943568655 -826612271 -1770180926 1698174099 -72006827 1626167272 1554160445 -1114639579 439520866 -675118713 -235597847 -910716560 -1146314407 -2057030967 1091621922 -965409045 126212877 -839196168 -712983291 -1552179459 2029804546 477625087 -1787537663 -1309912576 1197517057 -112395519 1085121538 972726019 2057847557 -1264393720 793453837 -470939883 322513954 -148425929 174088025 25662096 199750121 225412217 425162338 650574555 1075736893 1726311448 -1492918955 233392493 -1259526462 -1026133969 2009306865 983172896 -1302487535 -319314639 -1621802174 -1941116813 732048309 -1209068504 -477020195 -1686088699 2131858402 445769703 -1717339191 -1271569488 1306058617 34489129 1340547746 1375036875 -1579382675 -204345800 -1783728475 -1988074275 523164546 -1464909729 -941745183 1888312384 946567201 -1460087711 -513520510 -1973608221 1807838565 -165769656 1642068909 1476299253 -1176599134 299700119 -876899015 -577198896 -1454097911 -2031296807 809572578 -1221724229 -412151651 -1633875880 -2046027531 615063885 -1430963646 -815899761 2048103889 1232204128 -1014659279 217544849 -797114430 -579569581 -1376684011 -1956253592 962029693 -994223899 -32194206 -1026418105 -1058612311 -2085030416 1151324569 -933705847 217618722 -716087125 -498468403 -1214555528 -1713023931 1367387837 -345636094 1021751743 676115649 1697867392 -1920984255 -223116863 -2144101118 1927749315 -216351803 1711397512 1495045709 -1088524075 406521634 -682002441 -275480807 -957483248 -1232964055 2104519993 871555938 -1318891365 -447335427 -1766226792 2081405077 ``` ```C++ 'Bubble' Sort: -2144101118 -2143601239 -2133083224 -2119115239 -2114423111 -2112826472 -2094597475 -2092787285 -2085030416 -2084912574 -2080841703 -2079590721 -2057030967 -2055058686 -2046027531 -2035081783 -2031296807 -2027310878 -2021822589 -2018789147 -2015728079 -2001070731 -1998256175 -1991649848 -1988074275 -1978344965 -1973914317 -1973608221 -1973378861 -1964504990 -1960024281 -1958435240 -1956253592 -1951048327 -1946757903 -1941116813 -1920984255 -1888440239 -1869596475 -1843752867 -1842755184 -1840171592 -1837574691 -1832819855 -1827784403 -1810161984 -1787537663 -1783728475 -1781832971 -1778728559 -1770180926 -1766226792 -1741588030 -1735022872 -1725907855 -1724637263 -1717339191 -1713023931 -1709589543 -1698104478 -1696416131 -1691007710 -1686088699 -1683903143 -1681970654 -1681088483 -1674205151 -1666785273 -1652392144 -1633875880 -1627101779 -1621802174 -1581614984 -1579382675 -1571214277 -1563375471 -1559405063 -1552179459 -1538248318 -1520513971 -1517736479 -1507123775 -1501686169 -1492918955 -1477182014 -1465773487 -1464909729 -1460087711 -1458525411 -1454097911 -1446444701 -1430963646 -1418756969 -1413538459 -1408458269 -1405925440 -1376684011 -1361106235 -1358527051 -1352116919 -1344760007 -1342539447 -1323752223 -1318891365 -1317415307 -1309912576 -1302487535 -1294114401 -1289228135 -1287770608 -1280005790 -1271569488 -1264393720 -1262539787 -1259526462 -1256657054 -1242647099 -1234788993 -1232964055 -1230842041 -1225815811 -1221724229 -1215904419 -1214555528 -1209068504 -1207821037 -1194974568 -1190560040 -1176599134 -1146314407 -1144828775 -1141377086 -1128972440 -1114639579 -1109825406 -1109290494 -1088524075 -1084667583 -1078317847 -1074470104 -1070442683 -1062385681 -1060525039 -1058612311 -1055680967 -1046575423 -1044475943 -1036647147 -1026418105 -1026133969 -1014659279 -1008483263 -1003108240 -994223899 -980985167 -980107325 -965409045 -964780227 -957483248 -945834654 -944741150 -943568655 -941745183 -933705847 -933035789 -913206675 -912532095 -910716560 -891708798 -889489150 -879479411 -876899015 -868745827 -857968376 -855830631 -847398487 -839196168 -826612271 -823633339 -815899761 -811192543 -798870975 -798279241 -797114430 -736438571 -716087125 -715773696 -712997815 -712983291 -682002441 -675118713 -660827267 -636246171 -579569581 -577198896 -554735903 -552082539 -527201835 -514780119 -513520510 -498468403 -496196847 -477020195 -470939883 -463313648 -455734491 -447335427 -435019015 -433386095 -431939977 -424332979 -423890654 -416410341 -415841331 -412151651 -411513459 -401779575 -345636094 -339431207 -336972895 -327511477 -319314639 -298632863 -285007387 -284566019 -275480807 -246196702 -235597847 -223116863 -217763008 -216351803 -204345800 -196758399 -193297803 -188547518 -167647721 -165769656 -162532384 -148425929 -146431102 -141434315 -135135944 -119209887 -112395519 -111811039 -108333657 -98553121 -90618175 -86656399 -84033456 -77896355 -72006827 -46944862 -32194206 -27156414 -20656766 -8049323 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 23908491 24157817 25662096 30841243 34489129 38092160 38485749 39088169 54091296 57239589 63245986 67286597 70094349 102334155 112688866 116956384 126212877 135956833 140770274 153764121 165580141 171044845 174088025 192375533 199750121 207288144 217544849 217618722 225412217 233392493 267914296 277866872 297719717 299700119 305885837 307632137 319982248 322513954 363076002 368225352 375819880 385111345 406521634 407792008 425162338 428607904 433494437 439520866 445769703 447430277 476904098 477625087 479047640 484788320 485724693 510369096 511172301 512559680 519015297 519887010 523164546 537698139 538686495 572466946 575236290 596597538 615063885 626779336 650574555 653192827 663677033 668544240 676115649 679202349 680619202 695895453 696897233 701408733 708252800 732048309 764848393 788688354 791601474 793453837 797824181 809572578 814472144 822308361 844406421 858943736 863595449 871555938 878632002 885444751 887448560 946567201 962029693 968869026 972717154 972726019 976072482 982119865 983172896 1020930517 1021751743 1036105264 1071929805 1073992269 1075736893 1078443173 1082513827 1085121538 1091621922 1102226338 1122759743 1126134829 1134903170 1144438921 1149767586 1150043320 1151324569 1163854213 1177481423 1182303362 1183324359 1197517057 1203925421 1224874275 1231425347 1232204128 1250870283 1252772578 1260654389 1265227608 1270457195 1287498297 1297815145 1306058617 1306374013 1311674861 1330748738 1340547746 1367285497 1367387837 1371305377 1375036875 1390110773 1400843087 1407432322 1407736169 1412467027 1445263496 1476299253 1490993585 1495045709 1510415293 1526488431 1554160445 1582341984 1617528055 1626167272 1640636603 1642068909 1642909629 1697867392 1698174099 1711397512 1726311448 1750811945 1753804290 1766693207 1776683621 1796592009 1798021602 1798380843 1807838565 1818549533 1820529360 1836311903 1845853122 1867014871 1874176917 1886911151 1888312384 1911599776 1919601489 1927749315 1946118817 1950561807 1956813797 2004592773 2009306865 2029804546 2032742589 2048103889 2048113432 2056960834 2057847557 2080283312 2081405077 2087539970 2104519993 2118290601 2123398323 2131858402 2144908973 ``` ```C++ 'Merge' Sort: -2144101118 -2143601239 -2133083224 -2119115239 -2114423111 -2112826472 -2094597475 -2092787285 -2085030416 -2084912574 -2080841703 -2079590721 -2057030967 -2055058686 -2046027531 -2035081783 -2031296807 -2027310878 -2021822589 -2018789147 -2015728079 -2001070731 -1998256175 -1991649848 -1988074275 -1978344965 -1973914317 -1973608221 -1973378861 -1964504990 -1960024281 -1958435240 -1956253592 -1951048327 -1946757903 -1941116813 -1920984255 -1888440239 -1869596475 -1843752867 -1842755184 -1840171592 -1837574691 -1832819855 -1827784403 -1810161984 -1787537663 -1783728475 -1781832971 -1778728559 -1770180926 -1766226792 -1741588030 -1735022872 -1725907855 -1724637263 -1717339191 -1713023931 -1709589543 -1698104478 -1696416131 -1691007710 -1686088699 -1683903143 -1681970654 -1681088483 -1674205151 -1666785273 -1652392144 -1633875880 -1627101779 -1621802174 -1581614984 -1579382675 -1571214277 -1563375471 -1559405063 -1552179459 -1538248318 -1520513971 -1517736479 -1507123775 -1501686169 -1492918955 -1477182014 -1465773487 -1464909729 -1460087711 -1458525411 -1454097911 -1446444701 -1430963646 -1418756969 -1413538459 -1408458269 -1405925440 -1376684011 -1361106235 -1358527051 -1352116919 -1344760007 -1342539447 -1323752223 -1318891365 -1317415307 -1309912576 -1302487535 -1294114401 -1289228135 -1287770608 -1280005790 -1271569488 -1264393720 -1262539787 -1259526462 -1256657054 -1242647099 -1234788993 -1232964055 -1230842041 -1225815811 -1221724229 -1215904419 -1214555528 -1209068504 -1207821037 -1194974568 -1190560040 -1176599134 -1146314407 -1144828775 -1141377086 -1128972440 -1114639579 -1109825406 -1109290494 -1088524075 -1084667583 -1078317847 -1074470104 -1070442683 -1062385681 -1060525039 -1058612311 -1055680967 -1046575423 -1044475943 -1036647147 -1026418105 -1026133969 -1014659279 -1008483263 -1003108240 -994223899 -980985167 -980107325 -965409045 -964780227 -957483248 -945834654 -944741150 -943568655 -941745183 -933705847 -933035789 -913206675 -912532095 -910716560 -891708798 -889489150 -879479411 -876899015 -868745827 -857968376 -855830631 -847398487 -839196168 -826612271 -823633339 -815899761 -811192543 -798870975 -798279241 -797114430 -736438571 -716087125 -715773696 -712997815 -712983291 -682002441 -675118713 -660827267 -636246171 -579569581 -577198896 -554735903 -552082539 -527201835 -514780119 -513520510 -498468403 -496196847 -477020195 -470939883 -463313648 -455734491 -447335427 -435019015 -433386095 -431939977 -424332979 -423890654 -416410341 -415841331 -412151651 -411513459 -401779575 -345636094 -339431207 -336972895 -327511477 -319314639 -298632863 -285007387 -284566019 -275480807 -246196702 -235597847 -223116863 -217763008 -216351803 -204345800 -196758399 -193297803 -188547518 -167647721 -165769656 -162532384 -148425929 -146431102 -141434315 -135135944 -119209887 -112395519 -111811039 -108333657 -98553121 -90618175 -86656399 -84033456 -77896355 -72006827 -46944862 -32194206 -27156414 -20656766 -8049323 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 23908491 24157817 25662096 30841243 34489129 38092160 38485749 39088169 54091296 57239589 63245986 67286597 70094349 102334155 112688866 116956384 126212877 135956833 140770274 153764121 16558 ... ...

近期下载者

相关文件


收藏者