mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2026-11-18 01:48:16 +08:00
Compare commits
493 Commits
v11.5
...
sync/v13.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b946e35723 | ||
|
|
b7c5481c55 | ||
|
|
aeab82ff30 | ||
|
|
a4526d5229 | ||
|
|
f69622b6b6 | ||
|
|
722c5dd069 | ||
|
|
e32d17e67e | ||
|
|
5cf83b5a98 | ||
|
|
191900a7b4 | ||
|
|
338df69d0f | ||
|
|
9b7a6f907a | ||
|
|
5bbae96fd3 | ||
|
|
ce9407c240 | ||
|
|
cdedff42d2 | ||
|
|
6c4d183ba3 | ||
|
|
af49216f0c | ||
|
|
17113ea87e | ||
|
|
70fcdd353f | ||
|
|
5b2dd19a21 | ||
|
|
37dcb9b61d | ||
|
|
1bc6774795 | ||
|
|
4f735616ba | ||
|
|
4ff552244d | ||
|
|
df6edf644e | ||
|
|
85231cd1b6 | ||
|
|
46a782fb44 | ||
|
|
d5dedb24d6 | ||
|
|
9600b04a3c | ||
|
|
4eae2ccc04 | ||
|
|
d759a16c4b | ||
|
|
b8191f860a | ||
|
|
547f65851f | ||
|
|
9df0ef6411 | ||
|
|
1411d243a6 | ||
|
|
57e870596c | ||
|
|
fd6707ccaa | ||
|
|
cf01c5bb28 | ||
|
|
1165d53ddf | ||
|
|
8c324afd63 | ||
|
|
0fae54dcd6 | ||
|
|
320c7e6392 | ||
|
|
22fafb0a7c | ||
|
|
cccbf2c284 | ||
|
|
69186dc51e | ||
|
|
d298bf3e6f | ||
|
|
27c7e19849 | ||
|
|
7c190dde53 | ||
|
|
5e9d44634b | ||
|
|
b0a2f2049f | ||
|
|
3e6d1858af | ||
|
|
12b046a80e | ||
|
|
036638b713 | ||
|
|
9d703d090b | ||
|
|
cbc075ef59 | ||
|
|
6e23a98575 | ||
|
|
5fc7a4c897 | ||
|
|
3f1c509650 | ||
|
|
fbc40da311 | ||
|
|
1b36fefcd5 | ||
|
|
13c2fd9717 | ||
|
|
775d1b4dd3 | ||
|
|
a5267b83a5 | ||
|
|
2ab16e6d15 | ||
|
|
903c840a8c | ||
|
|
24e7c5b428 | ||
|
|
b38ed29c95 | ||
|
|
4a631c9fd6 | ||
|
|
98afcd6515 | ||
|
|
eb8891b839 | ||
|
|
688fff15b2 | ||
|
|
555353b4b5 | ||
|
|
1a35902577 | ||
|
|
8013610840 | ||
|
|
2369d4c649 | ||
|
|
8433f89993 | ||
|
|
a9a4db666f | ||
|
|
87d03ef003 | ||
|
|
7c8fccc0d4 | ||
|
|
45314d7ff8 | ||
|
|
2f0a55d7dc | ||
|
|
0d61031846 | ||
|
|
225f84d433 | ||
|
|
e674cc36fe | ||
|
|
a47b422205 | ||
|
|
ce28796d6c | ||
|
|
9424c15848 | ||
|
|
9075c50a3d | ||
|
|
de5fa98e6e | ||
|
|
6c9e9d3cd2 | ||
|
|
7f5390cec3 | ||
|
|
5f6d46dfea | ||
|
|
49307463b5 | ||
|
|
859debae1b | ||
|
|
9c0d5aaae6 | ||
|
|
74a9a08887 | ||
|
|
0d08748ffa | ||
|
|
c1166d3298 | ||
|
|
27f47634a0 | ||
|
|
40d297dfe7 | ||
|
|
f19d33ddbc | ||
|
|
20b90b5063 | ||
|
|
8a9e2c830c | ||
|
|
61225e22f0 | ||
|
|
bf25251720 | ||
|
|
f47f06f077 | ||
|
|
0c78a3e0de | ||
|
|
5a1f5008ed | ||
|
|
8219570c15 | ||
|
|
5ce8b512ea | ||
|
|
fc88988f23 | ||
|
|
adacf1cffd | ||
|
|
3e631f467a | ||
|
|
1141dd7af4 | ||
|
|
da3b7a2b3c | ||
|
|
5987a9e9fa | ||
|
|
107f3f537f | ||
|
|
c1b03b9f81 | ||
|
|
ee0ee417c9 | ||
|
|
ebc1078379 | ||
|
|
2861e78272 | ||
|
|
494d598f86 | ||
|
|
c6208f5897 | ||
|
|
8f33cc6094 | ||
|
|
2ec9cf394a | ||
|
|
770e433a9e | ||
|
|
dd1a11f648 | ||
|
|
c6af90553e | ||
|
|
7989d1fcc8 | ||
|
|
611008fa86 | ||
|
|
bf628887f1 | ||
|
|
f288b2e261 | ||
|
|
330dd8472f | ||
|
|
b530f1cf42 | ||
|
|
b63fd83b6c | ||
|
|
8ee551c99a | ||
|
|
148014e709 | ||
|
|
cab7c66b4f | ||
|
|
8d400cfb7f | ||
|
|
f2645c5df8 | ||
|
|
6d6d964f97 | ||
|
|
ab68d58d59 | ||
|
|
c70d79cf3b | ||
|
|
9ac81370fa | ||
|
|
14b1bfdcc4 | ||
|
|
c14a0114d6 | ||
|
|
ee15cc0fe2 | ||
|
|
3438fd4875 | ||
|
|
b27b55ec70 | ||
|
|
49159f3739 | ||
|
|
93cafa8fe9 | ||
|
|
1680a1dc7f | ||
|
|
49daf0e4e0 | ||
|
|
a45fd3bd7c | ||
|
|
1627e96677 | ||
|
|
7e90d36120 | ||
|
|
9e50fdc01f | ||
|
|
2c0b36a967 | ||
|
|
83397dc811 | ||
|
|
640b566412 | ||
|
|
da24673a9f | ||
|
|
bded2585a4 | ||
|
|
5384563c57 | ||
|
|
01a62e2bc0 | ||
|
|
02fdb070ad | ||
|
|
278f4adbd2 | ||
|
|
d00076a7c1 | ||
|
|
4672b8ba2b | ||
|
|
0345908807 | ||
|
|
3b9c8ce2e9 | ||
|
|
e77d6eb5ab | ||
|
|
ac700327a2 | ||
|
|
56e669e2e4 | ||
|
|
17703dd426 | ||
|
|
a1b5a6f6e3 | ||
|
|
a32d5badf7 | ||
|
|
1fd22429c3 | ||
|
|
00ac0a1673 | ||
|
|
b013387a39 | ||
|
|
9d921e0fe7 | ||
|
|
7d1730f348 | ||
|
|
a4fba501a6 | ||
|
|
718fe6486d | ||
|
|
ad9908e32b | ||
|
|
952d6edf92 | ||
|
|
685709bfc7 | ||
|
|
0c92c34ca9 | ||
|
|
0d82634f70 | ||
|
|
4abbdf4e80 | ||
|
|
89789bd848 | ||
|
|
914ca00f89 | ||
|
|
8f6b189dae | ||
|
|
c8034f368a | ||
|
|
69522dd5b7 | ||
|
|
eddc6fd7e1 | ||
|
|
ceab6e8bcc | ||
|
|
2cd58fbc9a | ||
|
|
7ceb3122fc | ||
|
|
c0ab53f986 | ||
|
|
b87c243bbb | ||
|
|
e214cd29aa | ||
|
|
06d72496c2 | ||
|
|
2848d3bd21 | ||
|
|
bd0f630bf4 | ||
|
|
ab9166a6b2 | ||
|
|
62781dc15e | ||
|
|
c90a1c6981 | ||
|
|
3f97ef1288 | ||
|
|
408c9f69a8 | ||
|
|
9370f11e69 | ||
|
|
291435e0b4 | ||
|
|
5df07f114e | ||
|
|
8d901e745d | ||
|
|
990ebc01c2 | ||
|
|
541e9fc3f5 | ||
|
|
9adce9d9f2 | ||
|
|
b6f3b7add9 | ||
|
|
bcad2c9e61 | ||
|
|
e7b23470d5 | ||
|
|
310e7f2a11 | ||
|
|
7f0f63f311 | ||
|
|
acd3a015c8 | ||
|
|
a9869fd6ea | ||
|
|
3e8f91d1a1 | ||
|
|
f3b7c41ad6 | ||
|
|
29fb758e62 | ||
|
|
3bc08136ff | ||
|
|
85eefa06c4 | ||
|
|
c357dd1e6b | ||
|
|
efb46383e0 | ||
|
|
8d564d5e3a | ||
|
|
37c5bcbef4 | ||
|
|
940a4c7a91 | ||
|
|
61bd39800d | ||
|
|
8a96d2eee7 | ||
|
|
e762d58260 | ||
|
|
8fd1701744 | ||
|
|
94765c1597 | ||
|
|
c87881f02c | ||
|
|
25400b6b3c | ||
|
|
e24f62e28c | ||
|
|
db3eea2394 | ||
|
|
04f3686bbe | ||
|
|
0e87b76137 | ||
|
|
fb6fcb0110 | ||
|
|
14b8ceb56f | ||
|
|
a6737fd72b | ||
|
|
96901090bc | ||
|
|
8b2b51e2a5 | ||
|
|
dcce6e1f14 | ||
|
|
cc3d94f81c | ||
|
|
7ee6db679e | ||
|
|
24a617c043 | ||
|
|
93f1c78c5b | ||
|
|
5932d18738 | ||
|
|
5206607816 | ||
|
|
f8f3e1b347 | ||
|
|
4fcfa82d7d | ||
|
|
7a9bd38ecc | ||
|
|
9582bb03a9 | ||
|
|
11bc856cad | ||
|
|
95308ffc23 | ||
|
|
56852fbb50 | ||
|
|
152ba4b941 | ||
|
|
a8138b60fe | ||
|
|
c7bfd4418b | ||
|
|
eb378b2fce | ||
|
|
fd5674f9e5 | ||
|
|
bb2aebaad8 | ||
|
|
2539826a99 | ||
|
|
1eb3c947c3 | ||
|
|
9d03b030a6 | ||
|
|
78f83ca02d | ||
|
|
e8a041d783 | ||
|
|
c631850c15 | ||
|
|
9539ca5fa3 | ||
|
|
0f4bdfad99 | ||
|
|
e3a5ae4aca | ||
|
|
30b411ad56 | ||
|
|
941670671c | ||
|
|
be5012ef69 | ||
|
|
9824a63101 | ||
|
|
5f6e6072d9 | ||
|
|
a80688012e | ||
|
|
aad89bb0ab | ||
|
|
ab0b386ac4 | ||
|
|
5cffc8815a | ||
|
|
27c0a166f3 | ||
|
|
08fae276b4 | ||
|
|
0f697f1819 | ||
|
|
b203467419 | ||
|
|
41d5f63ec5 | ||
|
|
3de3f2f46c | ||
|
|
95128a1cf3 | ||
|
|
3848a7c63c | ||
|
|
d9633314f8 | ||
|
|
576c24f97e | ||
|
|
970a6a1151 | ||
|
|
76e2d2052c | ||
|
|
03a7300081 | ||
|
|
ccb341a5e3 | ||
|
|
421e49450f | ||
|
|
886860a123 | ||
|
|
9a454d3ba9 | ||
|
|
1a466282da | ||
|
|
545194e7aa | ||
|
|
e2d3c20bd3 | ||
|
|
48e70c8b31 | ||
|
|
b518bfe9be | ||
|
|
e633580eff | ||
|
|
df9ea79df4 | ||
|
|
eacf41c980 | ||
|
|
f8fbd04007 | ||
|
|
01956cfecc | ||
|
|
380c065a0c | ||
|
|
6c548b5d43 | ||
|
|
11c70243db | ||
|
|
415ad05c98 | ||
|
|
2d0314212b | ||
|
|
feffc60cbf | ||
|
|
d3ded4a251 | ||
|
|
62b96a65b5 | ||
|
|
450038ea73 | ||
|
|
ce045e2ae9 | ||
|
|
f753e86e7a | ||
|
|
a1cf9e4183 | ||
|
|
e8492d1a78 | ||
|
|
11355321a0 | ||
|
|
3532ede709 | ||
|
|
8f1d565faa | ||
|
|
f00f52d154 | ||
|
|
dc24cde377 | ||
|
|
2c5c6dc7d4 | ||
|
|
3fc438428a | ||
|
|
5409227cf8 | ||
|
|
e36545ac1c | ||
|
|
41a65b94c8 | ||
|
|
89a84131fb | ||
|
|
bb121fe02b | ||
|
|
e228ad9389 | ||
|
|
1e0c660f22 | ||
|
|
e52cdee6c4 | ||
|
|
9045dd3a1a | ||
|
|
3e7bb5f2e8 | ||
|
|
88e5f4a395 | ||
|
|
5c9e573ece | ||
|
|
c08a2f31ff | ||
|
|
6fe4a6bab8 | ||
|
|
66631e4f96 | ||
|
|
7e1a257265 | ||
|
|
d9efeae3bb | ||
|
|
9c4287fc51 | ||
|
|
8d06d246b3 | ||
|
|
1292881b37 | ||
|
|
a55d6682d2 | ||
|
|
f9dd4323af | ||
|
|
fcd39008ec | ||
|
|
01b7ee41f6 | ||
|
|
25b33d2d04 | ||
|
|
bfd956bc5e | ||
|
|
0f5821a8c8 | ||
|
|
c1301d000a | ||
|
|
7f5859dda9 | ||
|
|
abb97e1dfb | ||
|
|
22bedd5cf0 | ||
|
|
d54d4d7419 | ||
|
|
03719b7623 | ||
|
|
11fc617794 | ||
|
|
7d7e0777a5 | ||
|
|
a60b4a984e | ||
|
|
7b0068a433 | ||
|
|
2ad2272e3d | ||
|
|
cbfab74480 | ||
|
|
00999c1789 | ||
|
|
090f957854 | ||
|
|
ea694a4b0d | ||
|
|
281daef279 | ||
|
|
23928df4ff | ||
|
|
8d2e39c395 | ||
|
|
1bb070deba | ||
|
|
07e5fc5473 | ||
|
|
de204853cf | ||
|
|
3f0693b37e | ||
|
|
4fc7cdb95c | ||
|
|
ba77e8d23b | ||
|
|
10e9b975c4 | ||
|
|
8b5c84cd22 | ||
|
|
6929eea2ed | ||
|
|
cd485da765 | ||
|
|
223e658beb | ||
|
|
c9794ff283 | ||
|
|
035dcfd357 | ||
|
|
37922e6429 | ||
|
|
05d2f991de | ||
|
|
b6f3065605 | ||
|
|
461fc3c649 | ||
|
|
b1837c0e4e | ||
|
|
7fde420160 | ||
|
|
0d161038a2 | ||
|
|
ee8ff3cf5b | ||
|
|
7568673fa6 | ||
|
|
4543e7bbab | ||
|
|
a3be0d3cd8 | ||
|
|
89f2e5c0c3 | ||
|
|
f93a9ab81c | ||
|
|
fb1eaa8323 | ||
|
|
2f826e305a | ||
|
|
9bebdf7ef4 | ||
|
|
6fd8228242 | ||
|
|
76210c84f7 | ||
|
|
62d32b38d7 | ||
|
|
dd73281bc6 | ||
|
|
df5ff58ca4 | ||
|
|
c7fe3b2f4c | ||
|
|
cd51392c0f | ||
|
|
0eaf6d4198 | ||
|
|
551f0dbebe | ||
|
|
29bde74c86 | ||
|
|
a60926da2c | ||
|
|
039e445f93 | ||
|
|
3fd2fbce00 | ||
|
|
b284c28ce5 | ||
|
|
74107d2da1 | ||
|
|
12d096790b | ||
|
|
5fab4d73f5 | ||
|
|
8a2c175abc | ||
|
|
0dc8ecc1f6 | ||
|
|
a14d734664 | ||
|
|
56ad17f97c | ||
|
|
7013a0b70a | ||
|
|
a461e61485 | ||
|
|
769a225af3 | ||
|
|
53a02af443 | ||
|
|
9b70771583 | ||
|
|
7ce058b479 | ||
|
|
8663c8bf19 | ||
|
|
2dfdd55e29 | ||
|
|
c52cfc339f | ||
|
|
bcf4a0dd31 | ||
|
|
9efe753a74 | ||
|
|
2dee482699 | ||
|
|
29a2098575 | ||
|
|
a0774d28f1 | ||
|
|
190d0cbaa7 | ||
|
|
e53fcad712 | ||
|
|
d06e42bf06 | ||
|
|
fd2c269ce3 | ||
|
|
a1cd67ca87 | ||
|
|
9a207a910a | ||
|
|
2a4d019282 | ||
|
|
8e03cbfcf9 | ||
|
|
9d8f61431e | ||
|
|
ff264a798f | ||
|
|
274836a1a2 | ||
|
|
c15a0c4bbf | ||
|
|
912f37963a | ||
|
|
82bcada84c | ||
|
|
22424227e7 | ||
|
|
9c688d7ff7 | ||
|
|
5f97d7d0df | ||
|
|
3559ca4d08 | ||
|
|
cd3bc1fa8e | ||
|
|
42ff742bf5 | ||
|
|
8ccb13c6f0 | ||
|
|
e8568c4173 | ||
|
|
b5c84e6996 | ||
|
|
c46754b877 | ||
|
|
03309a2d42 | ||
|
|
5688ee0013 | ||
|
|
8004ad59ab | ||
|
|
e612904184 | ||
|
|
81cf058e30 | ||
|
|
26665bf33b | ||
|
|
00bb9bc367 | ||
|
|
e4789153d5 | ||
|
|
1c2efac7c8 | ||
|
|
3d553b2ea1 | ||
|
|
9316529638 | ||
|
|
2b689228b7 | ||
|
|
81992093d2 | ||
|
|
b312abaa07 | ||
|
|
8f21b899b6 | ||
|
|
0cbe5f2d82 | ||
|
|
805e60bdfc | ||
|
|
9d4c014f60 | ||
|
|
bf8c6dd043 | ||
|
|
2e41896e1b | ||
|
|
11de19f00c | ||
|
|
471dd47f84 | ||
|
|
0563025cde | ||
|
|
3a05f29b94 | ||
|
|
e64c65a0d3 | ||
|
|
af0e1af181 | ||
|
|
01789304f0 |
49
.clang-format
Normal file
49
.clang-format
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveDeclarations: Consecutive
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: AlignAfterOperator
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterExternBlock: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
IndentBraces: false
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakBeforeConceptDeclarations: true
|
||||||
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakInheritanceList: BeforeComma
|
||||||
|
ColumnLimit: 120
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<.*>'
|
||||||
|
Priority: 1
|
||||||
|
- Regex: '^".*"'
|
||||||
|
Priority: 2
|
||||||
|
SortIncludes: true
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IndentWidth: 4
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
PointerAlignment: Right
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
Standard: c++17
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
build
|
||||||
|
build-*/
|
||||||
|
test-results*/
|
||||||
|
.vs
|
||||||
|
.vscode
|
||||||
|
.clangd
|
||||||
|
test
|
||||||
|
settings.json
|
||||||
|
launch.json
|
||||||
|
__pycache__/
|
||||||
|
*.py[co]
|
||||||
|
.pytest_cache/
|
||||||
116
.pre-commit-config.yaml
Normal file
116
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
# Copyright (c) 2024, NVIDIA CORPORATION.
|
||||||
|
ci:
|
||||||
|
autofix_commit_msg: |
|
||||||
|
[pre-commit.ci] auto code formatting
|
||||||
|
autofix_prs: false
|
||||||
|
autoupdate_branch: ''
|
||||||
|
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
|
||||||
|
autoupdate_schedule: quarterly
|
||||||
|
skip: []
|
||||||
|
submodules: false
|
||||||
|
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v5.0.0
|
||||||
|
hooks:
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
exclude: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.raw$|
|
||||||
|
.*\.bin$|
|
||||||
|
.*\.dat$|
|
||||||
|
.*\.nv12$|
|
||||||
|
data/.*|
|
||||||
|
Common/.*
|
||||||
|
)
|
||||||
|
files: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.txt$|
|
||||||
|
.*\.md$|
|
||||||
|
.*\.cpp$|
|
||||||
|
.*\.cxx$|
|
||||||
|
.*\.hpp$|
|
||||||
|
.*\.h$|
|
||||||
|
.*\.cu$|
|
||||||
|
.*\.cuh$|
|
||||||
|
.*\.py$|
|
||||||
|
.*\.json$
|
||||||
|
)
|
||||||
|
- id: mixed-line-ending
|
||||||
|
exclude: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.raw$|
|
||||||
|
.*\.bin$|
|
||||||
|
.*\.dat$|
|
||||||
|
.*\.nv12$|
|
||||||
|
data/.*|
|
||||||
|
Common/.*
|
||||||
|
)
|
||||||
|
files: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.txt$|
|
||||||
|
.*\.md$|
|
||||||
|
.*\.cpp$|
|
||||||
|
.*\.cxx$|
|
||||||
|
.*\.hpp$|
|
||||||
|
.*\.h$|
|
||||||
|
.*\.cu$|
|
||||||
|
.*\.cuh$|
|
||||||
|
.*\.py$|
|
||||||
|
.*\.json$
|
||||||
|
)
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.raw$|
|
||||||
|
.*\.bin$|
|
||||||
|
.*\.dat$|
|
||||||
|
.*\.nv12$|
|
||||||
|
data/.*|
|
||||||
|
Common/.*
|
||||||
|
)
|
||||||
|
files: |
|
||||||
|
(?x)^(
|
||||||
|
.*\.txt$|
|
||||||
|
.*\.md$|
|
||||||
|
.*\.cpp$|
|
||||||
|
.*\.cxx$|
|
||||||
|
.*\.hpp$|
|
||||||
|
.*\.h$|
|
||||||
|
.*\.cu$|
|
||||||
|
.*\.cuh$|
|
||||||
|
.*\.py$|
|
||||||
|
.*\.json$
|
||||||
|
)
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: v19.1.6
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
types_or: [file]
|
||||||
|
files: |
|
||||||
|
(?x)^(
|
||||||
|
^.*\.c$|
|
||||||
|
^.*\.cpp$|
|
||||||
|
^.*\.cu$|
|
||||||
|
^.*\.cuh$|
|
||||||
|
^.*\.cxx$|
|
||||||
|
^.*\.h$|
|
||||||
|
^.*\.hpp$|
|
||||||
|
^.*\.inl$|
|
||||||
|
^.*\.mm$
|
||||||
|
)
|
||||||
|
exclude: |
|
||||||
|
(?x)^(
|
||||||
|
Common/.*
|
||||||
|
)
|
||||||
|
args: ["-fallback-style=none", "-style=file", "-i"]
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.8.4
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
name: ruff lint
|
||||||
|
args: [--fix]
|
||||||
|
files: ^python/.*\.py$
|
||||||
|
- id: ruff-format
|
||||||
|
name: ruff format
|
||||||
|
files: ^python/.*\.py$
|
||||||
324
CHANGELOG.md
Normal file
324
CHANGELOG.md
Normal file
@@ -0,0 +1,324 @@
|
|||||||
|
## Changelog
|
||||||
|
|
||||||
|
### CUDA 13.4
|
||||||
|
* Removed obsolete samples `simpleHyperQ`, `simpleOccupancy`, `mergeSort`, `simpleTemplates`, `template`, `p2pBandwidthLatencyTest`.
|
||||||
|
* Removed redundant `_nvrtc` sample variants (`clock_nvrtc`, `matrixMul_nvrtc`, `simpleAssert_nvrtc`, `simpleAtomicIntrinsics_nvrtc`, `inlinePTX_nvrtc`, `binomialOptions_nvrtc`, `BlackScholes_nvrtc`, `quasirandomGenerator_nvrtc`); `vectorAdd_nvrtc` remains as the canonical NVRTC example.
|
||||||
|
* Rewrote `cpp/0_Introduction/simpleMultiGPU` to replace the hand-written reduction with `cub::BlockReduce` and the SDK stopwatch timer with CUDA events, removed helper header dependencies and merged `simpleMultiGPU.h` into the `.cu` for a single-file sample, modernized the code to C++17 (`std::vector`, `constexpr`), and added a minimum two-GPU check; updated README accordingly.
|
||||||
|
* Modernized `cpp/3_CUDA_Features/simpleCudaGraphs`: dropped `helper_cuda.h`/`cooperative_groups.h`; used `cub::BlockReduce`; migrated to the unified `cudaGraphAddNode` API; split into `simpleCudaGraphs_explicit` and `simpleCudaGraphs_capture` sharing `simpleCudaGraphs.cuh`; added a graph-reuse demo (fresh input each launch); rewrote README.
|
||||||
|
* Rewrote `cpp/0_Introduction/simpleAtomicIntrinsics` to show race conditions by comparing non-atomic vs atomic kernels (`atomicAdd`, `atomicMax`, `atomicCAS`), removed helper header dependencies; updated README accordingly.
|
||||||
|
* Reorganized CMake build system for all C++ samples: centralized GPU architecture detection (`DetectCudaArch.cmake`) and common build setup (`CudaSampleCommon.cmake`) into shared modules. Samples with restricted arch support now declare a `SAMPLE_DISALLOW_ARCHS` list instead of hardcoding their own arch list, and are gracefully skipped at configure time when the requested arch is unsupported.
|
||||||
|
* Added `sm_103` to the default set of GPU architectures the C++ samples build for.
|
||||||
|
* Added `sm_107` to the default set of GPU architectures the C++ samples build for.
|
||||||
|
* Rewrote `cpp/0_Introduction/simpleCallback` to replace the deprecated `cudaStreamAddCallback` with `cudaLaunchHostFunc`, replaced the `multithreading.h/.cpp` helpers with standard C++ `std::thread`, and simplified to a single-GPU, single-workload C++17 example; updated README accordingly.
|
||||||
|
* Rewrote `cpp/0_Introduction/simpleStreams` to simplify code and remove helper header dependencies; updated README accordingly.
|
||||||
|
* Added `python/2_CoreConcepts/persistentProgramCache` to demonstrate persisting and reusing compiled CUDA artifacts with `cuda.core` and `FileStreamProgramCache`.
|
||||||
|
* Updated `cpp/0_Introduction/clock` to replace the manual shared-memory tree reduction with `cub::BlockReduce` min-reduction, removed dependency on `helper_cuda.h` and `helper_functions.h`, and updated README.
|
||||||
|
* Rewrote `cpp/0_Introduction/vectorAdd` to match the corresponding example in the CUDA Programming Guide. The sample now uses Unified Memory (`cudaMallocManaged`) instead of explicit `cudaMalloc`/`cudaMemcpy`.
|
||||||
|
* Restructured the `cpp/0_Introduction/simplePrintf` README with newer style and updated sample code by removing helper dependency.
|
||||||
|
* Updated the `cpp/0_Introduction/simpleAssert` README to newer style, simplified code for better understanding.
|
||||||
|
* Added `cpp/3_CUDA_Features/dmabufInterop` - a Linux-only CUDA dma-buf interoperability sample demonstrating three scenarios in a single binary: (1) same-process round-trip export/import, (2) cross-process IPC via `fork()` + `SCM_RIGHTS`, and (3) cross-GPU sharing across processes (self-skips on systems without a qualifying GPU pair).
|
||||||
|
* Removed the unnecessary `set(CMAKE_POSITION_INDEPENDENT_CODE ON)` from the C++ sample `CMakeLists.txt` files.
|
||||||
|
* Removed `CUDA_SEPARABLE_COMPILATION ON` from C++ samples that don't require relocatable device code (kept for the CDP samples).
|
||||||
|
* Removed 26 math library samples from `cpp/4_CUDA_Libraries/` that are maintained in the [CUDA Library Samples](https://github.com/NVIDIA/CUDALibrarySamples) repository: cuBLAS (`simpleCUBLAS`, `simpleCUBLAS_LU`, `simpleCUBLASXT`, `matrixMulCUBLAS`, `batchCUBLAS`), cuFFT (`simpleCUFFT`, `simpleCUFFT_MGPU`, `simpleCUFFT_2d_MGPU`, `simpleCUFFT_callback`), cuRAND (`MersenneTwisterGP11213`), cuSOLVER (`cuSolverDn_LinearSolver`, `cuSolverRf`, `cuSolverSp_LinearSolver`, `cuSolverSp_LowlevelCholesky`, `cuSolverSp_LowlevelQR`), cuSPARSE (`conjugateGradient`, `conjugateGradientPrecond`, `conjugateGradientUM`), NPP (`boxFilterNPP`, `cannyEdgeDetectorNPP`, `FilterBorderControlNPP`, `freeImageInteropNPP`, `histEqualizationNPP`, `watershedSegmentationNPP`), and nvJPEG (`nvJPEG`, `nvJPEG_encoder`).
|
||||||
|
* Lifted the LLVM 14 upper bound on `cpp/7_libNVVM/cuda-c-linking`, which now builds against LLVM 15 and newer.
|
||||||
|
* Added samples for locality domains in `cpp/3_CUDA_FEATURES/localityDomains` and `cpp/3_CUDA_FEATURES/localityDomainsDrv`.
|
||||||
|
* Added Windows on Arm support: `cpp/5_Domain_Specific/marchingCubes` now detects the `glew32` GLEW library name used on Windows on Arm, and `cpp/7_libNVVM` searches the `nvvm/lib/arm64` directory for libNVVM.
|
||||||
|
|
||||||
|
### CUDA 13.3
|
||||||
|
* Added **CUDA Tile C++** samples under `cpp/9_CUDA_Tile`.
|
||||||
|
* Added a set of **CCCL 3.3 feature samples** under `cpp/4_CUDA_Libraries/`, each built against CCCL fetched via CPM (pinned to v3.3.3, with an optional `CCCL_SOURCE_DIR` override):
|
||||||
|
* `cubDeviceFind` - `cub::DeviceFind::FindIf`, `LowerBound`, and `UpperBound` device-wide search algorithms.
|
||||||
|
* `cubDeviceSegmentedScan` - `cub::DeviceSegmentedScan::ExclusiveSegmentedSum` and `InclusiveSegmentedScan` with a custom binary operator.
|
||||||
|
* `cubDeviceTransform` - N-to-M `cub::DeviceTransform::Transform` where the op returns a `cuda::std::tuple`.
|
||||||
|
* `libcuxxRandom` - `cuda::pcg64` and `cuda::std::philox4x32` engines driving the uniform, normal, Poisson, and Bernoulli distributions from `<cuda/std/random>`.
|
||||||
|
* `libcuxxMdspan` - DLPack <-> `cuda::std::mdspan` bridging via `cuda::to_device_mdspan` / `cuda::to_dlpack_tensor`, plus `cuda::shared_memory_mdspan` for multi-dimensional views of shared memory.
|
||||||
|
* Added **cuda.compute 1.0 Python samples** under `python/2_CoreConcepts/`:
|
||||||
|
* `cudaComputeLambdas` - Python lambdas / regular callables driving `reduce_into`, `unary_transform`, and `inclusive_scan` in `cuda.compute` (from the `cuda-cccl` package).
|
||||||
|
* `binarySearch` - parallel `cuda.compute.upper_bound` / `lower_bound`, verified against `numpy.searchsorted`.
|
||||||
|
|
||||||
|
|
||||||
|
### CUDA 13.2 (update)
|
||||||
|
* Added **CUDA Python samples** under `python/`. These scripts use [CUDA Python](https://nvidia.github.io/cuda-python/) (including `cuda.core`) and are organized like the C++ tree: `1_GettingStarted`, `2_CoreConcepts`, `3_FrameworkInterop`, and `4_DistributedComputing`, plus shared helpers in `python/Utilities`. Each sample includes a `README.md` and `requirements.txt`. They are **not** built by the root CMake project; install dependencies with `pip install -r requirements.txt` in the sample directory, then run the corresponding `.py` file as documented in that sample’s README.
|
||||||
|
* Renamed top-level `Samples` directory to `cpp` to accommodate Python samples alongside existing C++ samples; updated path references in `CMakeLists.txt`, `README.md`, and `Common` headers accordingly.
|
||||||
|
|
||||||
|
### CUDA 13.2
|
||||||
|
* Added the MSVC compile flag `-Xcompiler=/Zc:preprocessor` in CMakeLists.txt to comply with CUDA13.2 CCCL. Previously, using the traditional preprocessor triggered the warning “MSVC/cl.exe with traditional preprocessor is used…”, which now leads to a build error.
|
||||||
|
|
||||||
|
### CUDA 13.1
|
||||||
|
* Minor bug fixes and enhancements, no structural or functional changes
|
||||||
|
|
||||||
|
### CUDA 13.0
|
||||||
|
* Updated the samples using the cudaDeviceProp fields which are deprecated and removed in CUDA 13.0, replacing the fields with the equivalents in "cudaDeviceGetAttribute":
|
||||||
|
* Deprecated "cudaDeviceProp" fields
|
||||||
|
`int clockRate; // - Replaced with "cudaDevAttrClockRate"`
|
||||||
|
`int deviceOverlap; // - Replaced with "cudaDevAttrGpuOverlap */`
|
||||||
|
`int kernelExecTimeoutEnabled; // - Replaced with "cudaDevAttrKernelExecTimeout`
|
||||||
|
`int computeMode; // - Replaced with "cudaDevAttrComputeMode" */`
|
||||||
|
`int memoryClockRate; // - Replaced with "cudaDevAttrMemoryClockRate"`
|
||||||
|
`int cooperativeMultiDeviceLaunch; // - Deprecated, cudaLaunchCooperativeKernelMultiDevice is deprecated.`
|
||||||
|
* `0_Introduction`
|
||||||
|
* `UnifiedMemoryStreams`
|
||||||
|
* `simpleHyperQ`
|
||||||
|
* `simpleIPC`
|
||||||
|
* `simpleMultiCopy`
|
||||||
|
* `systemWideAtomics`
|
||||||
|
* `1_Utilitie`
|
||||||
|
* `deviceQuery`
|
||||||
|
* `2_Concepts_and_Techniques`
|
||||||
|
* `streamOrderedAllocationIPC`
|
||||||
|
* `4_CUDA_Libraries`
|
||||||
|
* `simpleCUBLASXT`
|
||||||
|
* `5_Domain_Specific`
|
||||||
|
* `simpleVulkan`
|
||||||
|
* `vulkanImageCUDA`
|
||||||
|
* Updated the samples using the CUDA driver API "cuCtxCreate" with adding the parameter "CUctxCreateParams" as "cuCtxCreate" is updated to "cuCtxCreate_v4" by default in CUDA 13.0:
|
||||||
|
* `Common`
|
||||||
|
* `nvrtc_helper.h`
|
||||||
|
* `0_Introduction`
|
||||||
|
* `UnifiedMemoryStreams`
|
||||||
|
* `matrixMulDrv`
|
||||||
|
* `simpleTextureDrv`
|
||||||
|
* `vectorAddDrv`
|
||||||
|
* `vectorAddMMAP`
|
||||||
|
* `2_Concepts_and_Techniques`
|
||||||
|
* `EGLStream_CUDA_CrossGPU`
|
||||||
|
* `EGLStream_CUDA_Interop`
|
||||||
|
* `threadMigration`
|
||||||
|
* `3_CUDA_Features`
|
||||||
|
* `graphMemoryFootprint`
|
||||||
|
* `memMapIPCDrv`
|
||||||
|
* `4_CUDA_Libraries`
|
||||||
|
* `jitLto`
|
||||||
|
* `7_libNVVM`
|
||||||
|
* `cuda-c-linking`
|
||||||
|
* `device-side-launch`
|
||||||
|
* `simple`
|
||||||
|
* `uvmlite`
|
||||||
|
* `8_Platform_Specific/Tegra`
|
||||||
|
* `EGLSync_CUDAEvent_Interop`
|
||||||
|
* Updated the sample using CUDA API "cudaGraphAddNode"/"cudaStreamGetCaptureInfo" with adding "cudaGraphEdgeData" pointer parameter as they are updated to "cudaGraphAddNode_v2"/"cudaStreamGetCaptureInfo_v3" by default in CUDA 13.0:
|
||||||
|
* `3_CUDA_Features`
|
||||||
|
* `graphConditionalNodes`
|
||||||
|
* Updated the samples using CUDA API "cudaMemAdvise"/"cudaMemPrefetchAsync" with changing the parameter "int device" to "cudaMemLocation location" as they are updated to "cudaMemAdvise_v2"/"cudaMemPrefetchAsyn_v2" by default in CUDA 13.0.
|
||||||
|
* `4_CUDA_Libraries`
|
||||||
|
* `conjugateGradientMultiDeviceCG`
|
||||||
|
* `6_Performance`
|
||||||
|
* `UnifiedMemoryPerf`
|
||||||
|
* Replaced "thrust::identity<uint>()" with "cuda::std::identity()" as it is deprecated in CUDA 13.0.
|
||||||
|
* `2_Concepts_and_Techniques`
|
||||||
|
* `segmentationTreeThrust`
|
||||||
|
* Updated the the headers file and samples for CUFFT error codes update.
|
||||||
|
* Deprecated CUFFT errors:
|
||||||
|
* `CUFFT_INCOMPLETE_PARAMETER_LIST`
|
||||||
|
* `CUFFT_PARSE_ERROR`
|
||||||
|
* `CUFFT_LICENSE_ERROR`
|
||||||
|
* New added CUFFT errors:
|
||||||
|
* `CUFFT_MISSING_DEPENDENCY`
|
||||||
|
* `CUFFT_NVRTC_FAILURE`
|
||||||
|
* `CUFFT_NVJITLINK_FAILURE`
|
||||||
|
* `CUFFT_NVSHMEM_FAILURE`
|
||||||
|
* Header files and samples that are related with this change:
|
||||||
|
* `Common/helper_cuda.h`
|
||||||
|
* `4_CUDA_Libraries`
|
||||||
|
* `simpleCUFFT`
|
||||||
|
* `simpleCUFFT_2d_MGPU`
|
||||||
|
* `simpleCUFFT_MGPU`
|
||||||
|
* `simpleCUFFT_callback`
|
||||||
|
* Updated toolchain for cross-compilation for Tegra QNX platforms.
|
||||||
|
|
||||||
|
### CUDA 12.9
|
||||||
|
* Updated toolchain for cross-compilation for Tegra Linux platforms.
|
||||||
|
* Added `run_tests.py` utility to exercise all samples. See README.md for details
|
||||||
|
* Repository has been updated with consistent code formatting across all samples
|
||||||
|
* Many small code tweaks and bug fixes (see commit history for details)
|
||||||
|
* Removed the following outdated samples:
|
||||||
|
* `1_Utilities`
|
||||||
|
* `bandwidthTest` - this sample was out of date and did not produce accurate results. For bandwidth
|
||||||
|
testing of NVIDIA GPU platforms, please refer to [NVBandwidth](https://github.com/NVIDIA/nvbandwidth)
|
||||||
|
|
||||||
|
### CUDA 12.8
|
||||||
|
* Updated build system across the repository to CMake. Removed Visual Studio project files and Makefiles.
|
||||||
|
* Removed the following outdated samples:
|
||||||
|
* `0_Introduction`
|
||||||
|
* `c++11_cuda` demonstrating CUDA and C++ 11 interoperability (reason: obsolete)
|
||||||
|
* `concurrentKernels` demonstrating the ability to run multiple kernels simultaneously (reason: obsolete)
|
||||||
|
* `cppIntegration` demonstrating calling between .cu and .cpp files (reason: obsolete)
|
||||||
|
* `cppOverload` demonstrating C++ function overloading (reason: obsolete)
|
||||||
|
* `simpleSeparateCompilation` demonstrating NVCC compilation to a static library (reason: trivial)
|
||||||
|
* `simpleTemplates_nvrtc` demonstrating NVRTC usage for `simpleTemplates` sample (reason: redundant)
|
||||||
|
* `simpleVoteIntrinsics_nvrtc` demonstrating NVRTC usage for `simpleVoteIntrinsics` sample (reason: redundant)
|
||||||
|
* `2_Concepts_and_Techniques`
|
||||||
|
* `cuHook` demonstrating dlsym hooks. (reason: incompatible with modern `glibc`)
|
||||||
|
* `4_CUDA_Libraries`
|
||||||
|
* `batchedLabelMarkersAndLabelCompressionNPP` demonstrating NPP features (reason: some functionality removed from library)
|
||||||
|
* `5_Domain_Specific`
|
||||||
|
* Legacy Direct3D 9 and 10 interoperability samples:
|
||||||
|
* `fluidsD3D9`
|
||||||
|
* `simpleD3D10`
|
||||||
|
* `simpleD3D10RenderTarget`
|
||||||
|
* `simpleD3D10Texture`
|
||||||
|
* `simpleD3D9`
|
||||||
|
* `simpleD3D9Texture`
|
||||||
|
* `SLID3D10Texture`
|
||||||
|
* `VFlockingD3D10`
|
||||||
|
* `8_Platform_Specific/Tegra`
|
||||||
|
* Temporarily removed the following two samples pending updates:
|
||||||
|
* `nbody_screen` demonstrating the nbody sample in QNX
|
||||||
|
* `simpleGLES_screen` demonstrating GLES interop in QNX
|
||||||
|
* Moved the following Tegra-specific samples to a dedicated subdirectory: `8_Platform_Specific/Tegra`
|
||||||
|
* `EGLSync_CUDAEvent_Interop`
|
||||||
|
* `cuDLAErrorReporting`
|
||||||
|
* `cuDLAHybridMode`
|
||||||
|
* `cuDLALayerwiseStatsHybrid`
|
||||||
|
* `cuDLALayerwiseStatsStandalone`
|
||||||
|
* `cuDLAStandaloneMode`
|
||||||
|
* `cudaNvSciBufMultiplanar`
|
||||||
|
* `cudaNvSciNvMedia`
|
||||||
|
* `fluidsGLES`
|
||||||
|
* `nbody_opengles`
|
||||||
|
* `simpleGLES`
|
||||||
|
* `simpleGLES_EGLOutput`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### CUDA 12.5
|
||||||
|
|
||||||
|
### CUDA 12.4
|
||||||
|
* Added graphConditionalNodes Sample
|
||||||
|
|
||||||
|
### CUDA 12.3
|
||||||
|
* Added cuDLA samples
|
||||||
|
* Fixed jitLto regression
|
||||||
|
|
||||||
|
### CUDA 12.2
|
||||||
|
* libNVVM samples received updates
|
||||||
|
* Fixed jitLto Case issues
|
||||||
|
* Enabled HOST_COMPILER flag to the makefiles for GCC which is untested but may still work.
|
||||||
|
|
||||||
|
### CUDA 12.1
|
||||||
|
* Added new sample for Large Kernels
|
||||||
|
|
||||||
|
### CUDA 12.0
|
||||||
|
* Added new flags for JIT compiling
|
||||||
|
* Removed deprecated APIs in Hopper Architecture
|
||||||
|
|
||||||
|
### CUDA 11.6
|
||||||
|
* Added new folder structure for samples
|
||||||
|
* Added support of Visual Studio 2022 to all samples supported on [Windows](#windows-1).
|
||||||
|
* All CUDA samples are now only available on [GitHub](https://github.com/nvidia/cuda-samples). They are no longer available via CUDA toolkit.
|
||||||
|
|
||||||
|
### CUDA 11.5
|
||||||
|
* Added `cuDLAHybridMode`. Demonstrate usage of cuDLA in hybrid mode.
|
||||||
|
* Added `cuDLAStandaloneMode`. Demonstrate usage of cuDLA in standalone mode.
|
||||||
|
* Added `cuDLAErrorReporting`. Demonstrate DLA error detection via CUDA.
|
||||||
|
* Added `graphMemoryNodes`. Demonstrates memory allocations and frees within CUDA graphs using Graph APIs and Stream Capture APIs.
|
||||||
|
* Added `graphMemoryFootprint`. Demonstrates how graph memory nodes re-use virtual addresses and physical memory.
|
||||||
|
* All samples from CUDA toolkit are now available on [GitHub](https://github.com/nvidia/cuda-samples).
|
||||||
|
|
||||||
|
### CUDA 11.4 update 1
|
||||||
|
* Added support for VS Code on linux platform.
|
||||||
|
|
||||||
|
### CUDA 11.4
|
||||||
|
* Added `cdpQuadtree`. Demonstrates Quad Trees implementation using CUDA Dynamic Parallelism.
|
||||||
|
* Updated `simpleVulkan`, `simpleVulkanMMAP` and `vulkanImageCUDA`. Demonstrates use of SPIR-V shaders.
|
||||||
|
|
||||||
|
### CUDA 11.3
|
||||||
|
* Added `streamOrderedAllocationIPC`. Demonstrates Inter Process Communication using one process per GPU for computation.
|
||||||
|
* Added `simpleCUBLAS_LU`. Demonstrates batched matrix LU decomposition using cuBLAS API `cublas<t>getrfBatched()`
|
||||||
|
* Updated `simpleVulkan`. Demonstrates use of timeline semaphore.
|
||||||
|
* Updated multiple samples to use pinned memory using `cudaMallocHost()`.
|
||||||
|
|
||||||
|
### CUDA 11.2
|
||||||
|
* Added `streamOrderedAllocation`. Demonstrates stream ordered memory allocation on a GPU using cudaMallocAsync and cudaMemPool family of APIs.
|
||||||
|
* Added `streamOrderedAllocationP2P`. Demonstrates peer-to-peer access of stream ordered memory allocated using cudaMallocAsync and cudaMemPool family of APIs.
|
||||||
|
* Dropped Visual Studio 2015 support from all the windows supported samples.
|
||||||
|
* FreeImage is no longer distributed with the CUDA Samples. On Windows, see the [Dependencies](./README.md#freeimage) section for more details on how to set up FreeImage. On Linux, it is recommended to install FreeImage with your distribution's package manager.
|
||||||
|
* All the samples using CUDA Pipeline & Arrive-wait barriers are been updated to use new `cuda::pipeline` and `cuda::barrier` interfaces.
|
||||||
|
* Updated all the samples to build with parallel build option `--threads` of `nvcc` cuda compiler.
|
||||||
|
* Added `cudaNvSciNvMedia`. Demonstrates CUDA-NvMedia interop via NvSciBuf/NvSciSync APIs.
|
||||||
|
* Added `simpleGL`. Demonstrates interoperability between CUDA and OpenGL.
|
||||||
|
|
||||||
|
### CUDA 11.1
|
||||||
|
* Added `watershedSegmentationNPP`. Demonstrates how to use the NPP watershed segmentation function.
|
||||||
|
* Added `batchedLabelMarkersAndLabelCompressionNPP`. Demonstrates how to use the NPP label markers generation and label compression functions based on a Union Find (UF) algorithm including both single image and batched image versions.
|
||||||
|
* Dropped Visual Studio 2012, 2013 support from all the windows supported samples.
|
||||||
|
* Added kernel performing warp aggregated atomic max in multi buckets using cg::labeled_partition & cg::reduce in `warpAggregatedAtomicsCG`.
|
||||||
|
* Added extended CG shuffle mechanics to `shfl_scan` sample.
|
||||||
|
* Added `cudaOpenMP`. Demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
||||||
|
* Added `simpleZeroCopy`. Demonstrates how to use zero copy, kernels can read and write directly to pinned system memory.
|
||||||
|
|
||||||
|
### CUDA 11.0
|
||||||
|
* Added `dmmaTensorCoreGemm`. Demonstrates double precision GEMM computation using the Double precision Warp Matrix Multiply and Accumulate (WMMA) API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `bf16TensorCoreGemm`. Demonstrates __nv_bfloat16 (e8m7) GEMM computation using the __nv_bfloat16 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `tf32TensorCoreGemm`. Demonstrates tf32 (e8m10) GEMM computation using the tf32 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
||||||
|
* Added `globalToShmemAsyncCopy`. Demonstrates async copy of data from global to shared memory when on compute capability 8.0 or higher. Also demonstrates arrive-wait barrier for synchronization.
|
||||||
|
* Added `simpleAWBarrier`. Demonstrates arrive wait barriers.
|
||||||
|
* Added `simpleAttributes`. Demonstrates the stream attributes that affect L2 locality.
|
||||||
|
* Added warp aggregated atomic multi bucket increments kernel using labeled_partition cooperative groups in `warpAggregatedAtomicsCG` which can be used on compute capability 7.0 and above GPU architectures.
|
||||||
|
* Added `binaryPartitionCG`. Demonstrates binary partition cooperative groups and reduction within the thread block.
|
||||||
|
* Added two new reduction kernels in `reduction` one which demonstrates reduce_add_sync intrinstic supported on compute capability 8.0 and another which uses cooperative_groups::reduce function which does thread_block_tile level reduction introduced from CUDA 11.0.
|
||||||
|
* Added `cudaCompressibleMemory`. Demonstrates compressible memory allocation using cuMemMap API.
|
||||||
|
* Added `simpleVulkanMMAP`. Demonstrates Vulkan CUDA Interop via cuMemMap APIs.
|
||||||
|
* Added `concurrentKernels`. Demonstrates the use of CUDA streams for concurrent execution of several kernels on a GPU.
|
||||||
|
* Dropped Mac OSX support from all samples.
|
||||||
|
|
||||||
|
### CUDA 10.2
|
||||||
|
* Added `simpleD3D11`. Demonstrates CUDA-D3D11 External Resource Interoperability APIs for updating D3D11 buffers from CUDA and synchronization between D3D11 and CUDA with Keyed Mutexes.
|
||||||
|
* Added `simpleDrvRuntime`. Demonstrates CUDA Driver and Runtime APIs working together to load fatbinary of a CUDA kernel.
|
||||||
|
* Added `vectorAddMMAP`. Demonstrates how cuMemMap API allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access.
|
||||||
|
* Added `memMapIPCDrv`. Demonstrates Inter Process Communication using cuMemMap APIs.
|
||||||
|
* Added `cudaNvSci`. Demonstrates CUDA-NvSciBuf/NvSciSync Interop.
|
||||||
|
* Added `jacobiCudaGraphs`. Demonstrates Instantiated CUDA Graph Update with Jacobi Iterative Method using different approaches.
|
||||||
|
* Added `cuSolverSp_LinearSolver`. Demonstrates cuSolverSP's LU, QR and Cholesky factorization.
|
||||||
|
* Added `MersenneTwisterGP11213`. Demonstrates the Mersenne Twister random number generator GP11213 in cuRAND.
|
||||||
|
|
||||||
|
### CUDA 10.1 Update 2
|
||||||
|
* Added `vulkanImageCUDA`. Demonstrates how to perform Vulkan image - CUDA Interop.
|
||||||
|
* Added `nvJPEG_encoder`. Demonstrates encoding of jpeg images using NVJPEG Library.
|
||||||
|
* Added Windows OS support to `nvJPEG` sample.
|
||||||
|
* Added `boxFilterNPP`. Demonstrates how to use NPP FilterBox function to perform a box filter.
|
||||||
|
* Added `cannyEdgeDetectorNPP`. Demonstrates the nppiFilterCannyBorder_8u_C1R Canny Edge Detection image filter function.
|
||||||
|
|
||||||
|
### CUDA 10.1 Update 1
|
||||||
|
* Added `NV12toBGRandResize`. Demonstrates how to convert and resize NV12 frames to BGR planars frames using CUDA in batch.
|
||||||
|
* Added `EGLStream_CUDA_Interop`. Demonstrates data exchange between CUDA and EGL Streams.
|
||||||
|
* Added `cuSolverDn_LinearSolver`. Demonstrates cuSolverDN's LU, QR and Cholesky factorization.
|
||||||
|
* Added support of Visual Studio 2019 to all samples supported on [Windows](./README.md#windows-1).
|
||||||
|
|
||||||
|
### CUDA 10.1
|
||||||
|
* Added `immaTensorCoreGemm`. Demonstrates integer GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API for integers employing the Tensor Cores.
|
||||||
|
* Added `simpleIPC`. Demonstrates Inter Process Communication with one process per GPU for computation.
|
||||||
|
* Added `nvJPEG`. Demonstrates single and batched decoding of jpeg images using NVJPEG Library.
|
||||||
|
* Added `bandwidthTest`. It measures the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e.
|
||||||
|
* Added `reduction`. Demonstrates several important optimization strategies for Data-Parallel Algorithms like reduction.
|
||||||
|
* Update all the samples to support CUDA 10.1.
|
||||||
|
|
||||||
|
|
||||||
|
### CUDA 10.0
|
||||||
|
* Added `simpleCudaGraphs`. Demonstrates CUDA Graphs creation, instantiation and launch using Graphs APIs and Stream Capture APIs.
|
||||||
|
* Added `conjugateGradientCudaGraphs`. Demonstrates conjugate gradient solver on GPU using CUBLAS and CUSPARSE library calls captured and called using CUDA Graph APIs.
|
||||||
|
* Added `simpleVulkan`. Demonstrates Vulkan - CUDA Interop.
|
||||||
|
* Added `simpleD3D12`. Demonstrates DX12 - CUDA Interop.
|
||||||
|
* Added `UnifiedMemoryPerf`. Demonstrates performance comparision of various memory types involved in system.
|
||||||
|
* Added `p2pBandwidthLatencyTest`. Demonstrates Peer-To-Peer (P2P) data transfers between pairs of GPUs and computes latency and bandwidth.
|
||||||
|
* Added `systemWideAtomics`. Demonstrates system wide atomic instructions.
|
||||||
|
* Added `simpleCUBLASXT`. Demonstrates CUBLAS-XT library which performs GEMM operations over multiple GPUs.
|
||||||
|
* Added Windows OS support to `conjugateGradientMultiDeviceCG` sample.
|
||||||
|
* Removed support of Visual Studio 2010 from all samples.
|
||||||
|
|
||||||
|
|
||||||
|
### CUDA 9.2
|
||||||
|
|
||||||
|
This is the first release of CUDA Samples on GitHub:
|
||||||
|
* Added `vectorAdd_nvrtc`. Demonstrates runtime compilation library using NVRTC of a simple vectorAdd kernel.
|
||||||
|
* Added `warpAggregatedAtomicsCG`. Demonstrates warp aggregated atomics using Cooperative Groups.
|
||||||
|
* Added `deviceQuery`. Enumerates the properties of the CUDA devices present in the system.
|
||||||
|
* Added `matrixMul`. Demonstrates a matrix multiplication using shared memory through tiled approach.
|
||||||
|
* Added `matrixMulDrv`. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.
|
||||||
|
* Added `cudaTensorCoreGemm`. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.
|
||||||
|
* Added `simpleVoteIntrinsics` which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.
|
||||||
|
* Added `shfl_scan` which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.
|
||||||
|
* Added `conjugateGradientMultiBlockCG`. Demonstrates a conjugate gradient solver on GPU using Multi Block Cooperative Groups.
|
||||||
|
* Added `conjugateGradientMultiDeviceCG`. Demonstrates a conjugate gradient solver on multiple GPUs using Multi Device Cooperative Groups, also uses unified memory prefetching and usage hints APIs.
|
||||||
|
* Added `simpleCUBLAS`. Demonstrates how perform GEMM operations using CUBLAS library.
|
||||||
|
* Added `simpleCUFFT`. Demonstrates how perform FFT operations using CUFFT library.
|
||||||
31
CMakeLists.txt
Normal file
31
CMakeLists.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
include(cmake/CudaSampleArchs.cmake)
|
||||||
|
|
||||||
|
# Default to all supported architectures if the user does not specify.
|
||||||
|
# Gated on CUDA_SAMPLES_ARCHS_DEFAULTED rather than CMAKE_CUDA_ARCHITECTURES so this
|
||||||
|
# decision is made once (on the first configure) and does not flip on reconfigure,
|
||||||
|
# when CMAKE_CUDA_ARCHITECTURES is already defined from our own cached default.
|
||||||
|
# The decision is revisited when the list itself moves, which the user can do with -D
|
||||||
|
# on any later configure of the same build directory. Keep the list each configure
|
||||||
|
# ends up with, so that such a change is told apart from our own cached default.
|
||||||
|
if(NOT DEFINED CUDA_SAMPLES_ARCHS_DEFAULTED)
|
||||||
|
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
|
||||||
|
list(JOIN CUDA_SAMPLES_MASTER_ARCHS ";" _default_archs)
|
||||||
|
set(CMAKE_CUDA_ARCHITECTURES "${_default_archs}" CACHE STRING "CUDA architectures")
|
||||||
|
unset(_default_archs)
|
||||||
|
set(CUDA_SAMPLES_ARCHS_DEFAULTED TRUE CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
set(CUDA_SAMPLES_ARCHS_DEFAULTED FALSE CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
elseif(NOT "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "${CUDA_SAMPLES_LAST_CONFIGURED_ARCHS}")
|
||||||
|
set(CUDA_SAMPLES_ARCHS_DEFAULTED FALSE CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CUDA_SAMPLES_LAST_CONFIGURED_ARCHS "${CMAKE_CUDA_ARCHITECTURES}" CACHE INTERNAL "")
|
||||||
|
|
||||||
|
project(cuda-samples LANGUAGES C CXX CUDA)
|
||||||
|
|
||||||
|
include(cmake/CudaSampleCommon.cmake)
|
||||||
|
|
||||||
|
add_subdirectory(cpp)
|
||||||
103
CONTRIBUTING.md
Normal file
103
CONTRIBUTING.md
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
# Contributing to the CUDA Samples
|
||||||
|
|
||||||
|
Thank you for your interest in contributing to the CUDA Samples!
|
||||||
|
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. **Fork & Clone the Repository**:
|
||||||
|
|
||||||
|
Fork the reporistory and clone the fork. For more information, check [GitHub's documentation on forking](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) and [cloning a repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
|
||||||
|
|
||||||
|
## Making Changes
|
||||||
|
|
||||||
|
1. **Create a New Branch**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout -b your-feature-branch
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Make Changes**.
|
||||||
|
|
||||||
|
3. **Build and Test**:
|
||||||
|
|
||||||
|
Ensure changes don't break existing functionality by building and running tests.
|
||||||
|
|
||||||
|
For more details on building and testing, refer to the [Building and Testing](#building-and-testing) section below.
|
||||||
|
|
||||||
|
4. **Commit Changes**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git commit -m "Brief description of the change"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building and Testing
|
||||||
|
|
||||||
|
For information on building a running tests on the samples, please refer to the main [README](README.md)
|
||||||
|
|
||||||
|
## Creating a Pull Request
|
||||||
|
|
||||||
|
1. Push changes to your fork
|
||||||
|
2. Create a pull request targeting the `master` branch of the original CUDA Samples repository. Refer to [GitHub's documentation](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) for more information on creating a pull request.
|
||||||
|
3. Describe the purpose and context of the changes in the pull request description.
|
||||||
|
|
||||||
|
## Code Formatting (pre-commit hooks)
|
||||||
|
|
||||||
|
The CUDA Samples repository uses [pre-commit](https://pre-commit.com/) to execute all code linters and formatters. These
|
||||||
|
tools ensure a consistent coding style throughout the project. Using pre-commit ensures that linter
|
||||||
|
versions and options are aligned for all developers. Additionally, there is a CI check in place to
|
||||||
|
enforce that committed code follows our standards.
|
||||||
|
|
||||||
|
The linters used by the CUDA Samples are listed in `.pre-commit-config.yaml`.
|
||||||
|
For example, C++ and CUDA code is formatted with [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html).
|
||||||
|
|
||||||
|
To use `pre-commit`, install via `conda` or `pip`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
conda config --add channels conda-forge
|
||||||
|
conda install pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pre-commit
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run pre-commit hooks before committing code:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pre-commit run
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, pre-commit runs on staged files (only changes and additions that will be committed).
|
||||||
|
To run pre-commit checks on all files, execute:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pre-commit run --all-files
|
||||||
|
```
|
||||||
|
|
||||||
|
Optionally, you may set up the pre-commit hooks to run automatically when you make a git commit. This can be done by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pre-commit install
|
||||||
|
```
|
||||||
|
|
||||||
|
Now code linters and formatters will be run each time you commit changes.
|
||||||
|
|
||||||
|
You can skip these checks with `git commit --no-verify` or with the short version `git commit -n`, althoguh please note
|
||||||
|
that this may result in pull requests being rejected if subsequent checks fail.
|
||||||
|
|
||||||
|
## Review Process
|
||||||
|
|
||||||
|
Once submitted, maintainers will be automatically assigned to review the pull request. They might suggest changes or improvements. Constructive feedback is a part of the collaborative process, aimed at ensuring the highest quality code.
|
||||||
|
|
||||||
|
For constructive feedback and effective communication during reviews, we recommend following [Conventional Comments](https://conventionalcomments.org/).
|
||||||
|
|
||||||
|
Further recommended reading for successful PR reviews:
|
||||||
|
|
||||||
|
- [How to Do Code Reviews Like a Human (Part One)](https://mtlynch.io/human-code-reviews-1/)
|
||||||
|
- [How to Do Code Reviews Like a Human (Part Two)](https://mtlynch.io/human-code-reviews-2/)
|
||||||
|
|
||||||
|
## Thank You
|
||||||
|
|
||||||
|
Your contributions enhance the CUDA Samples for the entire community. We appreciate your effort and collaboration!
|
||||||
@@ -1,197 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_EXCEPTIONS_H
|
|
||||||
#define NV_UTIL_NPP_EXCEPTIONS_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
/// All npp related C++ classes are put into the npp namespace.
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
/// Exception base class.
|
|
||||||
/// This exception base class will be used for everything C++ throught
|
|
||||||
/// the NPP project.
|
|
||||||
/// The exception contains a string message, as well as data fields for a string
|
|
||||||
/// containing the name of the file as well as the line number where the exception was thrown.
|
|
||||||
/// The easiest way of throwing exceptions and providing filename and line number is
|
|
||||||
/// to use one of the ASSERT macros defined for that purpose.
|
|
||||||
class Exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/// Constructor.
|
|
||||||
/// \param rMessage A message with information as to why the exception was thrown.
|
|
||||||
/// \param rFileName The name of the file where the exception was thrown.
|
|
||||||
/// \param nLineNumber Line number in the file where the exception was thrown.
|
|
||||||
explicit
|
|
||||||
Exception(const std::string &rMessage = "", const std::string &rFileName = "", unsigned int nLineNumber = 0)
|
|
||||||
: sMessage_(rMessage), sFileName_(rFileName), nLineNumber_(nLineNumber)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Exception(const Exception &rException)
|
|
||||||
: sMessage_(rException.sMessage_), sFileName_(rException.sFileName_), nLineNumber_(rException.nLineNumber_)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~Exception()
|
|
||||||
{ };
|
|
||||||
|
|
||||||
/// Get the exception's message.
|
|
||||||
const
|
|
||||||
std::string &
|
|
||||||
message()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return sMessage_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the exception's file info.
|
|
||||||
const
|
|
||||||
std::string &
|
|
||||||
fileName()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return sFileName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the exceptions's line info.
|
|
||||||
unsigned int
|
|
||||||
lineNumber()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return nLineNumber_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Create a clone of this exception.
|
|
||||||
/// This creates a new Exception object on the heap. It is
|
|
||||||
/// the responsibility of the user of this function to free this memory
|
|
||||||
/// (delete x).
|
|
||||||
virtual
|
|
||||||
Exception *
|
|
||||||
clone()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return new Exception(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a single string with all the exceptions information.
|
|
||||||
/// The virtual toString() method is used by the operator<<()
|
|
||||||
/// so that all exceptions derived from this base-class can print
|
|
||||||
/// their full information correctly even if a reference to their
|
|
||||||
/// exact type is not had at the time of printing (i.e. the basic
|
|
||||||
/// operator<<() is used).
|
|
||||||
virtual
|
|
||||||
std::string
|
|
||||||
toString()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
std::ostringstream oOutputString;
|
|
||||||
oOutputString << fileName() << ":" << lineNumber() << ": " << message();
|
|
||||||
return oOutputString.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string sMessage_; ///< Message regarding the cause of the exception.
|
|
||||||
std::string sFileName_; ///< Name of the file where the exception was thrown.
|
|
||||||
unsigned int nLineNumber_; ///< Line number in the file where the exception was thrown
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Output stream inserter for Exception.
|
|
||||||
/// \param rOutputStream The stream the exception information is written to.
|
|
||||||
/// \param rException The exception that's being written.
|
|
||||||
/// \return Reference to the output stream being used.
|
|
||||||
std::ostream &
|
|
||||||
operator << (std::ostream &rOutputStream, const Exception &rException)
|
|
||||||
{
|
|
||||||
rOutputStream << rException.toString();
|
|
||||||
return rOutputStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Basic assert macro.
|
|
||||||
/// This macro should be used to enforce any kind of pre or post conditions.
|
|
||||||
/// Unlike the C-runtime assert macro, this macro does not abort execution, but throws
|
|
||||||
/// a C++ exception. The exception is automatically filled with information about the failing
|
|
||||||
/// condition, the filename and line number where the exception was thrown.
|
|
||||||
/// \note The macro is written in such a way that omitting a semicolon after its usage
|
|
||||||
/// causes a compiler error. The correct way to invoke this macro is:
|
|
||||||
/// NPP_ASSERT(n < MAX);
|
|
||||||
#define NPP_ASSERT(C) do {if (!(C)) throw npp::Exception(#C " assertion faild!", __FILE__, __LINE__);} while(false)
|
|
||||||
|
|
||||||
// ASSERT macro.
|
|
||||||
// Same functionality as the basic assert macro with the added ability to pass
|
|
||||||
// a message M. M should be a string literal.
|
|
||||||
// Note: Never use code inside ASSERT() that causes a side-effect ASSERT macros may get compiled
|
|
||||||
// out in release mode.
|
|
||||||
#define NPP_ASSERT_MSG(C, M) do {if (!(C)) throw npp::Exception(#C " assertion faild! Message: " M, __FILE__, __LINE__);} while(false)
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
/// Basic debug assert macro.
|
|
||||||
/// This macro is identical in every respect to NPP_ASSERT(C) but it does get compiled to a
|
|
||||||
/// no-op in release builds. It is therefor of utmost importance to not put statements into
|
|
||||||
/// this macro that cause side effects required for correct program execution.
|
|
||||||
#define NPP_DEBUG_ASSERT(C) do {if (!(C)) throw npp::Exception(#C " debug assertion faild!", __FILE__, __LINE__);} while(false)
|
|
||||||
#else
|
|
||||||
#define NPP_DEBUG_ASSERT(C)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// ASSERT for null-pointer test.
|
|
||||||
/// It is safe to put code with side effects into this macro. Also: This macro never
|
|
||||||
/// gets compiled to a no-op because resource allocation may fail based on external causes not under
|
|
||||||
/// control of a software developer.
|
|
||||||
#define NPP_ASSERT_NOT_NULL(P) do {if ((P) == 0) throw npp::Exception(#P " not null assertion faild!", __FILE__, __LINE__);} while(false)
|
|
||||||
|
|
||||||
/// Macro for flagging methods as not implemented.
|
|
||||||
/// The macro throws an exception with a message that an implementation was missing
|
|
||||||
#define NPP_NOT_IMPLEMENTED() do {throw npp::Exception("Implementation missing!", __FILE__, __LINE__);} while(false)
|
|
||||||
|
|
||||||
/// Macro for checking error return code of CUDA (runtime) calls.
|
|
||||||
/// This macro never gets disabled.
|
|
||||||
#define NPP_CHECK_CUDA(S) do {cudaError_t eCUDAResult; \
|
|
||||||
eCUDAResult = S; \
|
|
||||||
if (eCUDAResult != cudaSuccess) std::cout << "NPP_CHECK_CUDA - eCUDAResult = " << eCUDAResult << std::endl; \
|
|
||||||
NPP_ASSERT(eCUDAResult == cudaSuccess);} while (false)
|
|
||||||
|
|
||||||
/// Macro for checking error return code for NPP calls.
|
|
||||||
#define NPP_CHECK_NPP(S) do {NppStatus eStatusNPP; \
|
|
||||||
eStatusNPP = S; \
|
|
||||||
if (eStatusNPP != NPP_SUCCESS) std::cout << "NPP_CHECK_NPP - eStatusNPP = " << _cudaGetErrorEnum(eStatusNPP) << "("<< eStatusNPP << ")" << std::endl; \
|
|
||||||
NPP_ASSERT(eStatusNPP == NPP_SUCCESS);} while (false)
|
|
||||||
|
|
||||||
/// Macro for checking error return codes from cuFFT calls.
|
|
||||||
#define NPP_CHECK_CUFFT(S) do {cufftResult eCUFFTResult; \
|
|
||||||
eCUFFTResult = S; \
|
|
||||||
if (eCUFFTResult != NPP_SUCCESS) std::cout << "NPP_CHECK_CUFFT - eCUFFTResult = " << eCUFFTResult << std::endl; \
|
|
||||||
NPP_ASSERT(eCUFFTResult == CUFFT_SUCCESS);} while (false)
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_EXCEPTIONS_H
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGE_H
|
|
||||||
#define NV_UTIL_NPP_IMAGE_H
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
class Image
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct Size
|
|
||||||
{
|
|
||||||
unsigned int nWidth;
|
|
||||||
unsigned int nHeight;
|
|
||||||
|
|
||||||
Size() : nWidth(0), nHeight(0)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Size(unsigned int nWidthNew, unsigned nHeightNew) : nWidth(nWidthNew), nHeight(nHeightNew)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Size(const Size &rSize) : nWidth(rSize.nWidth), nHeight(rSize.nHeight)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Size &
|
|
||||||
operator= (const Size &rSize)
|
|
||||||
{
|
|
||||||
if (&rSize == this)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
nWidth = rSize.nWidth;
|
|
||||||
nHeight = rSize.nHeight;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(Size &rSize)
|
|
||||||
{
|
|
||||||
unsigned int nTemp;
|
|
||||||
nTemp = nWidth;
|
|
||||||
nWidth = rSize.nWidth;
|
|
||||||
rSize.nWidth = nTemp;
|
|
||||||
|
|
||||||
nTemp = nHeight;
|
|
||||||
nHeight = rSize.nHeight;
|
|
||||||
rSize.nHeight = nTemp;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Image()
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Image(unsigned int nWidth, unsigned int nHeight) : oSize_(nWidth, nHeight)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Image(const Image::Size &rSize) : oSize_(rSize)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Image(const Image &rImage) : oSize_(rImage.oSize_)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~Image()
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Image &
|
|
||||||
operator= (const Image &rImage)
|
|
||||||
{
|
|
||||||
if (&rImage == this)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
oSize_ = rImage.oSize_;
|
|
||||||
return *this;
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
width()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return oSize_.nWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
height()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return oSize_.nHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Size
|
|
||||||
size()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return oSize_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(Image &rImage)
|
|
||||||
{
|
|
||||||
oSize_.swap(rImage.oSize_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Size oSize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator== (const Image::Size &rFirst, const Image::Size &rSecond)
|
|
||||||
{
|
|
||||||
return rFirst.nWidth == rSecond.nWidth && rFirst.nHeight == rSecond.nHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
operator!= (const Image::Size &rFirst, const Image::Size &rSecond)
|
|
||||||
{
|
|
||||||
return rFirst.nWidth != rSecond.nWidth || rFirst.nHeight != rSecond.nHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_IMAGE_H
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGE_ALLOCATORS_CPU_H
|
|
||||||
#define NV_UTIL_NPP_IMAGE_ALLOCATORS_CPU_H
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename D, size_t N>
|
|
||||||
class ImageAllocatorCPU
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
D *
|
|
||||||
Malloc2D(unsigned int nWidth, unsigned int nHeight, unsigned int *pPitch)
|
|
||||||
{
|
|
||||||
NPP_ASSERT(nWidth * nHeight > 0);
|
|
||||||
|
|
||||||
D *pResult = new D[nWidth * N * nHeight];
|
|
||||||
*pPitch = nWidth * sizeof(D) * N;
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free2D(D *pPixels)
|
|
||||||
{
|
|
||||||
delete[] pPixels;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy2D(D *pDst, size_t nDstPitch, const D *pSrc, size_t nSrcPitch, size_t nWidth, size_t nHeight)
|
|
||||||
{
|
|
||||||
const void *pSrcLine = pSrc;
|
|
||||||
void *pDstLine = pDst;
|
|
||||||
|
|
||||||
for (size_t iLine = 0; iLine < nHeight; ++iLine)
|
|
||||||
{
|
|
||||||
// copy one line worth of data
|
|
||||||
memcpy(pDst, pSrc, nWidth * N * sizeof(D));
|
|
||||||
// move data pointers to next line
|
|
||||||
pDst += nDstPitch;
|
|
||||||
pSrc += nSrcPitch;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_IMAGE_ALLOCATORS_CPU_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,149 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGE_IO_H
|
|
||||||
#define NV_UTIL_NPP_IMAGE_IO_H
|
|
||||||
|
|
||||||
#include "ImagesCPU.h"
|
|
||||||
#include "ImagesNPP.h"
|
|
||||||
|
|
||||||
#include "FreeImage.h"
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Error handler for FreeImage library.
|
|
||||||
// In case this handler is invoked, it throws an NPP exception.
|
|
||||||
void
|
|
||||||
FreeImageErrorHandler(FREE_IMAGE_FORMAT oFif, const char *zMessage)
|
|
||||||
{
|
|
||||||
throw npp::Exception(zMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
// Load a gray-scale image from disk.
|
|
||||||
void
|
|
||||||
loadImage(const std::string &rFileName, ImageCPU_8u_C1 &rImage)
|
|
||||||
{
|
|
||||||
// set your own FreeImage error handler
|
|
||||||
FreeImage_SetOutputMessage(FreeImageErrorHandler);
|
|
||||||
|
|
||||||
FREE_IMAGE_FORMAT eFormat = FreeImage_GetFileType(rFileName.c_str());
|
|
||||||
|
|
||||||
// no signature? try to guess the file format from the file extension
|
|
||||||
if (eFormat == FIF_UNKNOWN)
|
|
||||||
{
|
|
||||||
eFormat = FreeImage_GetFIFFromFilename(rFileName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
NPP_ASSERT(eFormat != FIF_UNKNOWN);
|
|
||||||
// check that the plugin has reading capabilities ...
|
|
||||||
FIBITMAP *pBitmap;
|
|
||||||
|
|
||||||
if (FreeImage_FIFSupportsReading(eFormat))
|
|
||||||
{
|
|
||||||
pBitmap = FreeImage_Load(eFormat, rFileName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
NPP_ASSERT(pBitmap != 0);
|
|
||||||
// make sure this is an 8-bit single channel image
|
|
||||||
NPP_ASSERT(FreeImage_GetColorType(pBitmap) == FIC_MINISBLACK);
|
|
||||||
NPP_ASSERT(FreeImage_GetBPP(pBitmap) == 8);
|
|
||||||
|
|
||||||
// create an ImageCPU to receive the loaded image data
|
|
||||||
ImageCPU_8u_C1 oImage(FreeImage_GetWidth(pBitmap), FreeImage_GetHeight(pBitmap));
|
|
||||||
|
|
||||||
// Copy the FreeImage data into the new ImageCPU
|
|
||||||
unsigned int nSrcPitch = FreeImage_GetPitch(pBitmap);
|
|
||||||
const Npp8u *pSrcLine = FreeImage_GetBits(pBitmap) + nSrcPitch * (FreeImage_GetHeight(pBitmap) -1);
|
|
||||||
Npp8u *pDstLine = oImage.data();
|
|
||||||
unsigned int nDstPitch = oImage.pitch();
|
|
||||||
|
|
||||||
for (size_t iLine = 0; iLine < oImage.height(); ++iLine)
|
|
||||||
{
|
|
||||||
memcpy(pDstLine, pSrcLine, oImage.width() * sizeof(Npp8u));
|
|
||||||
pSrcLine -= nSrcPitch;
|
|
||||||
pDstLine += nDstPitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
// swap the user given image with our result image, effecively
|
|
||||||
// moving our newly loaded image data into the user provided shell
|
|
||||||
oImage.swap(rImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save an gray-scale image to disk.
|
|
||||||
void
|
|
||||||
saveImage(const std::string &rFileName, const ImageCPU_8u_C1 &rImage)
|
|
||||||
{
|
|
||||||
// create the result image storage using FreeImage so we can easily
|
|
||||||
// save
|
|
||||||
FIBITMAP *pResultBitmap = FreeImage_Allocate(rImage.width(), rImage.height(), 8 /* bits per pixel */);
|
|
||||||
NPP_ASSERT_NOT_NULL(pResultBitmap);
|
|
||||||
unsigned int nDstPitch = FreeImage_GetPitch(pResultBitmap);
|
|
||||||
Npp8u *pDstLine = FreeImage_GetBits(pResultBitmap) + nDstPitch * (rImage.height()-1);
|
|
||||||
const Npp8u *pSrcLine = rImage.data();
|
|
||||||
unsigned int nSrcPitch = rImage.pitch();
|
|
||||||
|
|
||||||
for (size_t iLine = 0; iLine < rImage.height(); ++iLine)
|
|
||||||
{
|
|
||||||
memcpy(pDstLine, pSrcLine, rImage.width() * sizeof(Npp8u));
|
|
||||||
pSrcLine += nSrcPitch;
|
|
||||||
pDstLine -= nDstPitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
// now save the result image
|
|
||||||
bool bSuccess;
|
|
||||||
bSuccess = FreeImage_Save(FIF_PGM, pResultBitmap, rFileName.c_str(), 0) == TRUE;
|
|
||||||
NPP_ASSERT_MSG(bSuccess, "Failed to save result image.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load a gray-scale image from disk.
|
|
||||||
void
|
|
||||||
loadImage(const std::string &rFileName, ImageNPP_8u_C1 &rImage)
|
|
||||||
{
|
|
||||||
ImageCPU_8u_C1 oImage;
|
|
||||||
loadImage(rFileName, oImage);
|
|
||||||
ImageNPP_8u_C1 oResult(oImage);
|
|
||||||
rImage.swap(oResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save an gray-scale image to disk.
|
|
||||||
void
|
|
||||||
saveImage(const std::string &rFileName, const ImageNPP_8u_C1 &rImage)
|
|
||||||
{
|
|
||||||
ImageCPU_8u_C1 oHostImage(rImage.size());
|
|
||||||
// copy the device result data
|
|
||||||
rImage.copyTo(oHostImage.data(), oHostImage.pitch());
|
|
||||||
saveImage(rFileName, oHostImage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_IMAGE_IO_H
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGE_PACKED_H
|
|
||||||
#define NV_UTIL_NPP_IMAGE_PACKED_H
|
|
||||||
|
|
||||||
#include "Image.h"
|
|
||||||
#include "Pixel.h"
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
template<typename D, size_t N, class A>
|
|
||||||
class ImagePacked: public npp::Image
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef npp::Pixel<D, N> tPixel;
|
|
||||||
typedef D tData;
|
|
||||||
static const size_t gnChannels = N;
|
|
||||||
typedef npp::Image::Size tSize;
|
|
||||||
|
|
||||||
ImagePacked(): aPixels_(0)
|
|
||||||
, nPitch_(0)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagePacked(unsigned int nWidth, unsigned int nHeight): Image(nWidth, nHeight)
|
|
||||||
, aPixels_(0)
|
|
||||||
, nPitch_(0)
|
|
||||||
{
|
|
||||||
aPixels_ = A::Malloc2D(width(), height(), &nPitch_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagePacked(unsigned int nWidth, unsigned int nHeight, bool bTight): Image(nWidth, nHeight)
|
|
||||||
, aPixels_(0)
|
|
||||||
, nPitch_(0)
|
|
||||||
{
|
|
||||||
aPixels_ = A::Malloc2D(width(), height(), &nPitch_, bTight);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagePacked(const tSize &rSize): Image(rSize)
|
|
||||||
, aPixels_(0)
|
|
||||||
, nPitch_(0)
|
|
||||||
{
|
|
||||||
aPixels_ = A::Malloc2D(width(), height(), &nPitch_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagePacked(const ImagePacked<D, N, A> &rImage): Image(rImage)
|
|
||||||
, aPixels_(0)
|
|
||||||
, nPitch_(rImage.pitch())
|
|
||||||
{
|
|
||||||
aPixels_ = A::Malloc2D(width(), height(), &nPitch_);
|
|
||||||
A::Copy2D(aPixels_, nPitch_, rImage.pixels(), rImage.pitch(), width(), height());
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~ImagePacked()
|
|
||||||
{
|
|
||||||
A::Free2D(aPixels_);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagePacked &
|
|
||||||
operator= (const ImagePacked<D, N, A> &rImage)
|
|
||||||
{
|
|
||||||
// in case of self-assignment
|
|
||||||
if (&rImage == this)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
A::Free2D(aPixels_);
|
|
||||||
aPixels_ = 0;
|
|
||||||
nPitch_ = 0;
|
|
||||||
|
|
||||||
// assign parent class's data fields (width, height)
|
|
||||||
Image::operator =(rImage);
|
|
||||||
|
|
||||||
aPixels_ = A::Malloc2D(width(), height(), &nPitch_);
|
|
||||||
A::Copy2D(aPixels_, nPitch_, rImage.data(), rImage.pitch(), width(), height());
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
pitch()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return nPitch_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a pointer to the pixel array.
|
|
||||||
/// The result pointer can be offset to pixel at position (x, y) and
|
|
||||||
/// even negative offsets are allowed.
|
|
||||||
/// \param nX Horizontal pointer/array offset.
|
|
||||||
/// \param nY Vertical pointer/array offset.
|
|
||||||
/// \return Pointer to the pixel array (or first pixel in array with coordinates (nX, nY).
|
|
||||||
tPixel *
|
|
||||||
pixels(int nX = 0, int nY = 0)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<tPixel *>(reinterpret_cast<unsigned char *>(aPixels_) + nY * pitch() + nX * gnChannels * sizeof(D));
|
|
||||||
}
|
|
||||||
|
|
||||||
const
|
|
||||||
tPixel *
|
|
||||||
pixels(int nX = 0, int nY = 0)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const tPixel *>(reinterpret_cast<unsigned char *>(aPixels_) + nY * pitch() + nX * gnChannels * sizeof(D));
|
|
||||||
}
|
|
||||||
|
|
||||||
D *
|
|
||||||
data(int nX = 0, int nY = 0)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<D *>(pixels(nX, nY));
|
|
||||||
}
|
|
||||||
|
|
||||||
const
|
|
||||||
D *
|
|
||||||
data(int nX = 0, int nY = 0)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return reinterpret_cast<const D *>(pixels(nX, nY));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(ImagePacked<D, N, A> &rImage)
|
|
||||||
{
|
|
||||||
Image::swap(rImage);
|
|
||||||
|
|
||||||
tData *aTemp = aPixels_;
|
|
||||||
aPixels_ = rImage.aPixels_;
|
|
||||||
rImage.aPixels_ = aTemp;
|
|
||||||
|
|
||||||
unsigned int nTemp = nPitch_;
|
|
||||||
nPitch_ = rImage.nPitch_;
|
|
||||||
rImage.nPitch_ = nTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
D *aPixels_;
|
|
||||||
unsigned int nPitch_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_IMAGE_IPP_H
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGES_CPU_H
|
|
||||||
#define NV_UTIL_NPP_IMAGES_CPU_H
|
|
||||||
|
|
||||||
#include "ImagePacked.h"
|
|
||||||
|
|
||||||
#include "ImageAllocatorsCPU.h"
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
#include <npp.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
template<typename D, unsigned int N, class A>
|
|
||||||
class ImageCPU: public npp::ImagePacked<D, N, A>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
ImageCPU()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageCPU(unsigned int nWidth, unsigned int nHeight): ImagePacked<D, N, A>(nWidth, nHeight)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit
|
|
||||||
ImageCPU(const npp::Image::Size &rSize): ImagePacked<D, N, A>(rSize)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageCPU(const ImageCPU<D, N, A> &rImage): Image(rImage)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~ImageCPU()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageCPU &
|
|
||||||
operator= (const ImageCPU<D, N, A> &rImage)
|
|
||||||
{
|
|
||||||
ImagePacked<D, N, A>::operator= (rImage);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
npp::Pixel<D, N> &
|
|
||||||
operator()(unsigned int iX, unsigned int iY)
|
|
||||||
{
|
|
||||||
return *ImagePacked<D, N, A>::pixels(iX, iY);
|
|
||||||
}
|
|
||||||
|
|
||||||
npp::Pixel<D, N>
|
|
||||||
operator()(unsigned int iX, unsigned int iY)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return *ImagePacked<D, N, A>::pixels(iX, iY);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
typedef ImageCPU<Npp8u, 1, npp::ImageAllocatorCPU<Npp8u, 1> > ImageCPU_8u_C1;
|
|
||||||
typedef ImageCPU<Npp8u, 2, npp::ImageAllocatorCPU<Npp8u, 2> > ImageCPU_8u_C2;
|
|
||||||
typedef ImageCPU<Npp8u, 3, npp::ImageAllocatorCPU<Npp8u, 3> > ImageCPU_8u_C3;
|
|
||||||
typedef ImageCPU<Npp8u, 4, npp::ImageAllocatorCPU<Npp8u, 4> > ImageCPU_8u_C4;
|
|
||||||
|
|
||||||
typedef ImageCPU<Npp16u, 1, npp::ImageAllocatorCPU<Npp16u, 1> > ImageCPU_16u_C1;
|
|
||||||
typedef ImageCPU<Npp16u, 3, npp::ImageAllocatorCPU<Npp16u, 3> > ImageCPU_16u_C3;
|
|
||||||
typedef ImageCPU<Npp16u, 4, npp::ImageAllocatorCPU<Npp16u, 4> > ImageCPU_16u_C4;
|
|
||||||
|
|
||||||
typedef ImageCPU<Npp16s, 1, npp::ImageAllocatorCPU<Npp16s, 1> > ImageCPU_16s_C1;
|
|
||||||
typedef ImageCPU<Npp16s, 3, npp::ImageAllocatorCPU<Npp16s, 3> > ImageCPU_16s_C3;
|
|
||||||
typedef ImageCPU<Npp16s, 4, npp::ImageAllocatorCPU<Npp16s, 4> > ImageCPU_16s_C4;
|
|
||||||
|
|
||||||
typedef ImageCPU<Npp32s, 1, npp::ImageAllocatorCPU<Npp32s, 1> > ImageCPU_32s_C1;
|
|
||||||
typedef ImageCPU<Npp32s, 3, npp::ImageAllocatorCPU<Npp32s, 3> > ImageCPU_32s_C3;
|
|
||||||
typedef ImageCPU<Npp32s, 4, npp::ImageAllocatorCPU<Npp32s, 4> > ImageCPU_32s_C4;
|
|
||||||
|
|
||||||
typedef ImageCPU<Npp32f, 1, npp::ImageAllocatorCPU<Npp32f, 1> > ImageCPU_32f_C1;
|
|
||||||
typedef ImageCPU<Npp32f, 3, npp::ImageAllocatorCPU<Npp32f, 3> > ImageCPU_32f_C3;
|
|
||||||
typedef ImageCPU<Npp32f, 4, npp::ImageAllocatorCPU<Npp32f, 4> > ImageCPU_32f_C4;
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_IMAGE_IPP_H
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_IMAGES_NPP_H
|
|
||||||
#define NV_UTIL_NPP_IMAGES_NPP_H
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
#include "ImagePacked.h"
|
|
||||||
|
|
||||||
#include "ImageAllocatorsNPP.h"
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
// forward declaration
|
|
||||||
template<typename D, unsigned int N, class A> class ImageCPU;
|
|
||||||
|
|
||||||
template<typename D, unsigned int N>
|
|
||||||
class ImageNPP: public npp::ImagePacked<D, N, npp::ImageAllocator<D, N> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ImageNPP()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageNPP(unsigned int nWidth, unsigned int nHeight, bool bTight = false): ImagePacked<D, N, npp::ImageAllocator<D, N> >(nWidth, nHeight, bTight)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageNPP(const npp::Image::Size &rSize): ImagePacked<D, N, npp::ImageAllocator<D, N> >(rSize)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageNPP(const ImageNPP<D, N> &rImage): Image(rImage)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class X>
|
|
||||||
explicit
|
|
||||||
ImageNPP(const ImageCPU<D, N, X> &rImage, bool bTight = false): ImagePacked<D, N, npp::ImageAllocator<D, N> >(rImage.width(), rImage.height(), bTight)
|
|
||||||
{
|
|
||||||
npp::ImageAllocator<D, N>::HostToDeviceCopy2D(ImagePacked<D, N, npp::ImageAllocator<D, N> >::data(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::pitch(),
|
|
||||||
rImage.data(),
|
|
||||||
rImage.pitch(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::width(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::height());
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~ImageNPP()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageNPP &
|
|
||||||
operator= (const ImageNPP<D, N> &rImage)
|
|
||||||
{
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::operator= (rImage);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
copyTo(D *pData, unsigned int nPitch)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
NPP_ASSERT((ImagePacked<D, N, npp::ImageAllocator<D, N> >::width() * sizeof(npp::Pixel<D, N>) <= nPitch));
|
|
||||||
npp::ImageAllocator<D, N>::DeviceToHostCopy2D(pData,
|
|
||||||
nPitch,
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::data(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::pitch(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::width(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::height());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
copyFrom(D *pData, unsigned int nPitch)
|
|
||||||
{
|
|
||||||
NPP_ASSERT((ImagePacked<D, N, npp::ImageAllocator<D, N> >::width() * sizeof(npp::Pixel<D, N>) <= nPitch));
|
|
||||||
npp::ImageAllocator<D, N>::HostToDeviceCopy2D(ImagePacked<D, N, npp::ImageAllocator<D, N> >::data(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::pitch(),
|
|
||||||
pData,
|
|
||||||
nPitch,
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::width(),
|
|
||||||
ImagePacked<D, N, npp::ImageAllocator<D, N> >::height());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp8u, 1> ImageNPP_8u_C1;
|
|
||||||
typedef ImageNPP<Npp8u, 2> ImageNPP_8u_C2;
|
|
||||||
typedef ImageNPP<Npp8u, 3> ImageNPP_8u_C3;
|
|
||||||
typedef ImageNPP<Npp8u, 4> ImageNPP_8u_C4;
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp16u, 1> ImageNPP_16u_C1;
|
|
||||||
typedef ImageNPP<Npp16u, 2> ImageNPP_16u_C2;
|
|
||||||
typedef ImageNPP<Npp16u, 3> ImageNPP_16u_C3;
|
|
||||||
typedef ImageNPP<Npp16u, 4> ImageNPP_16u_C4;
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp16s, 1> ImageNPP_16s_C1;
|
|
||||||
typedef ImageNPP<Npp16s, 3> ImageNPP_16s_C3;
|
|
||||||
typedef ImageNPP<Npp16s, 4> ImageNPP_16s_C4;
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp32s, 1> ImageNPP_32s_C1;
|
|
||||||
typedef ImageNPP<Npp32s, 3> ImageNPP_32s_C3;
|
|
||||||
typedef ImageNPP<Npp32s, 4> ImageNPP_32s_C4;
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp32f, 1> ImageNPP_32f_C1;
|
|
||||||
typedef ImageNPP<Npp32f, 2> ImageNPP_32f_C2;
|
|
||||||
typedef ImageNPP<Npp32f, 3> ImageNPP_32f_C3;
|
|
||||||
typedef ImageNPP<Npp32f, 4> ImageNPP_32f_C4;
|
|
||||||
|
|
||||||
typedef ImageNPP<Npp64f, 1> ImageNPP_64f_C1;
|
|
||||||
typedef ImageNPP<Npp64f, 2> ImageNPP_64f_C2;
|
|
||||||
typedef ImageNPP<Npp64f, 3> ImageNPP_64f_C3;
|
|
||||||
typedef ImageNPP<Npp64f, 4> ImageNPP_64f_C4;
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_IMAGES_NPP_H
|
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_PIXEL_H
|
|
||||||
#define NV_UTIL_PIXEL_H
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
template <typename D, size_t N>
|
|
||||||
struct Pixel
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
struct Pixel<D, 1>
|
|
||||||
{
|
|
||||||
D x;
|
|
||||||
|
|
||||||
const D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 1);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
|
|
||||||
D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 1);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
struct Pixel<D, 2>
|
|
||||||
{
|
|
||||||
D x,y;
|
|
||||||
|
|
||||||
const D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 2);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
|
|
||||||
D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 2);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
struct Pixel<D, 3>
|
|
||||||
{
|
|
||||||
D x,y,z;
|
|
||||||
|
|
||||||
const D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 3);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
|
|
||||||
D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 3);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
struct Pixel<D, 4>
|
|
||||||
{
|
|
||||||
D x, y, z, w;
|
|
||||||
|
|
||||||
const D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 4);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
|
|
||||||
D &
|
|
||||||
operator[](size_t iChannel)
|
|
||||||
{
|
|
||||||
NPP_ASSERT(iChannel < 4);
|
|
||||||
return (&x)[iChannel];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_PIXEL_H
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_SIGNAL_H
|
|
||||||
#define NV_UTIL_NPP_SIGNAL_H
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
class Signal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Signal() : nSize_(0)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
explicit
|
|
||||||
Signal(size_t nSize) : nSize_(nSize)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
Signal(const Signal &rSignal) : nSize_(rSignal.nSize_)
|
|
||||||
{ };
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~Signal()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
Signal &
|
|
||||||
operator= (const Signal &rSignal)
|
|
||||||
{
|
|
||||||
nSize_ = rSignal.nSize_;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
size()
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return nSize_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(Signal &rSignal)
|
|
||||||
{
|
|
||||||
size_t nTemp = nSize_;
|
|
||||||
nSize_ = rSignal.nSize_;
|
|
||||||
rSignal.nSize_ = nTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
size_t nSize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename D, class A>
|
|
||||||
class SignalTemplate: public Signal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef D tData;
|
|
||||||
|
|
||||||
SignalTemplate(): aValues_(0)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalTemplate(size_t nSize): Signal(nSize)
|
|
||||||
, aValues_(0)
|
|
||||||
{
|
|
||||||
aValues_ = A::Malloc1D(size());
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalTemplate(const SignalTemplate<D, A> &rSignal): Signal(rSignal)
|
|
||||||
, aValues_(0)
|
|
||||||
{
|
|
||||||
aValues_ = A::Malloc1D(size());
|
|
||||||
A::Copy1D(aValues_, rSignal.values(), size());
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~SignalTemplate()
|
|
||||||
{
|
|
||||||
A::Free1D(aValues_);
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalTemplate &
|
|
||||||
operator= (const SignalTemplate<D, A> &rSignal)
|
|
||||||
{
|
|
||||||
// in case of self-assignment
|
|
||||||
if (&rSignal == this)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
A::Free1D(aValues_);
|
|
||||||
this->aPixels_ = 0;
|
|
||||||
|
|
||||||
// assign parent class's data fields (width, height)
|
|
||||||
Signal::operator =(rSignal);
|
|
||||||
|
|
||||||
aValues_ = A::Malloc1D(size());
|
|
||||||
A::Copy1D(aValues_, rSignal.value(), size());
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get a pointer to the pixel array.
|
|
||||||
/// The result pointer can be offset to pixel at position (x, y) and
|
|
||||||
/// even negative offsets are allowed.
|
|
||||||
/// \param nX Horizontal pointer/array offset.
|
|
||||||
/// \param nY Vertical pointer/array offset.
|
|
||||||
/// \return Pointer to the pixel array (or first pixel in array with coordinates (nX, nY).
|
|
||||||
tData *
|
|
||||||
values(int i = 0)
|
|
||||||
{
|
|
||||||
return aValues_ + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
const
|
|
||||||
tData *
|
|
||||||
values(int i = 0)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return aValues_ + i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
swap(SignalTemplate<D, A> &rSignal)
|
|
||||||
{
|
|
||||||
Signal::swap(rSignal);
|
|
||||||
|
|
||||||
tData *aTemp = this->aValues_;
|
|
||||||
this->aValues_ = rSignal.aValues_;
|
|
||||||
rSignal.aValues_ = aTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
D *aValues_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_SIGNAL_H
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_SIGNAL_ALLOCATORS_CPU_H
|
|
||||||
#define NV_UTIL_NPP_SIGNAL_ALLOCATORS_CPU_H
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
class SignalAllocatorCPU
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
D *
|
|
||||||
Malloc1D(unsigned int nSize)
|
|
||||||
{
|
|
||||||
return new D[nSize];;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(D *pPixels)
|
|
||||||
{
|
|
||||||
delete[] pPixels;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(D *pDst, const D *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
memcpy(pDst, pSrc, nSize * sizeof(D));
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_SIGNAL_ALLOCATORS_CPU_H
|
|
||||||
@@ -1,684 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_SIGNAL_ALLOCATORS_NPP_H
|
|
||||||
#define NV_UTIL_NPP_SIGNAL_ALLOCATORS_NPP_H
|
|
||||||
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
#include <npps.h>
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename D>
|
|
||||||
class SignalAllocator
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp8u>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp8u *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp8u *pResult = nppsMalloc_8u(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp8u *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp8u *pDst, const Npp8u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp8u),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp8u *pDst, const Npp8u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp8u), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp8u *pDst, const Npp8u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp8u), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp16s>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp16s *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp16s *pResult = nppsMalloc_16s(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp16s *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp16s *pDst, const Npp16s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16s),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp16s *pDst, const Npp16s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16s), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp16s *pDst, const Npp16s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16s), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp16u>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp16u *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp16u *pResult = nppsMalloc_16u(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp16u *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp16u *pDst, const Npp16u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16u),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp16u *pDst, const Npp16u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16u), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp16u *pDst, const Npp16u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16u), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp16sc>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp16sc *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp16sc *pResult = nppsMalloc_16sc(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp16sc *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp16sc *pDst, const Npp16sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16sc),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp16sc *pDst, const Npp16sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16sc), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp16sc *pDst, const Npp16sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp16sc), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp32u>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp32u *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp32u *pResult = nppsMalloc_32u(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp32u *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp32u *pDst, const Npp32u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32u),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp32u *pDst, const Npp32u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32u), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp32u *pDst, const Npp32u *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32u), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp32s>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp32s *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp32s *pResult = nppsMalloc_32s(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp32s *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp32s *pDst, const Npp32s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32s),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp32s *pDst, const Npp32s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32s), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp32s *pDst, const Npp32s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32s), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp32sc>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp32sc *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp32sc *pResult = nppsMalloc_32sc(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp32sc *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp32sc *pDst, const Npp32sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32sc),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp32sc *pDst, const Npp32sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32sc), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp32sc *pDst, const Npp32sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32sc), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp32f>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp32f *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp32f *pResult = nppsMalloc_32f(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp32f *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp32f *pDst, const Npp32f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32f),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp32f *pDst, const Npp32f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32f), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp32f *pDst, const Npp32f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32f), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp32fc>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp32fc *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp32fc *pResult = nppsMalloc_32fc(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp32fc *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp32fc *pDst, const Npp32fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32fc),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp32fc *pDst, const Npp32fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32fc), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp32fc *pDst, const Npp32fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp32fc), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp64s>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp64s *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp64s *pResult = nppsMalloc_64s(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp64s *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp64s *pDst, const Npp64s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64s),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp64s *pDst, const Npp64s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64s), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp64s *pDst, const Npp64s *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64s), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp64sc>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp64sc *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp64sc *pResult = nppsMalloc_64sc(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp64sc *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp64sc *pDst, const Npp64sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64sc),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp64sc *pDst, const Npp64sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64sc), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp64sc *pDst, const Npp64sc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64sc), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp64f>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp64f *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp64f *pResult = nppsMalloc_64f(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp64f *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp64f *pDst, const Npp64f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64f),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp64f *pDst, const Npp64f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64f), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp64f *pDst, const Npp64f *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64f), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
class SignalAllocator<Npp64fc>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static
|
|
||||||
Npp64fc *
|
|
||||||
Malloc1D(size_t nSize)
|
|
||||||
{
|
|
||||||
Npp64fc *pResult = nppsMalloc_64fc(static_cast<int>(nSize));
|
|
||||||
NPP_ASSERT(pResult != 0);
|
|
||||||
|
|
||||||
return pResult;
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Free1D(Npp64fc *pValues)
|
|
||||||
{
|
|
||||||
nppsFree(pValues);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
Copy1D(Npp64fc *pDst, const Npp64fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64fc),cudaMemcpyDeviceToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
HostToDeviceCopy1D(Npp64fc *pDst, const Npp64fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64fc), cudaMemcpyHostToDevice);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
|
||||||
void
|
|
||||||
DeviceToHostCopy1D(Npp64fc *pDst, const Npp64fc *pSrc, size_t nSize)
|
|
||||||
{
|
|
||||||
cudaError_t eResult;
|
|
||||||
eResult = cudaMemcpy(pDst, pSrc, nSize * sizeof(Npp64fc), cudaMemcpyDeviceToHost);
|
|
||||||
NPP_ASSERT(cudaSuccess == eResult);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_SIGNAL_ALLOCATORS_NPP_H
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_SIGNALS_CPU_H
|
|
||||||
#define NV_UTIL_NPP_SIGNALS_CPU_H
|
|
||||||
|
|
||||||
#include "Signal.h"
|
|
||||||
|
|
||||||
#include "SignalAllocatorsCPU.h"
|
|
||||||
#include "Exceptions.h"
|
|
||||||
|
|
||||||
#include <npp.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
|
|
||||||
template<typename D, class A>
|
|
||||||
class SignalCPU: public npp::SignalTemplate<D, A>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef typename npp::SignalTemplate<D, A>::tData tData;
|
|
||||||
|
|
||||||
SignalCPU()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalCPU(size_t nSize): SignalTemplate<D, A>(nSize)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalCPU(const SignalCPU<D, A> &rSignal): SignalTemplate<D, A>(rSignal)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~SignalCPU()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalCPU &
|
|
||||||
operator= (const SignalCPU<D,A> &rSignal)
|
|
||||||
{
|
|
||||||
SignalTemplate<D, A>::operator= (rSignal);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
tData &
|
|
||||||
operator [](unsigned int i)
|
|
||||||
{
|
|
||||||
return *SignalTemplate<D, A>::values(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
tData
|
|
||||||
operator [](unsigned int i)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
return *SignalTemplate<D, A>::values(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SignalCPU<Npp8u, npp::SignalAllocatorCPU<Npp8u> > SignalCPU_8u;
|
|
||||||
typedef SignalCPU<Npp32s, npp::SignalAllocatorCPU<Npp32s> > SignalCPU_32s;
|
|
||||||
typedef SignalCPU<Npp16s, npp::SignalAllocatorCPU<Npp16s> > SignalCPU_16s;
|
|
||||||
typedef SignalCPU<Npp16sc, npp::SignalAllocatorCPU<Npp16sc> > SignalCPU_16sc;
|
|
||||||
typedef SignalCPU<Npp32sc, npp::SignalAllocatorCPU<Npp32sc> > SignalCPU_32sc;
|
|
||||||
typedef SignalCPU<Npp32f, npp::SignalAllocatorCPU<Npp32f> > SignalCPU_32f;
|
|
||||||
typedef SignalCPU<Npp32fc, npp::SignalAllocatorCPU<Npp32fc> > SignalCPU_32fc;
|
|
||||||
typedef SignalCPU<Npp64s, npp::SignalAllocatorCPU<Npp64s> > SignalCPU_64s;
|
|
||||||
typedef SignalCPU<Npp64sc, npp::SignalAllocatorCPU<Npp64sc> > SignalCPU_64sc;
|
|
||||||
typedef SignalCPU<Npp64f, npp::SignalAllocatorCPU<Npp64f> > SignalCPU_64f;
|
|
||||||
typedef SignalCPU<Npp64fc, npp::SignalAllocatorCPU<Npp64fc> > SignalCPU_64fc;
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_SIGNALS_CPU_H
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NV_UTIL_NPP_SIGNALS_NPP_H
|
|
||||||
#define NV_UTIL_NPP_SIGNALS_NPP_H
|
|
||||||
|
|
||||||
#include "Exceptions.h"
|
|
||||||
#include "Signal.h"
|
|
||||||
|
|
||||||
#include "SignalAllocatorsNPP.h"
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
|
|
||||||
namespace npp
|
|
||||||
{
|
|
||||||
// forward declaration
|
|
||||||
template<typename D, class A> class SignalCPU;
|
|
||||||
|
|
||||||
template<typename D>
|
|
||||||
class SignalNPP: public npp::SignalTemplate<D, npp::SignalAllocator<D> >
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SignalNPP()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit
|
|
||||||
SignalNPP(size_t nSize): SignalTemplate<D, npp::SignalAllocator<D> >(nSize)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalNPP(const SignalNPP<D> &rSignal): SignalTemplate<D, npp::SignalAllocator<D> >(rSignal)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class X>
|
|
||||||
explicit
|
|
||||||
SignalNPP(const SignalCPU<D, X> &rSignal): SignalTemplate<D, npp::SignalAllocator<D> >(rSignal.size())
|
|
||||||
{
|
|
||||||
npp::SignalAllocator<D>::HostToDeviceCopy1D(SignalTemplate<D, npp::SignalAllocator<D> >::values(),
|
|
||||||
rSignal.values(), SignalTemplate<D, npp::SignalAllocator<D> >::size());
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual
|
|
||||||
~SignalNPP()
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalNPP &
|
|
||||||
operator= (const SignalNPP<D> &rSignal)
|
|
||||||
{
|
|
||||||
SignalTemplate<D, npp::SignalAllocator<D> >::operator= (rSignal);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
copyTo(D *pValues)
|
|
||||||
const
|
|
||||||
{
|
|
||||||
npp::SignalAllocator<D>::DeviceToHostCopy1D(pValues, SignalTemplate<D, npp::SignalAllocator<D> >::values(), SignalTemplate<D, npp::SignalAllocator<D> >::size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
copyFrom(D *pValues)
|
|
||||||
{
|
|
||||||
npp::SignalAllocator<D>::HostToDeviceCopy1D(SignalTemplate<D, npp::SignalAllocator<D> >::values(), pValues, SignalTemplate<D, npp::SignalAllocator<D> >::size());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SignalNPP<Npp8u> SignalNPP_8u;
|
|
||||||
typedef SignalNPP<Npp16s> SignalNPP_16s;
|
|
||||||
typedef SignalNPP<Npp16sc> SignalNPP_16sc;
|
|
||||||
typedef SignalNPP<Npp32s> SignalNPP_32s;
|
|
||||||
typedef SignalNPP<Npp32sc> SignalNPP_32sc;
|
|
||||||
typedef SignalNPP<Npp32f> SignalNPP_32f;
|
|
||||||
typedef SignalNPP<Npp32fc> SignalNPP_32fc;
|
|
||||||
typedef SignalNPP<Npp64s> SignalNPP_64s;
|
|
||||||
typedef SignalNPP<Npp64sc> SignalNPP_64sc;
|
|
||||||
typedef SignalNPP<Npp64f> SignalNPP_64f;
|
|
||||||
typedef SignalNPP<Npp64fc> SignalNPP_64fc;
|
|
||||||
|
|
||||||
} // npp namespace
|
|
||||||
|
|
||||||
#endif // NV_UTIL_NPP_SIGNALS_NPP_H
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
BIN
Common/data/teapot512.pgm
Normal file
BIN
Common/data/teapot512.pgm
Normal file
Binary file not shown.
BIN
Common/data/teapot_512x512_8u.raw
Normal file
BIN
Common/data/teapot_512x512_8u.raw
Normal file
Binary file not shown.
BIN
Common/data/teapot_512x512_8u_Gray.raw
Normal file
BIN
Common/data/teapot_512x512_8u_Gray.raw
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,294 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// File: dynlink_d3d10.h
|
|
||||||
//
|
|
||||||
// Shortcut macros and functions for using DX objects
|
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef _DYNLINK_D3D10_H_
|
|
||||||
#define _DYNLINK_D3D10_H_
|
|
||||||
|
|
||||||
// Standard Windows includes
|
|
||||||
#include <windows.h>
|
|
||||||
#include <initguid.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <wchar.h>
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#include <commctrl.h> // for InitCommonControls()
|
|
||||||
#include <shellapi.h> // for ExtractIcon()
|
|
||||||
#include <new.h> // for placement new
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// CRT's memory leak detection
|
|
||||||
#if defined(DEBUG) || defined(_DEBUG)
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Direct3D9 includes
|
|
||||||
#include <d3d9.h>
|
|
||||||
|
|
||||||
// Direct3D10 includes
|
|
||||||
#include <dxgi.h>
|
|
||||||
#include <d3d10_1.h>
|
|
||||||
#include <d3d10.h>
|
|
||||||
|
|
||||||
// XInput includes
|
|
||||||
#include <xinput.h>
|
|
||||||
|
|
||||||
// strsafe.h deprecates old unsecure string functions. If you
|
|
||||||
// really do not want to it to (not recommended), then uncomment the next line
|
|
||||||
//#define STRSAFE_NO_DEPRECATE
|
|
||||||
|
|
||||||
#ifndef STRSAFE_NO_DEPRECATE
|
|
||||||
#pragma deprecated("strncpy")
|
|
||||||
#pragma deprecated("wcsncpy")
|
|
||||||
#pragma deprecated("_tcsncpy")
|
|
||||||
#pragma deprecated("wcsncat")
|
|
||||||
#pragma deprecated("strncat")
|
|
||||||
#pragma deprecated("_tcsncat")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#pragma warning( disable : 4996 ) // disable deprecated warning
|
|
||||||
#include <strsafe.h>
|
|
||||||
#pragma warning( default : 4996 )
|
|
||||||
|
|
||||||
#include <DirectXMath.h>
|
|
||||||
|
|
||||||
using namespace DirectX;
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// Structs
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
struct DXUTD3D9DeviceSettings
|
|
||||||
{
|
|
||||||
UINT AdapterOrdinal;
|
|
||||||
D3DDEVTYPE DeviceType;
|
|
||||||
D3DFORMAT AdapterFormat;
|
|
||||||
DWORD BehaviorFlags;
|
|
||||||
D3DPRESENT_PARAMETERS pp;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DXUTD3D10DeviceSettings
|
|
||||||
{
|
|
||||||
UINT AdapterOrdinal;
|
|
||||||
D3D10_DRIVER_TYPE DriverType;
|
|
||||||
UINT Output;
|
|
||||||
DXGI_SWAP_CHAIN_DESC sd;
|
|
||||||
UINT32 CreateFlags;
|
|
||||||
UINT32 SyncInterval;
|
|
||||||
DWORD PresentFlags;
|
|
||||||
bool AutoCreateDepthStencil; // DXUT will create the a depth stencil resource and view if true
|
|
||||||
DXGI_FORMAT AutoDepthStencilFormat;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DXUTDeviceVersion { DXUT_D3D9_DEVICE, DXUT_D3D10_DEVICE };
|
|
||||||
struct DXUTDeviceSettings
|
|
||||||
{
|
|
||||||
DXUTDeviceVersion ver;
|
|
||||||
union
|
|
||||||
{
|
|
||||||
DXUTD3D9DeviceSettings d3d9; // only valid if ver == DXUT_D3D9_DEVICE
|
|
||||||
DXUTD3D10DeviceSettings d3d10; // only valid if ver == DXUT_D3D10_DEVICE
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
// Error codes
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
#define DXUTERR_NODIRECT3D MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0901)
|
|
||||||
#define DXUTERR_NOCOMPATIBLEDEVICES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0902)
|
|
||||||
#define DXUTERR_MEDIANOTFOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0903)
|
|
||||||
#define DXUTERR_NONZEROREFCOUNT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0904)
|
|
||||||
#define DXUTERR_CREATINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0905)
|
|
||||||
#define DXUTERR_RESETTINGDEVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0906)
|
|
||||||
#define DXUTERR_CREATINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0907)
|
|
||||||
#define DXUTERR_RESETTINGDEVICEOBJECTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x0908)
|
|
||||||
#define DXUTERR_DEVICEREMOVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x090A)
|
|
||||||
|
|
||||||
|
|
||||||
typedef HRESULT(WINAPI *LPCREATEDXGIFACTORY)(REFIID, void **);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICE)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT32,
|
|
||||||
ID3D10Device **);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICE1)(IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT,
|
|
||||||
D3D10_FEATURE_LEVEL1, UINT, ID3D10Device1 **);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATESTATEBLOCK)(ID3D10Device *pDevice, D3D10_STATE_BLOCK_MASK *pStateBlockMask,
|
|
||||||
ID3D10StateBlock **ppStateBlock);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKUNION)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
|
||||||
D3D10_STATE_BLOCK_MASK *pResult);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKINTERSECT)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
|
||||||
D3D10_STATE_BLOCK_MASK *pResult);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDIFFERENCE)(D3D10_STATE_BLOCK_MASK *pA, D3D10_STATE_BLOCK_MASK *pB,
|
|
||||||
D3D10_STATE_BLOCK_MASK *pResult);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKENABLECAPTURE)(D3D10_STATE_BLOCK_MASK *pMask,
|
|
||||||
D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart,
|
|
||||||
UINT RangeLength);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDISABLECAPTURE)(D3D10_STATE_BLOCK_MASK *pMask,
|
|
||||||
D3D10_DEVICE_STATE_TYPES StateType, UINT RangeStart,
|
|
||||||
UINT RangeLength);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKENABLEALL)(D3D10_STATE_BLOCK_MASK *pMask);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10STATEBLOCKMASKDISABLEALL)(D3D10_STATE_BLOCK_MASK *pMask);
|
|
||||||
typedef BOOL (WINAPI *LPD3D10STATEBLOCKMASKGETSETTING)(D3D10_STATE_BLOCK_MASK *pMask,
|
|
||||||
D3D10_DEVICE_STATE_TYPES StateType, UINT Entry);
|
|
||||||
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10COMPILEEFFECTFROMMEMORY)(void *pData, SIZE_T DataLength, LPCSTR pSrcFileName,
|
|
||||||
CONST D3D10_SHADER_MACRO *pDefines,
|
|
||||||
ID3D10Include *pInclude, UINT HLSLFlags, UINT FXFlags,
|
|
||||||
ID3D10Blob **ppCompiledEffect, ID3D10Blob **ppErrors);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEEFFECTFROMMEMORY)(void *pData, SIZE_T DataLength, UINT FXFlags,
|
|
||||||
ID3D10Device *pDevice,
|
|
||||||
ID3D10EffectPool *pEffectPool,
|
|
||||||
ID3D10Effect **ppEffect);
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEEFFECTPOOLFROMMEMORY)(void *pData, SIZE_T DataLength, UINT FXFlags,
|
|
||||||
ID3D10Device *pDevice, ID3D10EffectPool **ppEffectPool);
|
|
||||||
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICEANDSWAPCHAIN)(IDXGIAdapter *pAdapter,
|
|
||||||
D3D10_DRIVER_TYPE DriverType,
|
|
||||||
HMODULE Software,
|
|
||||||
UINT Flags,
|
|
||||||
UINT SDKVersion,
|
|
||||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
|
||||||
IDXGISwapChain **ppSwapChain,
|
|
||||||
ID3D10Device **ppDevice);
|
|
||||||
|
|
||||||
typedef HRESULT(WINAPI *LPD3D10CREATEDEVICEANDSWAPCHAIN1)(IDXGIAdapter *pAdapter,
|
|
||||||
D3D10_DRIVER_TYPE DriverType,
|
|
||||||
HMODULE Software,
|
|
||||||
UINT Flags,
|
|
||||||
D3D10_FEATURE_LEVEL1 HardwareLevel,
|
|
||||||
UINT SDKVersion,
|
|
||||||
DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
|
||||||
IDXGISwapChain **ppSwapChain,
|
|
||||||
ID3D10Device1 **ppDevice);
|
|
||||||
|
|
||||||
// Module and function pointers
|
|
||||||
static HMODULE g_hModDXGI = NULL;
|
|
||||||
static HMODULE g_hModD3D10 = NULL;
|
|
||||||
static HMODULE g_hModD3D101 = NULL;
|
|
||||||
static LPCREATEDXGIFACTORY sFnPtr_CreateDXGIFactory = NULL;
|
|
||||||
static LPD3D10CREATESTATEBLOCK sFnPtr_D3D10CreateStateBlock = NULL;
|
|
||||||
static LPD3D10CREATEDEVICE sFnPtr_D3D10CreateDevice = NULL;
|
|
||||||
static LPD3D10CREATEDEVICE1 sFnPtr_D3D10CreateDevice1 = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKUNION sFnPtr_D3D10StateBlockMaskUnion = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKINTERSECT sFnPtr_D3D10StateBlockMaskIntersect = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKDIFFERENCE sFnPtr_D3D10StateBlockMaskDifference = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKENABLECAPTURE sFnPtr_D3D10StateBlockMaskEnableCapture = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKDISABLECAPTURE sFnPtr_D3D10StateBlockMaskDisableCapture = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKENABLEALL sFnPtr_D3D10StateBlockMaskEnableAll = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKDISABLEALL sFnPtr_D3D10StateBlockMaskDisableAll = NULL;
|
|
||||||
static LPD3D10STATEBLOCKMASKGETSETTING sFnPtr_D3D10StateBlockMaskGetSetting = NULL;
|
|
||||||
static LPD3D10COMPILEEFFECTFROMMEMORY sFnPtr_D3D10CompileEffectFromMemory = NULL;
|
|
||||||
static LPD3D10CREATEEFFECTFROMMEMORY sFnPtr_D3D10CreateEffectFromMemory = NULL;
|
|
||||||
static LPD3D10CREATEEFFECTPOOLFROMMEMORY sFnPtr_D3D10CreateEffectPoolFromMemory = NULL;
|
|
||||||
static LPD3D10CREATEDEVICEANDSWAPCHAIN sFnPtr_D3D10CreateDeviceAndSwapChain = NULL;
|
|
||||||
static LPD3D10CREATEDEVICEANDSWAPCHAIN1 sFnPtr_D3D10CreateDeviceAndSwapChain1 = NULL;
|
|
||||||
|
|
||||||
// unload the D3D10 DLLs
|
|
||||||
static bool dynlinkUnloadD3D10API(void)
|
|
||||||
{
|
|
||||||
if (g_hModD3D10)
|
|
||||||
{
|
|
||||||
FreeLibrary(g_hModD3D10);
|
|
||||||
g_hModD3D10 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_hModDXGI)
|
|
||||||
{
|
|
||||||
FreeLibrary(g_hModDXGI);
|
|
||||||
g_hModDXGI = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_hModD3D101)
|
|
||||||
{
|
|
||||||
FreeLibrary(g_hModD3D101);
|
|
||||||
g_hModD3D101 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dynamically load the D3D10 DLLs loaded and map the function pointers
|
|
||||||
static bool dynlinkLoadD3D10API(void)
|
|
||||||
{
|
|
||||||
// First check to see if the D3D10 Library is present.
|
|
||||||
// if it succeeds, then we can call GetProcAddress to grab all of the DX10 functions
|
|
||||||
g_hModD3D10 = LoadLibrary("d3d10.dll");
|
|
||||||
|
|
||||||
if (g_hModD3D10 != NULL)
|
|
||||||
{
|
|
||||||
sFnPtr_D3D10CreateStateBlock = (LPD3D10CREATESTATEBLOCK) GetProcAddress(g_hModD3D10, "D3D10CreateStateBlock");
|
|
||||||
sFnPtr_D3D10CreateDevice = (LPD3D10CREATEDEVICE) GetProcAddress(g_hModD3D10, "D3D10CreateDevice");
|
|
||||||
|
|
||||||
sFnPtr_D3D10StateBlockMaskUnion = (LPD3D10STATEBLOCKMASKUNION) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskUnion");
|
|
||||||
sFnPtr_D3D10StateBlockMaskIntersect = (LPD3D10STATEBLOCKMASKINTERSECT) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskIntersect");
|
|
||||||
sFnPtr_D3D10StateBlockMaskDifference = (LPD3D10STATEBLOCKMASKDIFFERENCE) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDifference");
|
|
||||||
sFnPtr_D3D10StateBlockMaskEnableCapture = (LPD3D10STATEBLOCKMASKENABLECAPTURE) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskEnableCapture");
|
|
||||||
sFnPtr_D3D10StateBlockMaskDisableCapture = (LPD3D10STATEBLOCKMASKDISABLECAPTURE)GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDisableCapture");
|
|
||||||
|
|
||||||
sFnPtr_D3D10StateBlockMaskEnableAll = (LPD3D10STATEBLOCKMASKENABLEALL) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskEnableAll");
|
|
||||||
sFnPtr_D3D10StateBlockMaskDisableAll = (LPD3D10STATEBLOCKMASKDISABLEALL) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskDisableAll");
|
|
||||||
sFnPtr_D3D10StateBlockMaskGetSetting = (LPD3D10STATEBLOCKMASKGETSETTING) GetProcAddress(g_hModD3D10, "D3D10StateBlockMaskGetSetting");
|
|
||||||
|
|
||||||
sFnPtr_D3D10CompileEffectFromMemory = (LPD3D10COMPILEEFFECTFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CompileEffectFromMemory");
|
|
||||||
sFnPtr_D3D10CreateEffectFromMemory = (LPD3D10CREATEEFFECTFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CreateEffectFromMemory");
|
|
||||||
sFnPtr_D3D10CreateEffectPoolFromMemory = (LPD3D10CREATEEFFECTPOOLFROMMEMORY) GetProcAddress(g_hModD3D10, "D3D10CreateEffectPoolFromMemory");
|
|
||||||
|
|
||||||
sFnPtr_D3D10CreateDeviceAndSwapChain = (LPD3D10CREATEDEVICEANDSWAPCHAIN) GetProcAddress(g_hModD3D10, "D3D10CreateDeviceAndSwapChain");
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hModDXGI = LoadLibrary("dxgi.dll");
|
|
||||||
|
|
||||||
if (g_hModDXGI)
|
|
||||||
{
|
|
||||||
sFnPtr_CreateDXGIFactory = (LPCREATEDXGIFACTORY) GetProcAddress(g_hModDXGI , "CreateDXGIFactory");
|
|
||||||
}
|
|
||||||
|
|
||||||
// This may fail if this machine isn't Windows Vista SP1 or later
|
|
||||||
g_hModD3D101 = LoadLibrary("d3d10_1.dll");
|
|
||||||
|
|
||||||
if (g_hModD3D101 != NULL)
|
|
||||||
{
|
|
||||||
sFnPtr_D3D10CreateDevice1 = (LPD3D10CREATEDEVICE1) GetProcAddress(g_hModD3D101, "D3D10CreateDevice1");
|
|
||||||
sFnPtr_D3D10CreateDeviceAndSwapChain1 = (LPD3D10CREATEDEVICEANDSWAPCHAIN1) GetProcAddress(g_hModD3D101, "D3D10CreateDeviceAndSwapChain1");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_hModD3D10 == NULL || g_hModDXGI == NULL || g_hModD3D101 == NULL)
|
|
||||||
{
|
|
||||||
dynlinkUnloadD3D10API();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -138,26 +138,29 @@ static const char *_cudaGetErrorEnum(cufftResult error) {
|
|||||||
case CUFFT_UNALIGNED_DATA:
|
case CUFFT_UNALIGNED_DATA:
|
||||||
return "CUFFT_UNALIGNED_DATA";
|
return "CUFFT_UNALIGNED_DATA";
|
||||||
|
|
||||||
case CUFFT_INCOMPLETE_PARAMETER_LIST:
|
|
||||||
return "CUFFT_INCOMPLETE_PARAMETER_LIST";
|
|
||||||
|
|
||||||
case CUFFT_INVALID_DEVICE:
|
case CUFFT_INVALID_DEVICE:
|
||||||
return "CUFFT_INVALID_DEVICE";
|
return "CUFFT_INVALID_DEVICE";
|
||||||
|
|
||||||
case CUFFT_PARSE_ERROR:
|
|
||||||
return "CUFFT_PARSE_ERROR";
|
|
||||||
|
|
||||||
case CUFFT_NO_WORKSPACE:
|
case CUFFT_NO_WORKSPACE:
|
||||||
return "CUFFT_NO_WORKSPACE";
|
return "CUFFT_NO_WORKSPACE";
|
||||||
|
|
||||||
case CUFFT_NOT_IMPLEMENTED:
|
case CUFFT_NOT_IMPLEMENTED:
|
||||||
return "CUFFT_NOT_IMPLEMENTED";
|
return "CUFFT_NOT_IMPLEMENTED";
|
||||||
|
|
||||||
case CUFFT_LICENSE_ERROR:
|
|
||||||
return "CUFFT_LICENSE_ERROR";
|
|
||||||
|
|
||||||
case CUFFT_NOT_SUPPORTED:
|
case CUFFT_NOT_SUPPORTED:
|
||||||
return "CUFFT_NOT_SUPPORTED";
|
return "CUFFT_NOT_SUPPORTED";
|
||||||
|
|
||||||
|
case CUFFT_MISSING_DEPENDENCY:
|
||||||
|
return "CUFFT_MISSING_DEPENDENCY";
|
||||||
|
|
||||||
|
case CUFFT_NVRTC_FAILURE:
|
||||||
|
return "CUFFT_NVRTC_FAILURE";
|
||||||
|
|
||||||
|
case CUFFT_NVJITLINK_FAILURE:
|
||||||
|
return "CUFFT_NVJITLINK_FAILURE";
|
||||||
|
|
||||||
|
case CUFFT_NVSHMEM_FAILURE:
|
||||||
|
return "CUFFT_NVSHMEM_FAILURE";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "<unknown>";
|
return "<unknown>";
|
||||||
@@ -665,6 +668,16 @@ inline int _ConvertSMVer2Cores(int major, int minor) {
|
|||||||
{0x75, 64},
|
{0x75, 64},
|
||||||
{0x80, 64},
|
{0x80, 64},
|
||||||
{0x86, 128},
|
{0x86, 128},
|
||||||
|
{0x87, 128},
|
||||||
|
{0x89, 128},
|
||||||
|
{0x90, 128},
|
||||||
|
{0xa0, 128},
|
||||||
|
{0xa1, 128},
|
||||||
|
{0xa3, 128},
|
||||||
|
{0xa7, 128},
|
||||||
|
{0xb0, 128},
|
||||||
|
{0xc0, 128},
|
||||||
|
{0xc1, 128},
|
||||||
{-1, -1}};
|
{-1, -1}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -711,6 +724,16 @@ inline const char* _ConvertSMVer2ArchName(int major, int minor) {
|
|||||||
{0x75, "Turing"},
|
{0x75, "Turing"},
|
||||||
{0x80, "Ampere"},
|
{0x80, "Ampere"},
|
||||||
{0x86, "Ampere"},
|
{0x86, "Ampere"},
|
||||||
|
{0x87, "Ampere"},
|
||||||
|
{0x89, "Ada"},
|
||||||
|
{0x90, "Hopper"},
|
||||||
|
{0xa0, "Blackwell"},
|
||||||
|
{0xa1, "Blackwell"},
|
||||||
|
{0xa3, "Blackwell"},
|
||||||
|
{0xa7, "Rubin"},
|
||||||
|
{0xb0, "Blackwell"},
|
||||||
|
{0xc0, "Blackwell"},
|
||||||
|
{0xc1, "Blackwell"},
|
||||||
{-1, "Graphics Device"}};
|
{-1, "Graphics Device"}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -113,6 +113,16 @@ inline int _ConvertSMVer2CoresDRV(int major, int minor) {
|
|||||||
{0x75, 64},
|
{0x75, 64},
|
||||||
{0x80, 64},
|
{0x80, 64},
|
||||||
{0x86, 128},
|
{0x86, 128},
|
||||||
|
{0x87, 128},
|
||||||
|
{0x89, 128},
|
||||||
|
{0x90, 128},
|
||||||
|
{0xa0, 128},
|
||||||
|
{0xa1, 128},
|
||||||
|
{0xa3, 128},
|
||||||
|
{0xa7, 128},
|
||||||
|
{0xb0, 128},
|
||||||
|
{0xc0, 128},
|
||||||
|
{0xc1, 128},
|
||||||
{-1, -1}};
|
{-1, -1}};
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -235,7 +245,7 @@ inline int gpuGetMaxGflopsDeviceIdDRV() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long compute_perf =
|
unsigned long long compute_perf =
|
||||||
(unsigned long long)(multiProcessorCount * sm_per_multiproc *
|
((unsigned long long)multiProcessorCount * sm_per_multiproc *
|
||||||
clockRate);
|
clockRate);
|
||||||
|
|
||||||
if (compute_perf > max_compute_perf) {
|
if (compute_perf > max_compute_perf) {
|
||||||
@@ -402,4 +412,3 @@ bool inline findFatbinPath(const char *module_file, std::string &module_path, ch
|
|||||||
// end of CUDA Helper Functions
|
// end of CUDA Helper Functions
|
||||||
|
|
||||||
#endif // COMMON_HELPER_CUDA_DRVAPI_H_
|
#endif // COMMON_HELPER_CUDA_DRVAPI_H_
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -1143,10 +1143,16 @@ inline __host__ __device__ uint4 max(uint4 a, uint4 b)
|
|||||||
// - linear interpolation between a and b, based on value t in [0, 1] range
|
// - linear interpolation between a and b, based on value t in [0, 1] range
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// std::lerp (C++20) is pulled into the global namespace by GCC's <cmath>;
|
||||||
|
// only define our own scalar overload when std::lerp is unavailable, to avoid
|
||||||
|
// a redeclaration / ambiguous-overload clash. (The float2/3/4 overloads below
|
||||||
|
// take distinct argument types and never conflict.)
|
||||||
|
#if !defined(__cplusplus) || (__cplusplus < 202002L)
|
||||||
inline __device__ __host__ float lerp(float a, float b, float t)
|
inline __device__ __host__ float lerp(float a, float b, float t)
|
||||||
{
|
{
|
||||||
return a + t*(b-a);
|
return a + t*(b-a);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
inline __device__ __host__ float2 lerp(float2 a, float2 b, float t)
|
inline __device__ __host__ float2 lerp(float2 a, float2 b, float t)
|
||||||
{
|
{
|
||||||
return a + t*(b-a);
|
return a + t*(b-a);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -168,7 +168,7 @@ int waitProcess(Process *process) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) || defined(__QNX__)
|
||||||
int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
||||||
const std::vector<Process> &processes) {
|
const std::vector<Process> &processes) {
|
||||||
int server_fd;
|
int server_fd;
|
||||||
@@ -185,25 +185,32 @@ int ipcCreateSocket(ipcHandle *&handle, const char *name,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(name);
|
char path_name[sizeof(servaddr.sun_path)];
|
||||||
bzero(&servaddr, sizeof(servaddr));
|
|
||||||
servaddr.sun_family = AF_UNIX;
|
|
||||||
|
|
||||||
size_t len = strlen(name);
|
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
||||||
if (len > (sizeof(servaddr.sun_path) - 1)) {
|
int written = snprintf(path_name, sizeof(path_name), "%s/%u",
|
||||||
|
getSocketFolder().c_str(), getpid());
|
||||||
|
if (written < 0 || (size_t)written >= sizeof(path_name)) {
|
||||||
perror("IPC failure: Cannot bind provided name to socket. Name too large");
|
perror("IPC failure: Cannot bind provided name to socket. Name too large");
|
||||||
|
close(server_fd);
|
||||||
|
delete handle;
|
||||||
|
handle = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(servaddr.sun_path, name, len);
|
unlink(path_name);
|
||||||
|
memset(&servaddr, 0, sizeof(servaddr));
|
||||||
|
servaddr.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
strncpy(servaddr.sun_path, path_name, sizeof(servaddr.sun_path) - 1);
|
||||||
|
|
||||||
if (bind(server_fd, (struct sockaddr *)&servaddr, SUN_LEN(&servaddr)) < 0) {
|
if (bind(server_fd, (struct sockaddr *)&servaddr, SUN_LEN(&servaddr)) < 0) {
|
||||||
perror("IPC failure: Binding socket failed");
|
perror("IPC failure: Binding socket failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->socketName = new char[strlen(name) + 1];
|
handle->socketName = new char[strlen(path_name) + 1];
|
||||||
strcpy(handle->socketName, name);
|
strcpy(handle->socketName, path_name);
|
||||||
handle->socket = server_fd;
|
handle->socket = server_fd;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -220,12 +227,20 @@ int ipcOpenSocket(ipcHandle *&handle) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero(&cliaddr, sizeof(cliaddr));
|
memset(&cliaddr, 0, sizeof(cliaddr));
|
||||||
cliaddr.sun_family = AF_UNIX;
|
cliaddr.sun_family = AF_UNIX;
|
||||||
char temp[10];
|
char temp[sizeof(cliaddr.sun_path)];
|
||||||
|
|
||||||
// Create unique name for the socket.
|
// Create unique name for the socket with path if SOCK_FOLDER is set.
|
||||||
sprintf(temp, "%u", getpid());
|
int written = snprintf(temp, sizeof(temp), "%s/%u", getSocketFolder().c_str(),
|
||||||
|
getpid());
|
||||||
|
if (written < 0 || (size_t)written >= sizeof(temp)) {
|
||||||
|
perror("IPC failure: Cannot bind provided name to socket. Name too large");
|
||||||
|
close(sock);
|
||||||
|
delete handle;
|
||||||
|
handle = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(cliaddr.sun_path, temp);
|
strcpy(cliaddr.sun_path, temp);
|
||||||
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
|
if (bind(sock, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
|
||||||
@@ -262,41 +277,48 @@ int ipcRecvShareableHandle(ipcHandle *handle, ShareableHandle *shHandle) {
|
|||||||
// Union to guarantee alignment requirements for control array
|
// Union to guarantee alignment requirements for control array
|
||||||
union {
|
union {
|
||||||
struct cmsghdr cm;
|
struct cmsghdr cm;
|
||||||
char control[CMSG_SPACE(sizeof(int))];
|
// This will not work on QNX as QNX CMSG_SPACE calls __cmsg_alignbytes
|
||||||
|
// And __cmsg_alignbytes is a runtime function instead of compile-time macros
|
||||||
|
// char control[CMSG_SPACE(sizeof(int))]
|
||||||
|
char* control;
|
||||||
} control_un;
|
} control_un;
|
||||||
|
|
||||||
|
size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
|
||||||
|
control_un.control = (char*) malloc(sizeof_control);
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
int receivedfd;
|
int receivedfd;
|
||||||
char dummy_buffer[1];
|
char dummy_buffer[1];
|
||||||
ssize_t sendResult;
|
ssize_t sendResult;
|
||||||
|
|
||||||
msg.msg_control = control_un.control;
|
msg.msg_control = control_un.control;
|
||||||
msg.msg_controllen = sizeof(control_un.control);
|
msg.msg_controllen = sizeof_control;
|
||||||
|
|
||||||
iov[0].iov_base = (void *)dummy_buffer;
|
iov[0].iov_base = (void *)dummy_buffer;
|
||||||
iov[0].iov_len = sizeof(dummy_buffer);
|
iov[0].iov_len = sizeof(dummy_buffer);
|
||||||
|
|
||||||
msg.msg_iov = iov;
|
msg.msg_iov = iov;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
|
||||||
if ((n = recvmsg(handle->socket, &msg, 0)) <= 0) {
|
if ((n = recvmsg(handle->socket, &msg, 0)) <= 0) {
|
||||||
perror("IPC failure: Receiving data over socket failed");
|
perror("IPC failure: Receiving data over socket failed");
|
||||||
|
free(control_un.control);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((cmptr = CMSG_FIRSTHDR(&msg)) != NULL) &&
|
if (((cmptr = CMSG_FIRSTHDR(&msg)) != NULL) &&
|
||||||
(cmptr->cmsg_len == CMSG_LEN(sizeof(int)))) {
|
(cmptr->cmsg_len == CMSG_LEN(sizeof(int)))) {
|
||||||
if ((cmptr->cmsg_level != SOL_SOCKET) || (cmptr->cmsg_type != SCM_RIGHTS)) {
|
if ((cmptr->cmsg_level != SOL_SOCKET) || (cmptr->cmsg_type != SCM_RIGHTS)) {
|
||||||
|
free(control_un.control);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(&receivedfd, CMSG_DATA(cmptr), sizeof(receivedfd));
|
memmove(&receivedfd, CMSG_DATA(cmptr), sizeof(receivedfd));
|
||||||
*(int *)shHandle = receivedfd;
|
*(int *)shHandle = receivedfd;
|
||||||
} else {
|
} else {
|
||||||
|
free(control_un.control);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(control_un.control);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +341,7 @@ int ipcSendDataToServer(ipcHandle *handle, const char *serverName,
|
|||||||
ssize_t sendResult;
|
ssize_t sendResult;
|
||||||
struct sockaddr_un serveraddr;
|
struct sockaddr_un serveraddr;
|
||||||
|
|
||||||
bzero(&serveraddr, sizeof(serveraddr));
|
memset(&serveraddr, 0, sizeof(serveraddr));
|
||||||
serveraddr.sun_family = AF_UNIX;
|
serveraddr.sun_family = AF_UNIX;
|
||||||
strncpy(serveraddr.sun_path, serverName, sizeof(serveraddr.sun_path) - 1);
|
strncpy(serveraddr.sun_path, serverName, sizeof(serveraddr.sun_path) - 1);
|
||||||
|
|
||||||
@@ -340,19 +362,28 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
|
|
||||||
union {
|
union {
|
||||||
struct cmsghdr cm;
|
struct cmsghdr cm;
|
||||||
char control[CMSG_SPACE(sizeof(int))];
|
char* control;
|
||||||
} control_un;
|
} control_un;
|
||||||
|
|
||||||
|
size_t sizeof_control = CMSG_SPACE(sizeof(int)) * sizeof(char);
|
||||||
|
control_un.control = (char*) malloc(sizeof_control);
|
||||||
|
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
ssize_t readResult;
|
ssize_t readResult;
|
||||||
struct sockaddr_un cliaddr;
|
struct sockaddr_un cliaddr;
|
||||||
socklen_t len = sizeof(cliaddr);
|
socklen_t len = sizeof(cliaddr);
|
||||||
|
|
||||||
// Construct client address to send this SHareable handle to
|
// Construct client address to send this SHareable handle to
|
||||||
bzero(&cliaddr, sizeof(cliaddr));
|
memset(&cliaddr, 0, sizeof(cliaddr));
|
||||||
cliaddr.sun_family = AF_UNIX;
|
cliaddr.sun_family = AF_UNIX;
|
||||||
char temp[10];
|
char temp[sizeof(cliaddr.sun_path)];
|
||||||
sprintf(temp, "%u", process);
|
int written =
|
||||||
|
snprintf(temp, sizeof(temp), "%s/%u", getSocketFolder().c_str(), process);
|
||||||
|
if (written < 0 || (size_t)written >= sizeof(temp)) {
|
||||||
|
perror("IPC failure: Cannot address client socket. Name too large");
|
||||||
|
free(control_un.control);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
strcpy(cliaddr.sun_path, temp);
|
strcpy(cliaddr.sun_path, temp);
|
||||||
len = sizeof(cliaddr);
|
len = sizeof(cliaddr);
|
||||||
|
|
||||||
@@ -360,7 +391,7 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
int sendfd = (int)shareableHandles[data];
|
int sendfd = (int)shareableHandles[data];
|
||||||
|
|
||||||
msg.msg_control = control_un.control;
|
msg.msg_control = control_un.control;
|
||||||
msg.msg_controllen = sizeof(control_un.control);
|
msg.msg_controllen = sizeof_control;
|
||||||
|
|
||||||
cmptr = CMSG_FIRSTHDR(&msg);
|
cmptr = CMSG_FIRSTHDR(&msg);
|
||||||
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
|
cmptr->cmsg_len = CMSG_LEN(sizeof(int));
|
||||||
@@ -380,9 +411,11 @@ int ipcSendShareableHandle(ipcHandle *handle,
|
|||||||
ssize_t sendResult = sendmsg(handle->socket, &msg, 0);
|
ssize_t sendResult = sendmsg(handle->socket, &msg, 0);
|
||||||
if (sendResult <= 0) {
|
if (sendResult <= 0) {
|
||||||
perror("IPC failure: Sending data over socket failed");
|
perror("IPC failure: Sending data over socket failed");
|
||||||
|
free(control_un.control);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(control_un.control);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -54,6 +54,27 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// The Unix domain sockets creating folder on QNX has been restricted to qnx6-mounted directories since QNX SDP 8.0.3.
|
||||||
|
#if defined(__QNX__)
|
||||||
|
#include <string>
|
||||||
|
inline std::string getSocketFolder() {
|
||||||
|
return "/storage";
|
||||||
|
}
|
||||||
|
// Simple filesystem compatibility for GCC 8.x
|
||||||
|
#elif defined(__GNUC__) && __GNUC__ < 9
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
inline std::string getSocketFolder() {
|
||||||
|
const char* tmpdir = std::getenv("TMPDIR");
|
||||||
|
return tmpdir ? std::string(tmpdir) : "/tmp";
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include <filesystem>
|
||||||
|
inline std::string getSocketFolder() {
|
||||||
|
return std::filesystem::temp_directory_path().string();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct sharedMemoryInfo_st {
|
typedef struct sharedMemoryInfo_st {
|
||||||
void *addr;
|
void *addr;
|
||||||
size_t size;
|
size_t size;
|
||||||
@@ -84,7 +105,7 @@ int waitProcess(Process *process);
|
|||||||
#define checkIpcErrors(ipcFuncResult) \
|
#define checkIpcErrors(ipcFuncResult) \
|
||||||
if (ipcFuncResult == -1) { fprintf(stderr, "Failure at %u %s\n", __LINE__, __FILE__); exit(EXIT_FAILURE); }
|
if (ipcFuncResult == -1) { fprintf(stderr, "Failure at %u %s\n", __LINE__, __FILE__); exit(EXIT_FAILURE); }
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__) || defined(__QNX__)
|
||||||
struct ipcHandle_st {
|
struct ipcHandle_st {
|
||||||
int socket;
|
int socket;
|
||||||
char *socketName;
|
char *socketName;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -399,10 +399,10 @@ int getInputDir(std::string &input_dir, const char *executable_path) {
|
|||||||
// Search in default paths for input images.
|
// Search in default paths for input images.
|
||||||
std::string pathname = "";
|
std::string pathname = "";
|
||||||
const char *searchPath[] = {
|
const char *searchPath[] = {
|
||||||
"./images", "../../../../Samples/<executable_name>/images",
|
"./images",
|
||||||
"../../../Samples/<executable_name>/images",
|
"../../../../cpp/4_CUDA_Libraries/<executable_name>/images",
|
||||||
"../../Samples/<executable_name>/images"};
|
"../../../cpp/4_CUDA_Libraries/<executable_name>/images",
|
||||||
|
"../../cpp/4_CUDA_Libraries/<executable_name>/images"};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) {
|
for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) {
|
||||||
std::string pathname(searchPath[i]);
|
std::string pathname(searchPath[i]);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -285,17 +285,82 @@ inline char *sdkFindFilePath(const char *filename,
|
|||||||
// the .exe file, a .bat file launching an .exe, a browser .exe launching the
|
// the .exe file, a .bat file launching an .exe, a browser .exe launching the
|
||||||
// .exe or .bat, etc
|
// .exe or .bat, etc
|
||||||
const char *searchPath[] = {
|
const char *searchPath[] = {
|
||||||
"./", // same dir
|
"./", // same dir
|
||||||
"./data/", // same dir
|
"./data/", // same dir
|
||||||
"../../../../Samples/<executable_name>/", // up 4 in tree
|
|
||||||
"../../../Samples/<executable_name>/", // up 3 in tree
|
"../../../../cpp/<executable_name>/", // up 4 in tree
|
||||||
"../../Samples/<executable_name>/", // up 2 in tree
|
"../../../cpp/<executable_name>/", // up 3 in tree
|
||||||
"../../../../Samples/<executable_name>/data/", // up 4 in tree
|
"../../cpp/<executable_name>/", // up 2 in tree
|
||||||
"../../../Samples/<executable_name>/data/", // up 3 in tree
|
|
||||||
"../../Samples/<executable_name>/data/", // up 2 in tree
|
"../../../../cpp/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/0_Introduction/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/0_Introduction/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/0_Introduction/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/1_Utilities/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/1_Utilities/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/1_Utilities/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/2_Concepts_and_Techniques/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/2_Concepts_and_Techniques/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/2_Concepts_and_Techniques/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/3_CUDA_Features/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/3_CUDA_Features/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/3_CUDA_Features/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/4_CUDA_Libraries/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/4_CUDA_Libraries/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/4_CUDA_Libraries/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/5_Domain_Specific/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/5_Domain_Specific/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/5_Domain_Specific/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/6_Performance/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/6_Performance/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/6_Performance/<executable_name>/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/0_Introduction/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/0_Introduction/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/0_Introduction/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/1_Utilities/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/1_Utilities/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/1_Utilities/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/2_Concepts_and_Techniques/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/2_Concepts_and_Techniques/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/2_Concepts_and_Techniques/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/3_CUDA_Features/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/3_CUDA_Features/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/3_CUDA_Features/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/4_CUDA_Libraries/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/4_CUDA_Libraries/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/4_CUDA_Libraries/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/5_Domain_Specific/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/5_Domain_Specific/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/5_Domain_Specific/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/6_Performance/<executable_name>/data/", // up 4 in tree
|
||||||
|
"../../../cpp/6_Performance/<executable_name>/data/", // up 3 in tree
|
||||||
|
"../../cpp/6_Performance/<executable_name>/data/", // up 2 in tree
|
||||||
|
|
||||||
"../../../../Common/data/", // up 4 in tree
|
"../../../../Common/data/", // up 4 in tree
|
||||||
"../../../Common/data/", // up 3 in tree
|
"../../../Common/data/", // up 3 in tree
|
||||||
"../../Common/data/" // up 2 in tree
|
"../../Common/data/", // up 2 in tree
|
||||||
|
|
||||||
|
"../../../../cpp/9_CUDA_Tile/<executable_name>/", // up 4 in tree
|
||||||
|
"../../../cpp/9_CUDA_Tile/<executable_name>/", // up 3 in tree
|
||||||
|
"../../cpp/9_CUDA_Tile/<executable_name>/", // up 2 in tree
|
||||||
|
"../cpp/9_CUDA_Tile/<executable_name>/", // up 1 in tree
|
||||||
|
"./cpp/9_CUDA_Tile/<executable_name>/" // up 0 in tree
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract the executable name
|
// Extract the executable name
|
||||||
@@ -362,6 +427,7 @@ inline char *sdkFindFilePath(const char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// File not found
|
// File not found
|
||||||
|
printf("\nerror: sdkFindFilePath: file <%s> not found!\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -258,7 +258,7 @@ namespace nv
|
|||||||
s[2] = &r3[0];
|
s[2] = &r3[0];
|
||||||
s[3] = &r4[0];
|
s[3] = &r4[0];
|
||||||
|
|
||||||
register int i,j,p,jj;
|
int i,j,p,jj;
|
||||||
|
|
||||||
for (i=0; i<4; i++)
|
for (i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -49,6 +49,11 @@
|
|||||||
|
|
||||||
void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResult,
|
void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResult,
|
||||||
size_t *cubinResultSize, int requiresCGheaders) {
|
size_t *cubinResultSize, int requiresCGheaders) {
|
||||||
|
if (!filename) {
|
||||||
|
std::cerr << "\nerror: filename is empty for compileFileToCUBIN()!\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
std::ifstream inputFile(filename,
|
std::ifstream inputFile(filename,
|
||||||
std::ios::in | std::ios::binary | std::ios::ate);
|
std::ios::in | std::ios::binary | std::ios::ate);
|
||||||
|
|
||||||
@@ -111,7 +116,12 @@ void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResul
|
|||||||
|
|
||||||
compileOptions = "--include-path=";
|
compileOptions = "--include-path=";
|
||||||
|
|
||||||
std::string path = sdkFindFilePath(HeaderNames, argv[0]);
|
char *strPath = sdkFindFilePath(HeaderNames, argv[0]);
|
||||||
|
if (!strPath) {
|
||||||
|
std::cerr << "\nerror: header file " << HeaderNames << " not found!\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
std::string path = strPath;
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
std::size_t found = path.find(HeaderNames);
|
std::size_t found = path.find(HeaderNames);
|
||||||
path.erase(found);
|
path.erase(found);
|
||||||
@@ -120,6 +130,7 @@ void compileFileToCUBIN(char *filename, int argc, char **argv, char **cubinResul
|
|||||||
"\nCooperativeGroups headers not found, please install it in %s "
|
"\nCooperativeGroups headers not found, please install it in %s "
|
||||||
"sample directory..\n Exiting..\n",
|
"sample directory..\n Exiting..\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
compileOptions += path.c_str();
|
compileOptions += path.c_str();
|
||||||
compileParams[numCompileOptions] = reinterpret_cast<char *>(
|
compileParams[numCompileOptions] = reinterpret_cast<char *>(
|
||||||
@@ -176,6 +187,7 @@ CUmodule loadCUBIN(char *cubin, int argc, char **argv) {
|
|||||||
CUcontext context;
|
CUcontext context;
|
||||||
int major = 0, minor = 0;
|
int major = 0, minor = 0;
|
||||||
char deviceName[256];
|
char deviceName[256];
|
||||||
|
CUctxCreateParams ctxCreateParams = {};
|
||||||
|
|
||||||
// Picks the best CUDA device available
|
// Picks the best CUDA device available
|
||||||
CUdevice cuDevice = findCudaDeviceDRV(argc, (const char **)argv);
|
CUdevice cuDevice = findCudaDeviceDRV(argc, (const char **)argv);
|
||||||
@@ -189,7 +201,7 @@ CUmodule loadCUBIN(char *cubin, int argc, char **argv) {
|
|||||||
printf("> GPU Device has SM %d.%d compute capability\n", major, minor);
|
printf("> GPU Device has SM %d.%d compute capability\n", major, minor);
|
||||||
|
|
||||||
checkCudaErrors(cuInit(0));
|
checkCudaErrors(cuInit(0));
|
||||||
checkCudaErrors(cuCtxCreate(&context, 0, cuDevice));
|
checkCudaErrors(cuCtxCreate(&context, &ctxCreateParams, 0, cuDevice));
|
||||||
|
|
||||||
checkCudaErrors(cuModuleLoadData(&module, cubin));
|
checkCudaErrors(cuModuleLoadData(&module, cubin));
|
||||||
free(cubin);
|
free(cubin);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Utility funcs to wrap up saving a surface or the back buffer as a PPM file
|
|
||||||
// In addition, wraps up a threshold comparision of two PPMs.
|
|
||||||
//
|
|
||||||
// These functions are designed to be used to implement an automated QA testing
|
|
||||||
// for SDK samples.
|
|
||||||
//
|
|
||||||
// Author: Bryan Dudash
|
|
||||||
// Email: sdkfeedback@nvidia.com
|
|
||||||
//
|
|
||||||
// Copyright (c) NVIDIA Corporation. All rights reserved.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <helper_functions.h>
|
|
||||||
#include <rendercheck_d3d10.h>
|
|
||||||
|
|
||||||
HRESULT CheckRenderD3D10::ActiveRenderTargetToPPM(ID3D10Device *pDevice,
|
|
||||||
const char *zFileName) {
|
|
||||||
ID3D10RenderTargetView *pRTV = NULL;
|
|
||||||
pDevice->OMGetRenderTargets(1, &pRTV, NULL);
|
|
||||||
|
|
||||||
ID3D10Resource *pSourceResource = NULL;
|
|
||||||
pRTV->GetResource(&pSourceResource);
|
|
||||||
|
|
||||||
return ResourceToPPM(pDevice, pSourceResource, zFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT CheckRenderD3D10::ResourceToPPM(ID3D10Device *pDevice,
|
|
||||||
ID3D10Resource *pResource,
|
|
||||||
const char *zFileName) {
|
|
||||||
D3D10_RESOURCE_DIMENSION rType;
|
|
||||||
pResource->GetType(&rType);
|
|
||||||
|
|
||||||
if (rType != D3D10_RESOURCE_DIMENSION_TEXTURE2D) {
|
|
||||||
printf("SurfaceToPPM: pResource is not a 2D texture! Aborting...\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ID3D10Texture2D *pSourceTexture = (ID3D10Texture2D *)pResource;
|
|
||||||
ID3D10Texture2D *pTargetTexture = NULL;
|
|
||||||
|
|
||||||
D3D10_TEXTURE2D_DESC desc;
|
|
||||||
pSourceTexture->GetDesc(&desc);
|
|
||||||
desc.BindFlags = 0;
|
|
||||||
desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
|
|
||||||
desc.Usage = D3D10_USAGE_STAGING;
|
|
||||||
|
|
||||||
if (FAILED(pDevice->CreateTexture2D(&desc, NULL, &pTargetTexture))) {
|
|
||||||
printf(
|
|
||||||
"SurfaceToPPM: Unable to create target Texture resoruce! Aborting... "
|
|
||||||
"\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pDevice->CopyResource(pTargetTexture, pSourceTexture);
|
|
||||||
|
|
||||||
D3D10_MAPPED_TEXTURE2D mappedTex2D;
|
|
||||||
pTargetTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex2D);
|
|
||||||
|
|
||||||
// Need to convert from dx pitch to pitch=width
|
|
||||||
unsigned char *pPPMData = new unsigned char[desc.Width * desc.Height * 4];
|
|
||||||
|
|
||||||
for (unsigned int iHeight = 0; iHeight < desc.Height; iHeight++) {
|
|
||||||
memcpy(
|
|
||||||
&(pPPMData[iHeight * desc.Width * 4]),
|
|
||||||
(unsigned char *)(mappedTex2D.pData) + iHeight * mappedTex2D.RowPitch,
|
|
||||||
desc.Width * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
pTargetTexture->Unmap(0);
|
|
||||||
|
|
||||||
// Prepends the PPM header info and bumps byte data afterwards
|
|
||||||
sdkSavePPM4ub(zFileName, pPPMData, desc.Width, desc.Height);
|
|
||||||
|
|
||||||
delete[] pPPMData;
|
|
||||||
pTargetTexture->Release();
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckRenderD3D10::PPMvsPPM(const char *src_file, const char *ref_file,
|
|
||||||
const char *exec_path, const float epsilon,
|
|
||||||
const float threshold) {
|
|
||||||
char *ref_file_path = sdkFindFilePath(ref_file, exec_path);
|
|
||||||
|
|
||||||
if (ref_file_path == NULL) {
|
|
||||||
printf(
|
|
||||||
"CheckRenderD3D10::PPMvsPPM unable to find <%s> in <%s> Aborting "
|
|
||||||
"comparison!\n",
|
|
||||||
ref_file, exec_path);
|
|
||||||
printf(">>> Check info.xml and [project//data] folder <%s> <<<\n",
|
|
||||||
ref_file);
|
|
||||||
printf("Aborting comparison!\n");
|
|
||||||
printf(" FAILURE!\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (sdkComparePPM(src_file, ref_file_path, epsilon, threshold, true) ==
|
|
||||||
true);
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef _RENDERCHECK_D3D10_H_
|
|
||||||
#define _RENDERCHECK_D3D10_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <d3d10.h>
|
|
||||||
|
|
||||||
class CheckRenderD3D10 {
|
|
||||||
public:
|
|
||||||
CheckRenderD3D10() {}
|
|
||||||
|
|
||||||
static HRESULT ActiveRenderTargetToPPM(ID3D10Device *pDevice,
|
|
||||||
const char *zFileName);
|
|
||||||
static HRESULT ResourceToPPM(ID3D10Device *pDevice, ID3D10Resource *pResource,
|
|
||||||
const char *zFileName);
|
|
||||||
|
|
||||||
static bool PPMvsPPM(const char *src_file, const char *ref_file,
|
|
||||||
const char *exec_path, const float epsilon,
|
|
||||||
const float threshold = 0.0f);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
@@ -1,167 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Utility funcs to wrap up savings a surface or the back buffer as a PPM file
|
|
||||||
// In addition, wraps up a threshold comparision of two PPMs.
|
|
||||||
//
|
|
||||||
// These functions are designed to be used to implement an automated QA testing
|
|
||||||
// for SDK samples.
|
|
||||||
//
|
|
||||||
// Author: Bryan Dudash
|
|
||||||
// Email: sdkfeedback@nvidia.com
|
|
||||||
//
|
|
||||||
// Copyright (c) NVIDIA Corporation. All rights reserved.
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <helper_functions.h>
|
|
||||||
#include <rendercheck_d3d9.h>
|
|
||||||
|
|
||||||
// originally copied from checkrender_gl.cpp and slightly modified
|
|
||||||
bool CheckRenderD3D9::PPMvsPPM(const char *src_file, const char *ref_file,
|
|
||||||
const char *exec_path, const float epsilon,
|
|
||||||
const float threshold) {
|
|
||||||
char *ref_file_path = sdkFindFilePath(ref_file, exec_path);
|
|
||||||
|
|
||||||
if (ref_file_path == NULL) {
|
|
||||||
printf(
|
|
||||||
"CheckRenderD3D9::PPMvsPPM unable to find <%s> in <%s> Aborting "
|
|
||||||
"comparison!\n",
|
|
||||||
ref_file, exec_path);
|
|
||||||
printf(">>> Check info.xml and [project//data] folder <%s> <<<\n",
|
|
||||||
ref_file);
|
|
||||||
printf("Aborting comparison!\n");
|
|
||||||
printf(" FAILURE!\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (sdkComparePPM(src_file, ref_file_path, epsilon, threshold, true) ==
|
|
||||||
true);
|
|
||||||
};
|
|
||||||
|
|
||||||
HRESULT CheckRenderD3D9::BackbufferToPPM(IDirect3DDevice9 *pDevice,
|
|
||||||
const char *zFileName) {
|
|
||||||
IDirect3DSurface9 *pSurface = NULL;
|
|
||||||
|
|
||||||
if (FAILED(
|
|
||||||
pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pSurface))) {
|
|
||||||
printf("Unable to get the back buffer. Aborting...\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// D3DXSaveSurfaceToFile("C:\\bing.dds",D3DXIFF_DDS,pSurface,NULL,NULL);
|
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
|
||||||
hr = SurfaceToPPM(pDevice, pSurface, zFileName);
|
|
||||||
|
|
||||||
pSurface->Release();
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT CheckRenderD3D9::SurfaceToPPM(IDirect3DDevice9 *pDevice,
|
|
||||||
IDirect3DSurface9 *pSurface,
|
|
||||||
const char *zFileName) {
|
|
||||||
D3DSURFACE_DESC pDesc;
|
|
||||||
pSurface->GetDesc(&pDesc);
|
|
||||||
|
|
||||||
// $$ For now only support common 8bit formats. TODO: support for more
|
|
||||||
// complex formats via conversion?
|
|
||||||
if (!(pDesc.Format == D3DFMT_A8R8G8B8 || pDesc.Format == D3DFMT_X8R8G8B8)) {
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDirect3DTexture9 *pTargetTex = NULL;
|
|
||||||
|
|
||||||
if (FAILED(pDevice->CreateTexture(pDesc.Width, pDesc.Height, 1,
|
|
||||||
D3DUSAGE_DYNAMIC, pDesc.Format,
|
|
||||||
D3DPOOL_SYSTEMMEM, &pTargetTex, NULL))) {
|
|
||||||
printf("Unable to create texture for surface transfer! Aborting...\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDirect3DSurface9 *pTargetSurface = NULL;
|
|
||||||
|
|
||||||
if (FAILED(pTargetTex->GetSurfaceLevel(0, &pTargetSurface))) {
|
|
||||||
printf("Unable to get surface for surface transfer! Aborting...\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is required because we cannot lock a D3DPOOL_DEAULT surface directly.
|
|
||||||
// So, we copy to our sysmem surface.
|
|
||||||
if (FAILED(pDevice->GetRenderTargetData(pSurface, pTargetSurface))) {
|
|
||||||
printf(
|
|
||||||
"Unable to GetRenderTargetData() for surface transfer! Aborting...\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
D3DLOCKED_RECT lockedRect;
|
|
||||||
HRESULT hr = pTargetSurface->LockRect(&lockedRect, NULL, 0);
|
|
||||||
|
|
||||||
// Need to convert from dx pitch to pitch=width
|
|
||||||
//
|
|
||||||
// $ PPM is BGR and not RGB it seems. Saved image looks "funny" in viewer(red
|
|
||||||
// and blue swapped), but since ref will be dumped using same method, this is
|
|
||||||
// ok.
|
|
||||||
// however, if we want the saved image to be properly colored, then we
|
|
||||||
// can swizzle the color bytes here.
|
|
||||||
unsigned char *pPPMData = new unsigned char[pDesc.Width * pDesc.Height * 4];
|
|
||||||
|
|
||||||
for (unsigned int iHeight = 0; iHeight < pDesc.Height; iHeight++) {
|
|
||||||
#if 1 // swizzle to implment RGB to BGR conversion.
|
|
||||||
|
|
||||||
for (unsigned int iWidth = 0; iWidth < pDesc.Width; iWidth++) {
|
|
||||||
DWORD color = *(DWORD *)((unsigned char *)(lockedRect.pBits) +
|
|
||||||
iHeight * lockedRect.Pitch + iWidth * 4);
|
|
||||||
|
|
||||||
// R<->B, [7:0] <-> [23:16], swizzle
|
|
||||||
color = ((color & 0xFF) << 16) | (color & 0xFF00) |
|
|
||||||
((color & 0xFF0000) >> 16) | (color & 0xFF000000);
|
|
||||||
|
|
||||||
memcpy(&(pPPMData[(iHeight * pDesc.Width + iWidth) * 4]),
|
|
||||||
(unsigned char *)&color, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
memcpy(&(pPPMData[iHeight * pDesc.Width * 4]),
|
|
||||||
(unsigned char *)(lockedRect.pBits) + iHeight * lockedRect.Pitch,
|
|
||||||
pDesc.Width * 4);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
pTargetSurface->UnlockRect();
|
|
||||||
|
|
||||||
// Prepends the PPM header info and bumps byte data afterwards
|
|
||||||
sdkSavePPM4ub(zFileName, pPPMData, pDesc.Width, pDesc.Height);
|
|
||||||
|
|
||||||
delete[] pPPMData;
|
|
||||||
pTargetSurface->Release();
|
|
||||||
pTargetTex->Release();
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef _RENDERCHECK_D3D9_H_
|
|
||||||
#define _RENDERCHECK_D3D9_H_
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <d3d9.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
class CheckRenderD3D9 {
|
|
||||||
public:
|
|
||||||
CheckRenderD3D9() {}
|
|
||||||
|
|
||||||
static HRESULT BackbufferToPPM(IDirect3DDevice9 *pDevice,
|
|
||||||
const char *zFileName);
|
|
||||||
static HRESULT SurfaceToPPM(IDirect3DDevice9 *pDevice,
|
|
||||||
IDirect3DSurface9 *pSurface,
|
|
||||||
const char *zFileName);
|
|
||||||
|
|
||||||
static bool PPMvsPPM(const char *src_file, const char *ref_file,
|
|
||||||
const char *exec_path, const float epsilon,
|
|
||||||
const float threshold = 0.0f);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
/* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|||||||
1312
Common/rendercheck_gles.h
Normal file
1312
Common/rendercheck_gles.h
Normal file
File diff suppressed because it is too large
Load Diff
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions
|
modification, are permitted provided that the following conditions
|
||||||
|
|||||||
69
Makefile
69
Makefile
@@ -1,69 +0,0 @@
|
|||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
# * Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# * Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived
|
|
||||||
# from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
#
|
|
||||||
# CUDA Samples
|
|
||||||
#
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
TARGET_ARCH ?= $(shell uname -m)
|
|
||||||
|
|
||||||
# Project folders that contain CUDA samples
|
|
||||||
PROJECTS ?= $(shell find Samples -name Makefile)
|
|
||||||
|
|
||||||
FILTER_OUT :=
|
|
||||||
|
|
||||||
PROJECTS := $(filter-out $(FILTER_OUT),$(PROJECTS))
|
|
||||||
|
|
||||||
%.ph_build :
|
|
||||||
+@$(MAKE) -C $(dir $*) $(MAKECMDGOALS)
|
|
||||||
|
|
||||||
%.ph_clean :
|
|
||||||
+@$(MAKE) -C $(dir $*) clean $(USE_DEVICE)
|
|
||||||
|
|
||||||
%.ph_clobber :
|
|
||||||
+@$(MAKE) -C $(dir $*) clobber $(USE_DEVICE)
|
|
||||||
|
|
||||||
%.ph_run :
|
|
||||||
+@$(MAKE) -C $(dir $*) run
|
|
||||||
|
|
||||||
all: $(addsuffix .ph_build,$(PROJECTS))
|
|
||||||
@echo "Finished building CUDA samples"
|
|
||||||
|
|
||||||
build: $(addsuffix .ph_build,$(PROJECTS))
|
|
||||||
|
|
||||||
tidy:
|
|
||||||
@find * | egrep "#" | xargs rm -f
|
|
||||||
@find * | egrep "\~" | xargs rm -f
|
|
||||||
|
|
||||||
clean: tidy $(addsuffix .ph_clean,$(PROJECTS))
|
|
||||||
|
|
||||||
clobber: clean $(addsuffix .ph_clobber,$(PROJECTS))
|
|
||||||
|
|
||||||
run: $(addsuffix .ph_run,$(PROJECTS))
|
|
||||||
786
README.md
786
README.md
@@ -1,130 +1,20 @@
|
|||||||
# CUDA Samples
|
# CUDA Samples
|
||||||
|
|
||||||
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads).
|
Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports [CUDA Toolkit 13.4](https://developer.nvidia.com/cuda-downloads).
|
||||||
|
|
||||||
## Release Notes
|
## Release Notes
|
||||||
|
|
||||||
This section describes the release notes for the CUDA Samples on GitHub only.
|
This section describes the release notes for the CUDA Samples on GitHub only.
|
||||||
|
|
||||||
### CUDA 11.5
|
### Change Log
|
||||||
* Added `cuDLAHybridMode`. Demonstrate usage of cuDLA in hybrid mode.
|
|
||||||
* Added `cuDLAStandaloneMode`. Demonstrate usage of cuDLA in standalone mode.
|
|
||||||
* Added `cuDLAErrorReporting`. Demonstrate DLA error detection via CUDA.
|
|
||||||
* Added `graphMemoryNodes`. Demonstrates memory allocations and frees within CUDA graphs using Graph APIs and Stream Capture APIs.
|
|
||||||
* Added `graphMemoryFootprint`. Demonstrates how graph memory nodes re-use virtual addresses and physical memory.
|
|
||||||
* All samples from CUDA toolkit are now available on [GitHub](https://github.com/nvidia/cuda-samples).
|
|
||||||
|
|
||||||
### CUDA 11.4 update 1
|
### [Revision History](./CHANGELOG.md)
|
||||||
* Added support for VS Code on linux platform.
|
|
||||||
|
|
||||||
### CUDA 11.4
|
|
||||||
* Added `cdpQuadtree`. Demonstrates Quad Trees implementation using CUDA Dynamic Parallelism.
|
|
||||||
* Updated `simpleVulkan`, `simpleVulkanMMAP` and `vulkanImageCUDA`. Demonstrates use of SPIR-V shaders.
|
|
||||||
|
|
||||||
### CUDA 11.3
|
|
||||||
* Added `streamOrderedAllocationIPC`. Demonstrates Inter Process Communication using one process per GPU for computation.
|
|
||||||
* Added `simpleCUBLAS_LU`. Demonstrates batched matrix LU decomposition using cuBLAS API `cublas<t>getrfBatched()`
|
|
||||||
* Updated `simpleVulkan`. Demonstrates use of timeline semaphore.
|
|
||||||
* Updated multiple samples to use pinned memory using `cudaMallocHost()`.
|
|
||||||
|
|
||||||
### CUDA 11.2
|
|
||||||
* Added `streamOrderedAllocation`. Demonstrates stream ordered memory allocation on a GPU using cudaMallocAsync and cudaMemPool family of APIs.
|
|
||||||
* Added `streamOrderedAllocationP2P`. Demonstrates peer-to-peer access of stream ordered memory allocated using cudaMallocAsync and cudaMemPool family of APIs.
|
|
||||||
* Dropped Visual Studio 2015 support from all the windows supported samples.
|
|
||||||
* FreeImage is no longer distributed with the CUDA Samples. On Windows, see the [Dependencies](#freeimage) section for more details on how to set up FreeImage. On Linux, it is recommended to install FreeImage with your distribution's package manager.
|
|
||||||
* All the samples using CUDA Pipeline & Arrive-wait barriers are been updated to use new `cuda::pipeline` and `cuda::barrier` interfaces.
|
|
||||||
* Updated all the samples to build with parallel build option `--threads` of `nvcc` cuda compiler.
|
|
||||||
* Added `cudaNvSciNvMedia`. Demonstrates CUDA-NvMedia interop via NvSciBuf/NvSciSync APIs.
|
|
||||||
* Added `simpleGL`. Demonstrates interoperability between CUDA and OpenGL.
|
|
||||||
|
|
||||||
### CUDA 11.1
|
|
||||||
* Added `watershedSegmentationNPP`. Demonstrates how to use the NPP watershed segmentation function.
|
|
||||||
* Added `batchedLabelMarkersAndLabelCompressionNPP`. Demonstrates how to use the NPP label markers generation and label compression functions based on a Union Find (UF) algorithm including both single image and batched image versions.
|
|
||||||
* Dropped Visual Studio 2012, 2013 support from all the windows supported samples.
|
|
||||||
* Added kernel performing warp aggregated atomic max in multi buckets using cg::labeled_partition & cg::reduce in `warpAggregatedAtomicsCG`.
|
|
||||||
* Added extended CG shuffle mechanics to `shfl_scan` sample.
|
|
||||||
* Added `cudaOpenMP`. Demonstrates how to use OpenMP API to write an application for multiple GPUs.
|
|
||||||
* Added `simpleZeroCopy`. Demonstrates how to use zero copy, kernels can read and write directly to pinned system memory.
|
|
||||||
|
|
||||||
### CUDA 11.0
|
|
||||||
* Added `dmmaTensorCoreGemm`. Demonstrates double precision GEMM computation using the Double precision Warp Matrix Multiply and Accumulate (WMMA) API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `bf16TensorCoreGemm`. Demonstrates __nv_bfloat16 (e8m7) GEMM computation using the __nv_bfloat16 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `tf32TensorCoreGemm`. Demonstrates tf32 (e8m10) GEMM computation using the tf32 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.
|
|
||||||
* Added `globalToShmemAsyncCopy`. Demonstrates async copy of data from global to shared memory when on compute capability 8.0 or higher. Also demonstrates arrive-wait barrier for synchronization.
|
|
||||||
* Added `simpleAWBarrier`. Demonstrates arrive wait barriers.
|
|
||||||
* Added `simpleAttributes`. Demonstrates the stream attributes that affect L2 locality.
|
|
||||||
* Added warp aggregated atomic multi bucket increments kernel using labeled_partition cooperative groups in `warpAggregatedAtomicsCG` which can be used on compute capability 7.0 and above GPU architectures.
|
|
||||||
* Added `binaryPartitionCG`. Demonstrates binary partition cooperative groups and reduction within the thread block.
|
|
||||||
* Added two new reduction kernels in `reduction` one which demonstrates reduce_add_sync intrinstic supported on compute capability 8.0 and another which uses cooperative_groups::reduce function which does thread_block_tile level reduction introduced from CUDA 11.0.
|
|
||||||
* Added `cudaCompressibleMemory`. Demonstrates compressible memory allocation using cuMemMap API.
|
|
||||||
* Added `simpleVulkanMMAP`. Demonstrates Vulkan CUDA Interop via cuMemMap APIs.
|
|
||||||
* Added `concurrentKernels`. Demonstrates the use of CUDA streams for concurrent execution of several kernels on a GPU.
|
|
||||||
* Dropped Mac OSX support from all samples.
|
|
||||||
|
|
||||||
### CUDA 10.2
|
|
||||||
* Added `simpleD3D11`. Demonstrates CUDA-D3D11 External Resource Interoperability APIs for updating D3D11 buffers from CUDA and synchronization between D3D11 and CUDA with Keyed Mutexes.
|
|
||||||
* Added `simpleDrvRuntime`. Demonstrates CUDA Driver and Runtime APIs working together to load fatbinary of a CUDA kernel.
|
|
||||||
* Added `vectorAddMMAP`. Demonstrates how cuMemMap API allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access.
|
|
||||||
* Added `memMapIPCDrv`. Demonstrates Inter Process Communication using cuMemMap APIs.
|
|
||||||
* Added `cudaNvSci`. Demonstrates CUDA-NvSciBuf/NvSciSync Interop.
|
|
||||||
* Added `jacobiCudaGraphs`. Demonstrates Instantiated CUDA Graph Update with Jacobi Iterative Method using different approaches.
|
|
||||||
* Added `cuSolverSp_LinearSolver`. Demonstrates cuSolverSP's LU, QR and Cholesky factorization.
|
|
||||||
* Added `MersenneTwisterGP11213`. Demonstrates the Mersenne Twister random number generator GP11213 in cuRAND.
|
|
||||||
|
|
||||||
### CUDA 10.1 Update 2
|
|
||||||
* Added `vulkanImageCUDA`. Demonstrates how to perform Vulkan image - CUDA Interop.
|
|
||||||
* Added `nvJPEG_encoder`. Demonstrates encoding of jpeg images using NVJPEG Library.
|
|
||||||
* Added Windows OS support to `nvJPEG` sample.
|
|
||||||
* Added `boxFilterNPP`. Demonstrates how to use NPP FilterBox function to perform a box filter.
|
|
||||||
* Added `cannyEdgeDetectorNPP`. Demonstrates the nppiFilterCannyBorder_8u_C1R Canny Edge Detection image filter function.
|
|
||||||
|
|
||||||
### CUDA 10.1 Update 1
|
|
||||||
* Added `NV12toBGRandResize`. Demonstrates how to convert and resize NV12 frames to BGR planars frames using CUDA in batch.
|
|
||||||
* Added `EGLStream_CUDA_Interop`. Demonstrates data exchange between CUDA and EGL Streams.
|
|
||||||
* Added `cuSolverDn_LinearSolver`. Demonstrates cuSolverDN's LU, QR and Cholesky factorization.
|
|
||||||
* Added support of Visual Studio 2019 to all samples supported on [Windows](#windows-1).
|
|
||||||
|
|
||||||
### CUDA 10.1
|
|
||||||
* Added `immaTensorCoreGemm`. Demonstrates integer GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API for integers employing the Tensor Cores.
|
|
||||||
* Added `simpleIPC`. Demonstrates Inter Process Communication with one process per GPU for computation.
|
|
||||||
* Added `nvJPEG`. Demonstrates single and batched decoding of jpeg images using NVJPEG Library.
|
|
||||||
* Added `bandwidthTest`. It measures the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e.
|
|
||||||
* Added `reduction`. Demonstrates several important optimization strategies for Data-Parallel Algorithms like reduction.
|
|
||||||
* Update all the samples to support CUDA 10.1.
|
|
||||||
|
|
||||||
### CUDA 10.0
|
|
||||||
* Added `simpleCudaGraphs`. Demonstrates CUDA Graphs creation, instantiation and launch using Graphs APIs and Stream Capture APIs.
|
|
||||||
* Added `conjugateGradientCudaGraphs`. Demonstrates conjugate gradient solver on GPU using CUBLAS and CUSPARSE library calls captured and called using CUDA Graph APIs.
|
|
||||||
* Added `simpleVulkan`. Demonstrates Vulkan - CUDA Interop.
|
|
||||||
* Added `simpleD3D12`. Demonstrates DX12 - CUDA Interop.
|
|
||||||
* Added `UnifiedMemoryPerf`. Demonstrates performance comparision of various memory types involved in system.
|
|
||||||
* Added `p2pBandwidthLatencyTest`. Demonstrates Peer-To-Peer (P2P) data transfers between pairs of GPUs and computes latency and bandwidth.
|
|
||||||
* Added `systemWideAtomics`. Demonstrates system wide atomic instructions.
|
|
||||||
* Added `simpleCUBLASXT`. Demonstrates CUBLAS-XT library which performs GEMM operations over multiple GPUs.
|
|
||||||
* Added Windows OS support to `conjugateGradientMultiDeviceCG` sample.
|
|
||||||
* Removed support of Visual Studio 2010 from all samples.
|
|
||||||
|
|
||||||
### CUDA 9.2
|
|
||||||
|
|
||||||
This is the first release of CUDA Samples on GitHub:
|
|
||||||
* Added `vectorAdd_nvrtc`. Demonstrates runtime compilation library using NVRTC of a simple vectorAdd kernel.
|
|
||||||
* Added `warpAggregatedAtomicsCG`. Demonstrates warp aggregated atomics using Cooperative Groups.
|
|
||||||
* Added `deviceQuery`. Enumerates the properties of the CUDA devices present in the system.
|
|
||||||
* Added `matrixMul`. Demonstrates a matrix multiplication using shared memory through tiled approach.
|
|
||||||
* Added `matrixMulDrv`. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.
|
|
||||||
* Added `cudaTensorCoreGemm`. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.
|
|
||||||
* Added `simpleVoteIntrinsics` which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.
|
|
||||||
* Added `shfl_scan` which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.
|
|
||||||
* Added `conjugateGradientMultiBlockCG`. Demonstrates a conjugate gradient solver on GPU using Multi Block Cooperative Groups.
|
|
||||||
* Added `conjugateGradientMultiDeviceCG`. Demonstrates a conjugate gradient solver on multiple GPUs using Multi Device Cooperative Groups, also uses unified memory prefetching and usage hints APIs.
|
|
||||||
* Added `simpleCUBLAS`. Demonstrates how perform GEMM operations using CUBLAS library.
|
|
||||||
* Added `simpleCUFFT`. Demonstrates how perform FFT operations using CUFFT library.
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
Download and install the [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
||||||
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), and the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html).
|
For system requirements and installation instructions of cuda toolkit, please refer to the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/), and the [Windows Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html).
|
||||||
|
|
||||||
### Getting the CUDA Samples
|
### Getting the CUDA Samples
|
||||||
@@ -138,147 +28,517 @@ Without using git the easiest way to use these samples is to download the zip fi
|
|||||||
|
|
||||||
## Building CUDA Samples
|
## Building CUDA Samples
|
||||||
|
|
||||||
### Windows
|
The CUDA Samples are built using CMake. Follow the instructions below for building on Linux, Windows, and for cross-compilation to Tegra devices.
|
||||||
|
|
||||||
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
|
||||||
```
|
|
||||||
*_vs<version>.sln - for Visual Studio <version>
|
|
||||||
```
|
|
||||||
Complete samples solution files exist at parent directory of the repo:
|
|
||||||
|
|
||||||
Each individual sample has its own set of solution files at:
|
|
||||||
`<CUDA_SAMPLES_REPO>\Samples\<sample_dir>\`
|
|
||||||
|
|
||||||
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
|
||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
|
||||||
```
|
|
||||||
$ cd <sample_dir>
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
The samples makefiles can take advantage of certain options:
|
|
||||||
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
|
|
||||||
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
|
||||||
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
|
||||||
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details on cross platform compilation of cuda samples.
|
|
||||||
* **dbg=1** - build with debug symbols
|
|
||||||
```
|
|
||||||
$ make dbg=1
|
|
||||||
```
|
|
||||||
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
|
||||||
```
|
|
||||||
$ make SMS="50 60"
|
|
||||||
```
|
|
||||||
|
|
||||||
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
Ensure that CMake (version 3.20 or later) is installed. Install it using your package manager if necessary:
|
||||||
```
|
|
||||||
$ make HOST_COMPILER=g++
|
e.g.
|
||||||
```
|
```sudo apt install cmake```
|
||||||
|
|
||||||
|
Navigate to the root of the cloned repository and create a build directory:
|
||||||
|
```
|
||||||
|
mkdir build && cd build
|
||||||
|
```
|
||||||
|
Configure the project with CMake:
|
||||||
|
```
|
||||||
|
cmake ..
|
||||||
|
```
|
||||||
|
Build the samples:
|
||||||
|
```
|
||||||
|
make -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, samples are compiled for all GPU architectures supported by this release. If you only need to target a specific GPU, you can override this to build for a single architecture and reduce build time considerably:
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_CUDA_ARCHITECTURES=<arch> ..
|
||||||
|
```
|
||||||
|
Replace `<arch>` with your GPU's SM version (e.g. `90` for sm_90).
|
||||||
|
|
||||||
|
Run the samples from their respective directories in the build folder.
|
||||||
|
|
||||||
|
### Building a Single Sample
|
||||||
|
|
||||||
|
To build just one sample, configure CMake from within the sample's directory. You must explicitly specify a GPU architecture — standalone builds have no top-level default:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd cpp/<category>/<sampleName>
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake -DCMAKE_CUDA_ARCHITECTURES=<arch> ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `<arch>` with your GPU's SM version (e.g. `90` for sm_90).
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
Language services for CMake are available in Visual Studio 2019 version 16.5 or later, and you can directly import the CUDA samples repository from either the root level or from any
|
||||||
|
subdirectory or individual sample.
|
||||||
|
|
||||||
|
To build from the command line, open the `x64 Native Tools Command Prompt for VS` provided with your Visual Studio installation.
|
||||||
|
|
||||||
|
Navigate to the root of the cloned repository and create a build directory:
|
||||||
|
```
|
||||||
|
mkdir build && cd build
|
||||||
|
```
|
||||||
|
Configure the project with CMake - for example:
|
||||||
|
```
|
||||||
|
cmake .. -G "Visual Studio 16 2019" -A x64
|
||||||
|
```
|
||||||
|
Open the generated solution file CUDA_Samples.sln in Visual Studio. Build the samples by selecting the desired configuration (e.g., Debug or Release) and pressing F7 (Build Solution).
|
||||||
|
|
||||||
|
Run the samples from the output directories specified in Visual Studio.
|
||||||
|
|
||||||
|
### Enabling On-GPU Debugging
|
||||||
|
|
||||||
|
NVIDIA GPUs support on-GPU debugging through cuda-gdb. Enabling this may significantly affect application performance as certain compiler optimizations are disabled
|
||||||
|
in this configuration, hence it's not on by default. Enablement of on-device debugging is controlled via the `-G` switch to nvcc.
|
||||||
|
|
||||||
|
To enable cuda-gdb for samples builds, define the `ENABLE_CUDA_DEBUG` flag on the CMake command line. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DENABLE_CUDA_DEBUG=True ...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Platform-Specific Samples
|
||||||
|
|
||||||
|
Some CUDA samples are specific to certain platforms, and require passing flags into CMake to enable. In particular, we define the following platform-specific flags:
|
||||||
|
|
||||||
|
* `BUILD_TEGRA` - for Tegra-specific samples
|
||||||
|
|
||||||
|
To build these samples, set the variables either on the command line or through your CMake GUI. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DBUILD_TEGRA=True ..
|
||||||
|
```
|
||||||
|
|
||||||
|
### Cross-Compilation for Tegra Platforms
|
||||||
|
|
||||||
|
Install the NVIDIA toolchain and cross-compilation environment for Tegra devices as described in the Tegra Development Guide.
|
||||||
|
|
||||||
|
Ensure that CMake (version 3.20 or later) is installed.
|
||||||
|
|
||||||
|
Navigate to the root of the cloned repository and create a build directory:
|
||||||
|
```
|
||||||
|
mkdir build && cd build
|
||||||
|
```
|
||||||
|
Configure the project with CMake, specifying the Tegra toolchain file. And you can use -DTARGET_FS to point to the target file system root path for necessary include and library files:
|
||||||
|
```
|
||||||
|
cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-linux.cmake -DTARGET_FS=/path/to/target/system/file/system
|
||||||
|
```
|
||||||
|
Build the samples:
|
||||||
|
```
|
||||||
|
make -j$(nproc)
|
||||||
|
```
|
||||||
|
Transfer the built binaries to the Tegra device and execute them there.
|
||||||
|
|
||||||
|
|
||||||
|
### Cross Building for Automotive Linux Platforms from the DriveOS Docker containers
|
||||||
|
|
||||||
|
To build CUDA samples to the target platform from the DriveOS Docker containers, use the following instructions.
|
||||||
|
|
||||||
|
Mount the target Root Filesystem (RFS) in the container so that the CUDA cmake process has the correct paths to CUDA and other system libraries required to build the samples.
|
||||||
|
|
||||||
|
Create a temporary directory, `<temp>` is any temporary directory of your choosing, for example, you can use `/drive/temp`:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir /drive/<temp>
|
||||||
|
```
|
||||||
|
|
||||||
|
Mount the filesystem by running the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mount /drive/drive-linux/filesystem/targetfs-images/dev_nsr_desktop_ubuntu-24.04_thor_rfs.img /drive/temp
|
||||||
|
```
|
||||||
|
|
||||||
|
Configure the project by running the following cmake command:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ mkdir build && cd build
|
||||||
|
$ cmake .. -DBUILD_TEGRA=True \
|
||||||
|
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-linux.cmake \
|
||||||
|
-DTARGET_FS=/drive/temp \
|
||||||
|
-DCMAKE_LIBRARY_PATH=/drive/temp/usr/local/cuda-13.1/thor/lib64/ \
|
||||||
|
-DCMAKE_INCLUDE_PATH=/drive/temp/usr/local/cuda-13.1/thor/include/
|
||||||
|
```
|
||||||
|
|
||||||
|
Please note that the following libraries are not pre-installed in the DriveOS dev-nsr target filesystem:
|
||||||
|
* libdrm-dev
|
||||||
|
* Vulkan
|
||||||
|
|
||||||
|
This causes the cmake command to throw errors related to the missing files, and as a result, the related samples will not build in later steps. This issue will be addressed in a future DriveOS release.
|
||||||
|
|
||||||
|
To build the samples with ignore the error mentioned above, you can use `--ignore-errors`/`--keep-going` or comment out the comment out the corresponding `add_subdirectory` command in the CMakeLists.txt in the parent folder for the samples requiring Vulkan and libdrm_dev:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ make -j$(nproc) --ignore-errors # or --keep-going
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
# In cpp/5_Domain_Specific/CMakeList.txt
|
||||||
|
# add_subdirectory(simpleGL)
|
||||||
|
# add_subdirectory(simpleVulkan)
|
||||||
|
# add_subdirectory(simpleVulkanMMAP)
|
||||||
|
|
||||||
|
# In cpp/8_Platform_Specific/Tegra/CMakeList.txt
|
||||||
|
# add_subdirectory(simpleGLES_EGLOutput)
|
||||||
|
```
|
||||||
|
|
||||||
|
### QNX
|
||||||
|
|
||||||
|
Cross-compilation for QNX with CMake is supported in the CUDA 13.0 samples release and newer.
|
||||||
|
|
||||||
|
Set up the QNX SDP paths:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export QNX_HOST=/path/to/qnx/host
|
||||||
|
export QNX_TARGET=/path/to/qnx/target
|
||||||
|
```
|
||||||
|
|
||||||
|
Build the samples for the Tegra Thor QNX platform:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. \
|
||||||
|
-DBUILD_TEGRA=True \
|
||||||
|
-DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.3/bin/nvcc \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/toolchain-aarch64-qnx.cmake \
|
||||||
|
-DTARGET_FS=/path/to/qnx/targetfs \
|
||||||
|
-DCMAKE_LIBRARY_PATH=/usr/local/cuda-13.3/thor/targets/aarch64-qnx/lib/stubs/ \
|
||||||
|
-DCMAKE_INCLUDE_PATH=/usr/local/cuda-13.3/thor/targets/aarch64-qnx/include/
|
||||||
|
cmake --build .
|
||||||
|
```
|
||||||
|
|
||||||
|
`TARGET_FS` is the QNX target filesystem of your board. The `cudaNvSci` sample needs it, because the NvSci headers and libraries ship with the target filesystem and not with the CUDA toolkit. Without `TARGET_FS` the build reports `NvSCI not found` and skips the sample.
|
||||||
|
|
||||||
|
The target filesystem is part of the NVIDIA DRIVE OS QNX SDK, which registered users download from [NVONLINE](https://partners.nvidia.com). After the SDK is installed, the filesystem is in the DRIVE OS workspace: `<NV_WORKSPACE>/drive-qnx` for the standard SDK and `<NV_WORKSPACE>/drive-qnx-safety` for the safety SDK. See the [DRIVE OS documentation](https://docs.nvidia.com/drive/) for the installation guides.
|
||||||
|
|
||||||
|
For both QNX toolchains the build looks for `nvscibuf.h` in `<TARGET_FS>/include`, `<TARGET_FS>/../include` and `<TARGET_FS>/usr/include`, and for `libnvscibuf.so` in `<TARGET_FS>/lib-target`, `<TARGET_FS>/usr/libnvidia` and `<TARGET_FS>/usr/lib`. If your filesystem uses a different layout, set `NVSCIBUF_INCLUDE_DIR`, `NVSCISYNC_INCLUDE_DIR`, `NVSCIBUF_LIBRARY` and `NVSCISYNC_LIBRARY` on the cmake command line instead.
|
||||||
|
|
||||||
|
### QNX Safety (CUDA Safe toolkit)
|
||||||
|
|
||||||
|
Cross-compilation for **QNX Safety** uses the CUDA Safe toolkit (for example `/usr/local/cuda-13.3-safe`).
|
||||||
|
|
||||||
|
Set up the QNX SDP and Safe toolkit paths:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export QNX_HOST=/path/to/qnx/host
|
||||||
|
export QNX_TARGET=/path/to/qnx/target
|
||||||
|
export CUDA_PATH=/usr/local/cuda-13.3-safe
|
||||||
|
export PATH=$CUDA_PATH/nvvm/bin:$PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
Build a single sample (standalone configure from the sample directory).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchains/toolchain-aarch64-qnx-safe.cmake \
|
||||||
|
-DCMAKE_CUDA_COMPILER=$CUDA_PATH/bin/nvcc \
|
||||||
|
-DCMAKE_CUDA_ARCHITECTURES=110 \
|
||||||
|
-DTARGET_FS=/path/to/qnx/safety/targetfs
|
||||||
|
cmake --build .
|
||||||
|
```
|
||||||
|
|
||||||
|
The safe toolchain sets `-safety-compat`, links shared `libcudart` and `libcuda`, and uses QNX `q++` as the CUDA host compiler (`CMAKE_CUDA_HOST_COMPILER`). Set `CMAKE_CUDA_ARCHITECTURES` to match your GPU (`87` for Orin, `110` for Thor).
|
||||||
|
|
||||||
|
Supported QNX Safety samples: `matrixMul`, `cudaNvSci`.
|
||||||
|
|
||||||
|
`TARGET_FS` is only needed for `cudaNvSci`, which links the NvSci libraries from the safety target filesystem (`<NV_WORKSPACE>/drive-qnx-safety`, part of the DRIVE OS QNX Safety SDK). `matrixMul` builds without it. The NvSci search paths are the same as for the standard QNX build above.
|
||||||
|
|
||||||
|
### Forward Compatibility
|
||||||
|
|
||||||
|
To build samples with new CUDA Toolkit(CUDA 13.0 or later) and UMD(Version 580 or later) and old KMD(Version 550 or earlier),you need to set the `CMAKE_PREFIX_PATH` for using new driver library, the command might like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_PREFIX_PATH=/usr/local/cuda/lib64/stubs/ ..
|
||||||
|
```
|
||||||
|
|
||||||
|
## CUDA Python samples
|
||||||
|
|
||||||
|
The repository includes **Python** examples under the [`python/`](./python) directory. **These samples are cuda.core–focused:** they use [CUDA Python](https://nvidia.github.io/cuda-python/), with [`cuda.core`](https://nvidia.github.io/cuda-python/cuda-core/latest/) for devices, programs, launches, and memory, alongside NumPy, CuPy, or framework interop where each sample notes.
|
||||||
|
|
||||||
|
**Layout (same themes as the C++ samples):**
|
||||||
|
|
||||||
|
| Directory | Contents |
|
||||||
|
|-----------|----------|
|
||||||
|
| `python/1_GettingStarted/` | Introductory scripts (e.g. `vectorAdd`, `deviceQuery`, `systemInfo`, image blur with unified memory, NumPy vs CuPy). |
|
||||||
|
| `python/2_CoreConcepts/` | Algorithms and techniques (e.g. reductions, histograms, FFT, stream overlap, `memoryResources`, `cudaGraphs`, `jitLtoLinking`, `tmaTensorMap`). |
|
||||||
|
| `python/3_FrameworkInterop/` | Integration with PyTorch and TensorFlow. |
|
||||||
|
| `python/4_DistributedComputing/` | Multi-GPU, peer-to-peer, and IPC patterns (`ipcMemoryPool`). |
|
||||||
|
| `python/Utilities/` | Shared helpers imported by some samples. |
|
||||||
|
|
||||||
|
**How to run:** The top-level CMake build does **not** compile these samples. For each sample, use a Python 3.10+ environment with a matching [CUDA Toolkit](https://developer.nvidia.com/cuda-downloads) (the samples target CUDA 13.x and document exact package pins in `requirements.txt`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd python/<category>/<sampleName>
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python <sampleScript>.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Use each sample’s `README.md` for prerequisites, CLI options, and expected output.
|
||||||
|
|
||||||
|
## Install Samples
|
||||||
|
|
||||||
|
### Installation Path Structure
|
||||||
|
|
||||||
|
The installation system automatically organizes samples into a structured directory layout based on:
|
||||||
|
- **Target Architecture**: ${CMAKE_SYSTEM_PROCESSOR}, e.g. `x64`, `aarch64`, `amd64`, etc.
|
||||||
|
- **Target OS**: `linux`, `windows`, `darwin`, `qnx`
|
||||||
|
- **Build Type**: `release`, `debug`, etc.
|
||||||
|
|
||||||
|
The default installation path is: `build/bin/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE}`
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
- Linux x86_64 Release: `build/bin/x64/linux/release`
|
||||||
|
- Linux aarch64 Release: `build/bin/aarch64/linux/release`
|
||||||
|
- Windows amd64 Release: `build/bin/amd64/windows/release`
|
||||||
|
|
||||||
|
### Customizing Installation Paths
|
||||||
|
|
||||||
|
You can customize the installation location using CMake variables during the configuration step:
|
||||||
|
|
||||||
|
- `CMAKE_INSTALL_PREFIX`: Changes the root installation directory (default: `build/bin`)
|
||||||
|
```
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=/custom/path ..
|
||||||
|
```
|
||||||
|
This will install to: `/custom/path/${TARGET_ARCH}/${TARGET_OS}/${BUILD_TYPE}`
|
||||||
|
|
||||||
|
- `CUDA_SAMPLES_INSTALL_DIR`: Specifies the exact final installation directory (overrides the structured path)
|
||||||
|
```
|
||||||
|
cmake -DCUDA_SAMPLES_INSTALL_DIR=/exact/install/path ..
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install Samples on Linux
|
||||||
|
|
||||||
|
**Prerequisites:** You must first configure the project with CMake as described in the [Building CUDA Samples - Linux](#linux) or [Building]section.
|
||||||
|
|
||||||
|
After configuring and building, install the samples:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd build/
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install Samples on Windows
|
||||||
|
|
||||||
|
**Prerequisites:** You must first configure the project with CMake as described in the [Building CUDA Samples - Windows](#windows) section.
|
||||||
|
|
||||||
|
#### Using Command Line
|
||||||
|
|
||||||
|
After configuring with CMake, build and install from the `x64 Native Tools Command Prompt for VS`:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
cd build
|
||||||
|
cmake --build . --config Release
|
||||||
|
cmake --install . --config Release
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Replace `Release` with `Debug` if you want to install debug builds. For multi-configuration generators (like Visual Studio), the `--config` flag determines which build type to install.
|
||||||
|
|
||||||
|
#### Using Visual Studio IDE
|
||||||
|
|
||||||
|
Alternatively, open the generated solution file `CUDA_Samples.sln` in Visual Studio:
|
||||||
|
1. Select the desired configuration (`Release` or `Debug`)
|
||||||
|
2. Build the solution (F7 or Build > Build Solution)
|
||||||
|
3. Right-click on the `INSTALL` target under `CMakePredefinedTargets` in Solution Explorer
|
||||||
|
4. Select "Build"
|
||||||
|
|
||||||
|
## Running All Samples as Tests
|
||||||
|
|
||||||
|
It's important to note that the CUDA samples are _not_ intended as a validation suite for CUDA. They do not cover corner cases, they do not completely cover the
|
||||||
|
runtime and driver APIs, are not intended for performance benchmarking, etc. That said, it can sometimes be useful to run all of the samples as a quick sanity check and
|
||||||
|
we provide a script to do so, `run_tests.py`.
|
||||||
|
|
||||||
|
This Python3 script finds all executables in a subdirectory you choose, matching application names with command line arguments specified in `test_args.json`. It accepts
|
||||||
|
the following command line arguments:
|
||||||
|
|
||||||
|
| Switch | Purpose | Example |
|
||||||
|
| ---------- | -------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
||||||
|
| --dir | Specify the root directory to search for executables (recursively) | --dir ./build/cpp |
|
||||||
|
| --config | JSON configuration file for executable arguments | --config test_args.json |
|
||||||
|
| --output | Output directory for test results (stdout saved to .txt files - directory will be created if it doesn't exist) | --output ./test |
|
||||||
|
| --args | Global arguments to pass to all executables (not currently used) | --args arg_1 arg_2 ... |
|
||||||
|
| --parallel | Number of applications to execute in parallel. | --parallel 8 |
|
||||||
|
|
||||||
|
|
||||||
|
Application configurations are loaded from `test_args.json` and matched against executable names (discarding the `.exe` extension on Windows).
|
||||||
|
|
||||||
|
The script returns 0 on success, or the first non-zero error code encountered during testing on failure. It will also print a condensed list of samples that failed, if any.
|
||||||
|
|
||||||
|
There are three primary modes of configuration:
|
||||||
|
|
||||||
|
**Skip**
|
||||||
|
|
||||||
|
An executable configured with "skip" will not be executed. These generally rely on having attached graphical displays and are not suited to this kind of automation.
|
||||||
|
|
||||||
|
Configuration example:
|
||||||
|
```json
|
||||||
|
"fluidsGL": {
|
||||||
|
"skip": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You will see:
|
||||||
|
```
|
||||||
|
Skipping fluidsGL (marked as skip in config)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Single Run**
|
||||||
|
|
||||||
|
For executables to run one time only with arguments, specify each argument as a list entry. Each entry in the JSON file will be appended to the command line, separated
|
||||||
|
by a space.
|
||||||
|
|
||||||
|
All applications execute from their current directory, so all paths are relative to the application's location.
|
||||||
|
|
||||||
|
Note that if an application needs no arguments, this entry is optional. An executable found without a matching entry in the JSON will just run as `./application` from its
|
||||||
|
current directory.
|
||||||
|
|
||||||
|
Configuration example:
|
||||||
|
```json
|
||||||
|
"ptxgen": {
|
||||||
|
"args": [
|
||||||
|
"test.ll",
|
||||||
|
"-arch=compute_75"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You will see:
|
||||||
|
```
|
||||||
|
Running ptxgen
|
||||||
|
Command: ./ptxgen test.ll -arch=compute_75
|
||||||
|
Test completed with return code 0
|
||||||
|
```
|
||||||
|
|
||||||
|
**Multiple Runs**
|
||||||
|
|
||||||
|
For executables to run multiple times with different command line arguments, specify any number of sets of args within a "runs" list.
|
||||||
|
|
||||||
|
As with single runs, all applications execute from their current directory, so all paths are relative to the application's location.
|
||||||
|
|
||||||
|
Configuration example:
|
||||||
|
```json
|
||||||
|
"recursiveGaussian": {
|
||||||
|
"runs": [
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-sigma=10",
|
||||||
|
"-file=data/ref_10.ppm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-sigma=14",
|
||||||
|
"-file=data/ref_14.ppm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-sigma=18",
|
||||||
|
"-file=data/ref_18.ppm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": [
|
||||||
|
"-sigma=22",
|
||||||
|
"-file=data/ref_22.ppm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You will see:
|
||||||
|
```
|
||||||
|
Running recursiveGaussian (run 1/4)
|
||||||
|
Command: ./recursiveGaussian -sigma=10 -file=data/ref_10.ppm
|
||||||
|
Test completed with return code 0
|
||||||
|
Running recursiveGaussian (run 2/4)
|
||||||
|
Command: ./recursiveGaussian -sigma=14 -file=data/ref_14.ppm
|
||||||
|
Test completed with return code 0
|
||||||
|
Running recursiveGaussian (run 3/4)
|
||||||
|
Command: ./recursiveGaussian -sigma=18 -file=data/ref_18.ppm
|
||||||
|
Test completed with return code 0
|
||||||
|
Running recursiveGaussian (run 4/4)
|
||||||
|
Command: ./recursiveGaussian -sigma=22 -file=data/ref_22.ppm
|
||||||
|
Test completed with return code 0
|
||||||
|
```
|
||||||
|
|
||||||
|
### Example Usage
|
||||||
|
|
||||||
|
Here is an example set of commands to build and test all of the samples.
|
||||||
|
|
||||||
|
First, build:
|
||||||
|
```bash
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make -j$(nproc)
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, return to the samples root directory and run the test script:
|
||||||
|
```bash
|
||||||
|
cd ..
|
||||||
|
python3 run_tests.py --output ./test --dir ./build/cpp --config test_args.json
|
||||||
|
```
|
||||||
|
|
||||||
|
If all applications run successfully, you will see something similar to this (the specific number of samples will depend on your build type
|
||||||
|
and system configuration):
|
||||||
|
|
||||||
|
```
|
||||||
|
Test Summary:
|
||||||
|
Ran 199 test runs for 180 executables.
|
||||||
|
All test runs passed!
|
||||||
|
```
|
||||||
|
|
||||||
|
If some samples fail, you will see something like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
Test Summary:
|
||||||
|
Ran 199 test runs for 180 executables.
|
||||||
|
Failed runs (2):
|
||||||
|
bicubicTexture (run 1/5): Failed (code 1)
|
||||||
|
Mandelbrot (run 1/2): Failed (code 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can inspect the stdout logs in the output directory (generally `APM_<application_name>.txt` or `APM_<application_name>.run<n>.txt`) to help
|
||||||
|
determine what may have gone wrong from the output logs. Please file issues against the samples repository if you believe a sample is failing
|
||||||
|
incorrectly on your system.
|
||||||
|
|
||||||
## Samples list
|
## Samples list
|
||||||
|
|
||||||
### Samples by OS
|
### [0. Introduction](./cpp/0_Introduction/README.md)
|
||||||
|
Basic CUDA samples for beginners that illustrate key concepts with using CUDA and CUDA runtime APIs.
|
||||||
|
|
||||||
#### Linux
|
### [1. Utilities](./cpp/1_Utilities/README.md)
|
||||||
**[simpleAssert_nvrtc](./Samples/simpleAssert_nvrtc)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[graphMemoryFootprint](./Samples/graphMemoryFootprint)** | **[MC_EstimatePiQ](./Samples/MC_EstimatePiQ)** |
|
Utility samples that demonstrate how to query device capabilities and measure GPU/CPU bandwidth.
|
||||||
---|---|---|---|
|
|
||||||
**[reductionMultiBlockCG](./Samples/reductionMultiBlockCG)** | **[cuDLAStandaloneMode](./Samples/cuDLAStandaloneMode)** | **[conjugateGradientPrecond](./Samples/conjugateGradientPrecond)** | **[ptxjit](./Samples/ptxjit)** |
|
|
||||||
**[threadMigration](./Samples/threadMigration)** | **[EGLStream_CUDA_CrossGPU](./Samples/EGLStream_CUDA_CrossGPU)** | **[threadFenceReduction](./Samples/threadFenceReduction)** | **[simpleAtomicIntrinsics_nvrtc](./Samples/simpleAtomicIntrinsics_nvrtc)** |
|
|
||||||
**[shfl_scan](./Samples/shfl_scan)** | **[clock](./Samples/clock)** | **[binaryPartitionCG](./Samples/binaryPartitionCG)** | **[MC_EstimatePiP](./Samples/MC_EstimatePiP)** |
|
|
||||||
**[transpose](./Samples/transpose)** | **[simpleMultiCopy](./Samples/simpleMultiCopy)** | **[cuDLAErrorReporting](./Samples/cuDLAErrorReporting)** | **[concurrentKernels](./Samples/concurrentKernels)** |
|
|
||||||
**[streamOrderedAllocationIPC](./Samples/streamOrderedAllocationIPC)** | **[UnifiedMemoryPerf](./Samples/UnifiedMemoryPerf)** | **[cppIntegration](./Samples/cppIntegration)** | **[bf16TensorCoreGemm](./Samples/bf16TensorCoreGemm)** |
|
|
||||||
**[cuSolverSp_LinearSolver](./Samples/cuSolverSp_LinearSolver)** | **[nvJPEG](./Samples/nvJPEG)** | **[watershedSegmentationNPP](./Samples/watershedSegmentationNPP)** | **[MC_EstimatePiInlineP](./Samples/MC_EstimatePiInlineP)** |
|
|
||||||
**[vulkanImageCUDA](./Samples/vulkanImageCUDA)** | **[boxFilterNPP](./Samples/boxFilterNPP)** | **[simpleAssert](./Samples/simpleAssert)** | **[simpleTemplates](./Samples/simpleTemplates)** |
|
|
||||||
**[cuHook](./Samples/cuHook)** | **[simpleCUDA2GL](./Samples/simpleCUDA2GL)** | **[matrixMul](./Samples/matrixMul)** | **[quasirandomGenerator_nvrtc](./Samples/quasirandomGenerator_nvrtc)** |
|
|
||||||
**[nvJPEG_encoder](./Samples/nvJPEG_encoder)** | **[simpleCudaGraphs](./Samples/simpleCudaGraphs)** | **[simpleTextureDrv](./Samples/simpleTextureDrv)** | **[simpleCUFFT](./Samples/simpleCUFFT)** |
|
|
||||||
**[simpleCallback](./Samples/simpleCallback)** | **[batchCUBLAS](./Samples/batchCUBLAS)** | **[cudaTensorCoreGemm](./Samples/cudaTensorCoreGemm)** | **[simpleAtomicIntrinsics](./Samples/simpleAtomicIntrinsics)** |
|
|
||||||
**[newdelete](./Samples/newdelete)** | **[bicubicTexture](./Samples/bicubicTexture)** | **[dxtc](./Samples/dxtc)** | **[cudaOpenMP](./Samples/cudaOpenMP)** |
|
|
||||||
**[cdpBezierTessellation](./Samples/cdpBezierTessellation)** | **[randomFog](./Samples/randomFog)** | **[bilateralFilter](./Samples/bilateralFilter)** | **[conjugateGradient](./Samples/conjugateGradient)** |
|
|
||||||
**[particles](./Samples/particles)** | **[NV12toBGRandResize](./Samples/NV12toBGRandResize)** | **[Mandelbrot](./Samples/Mandelbrot)** | **[binomialOptions_nvrtc](./Samples/binomialOptions_nvrtc)** |
|
|
||||||
**[cudaNvSci](./Samples/cudaNvSci)** | **[mergeSort](./Samples/mergeSort)** | **[HSOpticalFlow](./Samples/HSOpticalFlow)** | **[immaTensorCoreGemm](./Samples/immaTensorCoreGemm)** |
|
|
||||||
**[convolutionTexture](./Samples/convolutionTexture)** | **[simpleVulkan](./Samples/simpleVulkan)** | **[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[jacobiCudaGraphs](./Samples/jacobiCudaGraphs)** |
|
|
||||||
**[eigenvalues](./Samples/eigenvalues)** | **[streamOrderedAllocationP2P](./Samples/streamOrderedAllocationP2P)** | **[cuSolverSp_LowlevelCholesky](./Samples/cuSolverSp_LowlevelCholesky)** | **[topologyQuery](./Samples/topologyQuery)** |
|
|
||||||
**[dmmaTensorCoreGemm](./Samples/dmmaTensorCoreGemm)** | **[volumeRender](./Samples/volumeRender)** | **[stereoDisparity](./Samples/stereoDisparity)** | **[simpleTexture](./Samples/simpleTexture)** |
|
|
||||||
**[simpleStreams](./Samples/simpleStreams)** | **[smokeParticles](./Samples/smokeParticles)** | **[simpleMultiGPU](./Samples/simpleMultiGPU)** | **[deviceQueryDrv](./Samples/deviceQueryDrv)** |
|
|
||||||
**[fastWalshTransform](./Samples/fastWalshTransform)** | **[quasirandomGenerator](./Samples/quasirandomGenerator)** | **[vectorAddMMAP](./Samples/vectorAddMMAP)** | **[MersenneTwisterGP11213](./Samples/MersenneTwisterGP11213)** |
|
|
||||||
**[conjugateGradientUM](./Samples/conjugateGradientUM)** | **[simpleVoteIntrinsics_nvrtc](./Samples/simpleVoteIntrinsics_nvrtc)** | **[simpleLayeredTexture](./Samples/simpleLayeredTexture)** | **[streamOrderedAllocation](./Samples/streamOrderedAllocation)** |
|
|
||||||
**[cuSolverDn_LinearSolver](./Samples/cuSolverDn_LinearSolver)** | **[cudaCompressibleMemory](./Samples/cudaCompressibleMemory)** | **[matrixMulCUBLAS](./Samples/matrixMulCUBLAS)** | **[histEqualizationNPP](./Samples/histEqualizationNPP)** |
|
|
||||||
**[simpleAWBarrier](./Samples/simpleAWBarrier)** | **[recursiveGaussian](./Samples/recursiveGaussian)** | **[imageDenoising](./Samples/imageDenoising)** | **[FunctionPointers](./Samples/FunctionPointers)** |
|
|
||||||
**[simpleGL](./Samples/simpleGL)** | **[segmentationTreeThrust](./Samples/segmentationTreeThrust)** | **[scalarProd](./Samples/scalarProd)** | **[SobolQRNG](./Samples/SobolQRNG)** |
|
|
||||||
**[p2pBandwidthLatencyTest](./Samples/p2pBandwidthLatencyTest)** | **[conjugateGradientCudaGraphs](./Samples/conjugateGradientCudaGraphs)** | **[simplePitchLinearTexture](./Samples/simplePitchLinearTexture)** | **[freeImageInteropNPP](./Samples/freeImageInteropNPP)** |
|
|
||||||
**[template](./Samples/template)** | **[dwtHaar1D](./Samples/dwtHaar1D)** | **[postProcessGL](./Samples/postProcessGL)** | **[BlackScholes](./Samples/BlackScholes)** |
|
|
||||||
**[volumeFiltering](./Samples/volumeFiltering)** | **[simpleCUFFT_callback](./Samples/simpleCUFFT_callback)** | **[UnifiedMemoryStreams](./Samples/UnifiedMemoryStreams)** | **[globalToShmemAsyncCopy](./Samples/globalToShmemAsyncCopy)** |
|
|
||||||
**[deviceQuery](./Samples/deviceQuery)** | **[simpleHyperQ](./Samples/simpleHyperQ)** | **[systemWideAtomics](./Samples/systemWideAtomics)** | **[cuSolverSp_LowlevelQR](./Samples/cuSolverSp_LowlevelQR)** |
|
|
||||||
**[inlinePTX](./Samples/inlinePTX)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[EGLStream_CUDA_Interop](./Samples/EGLStream_CUDA_Interop)** | **[cuDLAHybridMode](./Samples/cuDLAHybridMode)** |
|
|
||||||
**[asyncAPI](./Samples/asyncAPI)** | **[MC_EstimatePiInlineQ](./Samples/MC_EstimatePiInlineQ)** | **[scan](./Samples/scan)** | **[simpleCooperativeGroups](./Samples/simpleCooperativeGroups)** |
|
|
||||||
**[conjugateGradientMultiBlockCG](./Samples/conjugateGradientMultiBlockCG)** | **[simpleTemplates_nvrtc](./Samples/simpleTemplates_nvrtc)** | **[simpleTexture3D](./Samples/simpleTexture3D)** | **[lineOfSight](./Samples/lineOfSight)** |
|
|
||||||
**[simpleZeroCopy](./Samples/simpleZeroCopy)** | **[binomialOptions](./Samples/binomialOptions)** | **[simpleAttributes](./Samples/simpleAttributes)** | **[bindlessTexture](./Samples/bindlessTexture)** |
|
|
||||||
**[simpleCUFFT_2d_MGPU](./Samples/simpleCUFFT_2d_MGPU)** | **[simplePrintf](./Samples/simplePrintf)** | **[batchedLabelMarkersAndLabelCompressionNPP](./Samples/batchedLabelMarkersAndLabelCompressionNPP)** | **[histogram](./Samples/histogram)** |
|
|
||||||
**[matrixMulDynlinkJIT](./Samples/matrixMulDynlinkJIT)** | **[simpleP2P](./Samples/simpleP2P)** | **[conjugateGradientMultiDeviceCG](./Samples/conjugateGradientMultiDeviceCG)** | **[vectorAddDrv](./Samples/vectorAddDrv)** |
|
|
||||||
**[sortingNetworks](./Samples/sortingNetworks)** | **[alignedTypes](./Samples/alignedTypes)** | **[inlinePTX_nvrtc](./Samples/inlinePTX_nvrtc)** | **[simpleCubemapTexture](./Samples/simpleCubemapTexture)** |
|
|
||||||
**[simpleIPC](./Samples/simpleIPC)** | **[simpleVulkanMMAP](./Samples/simpleVulkanMMAP)** | **[radixSortThrust](./Samples/radixSortThrust)** | **[MonteCarloMultiGPU](./Samples/MonteCarloMultiGPU)** |
|
|
||||||
**[cudaNvSciNvMedia](./Samples/cudaNvSciNvMedia)** | **[vectorAdd](./Samples/vectorAdd)** | **[cdpSimplePrint](./Samples/cdpSimplePrint)** | **[FilterBorderControlNPP](./Samples/FilterBorderControlNPP)** |
|
|
||||||
**[simpleVoteIntrinsics](./Samples/simpleVoteIntrinsics)** | **[convolutionSeparable](./Samples/convolutionSeparable)** | **[nbody](./Samples/nbody)** | **[simpleCUBLAS_LU](./Samples/simpleCUBLAS_LU)** |
|
|
||||||
**[simpleSeparateCompilation](./Samples/simpleSeparateCompilation)** | **[c++11_cuda](./Samples/c++11_cuda)** | **[fluidsGL](./Samples/fluidsGL)** | **[bandwidthTest](./Samples/bandwidthTest)** |
|
|
||||||
**[clock_nvrtc](./Samples/clock_nvrtc)** | **[graphMemoryNodes](./Samples/graphMemoryNodes)** | **[cdpQuadtree](./Samples/cdpQuadtree)** | **[interval](./Samples/interval)** |
|
|
||||||
**[boxFilter](./Samples/boxFilter)** | **[matrixMul_nvrtc](./Samples/matrixMul_nvrtc)** | **[simpleCUBLASXT](./Samples/simpleCUBLASXT)** | **[cppOverload](./Samples/cppOverload)** |
|
|
||||||
**[marchingCubes](./Samples/marchingCubes)** | **[cuSolverRf](./Samples/cuSolverRf)** | **[BlackScholes_nvrtc](./Samples/BlackScholes_nvrtc)** | **[cdpAdvancedQuicksort](./Samples/cdpAdvancedQuicksort)** |
|
|
||||||
**[tf32TensorCoreGemm](./Samples/tf32TensorCoreGemm)** | **[cdpSimpleQuicksort](./Samples/cdpSimpleQuicksort)** | **[simpleOccupancy](./Samples/simpleOccupancy)** | **[simpleSurfaceWrite](./Samples/simpleSurfaceWrite)** |
|
|
||||||
**[simpleCUFFT_MGPU](./Samples/simpleCUFFT_MGPU)** | **[simpleDrvRuntime](./Samples/simpleDrvRuntime)** | **[convolutionFFT2D](./Samples/convolutionFFT2D)** | **[reduction](./Samples/reduction)** |
|
|
||||||
**[memMapIPCDrv](./Samples/memMapIPCDrv)** | **[SobelFilter](./Samples/SobelFilter)** | **[dct8x8](./Samples/dct8x8)** | **[fp16ScalarProduct](./Samples/fp16ScalarProduct)** |
|
|
||||||
**[FDTD3d](./Samples/FDTD3d)** | **[oceanFFT](./Samples/oceanFFT)** | **[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[StreamPriorities](./Samples/StreamPriorities)** |
|
|
||||||
**[cannyEdgeDetectorNPP](./Samples/cannyEdgeDetectorNPP)** | **[MC_SingleAsianOptionP](./Samples/MC_SingleAsianOptionP)** | **[simpleMPI](./Samples/simpleMPI)** |
|
|
||||||
|
|
||||||
#### Windows
|
### [2. Concepts and Techniques](./cpp/2_Concepts_and_Techniques/README.md)
|
||||||
**[simpleAssert_nvrtc](./Samples/simpleAssert_nvrtc)** | **[vectorAdd_nvrtc](./Samples/vectorAdd_nvrtc)** | **[graphMemoryFootprint](./Samples/graphMemoryFootprint)** | **[MC_EstimatePiQ](./Samples/MC_EstimatePiQ)** |
|
Samples that demonstrate CUDA related concepts and common problem solving techniques.
|
||||||
---|---|---|---|
|
|
||||||
**[reductionMultiBlockCG](./Samples/reductionMultiBlockCG)** | **[conjugateGradientPrecond](./Samples/conjugateGradientPrecond)** | **[ptxjit](./Samples/ptxjit)** | **[threadMigration](./Samples/threadMigration)** |
|
### [3. CUDA Features](./cpp/3_CUDA_Features/README.md)
|
||||||
**[threadFenceReduction](./Samples/threadFenceReduction)** | **[simpleAtomicIntrinsics_nvrtc](./Samples/simpleAtomicIntrinsics_nvrtc)** | **[shfl_scan](./Samples/shfl_scan)** | **[clock](./Samples/clock)** |
|
Samples that demonstrate CUDA Features (Cooperative Groups, CUDA Dynamic Parallelism, CUDA Graphs etc).
|
||||||
**[binaryPartitionCG](./Samples/binaryPartitionCG)** | **[MC_EstimatePiP](./Samples/MC_EstimatePiP)** | **[transpose](./Samples/transpose)** | **[simpleMultiCopy](./Samples/simpleMultiCopy)** |
|
|
||||||
**[concurrentKernels](./Samples/concurrentKernels)** | **[UnifiedMemoryPerf](./Samples/UnifiedMemoryPerf)** | **[cppIntegration](./Samples/cppIntegration)** | **[bf16TensorCoreGemm](./Samples/bf16TensorCoreGemm)** |
|
### [4. CUDA Libraries](./cpp/4_CUDA_Libraries/README.md)
|
||||||
**[cuSolverSp_LinearSolver](./Samples/cuSolverSp_LinearSolver)** | **[nvJPEG](./Samples/nvJPEG)** | **[watershedSegmentationNPP](./Samples/watershedSegmentationNPP)** | **[MC_EstimatePiInlineP](./Samples/MC_EstimatePiInlineP)** |
|
Samples that demonstrate how to use CUDA platform libraries (NPP, NVJPEG, NVGRAPH cuBLAS, cuFFT, cuSPARSE, cuSOLVER and cuRAND).
|
||||||
**[simpleD3D10](./Samples/simpleD3D10)** | **[vulkanImageCUDA](./Samples/vulkanImageCUDA)** | **[fluidsD3D9](./Samples/fluidsD3D9)** | **[boxFilterNPP](./Samples/boxFilterNPP)** |
|
|
||||||
**[simpleAssert](./Samples/simpleAssert)** | **[simpleTemplates](./Samples/simpleTemplates)** | **[simpleCUDA2GL](./Samples/simpleCUDA2GL)** | **[matrixMul](./Samples/matrixMul)** |
|
### [5. Domain Specific](./cpp/5_Domain_Specific/README.md)
|
||||||
**[quasirandomGenerator_nvrtc](./Samples/quasirandomGenerator_nvrtc)** | **[nvJPEG_encoder](./Samples/nvJPEG_encoder)** | **[simpleCudaGraphs](./Samples/simpleCudaGraphs)** | **[simpleTextureDrv](./Samples/simpleTextureDrv)** |
|
Samples that are specific to domain (Graphics, Finance, Image Processing).
|
||||||
**[simpleCUFFT](./Samples/simpleCUFFT)** | **[simpleCallback](./Samples/simpleCallback)** | **[SLID3D10Texture](./Samples/SLID3D10Texture)** | **[batchCUBLAS](./Samples/batchCUBLAS)** |
|
|
||||||
**[cudaTensorCoreGemm](./Samples/cudaTensorCoreGemm)** | **[simpleAtomicIntrinsics](./Samples/simpleAtomicIntrinsics)** | **[newdelete](./Samples/newdelete)** | **[bicubicTexture](./Samples/bicubicTexture)** |
|
### [6. Performance](./cpp/6_Performance/README.md)
|
||||||
**[dxtc](./Samples/dxtc)** | **[cudaOpenMP](./Samples/cudaOpenMP)** | **[cdpBezierTessellation](./Samples/cdpBezierTessellation)** | **[randomFog](./Samples/randomFog)** |
|
Samples that demonstrate performance optimization.
|
||||||
**[bilateralFilter](./Samples/bilateralFilter)** | **[conjugateGradient](./Samples/conjugateGradient)** | **[particles](./Samples/particles)** | **[NV12toBGRandResize](./Samples/NV12toBGRandResize)** |
|
|
||||||
**[Mandelbrot](./Samples/Mandelbrot)** | **[binomialOptions_nvrtc](./Samples/binomialOptions_nvrtc)** | **[simpleD3D10RenderTarget](./Samples/simpleD3D10RenderTarget)** | **[mergeSort](./Samples/mergeSort)** |
|
### [7. libNVVM](./cpp/7_libNVVM/README.md)
|
||||||
**[HSOpticalFlow](./Samples/HSOpticalFlow)** | **[immaTensorCoreGemm](./Samples/immaTensorCoreGemm)** | **[convolutionTexture](./Samples/convolutionTexture)** | **[simpleVulkan](./Samples/simpleVulkan)** |
|
Samples that demonstrate the use of libNVVVM and NVVM IR.
|
||||||
**[simpleD3D9Texture](./Samples/simpleD3D9Texture)** | **[simpleCUBLAS](./Samples/simpleCUBLAS)** | **[jacobiCudaGraphs](./Samples/jacobiCudaGraphs)** | **[eigenvalues](./Samples/eigenvalues)** |
|
|
||||||
**[simpleD3D10Texture](./Samples/simpleD3D10Texture)** | **[streamOrderedAllocationP2P](./Samples/streamOrderedAllocationP2P)** | **[cuSolverSp_LowlevelCholesky](./Samples/cuSolverSp_LowlevelCholesky)** | **[topologyQuery](./Samples/topologyQuery)** |
|
### [8. Platform Specific](./cpp/8_Platform_Specific/Tegra/README.md)
|
||||||
**[dmmaTensorCoreGemm](./Samples/dmmaTensorCoreGemm)** | **[volumeRender](./Samples/volumeRender)** | **[stereoDisparity](./Samples/stereoDisparity)** | **[simpleTexture](./Samples/simpleTexture)** |
|
Samples that are specific to certain platforms (Tegra, cuDLA, NvMedia, NvSci, OpenGL ES).
|
||||||
**[simpleStreams](./Samples/simpleStreams)** | **[smokeParticles](./Samples/smokeParticles)** | **[simpleMultiGPU](./Samples/simpleMultiGPU)** | **[deviceQueryDrv](./Samples/deviceQueryDrv)** |
|
|
||||||
**[fastWalshTransform](./Samples/fastWalshTransform)** | **[quasirandomGenerator](./Samples/quasirandomGenerator)** | **[vectorAddMMAP](./Samples/vectorAddMMAP)** | **[MersenneTwisterGP11213](./Samples/MersenneTwisterGP11213)** |
|
### [9. CUDA Tile](./cpp/9_CUDA_Tile/README.md)
|
||||||
**[conjugateGradientUM](./Samples/conjugateGradientUM)** | **[simpleVoteIntrinsics_nvrtc](./Samples/simpleVoteIntrinsics_nvrtc)** | **[simpleLayeredTexture](./Samples/simpleLayeredTexture)** | **[streamOrderedAllocation](./Samples/streamOrderedAllocation)** |
|
Samples that demonstrate how to use CUDA Tile C++.
|
||||||
**[cuSolverDn_LinearSolver](./Samples/cuSolverDn_LinearSolver)** | **[cudaCompressibleMemory](./Samples/cudaCompressibleMemory)** | **[matrixMulCUBLAS](./Samples/matrixMulCUBLAS)** | **[histEqualizationNPP](./Samples/histEqualizationNPP)** |
|
|
||||||
**[simpleAWBarrier](./Samples/simpleAWBarrier)** | **[recursiveGaussian](./Samples/recursiveGaussian)** | **[imageDenoising](./Samples/imageDenoising)** | **[FunctionPointers](./Samples/FunctionPointers)** |
|
|
||||||
**[simpleGL](./Samples/simpleGL)** | **[segmentationTreeThrust](./Samples/segmentationTreeThrust)** | **[scalarProd](./Samples/scalarProd)** | **[SobolQRNG](./Samples/SobolQRNG)** |
|
|
||||||
**[p2pBandwidthLatencyTest](./Samples/p2pBandwidthLatencyTest)** | **[conjugateGradientCudaGraphs](./Samples/conjugateGradientCudaGraphs)** | **[simplePitchLinearTexture](./Samples/simplePitchLinearTexture)** | **[freeImageInteropNPP](./Samples/freeImageInteropNPP)** |
|
|
||||||
**[template](./Samples/template)** | **[dwtHaar1D](./Samples/dwtHaar1D)** | **[simpleD3D11Texture](./Samples/simpleD3D11Texture)** | **[postProcessGL](./Samples/postProcessGL)** |
|
|
||||||
**[BlackScholes](./Samples/BlackScholes)** | **[simpleD3D11](./Samples/simpleD3D11)** | **[volumeFiltering](./Samples/volumeFiltering)** | **[UnifiedMemoryStreams](./Samples/UnifiedMemoryStreams)** |
|
|
||||||
**[globalToShmemAsyncCopy](./Samples/globalToShmemAsyncCopy)** | **[deviceQuery](./Samples/deviceQuery)** | **[simpleHyperQ](./Samples/simpleHyperQ)** | **[cuSolverSp_LowlevelQR](./Samples/cuSolverSp_LowlevelQR)** |
|
|
||||||
**[inlinePTX](./Samples/inlinePTX)** | **[matrixMulDrv](./Samples/matrixMulDrv)** | **[asyncAPI](./Samples/asyncAPI)** | **[MC_EstimatePiInlineQ](./Samples/MC_EstimatePiInlineQ)** |
|
|
||||||
**[scan](./Samples/scan)** | **[simpleCooperativeGroups](./Samples/simpleCooperativeGroups)** | **[conjugateGradientMultiBlockCG](./Samples/conjugateGradientMultiBlockCG)** | **[simpleTemplates_nvrtc](./Samples/simpleTemplates_nvrtc)** |
|
|
||||||
**[simpleTexture3D](./Samples/simpleTexture3D)** | **[lineOfSight](./Samples/lineOfSight)** | **[simpleZeroCopy](./Samples/simpleZeroCopy)** | **[binomialOptions](./Samples/binomialOptions)** |
|
|
||||||
**[simpleAttributes](./Samples/simpleAttributes)** | **[bindlessTexture](./Samples/bindlessTexture)** | **[simpleD3D12](./Samples/simpleD3D12)** | **[simpleCUFFT_2d_MGPU](./Samples/simpleCUFFT_2d_MGPU)** |
|
|
||||||
**[simplePrintf](./Samples/simplePrintf)** | **[batchedLabelMarkersAndLabelCompressionNPP](./Samples/batchedLabelMarkersAndLabelCompressionNPP)** | **[histogram](./Samples/histogram)** | **[matrixMulDynlinkJIT](./Samples/matrixMulDynlinkJIT)** |
|
|
||||||
**[simpleP2P](./Samples/simpleP2P)** | **[conjugateGradientMultiDeviceCG](./Samples/conjugateGradientMultiDeviceCG)** | **[vectorAddDrv](./Samples/vectorAddDrv)** | **[sortingNetworks](./Samples/sortingNetworks)** |
|
|
||||||
**[alignedTypes](./Samples/alignedTypes)** | **[inlinePTX_nvrtc](./Samples/inlinePTX_nvrtc)** | **[simpleCubemapTexture](./Samples/simpleCubemapTexture)** | **[simpleIPC](./Samples/simpleIPC)** |
|
|
||||||
**[simpleVulkanMMAP](./Samples/simpleVulkanMMAP)** | **[radixSortThrust](./Samples/radixSortThrust)** | **[MonteCarloMultiGPU](./Samples/MonteCarloMultiGPU)** | **[vectorAdd](./Samples/vectorAdd)** |
|
|
||||||
**[VFlockingD3D10](./Samples/VFlockingD3D10)** | **[simpleD3D9](./Samples/simpleD3D9)** | **[cdpSimplePrint](./Samples/cdpSimplePrint)** | **[FilterBorderControlNPP](./Samples/FilterBorderControlNPP)** |
|
|
||||||
**[simpleVoteIntrinsics](./Samples/simpleVoteIntrinsics)** | **[convolutionSeparable](./Samples/convolutionSeparable)** | **[nbody](./Samples/nbody)** | **[simpleCUBLAS_LU](./Samples/simpleCUBLAS_LU)** |
|
|
||||||
**[simpleSeparateCompilation](./Samples/simpleSeparateCompilation)** | **[c++11_cuda](./Samples/c++11_cuda)** | **[fluidsGL](./Samples/fluidsGL)** | **[bandwidthTest](./Samples/bandwidthTest)** |
|
|
||||||
**[clock_nvrtc](./Samples/clock_nvrtc)** | **[graphMemoryNodes](./Samples/graphMemoryNodes)** | **[cdpQuadtree](./Samples/cdpQuadtree)** | **[interval](./Samples/interval)** |
|
|
||||||
**[boxFilter](./Samples/boxFilter)** | **[matrixMul_nvrtc](./Samples/matrixMul_nvrtc)** | **[simpleCUBLASXT](./Samples/simpleCUBLASXT)** | **[cppOverload](./Samples/cppOverload)** |
|
|
||||||
**[marchingCubes](./Samples/marchingCubes)** | **[cuSolverRf](./Samples/cuSolverRf)** | **[BlackScholes_nvrtc](./Samples/BlackScholes_nvrtc)** | **[cdpAdvancedQuicksort](./Samples/cdpAdvancedQuicksort)** |
|
|
||||||
**[tf32TensorCoreGemm](./Samples/tf32TensorCoreGemm)** | **[cdpSimpleQuicksort](./Samples/cdpSimpleQuicksort)** | **[simpleOccupancy](./Samples/simpleOccupancy)** | **[simpleSurfaceWrite](./Samples/simpleSurfaceWrite)** |
|
|
||||||
**[simpleCUFFT_MGPU](./Samples/simpleCUFFT_MGPU)** | **[simpleDrvRuntime](./Samples/simpleDrvRuntime)** | **[convolutionFFT2D](./Samples/convolutionFFT2D)** | **[reduction](./Samples/reduction)** |
|
|
||||||
**[memMapIPCDrv](./Samples/memMapIPCDrv)** | **[SobelFilter](./Samples/SobelFilter)** | **[dct8x8](./Samples/dct8x8)** | **[fp16ScalarProduct](./Samples/fp16ScalarProduct)** |
|
|
||||||
**[FDTD3d](./Samples/FDTD3d)** | **[oceanFFT](./Samples/oceanFFT)** | **[warpAggregatedAtomicsCG](./Samples/warpAggregatedAtomicsCG)** | **[cannyEdgeDetectorNPP](./Samples/cannyEdgeDetectorNPP)** |
|
|
||||||
**[MC_SingleAsianOptionP](./Samples/MC_SingleAsianOptionP)** | **[simpleMPI](./Samples/simpleMPI)** |
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
@@ -296,7 +556,7 @@ These third-party dependencies are required by some CUDA samples. If available,
|
|||||||
|
|
||||||
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the FreeImage website.
|
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the FreeImage website.
|
||||||
|
|
||||||
To set up FreeImage on a Windows system, extract the FreeImage DLL distribution into the folder `../../Common/FreeImage/Dist/x64` such that it contains the .h, .dll, and .lib files.
|
To set up FreeImage on a Windows system, extract the FreeImage DLL distribution into the folder `./Common/FreeImage/Dist/x64` such that it contains the .h and .lib files. Copy the .dll file to the Release/ Debug/ execution folder or pass the FreeImage folder when cmake configuring with the `-DFreeImage_INCLUDE_DIR` and `-DFreeImage_LIBRARY` options.
|
||||||
|
|
||||||
#### Message Passing Interface
|
#### Message Passing Interface
|
||||||
|
|
||||||
@@ -322,13 +582,27 @@ OpenGL is a graphics library used for 2D and 3D rendering. On systems which supp
|
|||||||
|
|
||||||
OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver.
|
OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver.
|
||||||
|
|
||||||
|
#### Freeglut
|
||||||
|
|
||||||
|
Freeglut is an open-source software library that serves as a replacement for the original OpenGL Utility Toolkit (GLUT). Its primary purpose is to make it easier for developers to create and manage windows containing OpenGL contexts, as well as handle input from devices like the mouse, keyboard, and joystick, across a wide range of platforms. To set up Freeglut on a Windowson on ARM system, you need to download the source from [Freeglut website](https://freeglut.sourceforge.net/), build freeglut on your system, and copy the freeglut.lib into the folder `./Common/lib/x64` and copy the freeglut.dll file into the `./bin/win64/${BUILD_TYPE}` execution folder.
|
||||||
|
|
||||||
#### Vulkan
|
#### Vulkan
|
||||||
|
|
||||||
Vulkan is a low-overhead, cross-platform 3D graphics and compute API. Vulkan targets high-performance realtime 3D graphics applications such as video games and interactive media across all platforms. On systems which support Vulkan, NVIDIA's Vulkan implementation is provided with the CUDA Driver. For building and running Vulkan applications one needs to install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/).
|
Vulkan is a low-overhead, cross-platform 3D graphics and compute API. Vulkan targets high-performance realtime 3D graphics applications such as video games and interactive media across all platforms. On systems which support Vulkan, NVIDIA's Vulkan implementation is provided with the CUDA Driver. For building and running Vulkan applications one needs to install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/).
|
||||||
|
|
||||||
|
#### GLEW
|
||||||
|
|
||||||
|
GLEW (OpenGL Extension Wrangler Library) is a cross-platform, open-source C/C++ library designed to simplify the process of using modern OpenGL features and extensions. Its main function is to dynamically load OpenGL function pointers at runtime, allowing developers to access both core OpenGL functions and additional features provided by hardware vendors, known as extensions. To set up GLEW on a Windows on ARM system, you need to download the source from [GLEW website](https://glew.sourceforge.net/), build GLEW on your system, and copy the glew32.lib into the folder `./Common/lib/x64` and the glew32.dll into the `./bin/win64/${BUILD_TYPE}` execution folder.
|
||||||
|
|
||||||
|
#### GLFW
|
||||||
|
|
||||||
|
GLFW is a lightweight, open-source library designed for managing OpenGL, OpenGL ES, and Vulkan contexts. It simplifies the process of creating and managing windows, handling user input (keyboard, mouse, and joystick), and working with multiple monitors in a cross-platform manner.
|
||||||
|
|
||||||
|
To set up GLFW on a Windows system, Download the pre-built binaries from [GLFW website](https://www.glfw.org/download.html) and extract the zip file into the folder, pass the GLFW include header folder as `-DGLFW_INCLUDE_DIR` and lib folder as `-DGLFW_LIB_DIR` for cmake configuring.
|
||||||
|
|
||||||
#### OpenMP
|
#### OpenMP
|
||||||
|
|
||||||
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the [OpenMP website](http://openmp.org/).
|
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the [OpenMP website](http://openmp.org/). For compilers such as clang, make sure OpenMP is enabled when building LLVM by including `openmp` in `LLVM_ENABLE_PROJECTS`. If you use clang (from an installed prefix or directly from an LLVM build tree) with OpenMP enabled, set CMAKE_CXX_COMPILER and CMAKE_CUDA_HOST_COMPILER to that clang++ and let CMake detect OpenMP; extra OpenMP_* CMake variables are usually not needed. When using clang++ directly from an LLVM build tree, you may need to copy the generated `omp.h` into the `include/` directory under the path reported by `clang++ --print-resource-dir` before building the samples. When using an installed clang with OpenMP, if you see libomp.so: cannot open shared object file at runtime, add the directory that contains libomp.so to LD_LIBRARY_PATH (or configure it via ld.so.conf.d) so the dynamic linker can locate the OpenMP runtime.
|
||||||
|
|
||||||
#### Screen
|
#### Screen
|
||||||
|
|
||||||
@@ -418,6 +692,11 @@ NVJPEG library provides high-performance, GPU accelerated JPEG decoding function
|
|||||||
|
|
||||||
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
|
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
|
||||||
|
|
||||||
|
#### NVJITLINK
|
||||||
|
|
||||||
|
NVJITLINK is a CUDA runtime library that links multiple GPU device code objects at runtime and enables just‑in‑time link‑time optimization (JIT LTO).
|
||||||
|
It can take device code from tools such as NVCC and NVRTC, link and optimize it on the fly, and produce the final GPU binary.For more details, see: https://docs.nvidia.com/cuda/nvjitlink/index.html
|
||||||
|
|
||||||
#### Stream Priorities
|
#### Stream Priorities
|
||||||
|
|
||||||
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
|
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
|
||||||
@@ -434,6 +713,10 @@ FP16 is a 16-bit floating-point format. One bit is used for the sign, five bits
|
|||||||
|
|
||||||
NVCC support of [C++11 features](https://en.wikipedia.org/wiki/C++11).
|
NVCC support of [C++11 features](https://en.wikipedia.org/wiki/C++11).
|
||||||
|
|
||||||
|
#### CMake
|
||||||
|
|
||||||
|
The libNVVM samples are built using [CMake](https://cmake.org/) 3.10 or later.
|
||||||
|
|
||||||
## Contributors Guide
|
## Contributors Guide
|
||||||
|
|
||||||
We welcome your input on issues and suggestions for samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
|
We welcome your input on issues and suggestions for samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
|
||||||
@@ -446,6 +729,9 @@ Answers to frequently asked questions about CUDA can be found at http://develope
|
|||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* [CUDA Programming Guide](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html)
|
* [CUDA Programming Guide](https://docs.nvidia.com/cuda/cuda-programming-guide/index.html)
|
||||||
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
* [Accelerated Computing Blog](https://developer.nvidia.com/blog/?tags=accelerated-computing)
|
||||||
|
|
||||||
|
## Attributions
|
||||||
|
|
||||||
|
* Teapot image is obtained from [Wikimedia](https://en.wikipedia.org/wiki/File:Original_Utah_Teapot.jpg) and is licensed under the Creative Commons [Attribution-Share Alike 2.0](https://creativecommons.org/licenses/by-sa/2.0/deed.en) Generic license. The image is modified for samples use cases.
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
7
Samples/BlackScholes/.vscode/extensions.json
vendored
7
Samples/BlackScholes/.vscode/extensions.json
vendored
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"nvidia.nsight-vscode-edition",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"ms-vscode.makefile-tools"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
10
Samples/BlackScholes/.vscode/launch.json
vendored
10
Samples/BlackScholes/.vscode/launch.json
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "CUDA C++: Launch",
|
|
||||||
"type": "cuda-gdb",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/BlackScholes"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
15
Samples/BlackScholes/.vscode/tasks.json
vendored
15
Samples/BlackScholes/.vscode/tasks.json
vendored
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "sample",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make dbg=1",
|
|
||||||
"problemMatcher": ["$nvcc"],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This sample evaluates fair call and put prices for a
|
|
||||||
* given set of European options by Black-Scholes formula.
|
|
||||||
* See supplied whitepaper for more explanations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <helper_functions.h> // helper functions for string parsing
|
|
||||||
#include <helper_cuda.h> // helper functions CUDA error checking and initialization
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options on CPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
extern "C" void BlackScholesCPU(float *h_CallResult, float *h_PutResult,
|
|
||||||
float *h_StockPrice, float *h_OptionStrike,
|
|
||||||
float *h_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of OptN options on GPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#include "BlackScholes_kernel.cuh"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Helper function, returning uniformly distributed
|
|
||||||
// random float in [low, high] range
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
float RandFloat(float low, float high) {
|
|
||||||
float t = (float)rand() / (float)RAND_MAX;
|
|
||||||
return (1.0f - t) * low + t * high;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Data configuration
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
const int OPT_N = 4000000;
|
|
||||||
const int NUM_ITERATIONS = 512;
|
|
||||||
|
|
||||||
const int OPT_SZ = OPT_N * sizeof(float);
|
|
||||||
const float RISKFREE = 0.02f;
|
|
||||||
const float VOLATILITY = 0.30f;
|
|
||||||
|
|
||||||
#define DIV_UP(a, b) (((a) + (b)-1) / (b))
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Main program
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
// Start logs
|
|
||||||
printf("[%s] - Starting...\n", argv[0]);
|
|
||||||
|
|
||||||
//'h_' prefix - CPU (host) memory space
|
|
||||||
float
|
|
||||||
// Results calculated by CPU for reference
|
|
||||||
*h_CallResultCPU,
|
|
||||||
*h_PutResultCPU,
|
|
||||||
// CPU copy of GPU results
|
|
||||||
*h_CallResultGPU, *h_PutResultGPU,
|
|
||||||
// CPU instance of input data
|
|
||||||
*h_StockPrice, *h_OptionStrike, *h_OptionYears;
|
|
||||||
|
|
||||||
//'d_' prefix - GPU (device) memory space
|
|
||||||
float
|
|
||||||
// Results calculated by GPU
|
|
||||||
*d_CallResult,
|
|
||||||
*d_PutResult,
|
|
||||||
// GPU instance of input data
|
|
||||||
*d_StockPrice, *d_OptionStrike, *d_OptionYears;
|
|
||||||
|
|
||||||
double delta, ref, sum_delta, sum_ref, max_delta, L1norm, gpuTime;
|
|
||||||
|
|
||||||
StopWatchInterface *hTimer = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
findCudaDevice(argc, (const char **)argv);
|
|
||||||
|
|
||||||
sdkCreateTimer(&hTimer);
|
|
||||||
|
|
||||||
printf("Initializing data...\n");
|
|
||||||
printf("...allocating CPU memory for options.\n");
|
|
||||||
h_CallResultCPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_PutResultCPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_CallResultGPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_PutResultGPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_StockPrice = (float *)malloc(OPT_SZ);
|
|
||||||
h_OptionStrike = (float *)malloc(OPT_SZ);
|
|
||||||
h_OptionYears = (float *)malloc(OPT_SZ);
|
|
||||||
|
|
||||||
printf("...allocating GPU memory for options.\n");
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_CallResult, OPT_SZ));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_PutResult, OPT_SZ));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_StockPrice, OPT_SZ));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_OptionStrike, OPT_SZ));
|
|
||||||
checkCudaErrors(cudaMalloc((void **)&d_OptionYears, OPT_SZ));
|
|
||||||
|
|
||||||
printf("...generating input data in CPU mem.\n");
|
|
||||||
srand(5347);
|
|
||||||
|
|
||||||
// Generate options set
|
|
||||||
for (i = 0; i < OPT_N; i++) {
|
|
||||||
h_CallResultCPU[i] = 0.0f;
|
|
||||||
h_PutResultCPU[i] = -1.0f;
|
|
||||||
h_StockPrice[i] = RandFloat(5.0f, 30.0f);
|
|
||||||
h_OptionStrike[i] = RandFloat(1.0f, 100.0f);
|
|
||||||
h_OptionYears[i] = RandFloat(0.25f, 10.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("...copying input data to GPU mem.\n");
|
|
||||||
// Copy options data to GPU memory for further processing
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(d_StockPrice, h_StockPrice, OPT_SZ, cudaMemcpyHostToDevice));
|
|
||||||
checkCudaErrors(cudaMemcpy(d_OptionStrike, h_OptionStrike, OPT_SZ,
|
|
||||||
cudaMemcpyHostToDevice));
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(d_OptionYears, h_OptionYears, OPT_SZ, cudaMemcpyHostToDevice));
|
|
||||||
printf("Data init done.\n\n");
|
|
||||||
|
|
||||||
printf("Executing Black-Scholes GPU kernel (%i iterations)...\n",
|
|
||||||
NUM_ITERATIONS);
|
|
||||||
checkCudaErrors(cudaDeviceSynchronize());
|
|
||||||
sdkResetTimer(&hTimer);
|
|
||||||
sdkStartTimer(&hTimer);
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_ITERATIONS; i++) {
|
|
||||||
BlackScholesGPU<<<DIV_UP((OPT_N / 2), 128), 128 /*480, 128*/>>>(
|
|
||||||
(float2 *)d_CallResult, (float2 *)d_PutResult, (float2 *)d_StockPrice,
|
|
||||||
(float2 *)d_OptionStrike, (float2 *)d_OptionYears, RISKFREE, VOLATILITY,
|
|
||||||
OPT_N);
|
|
||||||
getLastCudaError("BlackScholesGPU() execution failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
checkCudaErrors(cudaDeviceSynchronize());
|
|
||||||
sdkStopTimer(&hTimer);
|
|
||||||
gpuTime = sdkGetTimerValue(&hTimer) / NUM_ITERATIONS;
|
|
||||||
|
|
||||||
// Both call and put is calculated
|
|
||||||
printf("Options count : %i \n", 2 * OPT_N);
|
|
||||||
printf("BlackScholesGPU() time : %f msec\n", gpuTime);
|
|
||||||
printf("Effective memory bandwidth: %f GB/s\n",
|
|
||||||
((double)(5 * OPT_N * sizeof(float)) * 1E-9) / (gpuTime * 1E-3));
|
|
||||||
printf("Gigaoptions per second : %f \n\n",
|
|
||||||
((double)(2 * OPT_N) * 1E-9) / (gpuTime * 1E-3));
|
|
||||||
|
|
||||||
printf(
|
|
||||||
"BlackScholes, Throughput = %.4f GOptions/s, Time = %.5f s, Size = %u "
|
|
||||||
"options, NumDevsUsed = %u, Workgroup = %u\n",
|
|
||||||
(((double)(2.0 * OPT_N) * 1.0E-9) / (gpuTime * 1.0E-3)), gpuTime * 1e-3,
|
|
||||||
(2 * OPT_N), 1, 128);
|
|
||||||
|
|
||||||
printf("\nReading back GPU results...\n");
|
|
||||||
// Read back GPU results to compare them to CPU results
|
|
||||||
checkCudaErrors(cudaMemcpy(h_CallResultGPU, d_CallResult, OPT_SZ,
|
|
||||||
cudaMemcpyDeviceToHost));
|
|
||||||
checkCudaErrors(
|
|
||||||
cudaMemcpy(h_PutResultGPU, d_PutResult, OPT_SZ, cudaMemcpyDeviceToHost));
|
|
||||||
|
|
||||||
printf("Checking the results...\n");
|
|
||||||
printf("...running CPU calculations.\n\n");
|
|
||||||
// Calculate options values on CPU
|
|
||||||
BlackScholesCPU(h_CallResultCPU, h_PutResultCPU, h_StockPrice, h_OptionStrike,
|
|
||||||
h_OptionYears, RISKFREE, VOLATILITY, OPT_N);
|
|
||||||
|
|
||||||
printf("Comparing the results...\n");
|
|
||||||
// Calculate max absolute difference and L1 distance
|
|
||||||
// between CPU and GPU results
|
|
||||||
sum_delta = 0;
|
|
||||||
sum_ref = 0;
|
|
||||||
max_delta = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < OPT_N; i++) {
|
|
||||||
ref = h_CallResultCPU[i];
|
|
||||||
delta = fabs(h_CallResultCPU[i] - h_CallResultGPU[i]);
|
|
||||||
|
|
||||||
if (delta > max_delta) {
|
|
||||||
max_delta = delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
sum_delta += delta;
|
|
||||||
sum_ref += fabs(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
L1norm = sum_delta / sum_ref;
|
|
||||||
printf("L1 norm: %E\n", L1norm);
|
|
||||||
printf("Max absolute error: %E\n\n", max_delta);
|
|
||||||
|
|
||||||
printf("Shutting down...\n");
|
|
||||||
printf("...releasing GPU memory.\n");
|
|
||||||
checkCudaErrors(cudaFree(d_OptionYears));
|
|
||||||
checkCudaErrors(cudaFree(d_OptionStrike));
|
|
||||||
checkCudaErrors(cudaFree(d_StockPrice));
|
|
||||||
checkCudaErrors(cudaFree(d_PutResult));
|
|
||||||
checkCudaErrors(cudaFree(d_CallResult));
|
|
||||||
|
|
||||||
printf("...releasing CPU memory.\n");
|
|
||||||
free(h_OptionYears);
|
|
||||||
free(h_OptionStrike);
|
|
||||||
free(h_StockPrice);
|
|
||||||
free(h_PutResultGPU);
|
|
||||||
free(h_CallResultGPU);
|
|
||||||
free(h_PutResultCPU);
|
|
||||||
free(h_CallResultCPU);
|
|
||||||
sdkDeleteTimer(&hTimer);
|
|
||||||
printf("Shutdown done.\n");
|
|
||||||
|
|
||||||
printf("\n[BlackScholes] - Test Summary\n");
|
|
||||||
|
|
||||||
if (L1norm > 1e-6) {
|
|
||||||
printf("Test failed!\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf(
|
|
||||||
"\nNOTE: The CUDA Samples are not meant for performance measurements. "
|
|
||||||
"Results may vary when GPU Boost is enabled.\n\n");
|
|
||||||
printf("Test passed\n");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Polynomial approximation of cumulative normal distribution function
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
static double CND(double d) {
|
|
||||||
const double A1 = 0.31938153;
|
|
||||||
const double A2 = -0.356563782;
|
|
||||||
const double A3 = 1.781477937;
|
|
||||||
const double A4 = -1.821255978;
|
|
||||||
const double A5 = 1.330274429;
|
|
||||||
const double RSQRT2PI = 0.39894228040143267793994605993438;
|
|
||||||
|
|
||||||
double K = 1.0 / (1.0 + 0.2316419 * fabs(d));
|
|
||||||
|
|
||||||
double cnd = RSQRT2PI * exp(-0.5 * d * d) *
|
|
||||||
(K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
|
||||||
|
|
||||||
if (d > 0) cnd = 1.0 - cnd;
|
|
||||||
|
|
||||||
return cnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Black-Scholes formula for both call and put
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
static void BlackScholesBodyCPU(float &callResult, float &putResult,
|
|
||||||
float Sf, // Stock price
|
|
||||||
float Xf, // Option strike
|
|
||||||
float Tf, // Option years
|
|
||||||
float Rf, // Riskless rate
|
|
||||||
float Vf // Volatility rate
|
|
||||||
) {
|
|
||||||
double S = Sf, X = Xf, T = Tf, R = Rf, V = Vf;
|
|
||||||
|
|
||||||
double sqrtT = sqrt(T);
|
|
||||||
double d1 = (log(S / X) + (R + 0.5 * V * V) * T) / (V * sqrtT);
|
|
||||||
double d2 = d1 - V * sqrtT;
|
|
||||||
double CNDD1 = CND(d1);
|
|
||||||
double CNDD2 = CND(d2);
|
|
||||||
|
|
||||||
// Calculate Call and Put simultaneously
|
|
||||||
double expRT = exp(-R * T);
|
|
||||||
callResult = (float)(S * CNDD1 - X * expRT * CNDD2);
|
|
||||||
putResult = (float)(X * expRT * (1.0 - CNDD2) - S * (1.0 - CNDD1));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
extern "C" void BlackScholesCPU(float *h_CallResult, float *h_PutResult,
|
|
||||||
float *h_StockPrice, float *h_OptionStrike,
|
|
||||||
float *h_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN) {
|
|
||||||
for (int opt = 0; opt < optN; opt++)
|
|
||||||
BlackScholesBodyCPU(h_CallResult[opt], h_PutResult[opt], h_StockPrice[opt],
|
|
||||||
h_OptionStrike[opt], h_OptionYears[opt], Riskfree,
|
|
||||||
Volatility);
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Polynomial approximation of cumulative normal distribution function
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
__device__ inline float cndGPU(float d) {
|
|
||||||
const float A1 = 0.31938153f;
|
|
||||||
const float A2 = -0.356563782f;
|
|
||||||
const float A3 = 1.781477937f;
|
|
||||||
const float A4 = -1.821255978f;
|
|
||||||
const float A5 = 1.330274429f;
|
|
||||||
const float RSQRT2PI = 0.39894228040143267793994605993438f;
|
|
||||||
|
|
||||||
float K = __fdividef(1.0f, (1.0f + 0.2316419f * fabsf(d)));
|
|
||||||
|
|
||||||
float cnd = RSQRT2PI * __expf(-0.5f * d * d) *
|
|
||||||
(K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
|
||||||
|
|
||||||
if (d > 0) cnd = 1.0f - cnd;
|
|
||||||
|
|
||||||
return cnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Black-Scholes formula for both call and put
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
__device__ inline void BlackScholesBodyGPU(float &CallResult, float &PutResult,
|
|
||||||
float S, // Stock price
|
|
||||||
float X, // Option strike
|
|
||||||
float T, // Option years
|
|
||||||
float R, // Riskless rate
|
|
||||||
float V // Volatility rate
|
|
||||||
) {
|
|
||||||
float sqrtT, expRT;
|
|
||||||
float d1, d2, CNDD1, CNDD2;
|
|
||||||
|
|
||||||
sqrtT = __fdividef(1.0F, rsqrtf(T));
|
|
||||||
d1 = __fdividef(__logf(S / X) + (R + 0.5f * V * V) * T, V * sqrtT);
|
|
||||||
d2 = d1 - V * sqrtT;
|
|
||||||
|
|
||||||
CNDD1 = cndGPU(d1);
|
|
||||||
CNDD2 = cndGPU(d2);
|
|
||||||
|
|
||||||
// Calculate Call and Put simultaneously
|
|
||||||
expRT = __expf(-R * T);
|
|
||||||
CallResult = S * CNDD1 - X * expRT * CNDD2;
|
|
||||||
PutResult = X * expRT * (1.0f - CNDD2) - S * (1.0f - CNDD1);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options on GPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
__launch_bounds__(128) __global__
|
|
||||||
void BlackScholesGPU(float2 *__restrict d_CallResult,
|
|
||||||
float2 *__restrict d_PutResult,
|
|
||||||
float2 *__restrict d_StockPrice,
|
|
||||||
float2 *__restrict d_OptionStrike,
|
|
||||||
float2 *__restrict d_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN) {
|
|
||||||
////Thread index
|
|
||||||
// const int tid = blockDim.x * blockIdx.x + threadIdx.x;
|
|
||||||
////Total number of threads in execution grid
|
|
||||||
// const int THREAD_N = blockDim.x * gridDim.x;
|
|
||||||
|
|
||||||
const int opt = blockDim.x * blockIdx.x + threadIdx.x;
|
|
||||||
|
|
||||||
// Calculating 2 options per thread to increase ILP (instruction level
|
|
||||||
// parallelism)
|
|
||||||
if (opt < (optN / 2)) {
|
|
||||||
float callResult1, callResult2;
|
|
||||||
float putResult1, putResult2;
|
|
||||||
BlackScholesBodyGPU(callResult1, putResult1, d_StockPrice[opt].x,
|
|
||||||
d_OptionStrike[opt].x, d_OptionYears[opt].x, Riskfree,
|
|
||||||
Volatility);
|
|
||||||
BlackScholesBodyGPU(callResult2, putResult2, d_StockPrice[opt].y,
|
|
||||||
d_OptionStrike[opt].y, d_OptionYears[opt].y, Riskfree,
|
|
||||||
Volatility);
|
|
||||||
d_CallResult[opt] = make_float2(callResult1, callResult2);
|
|
||||||
d_PutResult[opt] = make_float2(putResult1, putResult2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2017
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlackScholes", "BlackScholes_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
|
||||||
<RootNamespace>BlackScholes_vs2017</RootNamespace>
|
|
||||||
<ProjectName>BlackScholes</ProjectName>
|
|
||||||
<CudaToolkitCustomDir />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'==''">
|
|
||||||
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
|
|
||||||
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
|
|
||||||
<TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
|
||||||
<IncludePath>$(IncludePath)</IncludePath>
|
|
||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules />
|
|
||||||
<CodeAnalysisRuleAssemblies />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
|
||||||
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
|
||||||
<OutputFile>$(OutDir)/BlackScholes.exe</OutputFile>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<CodeGeneration>compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;compute_75,sm_75;compute_80,sm_80;compute_86,sm_86;</CodeGeneration>
|
|
||||||
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<Include>./;../../Common</Include>
|
|
||||||
<Defines>WIN32</Defines>
|
|
||||||
<AdditionalOptions>--threads 0</AdditionalOptions>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MTd</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MT</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<CudaCompile Include="BlackScholes.cu" />
|
|
||||||
<ClCompile Include="BlackScholes_gold.cpp" />
|
|
||||||
<None Include="BlackScholes_kernel.cuh" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.targets" />
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2019
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlackScholes", "BlackScholes_vs2019.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
|
||||||
<RootNamespace>BlackScholes_vs2019</RootNamespace>
|
|
||||||
<ProjectName>BlackScholes</ProjectName>
|
|
||||||
<CudaToolkitCustomDir />
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
|
||||||
<IncludePath>$(IncludePath)</IncludePath>
|
|
||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules />
|
|
||||||
<CodeAnalysisRuleAssemblies />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
|
||||||
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>cudart_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
|
||||||
<OutputFile>$(OutDir)/BlackScholes.exe</OutputFile>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<CodeGeneration>compute_35,sm_35;compute_37,sm_37;compute_50,sm_50;compute_52,sm_52;compute_60,sm_60;compute_61,sm_61;compute_70,sm_70;compute_75,sm_75;compute_80,sm_80;compute_86,sm_86;</CodeGeneration>
|
|
||||||
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<Include>./;../../Common</Include>
|
|
||||||
<Defines>WIN32</Defines>
|
|
||||||
<AdditionalOptions>--threads 0</AdditionalOptions>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MTd</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MT</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<CudaCompile Include="BlackScholes.cu" />
|
|
||||||
<ClCompile Include="BlackScholes_gold.cpp" />
|
|
||||||
<None Include="BlackScholes_kernel.cuh" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.targets" />
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,365 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
# * Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# * Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived
|
|
||||||
# from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# Makefile project only supported on Mac OS X and Linux Platforms)
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Location of the CUDA Toolkit
|
|
||||||
CUDA_PATH ?= /usr/local/cuda
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# start deprecated interface #
|
|
||||||
##############################
|
|
||||||
ifeq ($(x86_64),1)
|
|
||||||
$(info WARNING - x86_64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
|
||||||
TARGET_ARCH ?= x86_64
|
|
||||||
endif
|
|
||||||
ifeq ($(ARMv7),1)
|
|
||||||
$(info WARNING - ARMv7 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
|
||||||
TARGET_ARCH ?= armv7l
|
|
||||||
endif
|
|
||||||
ifeq ($(aarch64),1)
|
|
||||||
$(info WARNING - aarch64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
|
||||||
TARGET_ARCH ?= aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(ppc64le),1)
|
|
||||||
$(info WARNING - ppc64le variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
|
||||||
TARGET_ARCH ?= ppc64le
|
|
||||||
endif
|
|
||||||
ifneq ($(GCC),)
|
|
||||||
$(info WARNING - GCC variable has been deprecated)
|
|
||||||
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
|
||||||
HOST_COMPILER ?= $(GCC)
|
|
||||||
endif
|
|
||||||
ifneq ($(abi),)
|
|
||||||
$(error ERROR - abi variable has been removed)
|
|
||||||
endif
|
|
||||||
############################
|
|
||||||
# end deprecated interface #
|
|
||||||
############################
|
|
||||||
|
|
||||||
# architecture
|
|
||||||
HOST_ARCH := $(shell uname -m)
|
|
||||||
TARGET_ARCH ?= $(HOST_ARCH)
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le armv7l))
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le))
|
|
||||||
TARGET_SIZE := 64
|
|
||||||
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
|
||||||
TARGET_SIZE := 32
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
TARGET_SIZE := $(shell getconf LONG_BIT)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# sbsa and aarch64 systems look similar. Need to differentiate them at host level for now.
|
|
||||||
ifeq ($(HOST_ARCH),aarch64)
|
|
||||||
ifeq ($(CUDA_PATH)/targets/sbsa-linux,$(shell ls -1d $(CUDA_PATH)/targets/sbsa-linux 2>/dev/null))
|
|
||||||
HOST_ARCH := sbsa
|
|
||||||
TARGET_ARCH := sbsa
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-sbsa x86_64-ppc64le))
|
|
||||||
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
|
||||||
TARGET_ARCH = armv7l
|
|
||||||
endif
|
|
||||||
|
|
||||||
# operating system
|
|
||||||
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
|
||||||
TARGET_OS ?= $(HOST_OS)
|
|
||||||
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
|
||||||
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# host compiler
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
|
||||||
HOST_COMPILER ?= clang++
|
|
||||||
endif
|
|
||||||
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
HOST_COMPILER ?= arm-linux-androideabi-g++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),aarch64)
|
|
||||||
ifeq ($(TARGET_OS), linux)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/q++
|
|
||||||
else ifeq ($(TARGET_OS), android)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-android-clang++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),sbsa)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
HOST_COMPILER ?= g++
|
|
||||||
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
|
||||||
|
|
||||||
# internal flags
|
|
||||||
NVCCFLAGS := -m${TARGET_SIZE}
|
|
||||||
CCFLAGS :=
|
|
||||||
LDFLAGS :=
|
|
||||||
|
|
||||||
# build flags
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
|
||||||
CCFLAGS += -arch $(HOST_ARCH)
|
|
||||||
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
|
||||||
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
|
||||||
CCFLAGS += -mfloat-abi=hard
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
LDFLAGS += -pie
|
|
||||||
CCFLAGS += -fpie -fpic -fexceptions
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib -L$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib/aarch64-linux-gnu -L$(TARGET_FS)/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib -L$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/aarch64-linux-gnu -L$(TARGET_FS)/usr/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += --unresolved-symbols=ignore-in-shared-libs
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include/libdrm
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include/aarch64-linux-gnu -I$(TARGET_FS)/usr/include/aarch64-linux-gnu
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
NVCCFLAGS += --qpp-config 5.4.0,gcc_ntoaarch64le
|
|
||||||
CCFLAGS += -DWIN_INTERFACE_CUSTOM -I/usr/include/aarch64-qnx-gnu
|
|
||||||
LDFLAGS += -lsocket
|
|
||||||
LDFLAGS += -L/usr/lib/aarch64-qnx-gnu
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,/usr/lib/aarch64-qnx-gnu"
|
|
||||||
ifdef TARGET_OVERRIDE
|
|
||||||
LDFLAGS += -lslog2
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/lib
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/lib"
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/libnvidia
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/libnvidia"
|
|
||||||
CCFLAGS += -I$(TARGET_FS)/../include
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef TARGET_OVERRIDE # cuda toolkit targets override
|
|
||||||
NVCCFLAGS += -target-dir $(TARGET_OVERRIDE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Install directory of different arch
|
|
||||||
CUDA_INSTALL_TARGET_DIR :=
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/sbsa-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Debug build flags
|
|
||||||
ifeq ($(dbg),1)
|
|
||||||
NVCCFLAGS += -g -G
|
|
||||||
BUILD_TYPE := debug
|
|
||||||
else
|
|
||||||
BUILD_TYPE := release
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS :=
|
|
||||||
ALL_CCFLAGS += $(NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
|
||||||
|
|
||||||
SAMPLE_ENABLED := 1
|
|
||||||
|
|
||||||
ALL_LDFLAGS :=
|
|
||||||
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
|
||||||
|
|
||||||
# Common includes and paths for CUDA
|
|
||||||
INCLUDES := -I../../Common
|
|
||||||
LIBRARIES :=
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
#Detect if installed version of GCC supports required C++11
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
empty :=
|
|
||||||
space := $(empty) $(empty)
|
|
||||||
GCCVERSIONSTRING := $(shell expr `$(HOST_COMPILER) -dumpversion`)
|
|
||||||
#Create version number without "."
|
|
||||||
GCCVERSION := $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f1 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f2 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f3 -d.)
|
|
||||||
# Make sure the version number has at least 3 decimals
|
|
||||||
GCCVERSION += 00
|
|
||||||
# Remove spaces from the version number
|
|
||||||
GCCVERSION := $(subst $(space),$(empty),$(GCCVERSION))
|
|
||||||
#$(warning $(GCCVERSION))
|
|
||||||
|
|
||||||
IS_MIN_VERSION := $(shell expr `echo $(GCCVERSION)` \>= 51000)
|
|
||||||
|
|
||||||
ifeq ($(IS_MIN_VERSION), 1)
|
|
||||||
$(info >>> GCC Version is greater or equal to 5.1.0 <<<)
|
|
||||||
else
|
|
||||||
$(info >>> Waiving build. Minimum GCC version required is 5.1.0<<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Gencode arguments
|
|
||||||
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),armv7l aarch64))
|
|
||||||
SMS ?= 35 37 50 52 60 61 70 72 75 80 86
|
|
||||||
else
|
|
||||||
SMS ?= 35 37 50 52 60 61 70 75 80 86
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(SMS),)
|
|
||||||
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(GENCODE_FLAGS),)
|
|
||||||
# Generate SASS code for each SM architecture listed in $(SMS)
|
|
||||||
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
|
||||||
|
|
||||||
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
|
||||||
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
|
||||||
ifneq ($(HIGHEST_SM),)
|
|
||||||
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS += -maxrregcount=16 --threads 0 --std=c++11
|
|
||||||
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
EXEC ?= @echo "[@]"
|
|
||||||
endif
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Target rules
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build: BlackScholes
|
|
||||||
|
|
||||||
check.deps:
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
@echo "Sample will be waived due to the above missing dependencies"
|
|
||||||
else
|
|
||||||
@echo "Sample is ready - all dependencies have been met"
|
|
||||||
endif
|
|
||||||
|
|
||||||
BlackScholes.o:BlackScholes.cu
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
BlackScholes_gold.o:BlackScholes_gold.cpp
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
BlackScholes: BlackScholes.o BlackScholes_gold.o
|
|
||||||
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
|
||||||
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
|
|
||||||
run: build
|
|
||||||
$(EXEC) ./BlackScholes
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f BlackScholes BlackScholes.o BlackScholes_gold.o
|
|
||||||
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/BlackScholes
|
|
||||||
|
|
||||||
clobber: clean
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
|
||||||
<entry>
|
|
||||||
<name>BlackScholes</name>
|
|
||||||
<cflags>
|
|
||||||
<flag>-maxrregcount=16</flag>
|
|
||||||
</cflags>
|
|
||||||
<description><![CDATA[This sample evaluates fair call and put prices for a given set of European options by Black-Scholes formula.]]></description>
|
|
||||||
<devicecompilation>whole</devicecompilation>
|
|
||||||
<includepaths>
|
|
||||||
<path>./</path>
|
|
||||||
<path>../</path>
|
|
||||||
<path>../../Common</path>
|
|
||||||
</includepaths>
|
|
||||||
<keyconcepts>
|
|
||||||
<concept level="basic">Computational Finance</concept>
|
|
||||||
</keyconcepts>
|
|
||||||
<keywords>
|
|
||||||
<keyword>CUDA</keyword>
|
|
||||||
<keyword>Computational Finance</keyword>
|
|
||||||
<keyword>option pricing</keyword>
|
|
||||||
<keyword>Black-Scholes</keyword>
|
|
||||||
</keywords>
|
|
||||||
<libraries>
|
|
||||||
</libraries>
|
|
||||||
<librarypaths>
|
|
||||||
</librarypaths>
|
|
||||||
<nsight_eclipse>true</nsight_eclipse>
|
|
||||||
<primary_file>BlackScholes.cu</primary_file>
|
|
||||||
<scopes>
|
|
||||||
<scope>1:CUDA Basic Topics</scope>
|
|
||||||
<scope>3:Computational Finance</scope>
|
|
||||||
</scopes>
|
|
||||||
<sm-arch>sm35</sm-arch>
|
|
||||||
<sm-arch>sm37</sm-arch>
|
|
||||||
<sm-arch>sm50</sm-arch>
|
|
||||||
<sm-arch>sm52</sm-arch>
|
|
||||||
<sm-arch>sm60</sm-arch>
|
|
||||||
<sm-arch>sm61</sm-arch>
|
|
||||||
<sm-arch>sm70</sm-arch>
|
|
||||||
<sm-arch>sm72</sm-arch>
|
|
||||||
<sm-arch>sm75</sm-arch>
|
|
||||||
<sm-arch>sm80</sm-arch>
|
|
||||||
<sm-arch>sm86</sm-arch>
|
|
||||||
<supported_envs>
|
|
||||||
<env>
|
|
||||||
<arch>x86_64</arch>
|
|
||||||
<platform>linux</platform>
|
|
||||||
</env>
|
|
||||||
<env>
|
|
||||||
<platform>windows7</platform>
|
|
||||||
</env>
|
|
||||||
<env>
|
|
||||||
<arch>x86_64</arch>
|
|
||||||
<platform>macosx</platform>
|
|
||||||
</env>
|
|
||||||
<env>
|
|
||||||
<arch>arm</arch>
|
|
||||||
</env>
|
|
||||||
<env>
|
|
||||||
<arch>ppc64le</arch>
|
|
||||||
<platform>linux</platform>
|
|
||||||
</env>
|
|
||||||
</supported_envs>
|
|
||||||
<supported_sm_architectures>
|
|
||||||
<include>all</include>
|
|
||||||
</supported_sm_architectures>
|
|
||||||
<title>Black-Scholes Option Pricing</title>
|
|
||||||
<type>exe</type>
|
|
||||||
<whitepaper>doc\BlackScholes.pdf</whitepaper>
|
|
||||||
</entry>
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
# BlackScholes - Black-Scholes Option Pricing
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample evaluates fair call and put prices for a given set of European options by Black-Scholes formula.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Computational Finance
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](https://developer.nvidia.com/cuda-gpus) [SM 7.5 ](https://developer.nvidia.com/cuda-gpus) [SM 8.0 ](https://developer.nvidia.com/cuda-gpus) [SM 8.6 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, ppc64le, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
|
|
||||||
## Build and Run
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
|
||||||
```
|
|
||||||
*_vs<version>.sln - for Visual Studio <version>
|
|
||||||
```
|
|
||||||
Each individual sample has its own set of solution files in its directory:
|
|
||||||
|
|
||||||
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
|
||||||
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
|
||||||
|
|
||||||
### Linux
|
|
||||||
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
|
||||||
```
|
|
||||||
$ cd <sample_dir>
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
The samples makefiles can take advantage of certain options:
|
|
||||||
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l.
|
|
||||||
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
|
||||||
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=armv7l` <br/>
|
|
||||||
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
|
||||||
* **dbg=1** - build with debug symbols
|
|
||||||
```
|
|
||||||
$ make dbg=1
|
|
||||||
```
|
|
||||||
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
|
||||||
```
|
|
||||||
$ make SMS="50 60"
|
|
||||||
```
|
|
||||||
|
|
||||||
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
|
||||||
```
|
|
||||||
$ make HOST_COMPILER=g++
|
|
||||||
```
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"nvidia.nsight-vscode-edition",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"ms-vscode.makefile-tools"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
10
Samples/BlackScholes_nvrtc/.vscode/launch.json
vendored
10
Samples/BlackScholes_nvrtc/.vscode/launch.json
vendored
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "CUDA C++: Launch",
|
|
||||||
"type": "cuda-gdb",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/BlackScholes_nvrtc"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
15
Samples/BlackScholes_nvrtc/.vscode/tasks.json
vendored
15
Samples/BlackScholes_nvrtc/.vscode/tasks.json
vendored
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "sample",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make dbg=1",
|
|
||||||
"problemMatcher": ["$nvcc"],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,269 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This sample evaluates fair call and put prices for a
|
|
||||||
* given set of European options by Black-Scholes formula.
|
|
||||||
* See supplied whitepaper for more explanations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#include <nvrtc_helper.h>
|
|
||||||
|
|
||||||
#include <helper_functions.h> // helper functions for string parsing
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options on CPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
extern "C" void BlackScholesCPU(float *h_CallResult, float *h_PutResult,
|
|
||||||
float *h_StockPrice, float *h_OptionStrike,
|
|
||||||
float *h_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of OptN options on GPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Helper function, returning uniformly distributed
|
|
||||||
// random float in [low, high] range
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
float RandFloat(float low, float high) {
|
|
||||||
float t = (float)rand() / (float)RAND_MAX;
|
|
||||||
return (1.0f - t) * low + t * high;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Data configuration
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const int OPT_N = 4000000;
|
|
||||||
const int NUM_ITERATIONS = 512;
|
|
||||||
const int OPT_SZ = OPT_N * sizeof(float);
|
|
||||||
const float RISKFREE = 0.02f;
|
|
||||||
const float VOLATILITY = 0.30f;
|
|
||||||
|
|
||||||
#define DIV_UP(a, b) (((a) + (b)-1) / (b))
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Main program
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
// Start logs
|
|
||||||
printf("[%s] - Starting...\n", argv[0]);
|
|
||||||
|
|
||||||
//'h_' prefix - CPU (host) memory space
|
|
||||||
float
|
|
||||||
// Results calculated by CPU for reference
|
|
||||||
*h_CallResultCPU,
|
|
||||||
*h_PutResultCPU,
|
|
||||||
// CPU copy of GPU results
|
|
||||||
*h_CallResultGPU, *h_PutResultGPU,
|
|
||||||
// CPU instance of input data
|
|
||||||
*h_StockPrice, *h_OptionStrike, *h_OptionYears;
|
|
||||||
|
|
||||||
//'d_' prefix - GPU (device) memory space
|
|
||||||
CUdeviceptr
|
|
||||||
// Results calculated by GPU
|
|
||||||
d_CallResult,
|
|
||||||
d_PutResult,
|
|
||||||
|
|
||||||
// GPU instance of input data
|
|
||||||
d_StockPrice, d_OptionStrike, d_OptionYears;
|
|
||||||
|
|
||||||
double delta, ref, sum_delta, sum_ref, max_delta, L1norm, gpuTime;
|
|
||||||
|
|
||||||
StopWatchInterface *hTimer = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
sdkCreateTimer(&hTimer);
|
|
||||||
|
|
||||||
printf("Initializing data...\n");
|
|
||||||
printf("...allocating CPU memory for options.\n");
|
|
||||||
|
|
||||||
h_CallResultCPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_PutResultCPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_CallResultGPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_PutResultGPU = (float *)malloc(OPT_SZ);
|
|
||||||
h_StockPrice = (float *)malloc(OPT_SZ);
|
|
||||||
h_OptionStrike = (float *)malloc(OPT_SZ);
|
|
||||||
h_OptionYears = (float *)malloc(OPT_SZ);
|
|
||||||
|
|
||||||
char *cubin, *kernel_file;
|
|
||||||
size_t cubinSize;
|
|
||||||
kernel_file = sdkFindFilePath("BlackScholes_kernel.cuh", argv[0]);
|
|
||||||
|
|
||||||
// Compile the kernel BlackScholes_kernel.
|
|
||||||
compileFileToCUBIN(kernel_file, argc, argv, &cubin, &cubinSize, 0);
|
|
||||||
CUmodule module = loadCUBIN(cubin, argc, argv);
|
|
||||||
|
|
||||||
CUfunction kernel_addr;
|
|
||||||
checkCudaErrors(cuModuleGetFunction(&kernel_addr, module, "BlackScholesGPU"));
|
|
||||||
|
|
||||||
printf("...allocating GPU memory for options.\n");
|
|
||||||
checkCudaErrors(cuMemAlloc(&d_CallResult, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemAlloc(&d_PutResult, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemAlloc(&d_StockPrice, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemAlloc(&d_OptionStrike, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemAlloc(&d_OptionYears, OPT_SZ));
|
|
||||||
|
|
||||||
printf("...generating input data in CPU mem.\n");
|
|
||||||
srand(5347);
|
|
||||||
|
|
||||||
// Generate options set
|
|
||||||
for (i = 0; i < OPT_N; i++) {
|
|
||||||
h_CallResultCPU[i] = 0.0f;
|
|
||||||
h_PutResultCPU[i] = -1.0f;
|
|
||||||
h_StockPrice[i] = RandFloat(5.0f, 30.0f);
|
|
||||||
h_OptionStrike[i] = RandFloat(1.0f, 100.0f);
|
|
||||||
h_OptionYears[i] = RandFloat(0.25f, 10.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("...copying input data to GPU mem.\n");
|
|
||||||
// Copy options data to GPU memory for further processing
|
|
||||||
checkCudaErrors(cuMemcpyHtoD(d_StockPrice, h_StockPrice, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemcpyHtoD(d_OptionStrike, h_OptionStrike, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemcpyHtoD(d_OptionYears, h_OptionYears, OPT_SZ));
|
|
||||||
|
|
||||||
printf("Data init done.\n\n");
|
|
||||||
printf("Executing Black-Scholes GPU kernel (%i iterations)...\n",
|
|
||||||
NUM_ITERATIONS);
|
|
||||||
|
|
||||||
sdkResetTimer(&hTimer);
|
|
||||||
sdkStartTimer(&hTimer);
|
|
||||||
|
|
||||||
dim3 cudaBlockSize(128, 1, 1);
|
|
||||||
dim3 cudaGridSize(DIV_UP(OPT_N / 2, 128), 1, 1);
|
|
||||||
|
|
||||||
float risk = RISKFREE;
|
|
||||||
float volatility = VOLATILITY;
|
|
||||||
int optval = OPT_N;
|
|
||||||
|
|
||||||
void *arr[] = {(void *)&d_CallResult, (void *)&d_PutResult,
|
|
||||||
(void *)&d_StockPrice, (void *)&d_OptionStrike,
|
|
||||||
(void *)&d_OptionYears, (void *)&risk,
|
|
||||||
(void *)&volatility, (void *)&optval};
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_ITERATIONS; i++) {
|
|
||||||
checkCudaErrors(cuLaunchKernel(kernel_addr, cudaGridSize.x, cudaGridSize.y,
|
|
||||||
cudaGridSize.z, /* grid dim */
|
|
||||||
cudaBlockSize.x, cudaBlockSize.y,
|
|
||||||
cudaBlockSize.z, /* block dim */
|
|
||||||
0, 0, /* shared mem, stream */
|
|
||||||
&arr[0], /* arguments */
|
|
||||||
0));
|
|
||||||
}
|
|
||||||
|
|
||||||
checkCudaErrors(cuCtxSynchronize());
|
|
||||||
|
|
||||||
sdkStopTimer(&hTimer);
|
|
||||||
gpuTime = sdkGetTimerValue(&hTimer) / NUM_ITERATIONS;
|
|
||||||
|
|
||||||
// Both call and put is calculated
|
|
||||||
printf("Options count : %i \n", 2 * OPT_N);
|
|
||||||
printf("BlackScholesGPU() time : %f msec\n", gpuTime);
|
|
||||||
printf("Effective memory bandwidth: %f GB/s\n",
|
|
||||||
((double)(5 * OPT_N * sizeof(float)) * 1E-9) / (gpuTime * 1E-3));
|
|
||||||
printf("Gigaoptions per second : %f \n\n",
|
|
||||||
((double)(2 * OPT_N) * 1E-9) / (gpuTime * 1E-3));
|
|
||||||
printf(
|
|
||||||
"BlackScholes, Throughput = %.4f GOptions/s, Time = %.5f s, Size = %u "
|
|
||||||
"options, NumDevsUsed = %u, Workgroup = %u\n",
|
|
||||||
(((double)(2.0 * OPT_N) * 1.0E-9) / (gpuTime * 1.0E-3)), gpuTime * 1e-3,
|
|
||||||
(2 * OPT_N), 1, 128);
|
|
||||||
|
|
||||||
printf("\nReading back GPU results...\n");
|
|
||||||
|
|
||||||
// Read back GPU results to compare them to CPU results
|
|
||||||
checkCudaErrors(cuMemcpyDtoH(h_CallResultGPU, d_CallResult, OPT_SZ));
|
|
||||||
checkCudaErrors(cuMemcpyDtoH(h_PutResultGPU, d_PutResult, OPT_SZ));
|
|
||||||
|
|
||||||
printf("Checking the results...\n");
|
|
||||||
printf("...running CPU calculations.\n\n");
|
|
||||||
|
|
||||||
// Calculate options values on CPU
|
|
||||||
BlackScholesCPU(h_CallResultCPU, h_PutResultCPU, h_StockPrice, h_OptionStrike,
|
|
||||||
h_OptionYears, RISKFREE, VOLATILITY, OPT_N);
|
|
||||||
|
|
||||||
printf("Comparing the results...\n");
|
|
||||||
// Calculate max absolute difference and L1 distance
|
|
||||||
// between CPU and GPU results
|
|
||||||
sum_delta = 0;
|
|
||||||
sum_ref = 0;
|
|
||||||
max_delta = 0;
|
|
||||||
|
|
||||||
for (i = 0; i < OPT_N; i++) {
|
|
||||||
ref = h_CallResultCPU[i];
|
|
||||||
delta = fabs(h_CallResultCPU[i] - h_CallResultGPU[i]);
|
|
||||||
|
|
||||||
if (delta > max_delta) {
|
|
||||||
max_delta = delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
sum_delta += delta;
|
|
||||||
sum_ref += fabs(ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
L1norm = sum_delta / sum_ref;
|
|
||||||
printf("L1 norm: %E\n", L1norm);
|
|
||||||
printf("Max absolute error: %E\n\n", max_delta);
|
|
||||||
|
|
||||||
printf("Shutting down...\n");
|
|
||||||
printf("...releasing GPU memory.\n");
|
|
||||||
|
|
||||||
checkCudaErrors(cuMemFree(d_OptionYears));
|
|
||||||
checkCudaErrors(cuMemFree(d_OptionStrike));
|
|
||||||
checkCudaErrors(cuMemFree(d_StockPrice));
|
|
||||||
checkCudaErrors(cuMemFree(d_PutResult));
|
|
||||||
checkCudaErrors(cuMemFree(d_CallResult));
|
|
||||||
|
|
||||||
printf("...releasing CPU memory.\n");
|
|
||||||
|
|
||||||
free(h_OptionYears);
|
|
||||||
free(h_OptionStrike);
|
|
||||||
free(h_StockPrice);
|
|
||||||
free(h_PutResultGPU);
|
|
||||||
free(h_CallResultGPU);
|
|
||||||
free(h_PutResultCPU);
|
|
||||||
free(h_CallResultCPU);
|
|
||||||
|
|
||||||
sdkDeleteTimer(&hTimer);
|
|
||||||
printf("Shutdown done.\n");
|
|
||||||
|
|
||||||
printf("\n[%s] - Test Summary\n", argv[0]);
|
|
||||||
|
|
||||||
if (L1norm > 1e-6) {
|
|
||||||
printf("Test failed!\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Test passed\n");
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Polynomial approximation of cumulative normal distribution function
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static double CND(double d) {
|
|
||||||
const double A1 = 0.31938153;
|
|
||||||
const double A2 = -0.356563782;
|
|
||||||
const double A3 = 1.781477937;
|
|
||||||
const double A4 = -1.821255978;
|
|
||||||
const double A5 = 1.330274429;
|
|
||||||
const double RSQRT2PI = 0.39894228040143267793994605993438;
|
|
||||||
|
|
||||||
double K = 1.0 / (1.0 + 0.2316419 * fabs(d));
|
|
||||||
|
|
||||||
double cnd = RSQRT2PI * exp(-0.5 * d * d) *
|
|
||||||
(K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
|
||||||
|
|
||||||
if (d > 0) cnd = 1.0 - cnd;
|
|
||||||
|
|
||||||
return cnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Black-Scholes formula for both call and put
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
static void BlackScholesBodyCPU(float &callResult, float &putResult,
|
|
||||||
float Sf, // Stock price
|
|
||||||
float Xf, // Option strike
|
|
||||||
float Tf, // Option years
|
|
||||||
float Rf, // Riskless rate
|
|
||||||
float Vf // Volatility rate
|
|
||||||
) {
|
|
||||||
double S = Sf, X = Xf, T = Tf, R = Rf, V = Vf;
|
|
||||||
double sqrtT = sqrt(T);
|
|
||||||
double d1 = (log(S / X) + (R + 0.5 * V * V) * T) / (V * sqrtT);
|
|
||||||
double d2 = d1 - V * sqrtT;
|
|
||||||
double CNDD1 = CND(d1);
|
|
||||||
double CNDD2 = CND(d2);
|
|
||||||
|
|
||||||
// Calculate Call and Put simultaneously
|
|
||||||
double expRT = exp(-R * T);
|
|
||||||
|
|
||||||
callResult = (float)(S * CNDD1 - X * expRT * CNDD2);
|
|
||||||
putResult = (float)(X * expRT * (1.0 - CNDD2) - S * (1.0 - CNDD1));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
extern "C" void BlackScholesCPU(float *h_CallResult, float *h_PutResult,
|
|
||||||
float *h_StockPrice, float *h_OptionStrike,
|
|
||||||
float *h_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN) {
|
|
||||||
for (int opt = 0; opt < optN; opt++)
|
|
||||||
BlackScholesBodyCPU(h_CallResult[opt], h_PutResult[opt], h_StockPrice[opt],
|
|
||||||
h_OptionStrike[opt], h_OptionYears[opt], Riskfree,
|
|
||||||
Volatility);
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Polynomial approximation of cumulative normal distribution function
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
__device__ inline float cndGPU(float d) {
|
|
||||||
const float A1 = 0.31938153f;
|
|
||||||
const float A2 = -0.356563782f;
|
|
||||||
const float A3 = 1.781477937f;
|
|
||||||
const float A4 = -1.821255978f;
|
|
||||||
const float A5 = 1.330274429f;
|
|
||||||
const float RSQRT2PI = 0.39894228040143267793994605993438f;
|
|
||||||
|
|
||||||
float K = __fdividef(1.0f, (1.0f + 0.2316419f * fabsf(d)));
|
|
||||||
|
|
||||||
float cnd = RSQRT2PI * __expf(-0.5f * d * d) *
|
|
||||||
(K * (A1 + K * (A2 + K * (A3 + K * (A4 + K * A5)))));
|
|
||||||
|
|
||||||
if (d > 0) cnd = 1.0f - cnd;
|
|
||||||
|
|
||||||
return cnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Black-Scholes formula for both call and put
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
__device__ inline void BlackScholesBodyGPU(float &CallResult, float &PutResult,
|
|
||||||
float S, // Stock price
|
|
||||||
float X, // Option strike
|
|
||||||
float T, // Option years
|
|
||||||
float R, // Riskless rate
|
|
||||||
float V // Volatility rate
|
|
||||||
) {
|
|
||||||
float sqrtT, expRT;
|
|
||||||
float d1, d2, CNDD1, CNDD2;
|
|
||||||
|
|
||||||
sqrtT = __fdividef(1.0F, rsqrtf(T));
|
|
||||||
d1 = __fdividef(__logf(S / X) + (R + 0.5f * V * V) * T, V * sqrtT);
|
|
||||||
d2 = d1 - V * sqrtT;
|
|
||||||
|
|
||||||
CNDD1 = cndGPU(d1);
|
|
||||||
CNDD2 = cndGPU(d2);
|
|
||||||
|
|
||||||
// Calculate Call and Put simultaneously
|
|
||||||
expRT = __expf(-R * T);
|
|
||||||
CallResult = S * CNDD1 - X * expRT * CNDD2;
|
|
||||||
PutResult = X * expRT * (1.0f - CNDD2) - S * (1.0f - CNDD1);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Process an array of optN options on GPU
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
extern "C" __launch_bounds__(128) __global__
|
|
||||||
void BlackScholesGPU(float2 *__restrict d_CallResult,
|
|
||||||
float2 *__restrict d_PutResult,
|
|
||||||
float2 *__restrict d_StockPrice,
|
|
||||||
float2 *__restrict d_OptionStrike,
|
|
||||||
float2 *__restrict d_OptionYears, float Riskfree,
|
|
||||||
float Volatility, int optN) {
|
|
||||||
////Thread index
|
|
||||||
const int opt = blockDim.x * blockIdx.x + threadIdx.x;
|
|
||||||
|
|
||||||
// Calculating 2 options per thread to increase ILP (instruction level
|
|
||||||
// parallelism)
|
|
||||||
if (opt < (optN / 2)) {
|
|
||||||
float callResult1, callResult2;
|
|
||||||
float putResult1, putResult2;
|
|
||||||
BlackScholesBodyGPU(callResult1, putResult1, d_StockPrice[opt].x,
|
|
||||||
d_OptionStrike[opt].x, d_OptionYears[opt].x, Riskfree,
|
|
||||||
Volatility);
|
|
||||||
BlackScholesBodyGPU(callResult2, putResult2, d_StockPrice[opt].y,
|
|
||||||
d_OptionStrike[opt].y, d_OptionYears[opt].y, Riskfree,
|
|
||||||
Volatility);
|
|
||||||
d_CallResult[opt] = make_float2(callResult1, callResult2);
|
|
||||||
d_PutResult[opt] = make_float2(putResult1, putResult2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2017
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlackScholes_nvrtc", "BlackScholes_nvrtc_vs2017.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
|
||||||
<RootNamespace>BlackScholes_nvrtc_vs2017</RootNamespace>
|
|
||||||
<ProjectName>BlackScholes_nvrtc</ProjectName>
|
|
||||||
<CudaToolkitCustomDir />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'==''">
|
|
||||||
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
|
|
||||||
<WindowsTargetPlatformVersion Condition="'$(WindowsTargetPlatformVersion)' == ''">$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
|
|
||||||
<TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
|
||||||
<IncludePath>$(IncludePath)</IncludePath>
|
|
||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules />
|
|
||||||
<CodeAnalysisRuleAssemblies />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
|
||||||
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>cuda.lib;nvrtc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
|
||||||
<OutputFile>$(OutDir)/BlackScholes_nvrtc.exe</OutputFile>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<CodeGeneration></CodeGeneration>
|
|
||||||
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<Include>./;../../Common</Include>
|
|
||||||
<Defines>WIN32</Defines>
|
|
||||||
<AdditionalOptions>--threads 0</AdditionalOptions>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MTd</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MT</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="BlackScholes.cpp" />
|
|
||||||
<ClCompile Include="BlackScholes_gold.cpp" />
|
|
||||||
<None Include="BlackScholes_kernel.cuh" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.targets" />
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2019
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlackScholes_nvrtc", "BlackScholes_nvrtc_vs2019.vcxproj", "{997E0757-EA74-4A4E-A0FC-47D8C8831A15}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{997E0757-EA74-4A4E-A0FC-47D8C8831A15}.Release|x64.Build.0 = Release|x64
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<CUDAPropsPath Condition="'$(CUDAPropsPath)'==''">$(VCTargetsPath)\BuildCustomizations</CUDAPropsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{997E0757-EA74-4A4E-A0FC-47D8C8831A15}</ProjectGuid>
|
|
||||||
<RootNamespace>BlackScholes_nvrtc_vs2019</RootNamespace>
|
|
||||||
<ProjectName>BlackScholes_nvrtc</ProjectName>
|
|
||||||
<CudaToolkitCustomDir />
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<PlatformToolset>v142</PlatformToolset>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets">
|
|
||||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup>
|
|
||||||
<IntDir>$(Platform)/$(Configuration)/</IntDir>
|
|
||||||
<IncludePath>$(IncludePath)</IncludePath>
|
|
||||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
<CodeAnalysisRules />
|
|
||||||
<CodeAnalysisRuleAssemblies />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Platform)'=='x64'">
|
|
||||||
<OutDir>../../bin/win64/$(Configuration)/</OutDir>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup>
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PreprocessorDefinitions>WIN32;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<AdditionalIncludeDirectories>./;$(CudaToolkitDir)/include;../../Common;$(CudaToolkitIncludeDir);$(CUDA_PATH)/include;</AdditionalIncludeDirectories>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<AdditionalDependencies>cuda.lib;nvrtc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalLibraryDirectories>$(CudaToolkitLibDir);</AdditionalLibraryDirectories>
|
|
||||||
<OutputFile>$(OutDir)/BlackScholes_nvrtc.exe</OutputFile>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<CodeGeneration></CodeGeneration>
|
|
||||||
<AdditionalOptions>-Xcompiler "/wd 4819" %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<Include>./;../../Common</Include>
|
|
||||||
<Defines>WIN32</Defines>
|
|
||||||
<AdditionalOptions>--threads 0</AdditionalOptions>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MTd</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
|
|
||||||
<ClCompile>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
|
||||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
|
||||||
</Link>
|
|
||||||
<CudaCompile>
|
|
||||||
<Runtime>MT</Runtime>
|
|
||||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
|
||||||
</CudaCompile>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="BlackScholes.cpp" />
|
|
||||||
<ClCompile Include="BlackScholes_gold.cpp" />
|
|
||||||
<None Include="BlackScholes_kernel.cuh" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
<Import Project="$(CUDAPropsPath)\CUDA 11.5.targets" />
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,422 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
# * Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# * Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived
|
|
||||||
# from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# Makefile project only supported on Mac OS X and Linux Platforms)
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Location of the CUDA Toolkit
|
|
||||||
CUDA_PATH ?= /usr/local/cuda
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# start deprecated interface #
|
|
||||||
##############################
|
|
||||||
ifeq ($(x86_64),1)
|
|
||||||
$(info WARNING - x86_64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
|
||||||
TARGET_ARCH ?= x86_64
|
|
||||||
endif
|
|
||||||
ifeq ($(ARMv7),1)
|
|
||||||
$(info WARNING - ARMv7 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
|
||||||
TARGET_ARCH ?= armv7l
|
|
||||||
endif
|
|
||||||
ifeq ($(aarch64),1)
|
|
||||||
$(info WARNING - aarch64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
|
||||||
TARGET_ARCH ?= aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(ppc64le),1)
|
|
||||||
$(info WARNING - ppc64le variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
|
||||||
TARGET_ARCH ?= ppc64le
|
|
||||||
endif
|
|
||||||
ifneq ($(GCC),)
|
|
||||||
$(info WARNING - GCC variable has been deprecated)
|
|
||||||
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
|
||||||
HOST_COMPILER ?= $(GCC)
|
|
||||||
endif
|
|
||||||
ifneq ($(abi),)
|
|
||||||
$(error ERROR - abi variable has been removed)
|
|
||||||
endif
|
|
||||||
############################
|
|
||||||
# end deprecated interface #
|
|
||||||
############################
|
|
||||||
|
|
||||||
# architecture
|
|
||||||
HOST_ARCH := $(shell uname -m)
|
|
||||||
TARGET_ARCH ?= $(HOST_ARCH)
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le armv7l))
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le))
|
|
||||||
TARGET_SIZE := 64
|
|
||||||
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
|
||||||
TARGET_SIZE := 32
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
TARGET_SIZE := $(shell getconf LONG_BIT)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# sbsa and aarch64 systems look similar. Need to differentiate them at host level for now.
|
|
||||||
ifeq ($(HOST_ARCH),aarch64)
|
|
||||||
ifeq ($(CUDA_PATH)/targets/sbsa-linux,$(shell ls -1d $(CUDA_PATH)/targets/sbsa-linux 2>/dev/null))
|
|
||||||
HOST_ARCH := sbsa
|
|
||||||
TARGET_ARCH := sbsa
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-sbsa x86_64-ppc64le))
|
|
||||||
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
|
||||||
TARGET_ARCH = armv7l
|
|
||||||
endif
|
|
||||||
|
|
||||||
# operating system
|
|
||||||
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
|
||||||
TARGET_OS ?= $(HOST_OS)
|
|
||||||
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
|
||||||
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# host compiler
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
|
||||||
HOST_COMPILER ?= clang++
|
|
||||||
endif
|
|
||||||
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
HOST_COMPILER ?= arm-linux-androideabi-g++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),aarch64)
|
|
||||||
ifeq ($(TARGET_OS), linux)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/q++
|
|
||||||
else ifeq ($(TARGET_OS), android)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-android-clang++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),sbsa)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
HOST_COMPILER ?= g++
|
|
||||||
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
|
||||||
|
|
||||||
# internal flags
|
|
||||||
NVCCFLAGS := -m${TARGET_SIZE}
|
|
||||||
CCFLAGS :=
|
|
||||||
LDFLAGS :=
|
|
||||||
|
|
||||||
# build flags
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
|
||||||
CCFLAGS += -arch $(HOST_ARCH)
|
|
||||||
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
|
||||||
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
|
||||||
CCFLAGS += -mfloat-abi=hard
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
LDFLAGS += -pie
|
|
||||||
CCFLAGS += -fpie -fpic -fexceptions
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib -L$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib/aarch64-linux-gnu -L$(TARGET_FS)/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib -L$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/aarch64-linux-gnu -L$(TARGET_FS)/usr/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += --unresolved-symbols=ignore-in-shared-libs
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include/libdrm
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include/aarch64-linux-gnu -I$(TARGET_FS)/usr/include/aarch64-linux-gnu
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
NVCCFLAGS += --qpp-config 5.4.0,gcc_ntoaarch64le
|
|
||||||
CCFLAGS += -DWIN_INTERFACE_CUSTOM -I/usr/include/aarch64-qnx-gnu
|
|
||||||
LDFLAGS += -lsocket
|
|
||||||
LDFLAGS += -L/usr/lib/aarch64-qnx-gnu
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,/usr/lib/aarch64-qnx-gnu"
|
|
||||||
ifdef TARGET_OVERRIDE
|
|
||||||
LDFLAGS += -lslog2
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/lib
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/lib"
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/libnvidia
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/libnvidia"
|
|
||||||
CCFLAGS += -I$(TARGET_FS)/../include
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef TARGET_OVERRIDE # cuda toolkit targets override
|
|
||||||
NVCCFLAGS += -target-dir $(TARGET_OVERRIDE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Install directory of different arch
|
|
||||||
CUDA_INSTALL_TARGET_DIR :=
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/sbsa-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Debug build flags
|
|
||||||
ifeq ($(dbg),1)
|
|
||||||
CCFLAGS += -g
|
|
||||||
BUILD_TYPE := debug
|
|
||||||
else
|
|
||||||
BUILD_TYPE := release
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS :=
|
|
||||||
ALL_CCFLAGS += $(NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
|
||||||
|
|
||||||
UBUNTU = $(shell lsb_release -i -s 2>/dev/null | grep -i ubuntu)
|
|
||||||
|
|
||||||
SAMPLE_ENABLED := 1
|
|
||||||
|
|
||||||
# This sample is not supported on ARMv7
|
|
||||||
ifeq ($(TARGET_ARCH),armv7l)
|
|
||||||
$(info >>> WARNING - BlackScholes_nvrtc is not supported on ARMv7 - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This sample is not supported on QNX
|
|
||||||
ifeq ($(TARGET_OS),qnx)
|
|
||||||
$(info >>> WARNING - BlackScholes_nvrtc is not supported on QNX - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_LDFLAGS :=
|
|
||||||
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
|
||||||
|
|
||||||
# Common includes and paths for CUDA
|
|
||||||
INCLUDES := -I../../Common
|
|
||||||
LIBRARIES :=
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# libNVRTC specific libraries
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
LDFLAGS += -L$(CUDA_PATH)/lib -F/Library/Frameworks -framework CUDA
|
|
||||||
endif
|
|
||||||
|
|
||||||
#Detect if installed version of GCC supports required C++11
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
empty :=
|
|
||||||
space := $(empty) $(empty)
|
|
||||||
GCCVERSIONSTRING := $(shell expr `$(HOST_COMPILER) -dumpversion`)
|
|
||||||
#Create version number without "."
|
|
||||||
GCCVERSION := $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f1 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f2 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f3 -d.)
|
|
||||||
# Make sure the version number has at least 3 decimals
|
|
||||||
GCCVERSION += 00
|
|
||||||
# Remove spaces from the version number
|
|
||||||
GCCVERSION := $(subst $(space),$(empty),$(GCCVERSION))
|
|
||||||
#$(warning $(GCCVERSION))
|
|
||||||
|
|
||||||
IS_MIN_VERSION := $(shell expr `echo $(GCCVERSION)` \>= 51000)
|
|
||||||
|
|
||||||
ifeq ($(IS_MIN_VERSION), 1)
|
|
||||||
$(info >>> GCC Version is greater or equal to 5.1.0 <<<)
|
|
||||||
else
|
|
||||||
$(info >>> Waiving build. Minimum GCC version required is 5.1.0<<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
ALL_LDFLAGS += -Xcompiler -F/Library/Frameworks -Xlinker -framework -Xlinker CUDA
|
|
||||||
else
|
|
||||||
ifeq ($(TARGET_ARCH),x86_64)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs
|
|
||||||
CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/x86_64-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-gnueabihf/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/sbsa-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-androideabi/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux-androideabi/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ARMv7-linux-QNX/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-qnx/lib/stubs
|
|
||||||
ifdef TARGET_OVERRIDE
|
|
||||||
CUDA_SEARCH_PATH := $(CUDA_PATH)/targets/$(TARGET_OVERRIDE)/lib/stubs
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ppc64le-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(HOST_ARCH),ppc64le)
|
|
||||||
CUDA_SEARCH_PATH += $(CUDA_PATH)/lib64/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null)
|
|
||||||
ifeq ("$(CUDALIB)","")
|
|
||||||
$(info >>> WARNING - libcuda.so not found, CUDA Driver is not installed. Please re-install the driver. <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
else
|
|
||||||
CUDALIB := $(shell echo $(CUDALIB) | sed "s/ .*//" | sed "s/\/libcuda.so//" )
|
|
||||||
LIBRARIES += -L$(CUDALIB) -lcuda
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS += --threads 0 --std=c++11
|
|
||||||
|
|
||||||
INCLUDES += -I$(CUDA_PATH)/include
|
|
||||||
|
|
||||||
LIBRARIES += -lnvrtc
|
|
||||||
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
EXEC ?= @echo "[@]"
|
|
||||||
endif
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Target rules
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build: BlackScholes_nvrtc
|
|
||||||
|
|
||||||
check.deps:
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
@echo "Sample will be waived due to the above missing dependencies"
|
|
||||||
else
|
|
||||||
@echo "Sample is ready - all dependencies have been met"
|
|
||||||
endif
|
|
||||||
|
|
||||||
BlackScholes.o:BlackScholes.cpp
|
|
||||||
$(EXEC) $(HOST_COMPILER) $(INCLUDES) $(CCFLAGS) $(EXTRA_CCFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
BlackScholes_gold.o:BlackScholes_gold.cpp
|
|
||||||
$(EXEC) $(HOST_COMPILER) $(INCLUDES) $(CCFLAGS) $(EXTRA_CCFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
BlackScholes_nvrtc: BlackScholes.o BlackScholes_gold.o
|
|
||||||
$(EXEC) $(HOST_COMPILER) $(LDFLAGS) -o $@ $+ $(LIBRARIES)
|
|
||||||
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
|
|
||||||
run: build
|
|
||||||
$(EXEC) ./BlackScholes_nvrtc
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f BlackScholes_nvrtc BlackScholes.o BlackScholes_gold.o
|
|
||||||
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/BlackScholes_nvrtc
|
|
||||||
|
|
||||||
clobber: clean
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
# BlackScholes_nvrtc - Black-Scholes Option Pricing with libNVRTC
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This sample evaluates fair call and put prices for a given set of European options by Black-Scholes formula, compiling the CUDA kernels involved at runtime using NVRTC.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
Computational Finance, Runtime Compilation
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](https://developer.nvidia.com/cuda-gpus) [SM 7.5 ](https://developer.nvidia.com/cuda-gpus) [SM 8.0 ](https://developer.nvidia.com/cuda-gpus) [SM 8.6 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux, Windows
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, ppc64le, aarch64
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[NVRTC](../../README.md#nvrtc)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
|
|
||||||
|
|
||||||
## Build and Run
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
|
|
||||||
```
|
|
||||||
*_vs<version>.sln - for Visual Studio <version>
|
|
||||||
```
|
|
||||||
Each individual sample has its own set of solution files in its directory:
|
|
||||||
|
|
||||||
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
|
|
||||||
> **Note:** Some samples require that the Microsoft DirectX SDK (June 2010 or newer) be installed and that the VC++ directory paths are properly set up (**Tools > Options...**). Check DirectX Dependencies section for details."
|
|
||||||
|
|
||||||
### Linux
|
|
||||||
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
|
||||||
```
|
|
||||||
$ cd <sample_dir>
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
The samples makefiles can take advantage of certain options:
|
|
||||||
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, aarch64.
|
|
||||||
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
|
||||||
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=ppc64le` <br/> `$ make TARGET_ARCH=aarch64` <br/>
|
|
||||||
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
|
||||||
* **dbg=1** - build with debug symbols
|
|
||||||
```
|
|
||||||
$ make dbg=1
|
|
||||||
```
|
|
||||||
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
|
||||||
```
|
|
||||||
$ make SMS="50 60"
|
|
||||||
```
|
|
||||||
|
|
||||||
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
|
||||||
```
|
|
||||||
$ make HOST_COMPILER=g++
|
|
||||||
```
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"${workspaceFolder}/../../Common"
|
|
||||||
],
|
|
||||||
"defines": [],
|
|
||||||
"compilerPath": "/usr/local/cuda/bin/nvcc",
|
|
||||||
"cStandard": "gnu17",
|
|
||||||
"cppStandard": "gnu++14",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64",
|
|
||||||
"configurationProvider": "ms-vscode.makefile-tools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"nvidia.nsight-vscode-edition",
|
|
||||||
"ms-vscode.cpptools",
|
|
||||||
"ms-vscode.makefile-tools"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "CUDA C++: Launch",
|
|
||||||
"type": "cuda-gdb",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/EGLStream_CUDA_CrossGPU"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "sample",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "make dbg=1",
|
|
||||||
"problemMatcher": ["$nvcc"],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,453 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
# * Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# * Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in the
|
|
||||||
# documentation and/or other materials provided with the distribution.
|
|
||||||
# * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
# contributors may be used to endorse or promote products derived
|
|
||||||
# from this software without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# Makefile project only supported on Mac OS X and Linux Platforms)
|
|
||||||
#
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Location of the CUDA Toolkit
|
|
||||||
CUDA_PATH ?= /usr/local/cuda
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# start deprecated interface #
|
|
||||||
##############################
|
|
||||||
ifeq ($(x86_64),1)
|
|
||||||
$(info WARNING - x86_64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=x86_64 instead)
|
|
||||||
TARGET_ARCH ?= x86_64
|
|
||||||
endif
|
|
||||||
ifeq ($(ARMv7),1)
|
|
||||||
$(info WARNING - ARMv7 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=armv7l instead)
|
|
||||||
TARGET_ARCH ?= armv7l
|
|
||||||
endif
|
|
||||||
ifeq ($(aarch64),1)
|
|
||||||
$(info WARNING - aarch64 variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=aarch64 instead)
|
|
||||||
TARGET_ARCH ?= aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(ppc64le),1)
|
|
||||||
$(info WARNING - ppc64le variable has been deprecated)
|
|
||||||
$(info WARNING - please use TARGET_ARCH=ppc64le instead)
|
|
||||||
TARGET_ARCH ?= ppc64le
|
|
||||||
endif
|
|
||||||
ifneq ($(GCC),)
|
|
||||||
$(info WARNING - GCC variable has been deprecated)
|
|
||||||
$(info WARNING - please use HOST_COMPILER=$(GCC) instead)
|
|
||||||
HOST_COMPILER ?= $(GCC)
|
|
||||||
endif
|
|
||||||
ifneq ($(abi),)
|
|
||||||
$(error ERROR - abi variable has been removed)
|
|
||||||
endif
|
|
||||||
############################
|
|
||||||
# end deprecated interface #
|
|
||||||
############################
|
|
||||||
|
|
||||||
# architecture
|
|
||||||
HOST_ARCH := $(shell uname -m)
|
|
||||||
TARGET_ARCH ?= $(HOST_ARCH)
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le armv7l))
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifneq (,$(filter $(TARGET_ARCH),x86_64 aarch64 sbsa ppc64le))
|
|
||||||
TARGET_SIZE := 64
|
|
||||||
else ifneq (,$(filter $(TARGET_ARCH),armv7l))
|
|
||||||
TARGET_SIZE := 32
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
TARGET_SIZE := $(shell getconf LONG_BIT)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
$(error ERROR - unsupported value $(TARGET_ARCH) for TARGET_ARCH!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# sbsa and aarch64 systems look similar. Need to differentiate them at host level for now.
|
|
||||||
ifeq ($(HOST_ARCH),aarch64)
|
|
||||||
ifeq ($(CUDA_PATH)/targets/sbsa-linux,$(shell ls -1d $(CUDA_PATH)/targets/sbsa-linux 2>/dev/null))
|
|
||||||
HOST_ARCH := sbsa
|
|
||||||
TARGET_ARCH := sbsa
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq (,$(filter $(HOST_ARCH)-$(TARGET_ARCH),aarch64-armv7l x86_64-armv7l x86_64-aarch64 x86_64-sbsa x86_64-ppc64le))
|
|
||||||
$(error ERROR - cross compiling from $(HOST_ARCH) to $(TARGET_ARCH) is not supported!)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# When on native aarch64 system with userspace of 32-bit, change TARGET_ARCH to armv7l
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_SIZE),aarch64-aarch64-32)
|
|
||||||
TARGET_ARCH = armv7l
|
|
||||||
endif
|
|
||||||
|
|
||||||
# operating system
|
|
||||||
HOST_OS := $(shell uname -s 2>/dev/null | tr "[:upper:]" "[:lower:]")
|
|
||||||
TARGET_OS ?= $(HOST_OS)
|
|
||||||
ifeq (,$(filter $(TARGET_OS),linux darwin qnx android))
|
|
||||||
$(error ERROR - unsupported value $(TARGET_OS) for TARGET_OS!)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# host compiler
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
ifeq ($(shell expr `xcodebuild -version | grep -i xcode | awk '{print $$2}' | cut -d'.' -f1` \>= 5),1)
|
|
||||||
HOST_COMPILER ?= clang++
|
|
||||||
endif
|
|
||||||
else ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(HOST_ARCH)-$(TARGET_ARCH),x86_64-armv7l)
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
HOST_COMPILER ?= arm-linux-gnueabihf-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/arm-unknown-nto-qnx6.6.0eabi-g++
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
HOST_COMPILER ?= arm-linux-androideabi-g++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),aarch64)
|
|
||||||
ifeq ($(TARGET_OS), linux)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_OS),qnx)
|
|
||||||
ifeq ($(QNX_HOST),)
|
|
||||||
$(error ERROR - QNX_HOST must be passed to the QNX host toolchain)
|
|
||||||
endif
|
|
||||||
ifeq ($(QNX_TARGET),)
|
|
||||||
$(error ERROR - QNX_TARGET must be passed to the QNX target toolchain)
|
|
||||||
endif
|
|
||||||
export QNX_HOST
|
|
||||||
export QNX_TARGET
|
|
||||||
HOST_COMPILER ?= $(QNX_HOST)/usr/bin/q++
|
|
||||||
else ifeq ($(TARGET_OS), android)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-android-clang++
|
|
||||||
endif
|
|
||||||
else ifeq ($(TARGET_ARCH),sbsa)
|
|
||||||
HOST_COMPILER ?= aarch64-linux-gnu-g++
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
HOST_COMPILER ?= powerpc64le-linux-gnu-g++
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
HOST_COMPILER ?= g++
|
|
||||||
NVCC := $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
|
|
||||||
|
|
||||||
# internal flags
|
|
||||||
NVCCFLAGS := -m${TARGET_SIZE}
|
|
||||||
CCFLAGS :=
|
|
||||||
LDFLAGS :=
|
|
||||||
|
|
||||||
# build flags
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
LDFLAGS += -rpath $(CUDA_PATH)/lib
|
|
||||||
CCFLAGS += -arch $(HOST_ARCH)
|
|
||||||
else ifeq ($(HOST_ARCH)-$(TARGET_ARCH)-$(TARGET_OS),x86_64-armv7l-linux)
|
|
||||||
LDFLAGS += --dynamic-linker=/lib/ld-linux-armhf.so.3
|
|
||||||
CCFLAGS += -mfloat-abi=hard
|
|
||||||
else ifeq ($(TARGET_OS),android)
|
|
||||||
LDFLAGS += -pie
|
|
||||||
CCFLAGS += -fpie -fpic -fexceptions
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_ARCH),$(HOST_ARCH))
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/arm-linux-gnueabihf
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
GCCVERSIONLTEQ46 := $(shell expr `$(HOST_COMPILER) -dumpversion` \<= 4.6)
|
|
||||||
ifeq ($(GCCVERSIONLTEQ46),1)
|
|
||||||
CCFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
endif
|
|
||||||
LDFLAGS += --sysroot=$(TARGET_FS)
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib -L$(TARGET_FS)/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/lib/aarch64-linux-gnu -L$(TARGET_FS)/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib -L$(TARGET_FS)/usr/lib
|
|
||||||
LDFLAGS += -rpath-link=$(TARGET_FS)/usr/lib/aarch64-linux-gnu -L$(TARGET_FS)/usr/lib/aarch64-linux-gnu
|
|
||||||
LDFLAGS += --unresolved-symbols=ignore-in-shared-libs
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include -I$(TARGET_FS)/usr/include/libdrm
|
|
||||||
CCFLAGS += -isystem=$(TARGET_FS)/usr/include/aarch64-linux-gnu -I$(TARGET_FS)/usr/include/aarch64-linux-gnu
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
NVCCFLAGS += --qpp-config 5.4.0,gcc_ntoaarch64le
|
|
||||||
CCFLAGS += -DWIN_INTERFACE_CUSTOM -I/usr/include/aarch64-qnx-gnu
|
|
||||||
LDFLAGS += -lsocket
|
|
||||||
LDFLAGS += -L/usr/lib/aarch64-qnx-gnu
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,/usr/lib/aarch64-qnx-gnu"
|
|
||||||
ifdef TARGET_OVERRIDE
|
|
||||||
LDFLAGS += -lslog2
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(TARGET_FS),)
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/lib
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/lib"
|
|
||||||
LDFLAGS += -L$(TARGET_FS)/usr/libnvidia
|
|
||||||
CCFLAGS += "-Wl\,-rpath-link\,$(TARGET_FS)/usr/libnvidia"
|
|
||||||
CCFLAGS += -I$(TARGET_FS)/../include
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef TARGET_OVERRIDE # cuda toolkit targets override
|
|
||||||
NVCCFLAGS += -target-dir $(TARGET_OVERRIDE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Install directory of different arch
|
|
||||||
CUDA_INSTALL_TARGET_DIR :=
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-gnueabihf/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/sbsa-linux/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/armv7-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-linux-androideabi/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ARMv7-linux-QNX/
|
|
||||||
else ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/aarch64-qnx/
|
|
||||||
else ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
CUDA_INSTALL_TARGET_DIR = targets/ppc64le-linux/
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Debug build flags
|
|
||||||
ifeq ($(dbg),1)
|
|
||||||
NVCCFLAGS += -g -G
|
|
||||||
BUILD_TYPE := debug
|
|
||||||
else
|
|
||||||
BUILD_TYPE := release
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS :=
|
|
||||||
ALL_CCFLAGS += $(NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(EXTRA_NVCCFLAGS)
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(CCFLAGS))
|
|
||||||
ALL_CCFLAGS += $(addprefix -Xcompiler ,$(EXTRA_CCFLAGS))
|
|
||||||
|
|
||||||
UBUNTU = $(shell lsb_release -i -s 2>/dev/null | grep -i ubuntu)
|
|
||||||
|
|
||||||
SAMPLE_ENABLED := 1
|
|
||||||
|
|
||||||
# This sample is not supported on Mac OSX
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
$(info >>> WARNING - EGLStream_CUDA_CrossGPU is not supported on Mac OSX - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
# This sample is not supported on android
|
|
||||||
ifeq ($(TARGET_OS),android)
|
|
||||||
$(info >>> WARNING - EGLStream_CUDA_CrossGPU is not supported on android - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_LDFLAGS :=
|
|
||||||
ALL_LDFLAGS += $(ALL_CCFLAGS)
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(LDFLAGS))
|
|
||||||
ALL_LDFLAGS += $(addprefix -Xlinker ,$(EXTRA_LDFLAGS))
|
|
||||||
|
|
||||||
# Common includes and paths for CUDA
|
|
||||||
INCLUDES := -I../../Common
|
|
||||||
LIBRARIES :=
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Makefile include to help find EGL Libraries
|
|
||||||
include ./findegl.mk
|
|
||||||
|
|
||||||
# EGL specific libraries
|
|
||||||
ifneq ($(TARGET_OS),darwin)
|
|
||||||
LIBRARIES += -lEGL
|
|
||||||
endif
|
|
||||||
|
|
||||||
#Detect if installed version of GCC supports required C++11
|
|
||||||
ifeq ($(TARGET_OS),linux)
|
|
||||||
empty :=
|
|
||||||
space := $(empty) $(empty)
|
|
||||||
GCCVERSIONSTRING := $(shell expr `$(HOST_COMPILER) -dumpversion`)
|
|
||||||
#Create version number without "."
|
|
||||||
GCCVERSION := $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f1 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f2 -d.)
|
|
||||||
GCCVERSION += $(shell expr `echo $(GCCVERSIONSTRING)` | cut -f3 -d.)
|
|
||||||
# Make sure the version number has at least 3 decimals
|
|
||||||
GCCVERSION += 00
|
|
||||||
# Remove spaces from the version number
|
|
||||||
GCCVERSION := $(subst $(space),$(empty),$(GCCVERSION))
|
|
||||||
#$(warning $(GCCVERSION))
|
|
||||||
|
|
||||||
IS_MIN_VERSION := $(shell expr `echo $(GCCVERSION)` \>= 51000)
|
|
||||||
|
|
||||||
ifeq ($(IS_MIN_VERSION), 1)
|
|
||||||
$(info >>> GCC Version is greater or equal to 5.1.0 <<<)
|
|
||||||
else
|
|
||||||
$(info >>> Waiving build. Minimum GCC version required is 5.1.0<<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Gencode arguments
|
|
||||||
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),armv7l aarch64))
|
|
||||||
SMS ?= 35 37 50 52 60 61 70 72 75 80 86
|
|
||||||
else
|
|
||||||
SMS ?= 35 37 50 52 60 61 70 75 80 86
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(SMS),)
|
|
||||||
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(GENCODE_FLAGS),)
|
|
||||||
# Generate SASS code for each SM architecture listed in $(SMS)
|
|
||||||
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
|
|
||||||
|
|
||||||
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
|
|
||||||
HIGHEST_SM := $(lastword $(sort $(SMS)))
|
|
||||||
ifneq ($(HIGHEST_SM),)
|
|
||||||
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_OS),darwin)
|
|
||||||
ALL_LDFLAGS += -Xcompiler -F/Library/Frameworks -Xlinker -framework -Xlinker CUDA
|
|
||||||
else
|
|
||||||
ifeq ($(TARGET_ARCH),x86_64)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/lib64/stubs
|
|
||||||
CUDA_SEARCH_PATH += $(CUDA_PATH)/targets/x86_64-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-gnueabihf/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),sbsa-linux)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/sbsa-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-android)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/armv7-linux-androideabi/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-android)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-linux-androideabi/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),armv7l-qnx)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ARMv7-linux-QNX/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH)-$(TARGET_OS),aarch64-qnx)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/aarch64-qnx/lib/stubs
|
|
||||||
ifdef TARGET_OVERRIDE
|
|
||||||
CUDA_SEARCH_PATH := $(CUDA_PATH)/targets/$(TARGET_OVERRIDE)/lib/stubs
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCH),ppc64le)
|
|
||||||
CUDA_SEARCH_PATH ?= $(CUDA_PATH)/targets/ppc64le-linux/lib/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(HOST_ARCH),ppc64le)
|
|
||||||
CUDA_SEARCH_PATH += $(CUDA_PATH)/lib64/stubs
|
|
||||||
endif
|
|
||||||
|
|
||||||
CUDALIB ?= $(shell find -L $(CUDA_SEARCH_PATH) -maxdepth 1 -name libcuda.so 2> /dev/null)
|
|
||||||
ifeq ("$(CUDALIB)","")
|
|
||||||
$(info >>> WARNING - libcuda.so not found, CUDA Driver is not installed. Please re-install the driver. <<<)
|
|
||||||
SAMPLE_ENABLED := 0
|
|
||||||
else
|
|
||||||
CUDALIB := $(shell echo $(CUDALIB) | sed "s/ .*//" | sed "s/\/libcuda.so//" )
|
|
||||||
LIBRARIES += -L$(CUDALIB) -lcuda
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ALL_CCFLAGS += --threads 0 --std=c++11
|
|
||||||
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
EXEC ?= @echo "[@]"
|
|
||||||
endif
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
# Target rules
|
|
||||||
all: build
|
|
||||||
|
|
||||||
build: EGLStream_CUDA_CrossGPU
|
|
||||||
|
|
||||||
check.deps:
|
|
||||||
ifeq ($(SAMPLE_ENABLED),0)
|
|
||||||
@echo "Sample will be waived due to the above missing dependencies"
|
|
||||||
else
|
|
||||||
@echo "Sample is ready - all dependencies have been met"
|
|
||||||
endif
|
|
||||||
|
|
||||||
cuda_consumer.o:cuda_consumer.cpp
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
cuda_producer.o:cuda_producer.cpp
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
eglstrm_common.o:eglstrm_common.cpp
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
kernel.o:kernel.cu
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
main.o:main.cpp
|
|
||||||
$(EXEC) $(NVCC) $(INCLUDES) $(ALL_CCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
EGLStream_CUDA_CrossGPU: cuda_consumer.o cuda_producer.o eglstrm_common.o kernel.o main.o
|
|
||||||
$(EXEC) $(NVCC) $(ALL_LDFLAGS) $(GENCODE_FLAGS) -o $@ $+ $(LIBRARIES)
|
|
||||||
$(EXEC) mkdir -p ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
$(EXEC) cp $@ ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)
|
|
||||||
|
|
||||||
run: build
|
|
||||||
$(EXEC) ./EGLStream_CUDA_CrossGPU
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f EGLStream_CUDA_CrossGPU cuda_consumer.o cuda_producer.o eglstrm_common.o kernel.o main.o
|
|
||||||
rm -rf ../../bin/$(TARGET_ARCH)/$(TARGET_OS)/$(BUILD_TYPE)/EGLStream_CUDA_CrossGPU
|
|
||||||
|
|
||||||
clobber: clean
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE entry SYSTEM "SamplesInfo.dtd">
|
|
||||||
<entry>
|
|
||||||
<name>EGLStream_CUDA_CrossGPU</name>
|
|
||||||
<cuda_api_list>
|
|
||||||
<driver>cuDeviceGet</driver>
|
|
||||||
<driver>cuDeviceGetAttribute</driver>
|
|
||||||
<driver>cuDeviceComputeCapability</driver>
|
|
||||||
<driver>cuDeviceGetCount</driver>
|
|
||||||
<driver>cuDeviceGetName</driver>
|
|
||||||
<driver>cuGraphicsResourceGetMappedEglFrame</driver>
|
|
||||||
<driver>cuEGLStreamConsumerAcquireFrame</driver>
|
|
||||||
<driver>cuEGLStreamConsumerReleaseFrame</driver>
|
|
||||||
<driver>cuEGLStreamProducerReturnFrame</driver>
|
|
||||||
<driver>cuEGLStreamProducerPresentFrame</driver>
|
|
||||||
<driver>cuCtxCreate</driver>
|
|
||||||
<driver>cuMemAlloc</driver>
|
|
||||||
<driver>cuMemFree</driver>
|
|
||||||
<driver>cuMemcpy3D</driver>
|
|
||||||
<driver>cuStreamCreate</driver>
|
|
||||||
<driver>cuCtxPushCurrent</driver>
|
|
||||||
<driver>cuCtxPopCurrent</driver>
|
|
||||||
<driver>cuCtxDestroy</driver>
|
|
||||||
</cuda_api_list>
|
|
||||||
<description><![CDATA[Demonstrates CUDA and EGL Streams interop, where consumer's EGL Stream is on one GPU and producer's on other and both consumer-producer are different processes.]]></description>
|
|
||||||
<devicecompilation>whole</devicecompilation>
|
|
||||||
<includepaths>
|
|
||||||
<path>./</path>
|
|
||||||
<path>../</path>
|
|
||||||
<path>../../Common</path>
|
|
||||||
</includepaths>
|
|
||||||
<keyconcepts>
|
|
||||||
<concept level="basic">EGLStreams Interop</concept>
|
|
||||||
</keyconcepts>
|
|
||||||
<keywords>
|
|
||||||
<keyword>EGL Streams</keyword>
|
|
||||||
</keywords>
|
|
||||||
<libraries>
|
|
||||||
<library os="linux">cuda</library>
|
|
||||||
<library framework="true" os="macosx">CUDA</library>
|
|
||||||
</libraries>
|
|
||||||
<librarypaths>
|
|
||||||
</librarypaths>
|
|
||||||
<nsight_eclipse>true</nsight_eclipse>
|
|
||||||
<primary_file>main.cpp</primary_file>
|
|
||||||
<required_dependencies>
|
|
||||||
<dependency>EGL</dependency>
|
|
||||||
</required_dependencies>
|
|
||||||
<scopes>
|
|
||||||
<scope>1:CUDA Advanced Topics</scope>
|
|
||||||
<scope>2:Graphics Interop</scope>
|
|
||||||
</scopes>
|
|
||||||
<sm-arch>sm35</sm-arch>
|
|
||||||
<sm-arch>sm37</sm-arch>
|
|
||||||
<sm-arch>sm50</sm-arch>
|
|
||||||
<sm-arch>sm52</sm-arch>
|
|
||||||
<sm-arch>sm60</sm-arch>
|
|
||||||
<sm-arch>sm61</sm-arch>
|
|
||||||
<sm-arch>sm70</sm-arch>
|
|
||||||
<sm-arch>sm72</sm-arch>
|
|
||||||
<sm-arch>sm75</sm-arch>
|
|
||||||
<sm-arch>sm80</sm-arch>
|
|
||||||
<sm-arch>sm86</sm-arch>
|
|
||||||
<supported_envs>
|
|
||||||
<env>
|
|
||||||
<arch>x86_64</arch>
|
|
||||||
<platform>linux</platform>
|
|
||||||
</env>
|
|
||||||
<env>
|
|
||||||
<arch>arm</arch>
|
|
||||||
</env>
|
|
||||||
</supported_envs>
|
|
||||||
<supported_sm_architectures>
|
|
||||||
<include>all</include>
|
|
||||||
</supported_sm_architectures>
|
|
||||||
<title>EGLStream_CUDA_CrossGPU</title>
|
|
||||||
<type>exe</type>
|
|
||||||
</entry>
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
# EGLStream_CUDA_CrossGPU - EGLStream_CUDA_CrossGPU
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
Demonstrates CUDA and EGL Streams interop, where consumer's EGL Stream is on one GPU and producer's on other and both consumer-producer are different processes.
|
|
||||||
|
|
||||||
## Key Concepts
|
|
||||||
|
|
||||||
EGLStreams Interop
|
|
||||||
|
|
||||||
## Supported SM Architectures
|
|
||||||
|
|
||||||
[SM 3.5 ](https://developer.nvidia.com/cuda-gpus) [SM 3.7 ](https://developer.nvidia.com/cuda-gpus) [SM 5.0 ](https://developer.nvidia.com/cuda-gpus) [SM 5.2 ](https://developer.nvidia.com/cuda-gpus) [SM 6.0 ](https://developer.nvidia.com/cuda-gpus) [SM 6.1 ](https://developer.nvidia.com/cuda-gpus) [SM 7.0 ](https://developer.nvidia.com/cuda-gpus) [SM 7.2 ](https://developer.nvidia.com/cuda-gpus) [SM 7.5 ](https://developer.nvidia.com/cuda-gpus) [SM 8.0 ](https://developer.nvidia.com/cuda-gpus) [SM 8.6 ](https://developer.nvidia.com/cuda-gpus)
|
|
||||||
|
|
||||||
## Supported OSes
|
|
||||||
|
|
||||||
Linux
|
|
||||||
|
|
||||||
## Supported CPU Architecture
|
|
||||||
|
|
||||||
x86_64, armv7l
|
|
||||||
|
|
||||||
## CUDA APIs involved
|
|
||||||
|
|
||||||
### [CUDA Driver API](http://docs.nvidia.com/cuda/cuda-driver-api/index.html)
|
|
||||||
cuDeviceGet, cuDeviceGetAttribute, cuDeviceComputeCapability, cuDeviceGetCount, cuDeviceGetName, cuGraphicsResourceGetMappedEglFrame, cuEGLStreamConsumerAcquireFrame, cuEGLStreamConsumerReleaseFrame, cuEGLStreamProducerReturnFrame, cuEGLStreamProducerPresentFrame, cuCtxCreate, cuMemAlloc, cuMemFree, cuMemcpy3D, cuStreamCreate, cuCtxPushCurrent, cuCtxPopCurrent, cuCtxDestroy
|
|
||||||
|
|
||||||
## Dependencies needed to build/run
|
|
||||||
[EGL](../../README.md#egl)
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
Download and install the [CUDA Toolkit 11.5](https://developer.nvidia.com/cuda-downloads) for your corresponding platform.
|
|
||||||
Make sure the dependencies mentioned in [Dependencies]() section above are installed.
|
|
||||||
|
|
||||||
## Build and Run
|
|
||||||
|
|
||||||
### Linux
|
|
||||||
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
|
|
||||||
```
|
|
||||||
$ cd <sample_dir>
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
The samples makefiles can take advantage of certain options:
|
|
||||||
* **TARGET_ARCH=<arch>** - cross-compile targeting a specific architecture. Allowed architectures are x86_64, armv7l.
|
|
||||||
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.<br/>
|
|
||||||
`$ make TARGET_ARCH=x86_64` <br/> `$ make TARGET_ARCH=armv7l` <br/>
|
|
||||||
See [here](http://docs.nvidia.com/cuda/cuda-samples/index.html#cross-samples) for more details.
|
|
||||||
* **dbg=1** - build with debug symbols
|
|
||||||
```
|
|
||||||
$ make dbg=1
|
|
||||||
```
|
|
||||||
* **SMS="A B ..."** - override the SM architectures for which the sample will be built, where `"A B ..."` is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use `SMS="50 60"`.
|
|
||||||
```
|
|
||||||
$ make SMS="50 60"
|
|
||||||
```
|
|
||||||
|
|
||||||
* **HOST_COMPILER=<host_compiler>** - override the default g++ host compiler. See the [Linux Installation Guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements) for a list of supported host compilers.
|
|
||||||
```
|
|
||||||
$ make HOST_COMPILER=g++
|
|
||||||
```
|
|
||||||
|
|
||||||
## References (for more details)
|
|
||||||
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// DESCRIPTION: Simple CUDA consumer rendering sample app
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#include "cuda_consumer.h"
|
|
||||||
#include "eglstrm_common.h"
|
|
||||||
#include <math.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#if defined(EXTENSION_LIST)
|
|
||||||
EXTENSION_LIST(EXTLST_EXTERN)
|
|
||||||
#endif
|
|
||||||
CUgraphicsResource cudaResource;
|
|
||||||
|
|
||||||
static int count_acq = 0;
|
|
||||||
static double acquire_time[25000] = {0}, total_time_acq = 0;
|
|
||||||
|
|
||||||
static int count_rel = 0;
|
|
||||||
static double rel_time[25000] = {0}, total_time_rel = 0;
|
|
||||||
|
|
||||||
void acquireApiStat(void);
|
|
||||||
void acquireApiStat(void) {
|
|
||||||
int i = 0;
|
|
||||||
double min = 10000000, max = 0;
|
|
||||||
double average_launch_time = 0, standard_deviation = 0;
|
|
||||||
if (count_acq == 0) return;
|
|
||||||
// lets compute the standard deviation
|
|
||||||
min = max = acquire_time[1];
|
|
||||||
average_launch_time = (total_time_acq - acquire_time[0]) / count_acq;
|
|
||||||
for (i = 1; i < count_acq; i++) {
|
|
||||||
standard_deviation += (acquire_time[i] - average_launch_time) *
|
|
||||||
(acquire_time[i] - average_launch_time);
|
|
||||||
if (acquire_time[i] < min) min = acquire_time[i];
|
|
||||||
if (acquire_time[i] > max) max = acquire_time[i];
|
|
||||||
}
|
|
||||||
standard_deviation = sqrt(standard_deviation / count_acq);
|
|
||||||
printf("acquire Avg: %lf\n", average_launch_time);
|
|
||||||
printf("acquire SD: %lf\n", standard_deviation);
|
|
||||||
printf("acquire min: %lf\n", min);
|
|
||||||
printf("acquire max: %lf\n", max);
|
|
||||||
|
|
||||||
min = max = rel_time[1];
|
|
||||||
average_launch_time = (total_time_rel - rel_time[0]) / count_rel;
|
|
||||||
for (i = 1; i < count_rel; i++) {
|
|
||||||
standard_deviation += (rel_time[i] - average_launch_time) *
|
|
||||||
(rel_time[i] - average_launch_time);
|
|
||||||
if (rel_time[i] < min) min = rel_time[i];
|
|
||||||
if (rel_time[i] > max) max = rel_time[i];
|
|
||||||
}
|
|
||||||
standard_deviation = sqrt(standard_deviation / count_rel);
|
|
||||||
printf("release Avg: %lf\n", average_launch_time);
|
|
||||||
printf("release SD: %lf\n", standard_deviation);
|
|
||||||
printf("release min: %lf\n", min);
|
|
||||||
printf("release max: %lf\n", max);
|
|
||||||
}
|
|
||||||
CUresult cudaConsumerAcquireFrame(test_cuda_consumer_s *cudaConsumer,
|
|
||||||
int frameNumber) {
|
|
||||||
CUresult cuStatus = CUDA_SUCCESS;
|
|
||||||
CUeglFrame cudaEgl;
|
|
||||||
struct timespec start, end;
|
|
||||||
EGLint streamState = 0;
|
|
||||||
double curTime;
|
|
||||||
|
|
||||||
if (!cudaConsumer) {
|
|
||||||
printf("%s: Bad parameter\n", __func__);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (!eglQueryStreamKHR(cudaConsumer->eglDisplay, cudaConsumer->eglStream,
|
|
||||||
EGL_STREAM_STATE_KHR, &streamState)) {
|
|
||||||
printf("Cuda Consumer: eglQueryStreamKHR EGL_STREAM_STATE_KHR failed\n");
|
|
||||||
cuStatus = CUDA_ERROR_UNKNOWN;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (streamState == EGL_STREAM_STATE_DISCONNECTED_KHR) {
|
|
||||||
printf("Cuda Consumer: EGL_STREAM_STATE_DISCONNECTED_KHR received\n");
|
|
||||||
cuStatus = CUDA_ERROR_UNKNOWN;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (streamState == EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cudaConsumer->profileAPI) {
|
|
||||||
getTime(&start);
|
|
||||||
}
|
|
||||||
cuStatus =
|
|
||||||
cuEGLStreamConsumerAcquireFrame(&(cudaConsumer->cudaConn), &cudaResource,
|
|
||||||
&cudaConsumer->consCudaStream, 16000);
|
|
||||||
if (cudaConsumer->profileAPI) {
|
|
||||||
getTime(&end);
|
|
||||||
curTime = TIME_DIFF(end, start);
|
|
||||||
acquire_time[count_acq++] = curTime;
|
|
||||||
if (count_acq == 25000) count_acq = 0;
|
|
||||||
total_time_acq += curTime;
|
|
||||||
}
|
|
||||||
if (cuStatus == CUDA_SUCCESS) {
|
|
||||||
CUdeviceptr pDevPtr = 0;
|
|
||||||
cudaError_t err;
|
|
||||||
|
|
||||||
cuStatus =
|
|
||||||
cuGraphicsResourceGetMappedEglFrame(&cudaEgl, cudaResource, 0, 0);
|
|
||||||
if (cuStatus != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda get resource failed with %d\n", cuStatus);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
pDevPtr = (CUdeviceptr)cudaEgl.frame.pPitch[0];
|
|
||||||
|
|
||||||
err = cudaConsumer_filter(cudaConsumer->consCudaStream, (char *)pDevPtr,
|
|
||||||
WIDTH * 4, HEIGHT, PROD_DATA + frameNumber,
|
|
||||||
CONS_DATA + frameNumber, frameNumber);
|
|
||||||
if (err != cudaSuccess) {
|
|
||||||
printf("Cuda Consumer: kernel failed with: %s\n",
|
|
||||||
cudaGetErrorString(err));
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
return cuStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cudaConsumerReleaseFrame(test_cuda_consumer_s *cudaConsumer,
|
|
||||||
int frameNumber) {
|
|
||||||
CUresult cuStatus = CUDA_SUCCESS;
|
|
||||||
struct timespec start, end;
|
|
||||||
double curTime;
|
|
||||||
|
|
||||||
if (!cudaConsumer) {
|
|
||||||
printf("%s: Bad parameter\n", __func__);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (cudaConsumer->profileAPI) {
|
|
||||||
getTime(&start);
|
|
||||||
}
|
|
||||||
cuStatus = cuEGLStreamConsumerReleaseFrame(
|
|
||||||
&cudaConsumer->cudaConn, cudaResource, &cudaConsumer->consCudaStream);
|
|
||||||
if (cudaConsumer->profileAPI) {
|
|
||||||
getTime(&end);
|
|
||||||
curTime = TIME_DIFF(end, start);
|
|
||||||
rel_time[count_rel++] = curTime;
|
|
||||||
if (count_rel == 25000) count_rel = 0;
|
|
||||||
total_time_rel += curTime;
|
|
||||||
}
|
|
||||||
if (cuStatus != CUDA_SUCCESS) {
|
|
||||||
printf("cuEGLStreamConsumerReleaseFrame failed, status:%d\n", cuStatus);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
|
||||||
return cuStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cudaDeviceCreateConsumer(test_cuda_consumer_s *cudaConsumer) {
|
|
||||||
CUdevice device;
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS != (status = cuInit(0))) {
|
|
||||||
printf("Failed to initialize CUDA\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS !=
|
|
||||||
(status = cuDeviceGet(&device, cudaConsumer->cudaDevId))) {
|
|
||||||
printf("failed to get CUDA device\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS !=
|
|
||||||
(status = cuCtxCreate(&cudaConsumer->context, 0, device))) {
|
|
||||||
printf("failed to create CUDA context\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
int major = 0, minor = 0;
|
|
||||||
char deviceName[256];
|
|
||||||
cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
|
|
||||||
device);
|
|
||||||
cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
|
|
||||||
device);
|
|
||||||
cuDeviceGetName(deviceName, 256, device);
|
|
||||||
printf(
|
|
||||||
"CUDA Consumer on GPU Device %d: \"%s\" with compute capability "
|
|
||||||
"%d.%d\n\n",
|
|
||||||
device, deviceName, major, minor);
|
|
||||||
|
|
||||||
cuCtxPopCurrent(&cudaConsumer->context);
|
|
||||||
if (major < 6) {
|
|
||||||
printf(
|
|
||||||
"EGLStream_CUDA_CrossGPU requires SM 6.0 or higher arch GPU. "
|
|
||||||
"Exiting...\n");
|
|
||||||
exit(2); // EXIT_WAIVED
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cuda_consumer_init(test_cuda_consumer_s *cudaConsumer,
|
|
||||||
TestArgs *args) {
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
int bufferSize;
|
|
||||||
|
|
||||||
cudaConsumer->charCnt = args->charCnt;
|
|
||||||
bufferSize = args->charCnt;
|
|
||||||
|
|
||||||
cudaConsumer->pCudaCopyMem = (unsigned char *)malloc(bufferSize);
|
|
||||||
if (cudaConsumer->pCudaCopyMem == NULL) {
|
|
||||||
printf("Cuda Consumer: malloc failed\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = cuStreamCreate(&cudaConsumer->consCudaStream, 0);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Consumer: cuStreamCreate failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
atexit(acquireApiStat);
|
|
||||||
done:
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cuda_consumer_Deinit(test_cuda_consumer_s *cudaConsumer) {
|
|
||||||
if (cudaConsumer->pCudaCopyMem) {
|
|
||||||
free(cudaConsumer->pCudaCopyMem);
|
|
||||||
}
|
|
||||||
return cuEGLStreamConsumerDisconnect(&cudaConsumer->cudaConn);
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// DESCRIPTION: CUDA consumer header file
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _CUDA_CONSUMER_H_
|
|
||||||
#define _CUDA_CONSUMER_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "cudaEGL.h"
|
|
||||||
#include "eglstrm_common.h"
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#include <cuda.h>
|
|
||||||
|
|
||||||
typedef struct _test_cuda_consumer_s {
|
|
||||||
CUcontext context;
|
|
||||||
CUeglStreamConnection cudaConn;
|
|
||||||
int cudaDevId;
|
|
||||||
EGLDisplay eglDisplay;
|
|
||||||
EGLStreamKHR eglStream;
|
|
||||||
unsigned int charCnt;
|
|
||||||
char *cudaBuf;
|
|
||||||
bool profileAPI;
|
|
||||||
unsigned char *pCudaCopyMem;
|
|
||||||
CUstream consCudaStream;
|
|
||||||
} test_cuda_consumer_s;
|
|
||||||
|
|
||||||
CUresult cuda_consumer_init(test_cuda_consumer_s *cudaConsumer, TestArgs *args);
|
|
||||||
CUresult cuda_consumer_Deinit(test_cuda_consumer_s *cudaConsumer);
|
|
||||||
CUresult cudaConsumerAcquireFrame(test_cuda_consumer_s *data, int frameNumber);
|
|
||||||
CUresult cudaConsumerReleaseFrame(test_cuda_consumer_s *data, int frameNumber);
|
|
||||||
CUresult cudaDeviceCreateConsumer(test_cuda_consumer_s *cudaConsumer);
|
|
||||||
cudaError_t cudaConsumer_filter(CUstream cStream, char *pSrc, int width,
|
|
||||||
int height, char expectedVal, char newVal,
|
|
||||||
int frameNumber);
|
|
||||||
cudaError_t cudaGetValueMismatch(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,288 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// DESCRIPTION: Simple cuda EGL stream producer app
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "cudaEGL.h"
|
|
||||||
#include "cuda_producer.h"
|
|
||||||
#include "eglstrm_common.h"
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#if defined(EXTENSION_LIST)
|
|
||||||
EXTENSION_LIST(EXTLST_EXTERN)
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "cuda_runtime.h"
|
|
||||||
#include "math.h"
|
|
||||||
|
|
||||||
int cudaPresentReturnData = INIT_DATA;
|
|
||||||
int fakePresent = 0;
|
|
||||||
CUeglFrame fakeFrame;
|
|
||||||
CUdeviceptr cudaPtrFake;
|
|
||||||
extern bool isCrossDevice;
|
|
||||||
|
|
||||||
void cudaProducerPrepareFrame(CUeglFrame *cudaEgl, CUdeviceptr cudaPtr,
|
|
||||||
int bufferSize) {
|
|
||||||
cudaEgl->frame.pPitch[0] = (void *)cudaPtr;
|
|
||||||
cudaEgl->width = WIDTH;
|
|
||||||
cudaEgl->depth = 0;
|
|
||||||
cudaEgl->height = HEIGHT;
|
|
||||||
cudaEgl->pitch = WIDTH * 4;
|
|
||||||
cudaEgl->frameType = CU_EGL_FRAME_TYPE_PITCH;
|
|
||||||
cudaEgl->planeCount = 1;
|
|
||||||
cudaEgl->numChannels = 4;
|
|
||||||
cudaEgl->eglColorFormat = CU_EGL_COLOR_FORMAT_ARGB;
|
|
||||||
cudaEgl->cuFormat = CU_AD_FORMAT_UNSIGNED_INT8;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int count_present = 0, count_return = 0;
|
|
||||||
static double present_time[25000] = {0}, total_time_present = 0;
|
|
||||||
static double return_time[25000] = {0}, total_time_return = 0;
|
|
||||||
|
|
||||||
void presentApiStat(void);
|
|
||||||
void presentApiStat(void) {
|
|
||||||
int i = 0;
|
|
||||||
double min = 10000000, max = 0;
|
|
||||||
double average_launch_time = 0, standard_deviation = 0;
|
|
||||||
if (count_present == 0) return;
|
|
||||||
// lets compute the standard deviation
|
|
||||||
min = max = present_time[1];
|
|
||||||
average_launch_time = (total_time_present) / count_present;
|
|
||||||
for (i = 1; i < count_present; i++) {
|
|
||||||
standard_deviation += (present_time[i] - average_launch_time) *
|
|
||||||
(present_time[i] - average_launch_time);
|
|
||||||
if (present_time[i] < min) min = present_time[i];
|
|
||||||
if (present_time[i] > max) max = present_time[i];
|
|
||||||
}
|
|
||||||
standard_deviation = sqrt(standard_deviation / count_present);
|
|
||||||
printf("present Avg: %lf\n", average_launch_time);
|
|
||||||
printf("present SD: %lf\n", standard_deviation);
|
|
||||||
printf("present min: %lf\n", min);
|
|
||||||
printf("present max: %lf\n", max);
|
|
||||||
|
|
||||||
min = max = return_time[1];
|
|
||||||
average_launch_time = (total_time_return - return_time[0]) / count_return;
|
|
||||||
for (i = 1; i < count_return; i++) {
|
|
||||||
standard_deviation += (return_time[i] - average_launch_time) *
|
|
||||||
(return_time[i] - average_launch_time);
|
|
||||||
if (return_time[i] < min) min = return_time[i];
|
|
||||||
if (return_time[i] > max) max = return_time[i];
|
|
||||||
}
|
|
||||||
standard_deviation = sqrt(standard_deviation / count_return);
|
|
||||||
printf("return Avg: %lf\n", average_launch_time);
|
|
||||||
printf("return SD: %lf\n", standard_deviation);
|
|
||||||
printf("return min: %lf\n", min);
|
|
||||||
printf("return max: %lf\n", max);
|
|
||||||
}
|
|
||||||
CUresult cudaProducerPresentFrame(test_cuda_producer_s *cudaProducer,
|
|
||||||
CUeglFrame cudaEgl, int t) {
|
|
||||||
static int flag = 0;
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
struct timespec start, end;
|
|
||||||
double curTime;
|
|
||||||
CUdeviceptr pDevPtr = (CUdeviceptr)cudaEgl.frame.pPitch[0];
|
|
||||||
cudaProducer_filter(cudaProducer->prodCudaStream, (char *)pDevPtr, WIDTH * 4,
|
|
||||||
HEIGHT, cudaPresentReturnData, PROD_DATA + t, t);
|
|
||||||
if (cudaProducer->profileAPI) {
|
|
||||||
getTime(&start);
|
|
||||||
}
|
|
||||||
status = cuEGLStreamProducerPresentFrame(&cudaProducer->cudaConn, cudaEgl,
|
|
||||||
&cudaProducer->prodCudaStream);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: Present frame failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
flag++;
|
|
||||||
if (cudaProducer->profileAPI && flag > 10) {
|
|
||||||
getTime(&end);
|
|
||||||
curTime = TIME_DIFF(end, start);
|
|
||||||
present_time[count_present++] = curTime;
|
|
||||||
if (count_present == 25000) count_present = 0;
|
|
||||||
total_time_present += curTime;
|
|
||||||
}
|
|
||||||
done:
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
int flag = 0;
|
|
||||||
CUresult cudaProducerReturnFrame(test_cuda_producer_s *cudaProducer,
|
|
||||||
CUeglFrame cudaEgl, int t) {
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
struct timespec start, end;
|
|
||||||
double curTime;
|
|
||||||
CUdeviceptr pDevPtr = 0;
|
|
||||||
|
|
||||||
pDevPtr = (CUdeviceptr)cudaEgl.frame.pPitch[0];
|
|
||||||
if (cudaProducer->profileAPI) {
|
|
||||||
getTime(&start);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
status = cuEGLStreamProducerReturnFrame(&cudaProducer->cudaConn, &cudaEgl,
|
|
||||||
&cudaProducer->prodCudaStream);
|
|
||||||
if (status == CUDA_ERROR_LAUNCH_TIMEOUT) {
|
|
||||||
continue;
|
|
||||||
} else if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: Return frame failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (cudaProducer->profileAPI) {
|
|
||||||
getTime(&end);
|
|
||||||
curTime = TIME_DIFF(end, start);
|
|
||||||
return_time[count_return++] = curTime;
|
|
||||||
if (count_return == 25000) count_return = 0;
|
|
||||||
total_time_return += curTime;
|
|
||||||
}
|
|
||||||
if (flag % 2 == 0) {
|
|
||||||
cudaPresentReturnData++;
|
|
||||||
}
|
|
||||||
cudaProducer_filter(cudaProducer->prodCudaStream, (char *)pDevPtr, WIDTH * 4,
|
|
||||||
HEIGHT, CONS_DATA + t, cudaPresentReturnData, t);
|
|
||||||
flag++;
|
|
||||||
done:
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cudaDeviceCreateProducer(test_cuda_producer_s *cudaProducer) {
|
|
||||||
CUdevice device;
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS != (status = cuInit(0))) {
|
|
||||||
printf("Failed to initialize CUDA\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS !=
|
|
||||||
(status = cuDeviceGet(&device, cudaProducer->cudaDevId))) {
|
|
||||||
printf("failed to get CUDA device\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CUDA_SUCCESS !=
|
|
||||||
(status = cuCtxCreate(&cudaProducer->context, 0, device))) {
|
|
||||||
printf("failed to create CUDA context\n");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
int major = 0, minor = 0;
|
|
||||||
char deviceName[256];
|
|
||||||
cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
|
|
||||||
device);
|
|
||||||
cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
|
|
||||||
device);
|
|
||||||
cuDeviceGetName(deviceName, 256, device);
|
|
||||||
printf(
|
|
||||||
"CUDA Producer on GPU Device %d: \"%s\" with compute capability "
|
|
||||||
"%d.%d\n\n",
|
|
||||||
device, deviceName, major, minor);
|
|
||||||
|
|
||||||
cuCtxPopCurrent(&cudaProducer->context);
|
|
||||||
|
|
||||||
if (major < 6) {
|
|
||||||
printf(
|
|
||||||
"EGLStream_CUDA_CrossGPU requires SM 6.0 or higher arch GPU. "
|
|
||||||
"Exiting...\n");
|
|
||||||
exit(2); // EXIT_WAIVED
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cudaProducerInit(test_cuda_producer_s *cudaProducer, TestArgs *args) {
|
|
||||||
CUresult status = CUDA_SUCCESS;
|
|
||||||
int bufferSize;
|
|
||||||
|
|
||||||
cudaProducer->charCnt = args->charCnt;
|
|
||||||
bufferSize = cudaProducer->charCnt;
|
|
||||||
|
|
||||||
cudaProducer->tempBuff = (char *)malloc(bufferSize);
|
|
||||||
if (!cudaProducer->tempBuff) {
|
|
||||||
printf("Cuda Producer: Failed to allocate image buffer\n");
|
|
||||||
status = CUDA_ERROR_UNKNOWN;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
memset((void *)cudaProducer->tempBuff, INIT_DATA, cudaProducer->charCnt);
|
|
||||||
|
|
||||||
// Fill this init data
|
|
||||||
status = cuMemAlloc(&cudaProducer->cudaPtr, bufferSize);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuda Malloc failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
status = cuMemcpyHtoD(cudaProducer->cudaPtr, (void *)(cudaProducer->tempBuff),
|
|
||||||
bufferSize);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuMemCpy failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill this init data
|
|
||||||
status = cuMemAlloc(&cudaProducer->cudaPtr1, bufferSize);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuda Malloc failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
status = cuMemcpyHtoD(cudaProducer->cudaPtr1,
|
|
||||||
(void *)(cudaProducer->tempBuff), bufferSize);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuMemCpy failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = cuStreamCreate(&cudaProducer->prodCudaStream, 0);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuStreamCreate failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill this init data
|
|
||||||
status = cuMemAlloc(&cudaPtrFake, 100);
|
|
||||||
if (status != CUDA_SUCCESS) {
|
|
||||||
printf("Cuda Producer: cuda Malloc failed, status:%d\n", status);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
atexit(presentApiStat);
|
|
||||||
done:
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CUresult cudaProducerDeinit(test_cuda_producer_s *cudaProducer) {
|
|
||||||
if (cudaProducer->tempBuff) {
|
|
||||||
free(cudaProducer->tempBuff);
|
|
||||||
}
|
|
||||||
if (cudaProducer->cudaPtr) {
|
|
||||||
cuMemFree(cudaProducer->cudaPtr);
|
|
||||||
}
|
|
||||||
return cuEGLStreamProducerDisconnect(&cudaProducer->cudaConn);
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of NVIDIA CORPORATION nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
||||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// DESCRIPTION: Simple cuda producer header file
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef _CUDA_PRODUCER_H_
|
|
||||||
#define _CUDA_PRODUCER_H_
|
|
||||||
#include <EGL/egl.h>
|
|
||||||
#include <EGL/eglext.h>
|
|
||||||
#include "cudaEGL.h"
|
|
||||||
#include "eglstrm_common.h"
|
|
||||||
#include <cuda_runtime.h>
|
|
||||||
#include <cuda.h>
|
|
||||||
|
|
||||||
typedef struct _test_cuda_producer_s {
|
|
||||||
// Stream params
|
|
||||||
CUcontext context;
|
|
||||||
CUeglStreamConnection cudaConn;
|
|
||||||
int cudaDevId;
|
|
||||||
EGLStreamKHR eglStream;
|
|
||||||
EGLDisplay eglDisplay;
|
|
||||||
unsigned int charCnt;
|
|
||||||
bool profileAPI;
|
|
||||||
char *tempBuff;
|
|
||||||
CUdeviceptr cudaPtr;
|
|
||||||
CUdeviceptr cudaPtr1;
|
|
||||||
CUstream prodCudaStream;
|
|
||||||
} test_cuda_producer_s;
|
|
||||||
|
|
||||||
CUresult cudaProducerInit(test_cuda_producer_s *cudaProducer, TestArgs *args);
|
|
||||||
CUresult cudaProducerPresentFrame(test_cuda_producer_s *parserArg,
|
|
||||||
CUeglFrame cudaEgl, int t);
|
|
||||||
CUresult cudaProducerReturnFrame(test_cuda_producer_s *parserArg,
|
|
||||||
CUeglFrame cudaEgl, int t);
|
|
||||||
CUresult cudaProducerDeinit(test_cuda_producer_s *cudaProducer);
|
|
||||||
CUresult cudaDeviceCreateProducer(test_cuda_producer_s *cudaProducer);
|
|
||||||
cudaError_t cudaProducer_filter(CUstream cStream, char *pSrc, int width,
|
|
||||||
int height, char expectedVal, char newVal,
|
|
||||||
int frameNumber);
|
|
||||||
void cudaProducerPrepareFrame(CUeglFrame *cudaEgl, CUdeviceptr cudaPtr,
|
|
||||||
int bufferSize);
|
|
||||||
#endif
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user