Compare commits
788
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc78cfde2f | ||
|
|
1f8c05eb4c | ||
|
|
71fc784c84 | ||
|
|
8123fe0856 | ||
|
|
91461a0cea | ||
|
|
793c9f1664 | ||
|
|
1969bac0cb | ||
|
|
92d2a2f2e8 | ||
|
|
3c6a69b906 | ||
|
|
338e4c892d | ||
|
|
613f6feb4a | ||
|
|
e6875310c1 | ||
|
|
fc33946748 | ||
|
|
6af94a30e3 | ||
|
|
5b63be8239 | ||
|
|
cc8ac3f54d | ||
|
|
9bd77e49ff | ||
|
|
968d2ba049 | ||
|
|
9fd5b04af6 | ||
|
|
07859f93ce | ||
|
|
3d03a1b9fd | ||
|
|
b8190e4aa7 | ||
|
|
a9357e1ec8 | ||
|
|
57f8f776fb | ||
|
|
ffd6cf38bf | ||
|
|
b97567a451 | ||
|
|
bfcf7a9e52 | ||
|
|
16ebe53b72 | ||
|
|
5d0c0a665d | ||
|
|
a81ab0f7a5 | ||
|
|
ff73bda584 | ||
|
|
2fdc10a39c | ||
|
|
13e333d3e2 | ||
|
|
27199e2a4d | ||
|
|
96adaf986c | ||
|
|
5b1b77ba95 | ||
|
|
0961544c85 | ||
|
|
51c02a7e9a | ||
|
|
84337459b8 | ||
|
|
e21640545f | ||
|
|
fd406f02c2 | ||
|
|
d8a64d4bd2 | ||
|
|
78dad7dd65 | ||
|
|
b71f85ec31 | ||
|
|
50781f00eb | ||
|
|
30db7d2433 | ||
|
|
3761774ccf | ||
|
|
f1a7de4e9e | ||
|
|
b54be470e1 | ||
|
|
69e12962fc | ||
|
|
73dd6aac5c | ||
|
|
11a512f2a7 | ||
|
|
91af8ab6e6 | ||
|
|
6165562839 | ||
|
|
72466ee476 | ||
|
|
b70409ab5b | ||
|
|
18d29914ec | ||
|
|
6c0e656030 | ||
|
|
015d129aa6 | ||
|
|
cf886b5907 | ||
|
|
d19e2a1e62 | ||
|
|
df4fcbe3a4 | ||
|
|
bfa616a2a4 | ||
|
|
dfff3b3f98 | ||
|
|
2e0a977784 | ||
|
|
e1575c5cb2 | ||
|
|
ed27598a7a | ||
|
|
cf18cb632c | ||
|
|
e505d1051d | ||
|
|
5a90db192a | ||
|
|
3dbcc5dbbf | ||
|
|
575aa1a0e4 | ||
|
|
4d09d856f6 | ||
|
|
e3e848149c | ||
|
|
ebf055d585 | ||
|
|
d47dd9de39 | ||
|
|
949061d223 | ||
|
|
1e71dc5782 | ||
|
|
6055af1fa9 | ||
|
|
dfdf4b0691 | ||
|
|
5001a0cd1b | ||
|
|
2e56177a2d | ||
|
|
9a7d74eac4 | ||
|
|
6e32ec2be0 | ||
|
|
9f113effd8 | ||
|
|
9c053042c9 | ||
|
|
08a3f3402c | ||
|
|
9c4b8caf1a | ||
|
|
cbede12c47 | ||
|
|
5aa50a4215 | ||
|
|
7ce3f2ccce | ||
|
|
807e141a4d | ||
|
|
9dedec5ecd | ||
|
|
c120ecae1d | ||
|
|
1473a8fd6f | ||
|
|
79f8f71fc3 | ||
|
|
037bbe3ad3 | ||
|
|
0f3fac9536 | ||
|
|
bcadca2c45 | ||
|
|
05abaf2b26 | ||
|
|
21600491b8 | ||
|
|
8cf21599d4 | ||
|
|
c44be3f81d | ||
|
|
47472ed3f1 | ||
|
|
b372729ce6 | ||
|
|
857c1819c9 | ||
|
|
e584f28441 | ||
|
|
81d5f4e862 | ||
|
|
5dfeee45ec | ||
|
|
762c7f8656 | ||
|
|
e23b577e32 | ||
|
|
8e4d059a41 | ||
|
|
063992b25b | ||
|
|
d2f836119a | ||
|
|
6c9852c153 | ||
|
|
80c755188d | ||
|
|
61231bc66c | ||
|
|
0041bf47f1 | ||
|
|
73f6720121 | ||
|
|
e388c11c02 | ||
|
|
2cdf2ddd43 | ||
|
|
18637503f2 | ||
|
|
de41bc9d21 | ||
|
|
07ebcb544d | ||
|
|
3ede61b0cc | ||
|
|
1b7c2fc296 | ||
|
|
ebef3c8656 | ||
|
|
3d70026ae6 | ||
|
|
4d95ef4aec | ||
|
|
1d5db48797 | ||
|
|
b549bd54fe | ||
|
|
c66e8622b3 | ||
|
|
4da35e0bcf | ||
|
|
3fab2792fd | ||
|
|
916ec5047e | ||
|
|
aaa24a6262 | ||
|
|
ef44e88ef9 | ||
|
|
b9da6c67f5 | ||
|
|
6440a9bf41 | ||
|
|
2152fd102d | ||
|
|
aaef92cab2 | ||
|
|
b47d9acaf5 | ||
|
|
c8ff854456 | ||
|
|
0ff75791e5 | ||
|
|
5a77d36635 | ||
|
|
feb99d020f | ||
|
|
16ac9b688f | ||
|
|
013cda1cd2 | ||
|
|
496052e47d | ||
|
|
dc816b4673 | ||
|
|
def9888bd5 | ||
|
|
214f392778 | ||
|
|
94aa6b8e91 | ||
|
|
588c7ba361 | ||
|
|
bd030db5d1 | ||
|
|
23be7f308d | ||
|
|
e231343060 | ||
|
|
12ae185594 | ||
|
|
0dd022779b | ||
|
|
242aa4144b | ||
|
|
93adb56c8e | ||
|
|
39aad5a003 | ||
|
|
804b5b5f53 | ||
|
|
2479ffaaa2 | ||
|
|
c1f1ad9280 | ||
|
|
066a569357 | ||
|
|
2bbccc5ff4 | ||
|
|
099389f64f | ||
|
|
50534789bc | ||
|
|
c11901260a | ||
|
|
44bd244fc4 | ||
|
|
ce6a8da188 | ||
|
|
397472818d | ||
|
|
36aedbb48e | ||
|
|
3eba451d4c | ||
|
|
c27f3139aa | ||
|
|
056098dd86 | ||
|
|
7b82915032 | ||
|
|
225f25a6b9 | ||
|
|
665de3a1f2 | ||
|
|
1a31d4d2d6 | ||
|
|
f84c83afe5 | ||
|
|
5a0b779434 | ||
|
|
a43205a84f | ||
|
|
6f6cf966f8 | ||
|
|
9eead77027 | ||
|
|
2f57ee9157 | ||
|
|
009b013d25 | ||
|
|
0f8271f849 | ||
|
|
c933ad901e | ||
|
|
34e97bf3e6 | ||
|
|
65cd430d76 | ||
|
|
9f2ed5135b | ||
|
|
f982fd70d5 | ||
|
|
f8aa16f8d2 | ||
|
|
683dc0e149 | ||
|
|
8f965c2cb2 | ||
|
|
1a51a84a94 | ||
|
|
2520f9a388 | ||
|
|
35bfe8d191 | ||
|
|
d8e518ac3d | ||
|
|
b31fb5316b | ||
|
|
3d701944b2 | ||
|
|
883fb19908 | ||
|
|
de738ccc2b | ||
|
|
0a0fd33cac | ||
|
|
8985f7ee91 | ||
|
|
9123eff7dd | ||
|
|
af1d5c9f3d | ||
|
|
78c3d25ccf | ||
|
|
be8be03eb8 | ||
|
|
6abee0659e | ||
|
|
bf17f34001 | ||
|
|
223077d11a | ||
|
|
940c1b3a2f | ||
|
|
5703a74e22 | ||
|
|
dbb9507d2b | ||
|
|
4ca7b5a404 | ||
|
|
26a862c7f6 | ||
|
|
a4196b341d | ||
|
|
c0e9370ba2 | ||
|
|
06e2485128 | ||
|
|
374174c7c8 | ||
|
|
3fe4dda4c1 | ||
|
|
39d0e42b11 | ||
|
|
fc1472b5f7 | ||
|
|
0e942bf60c | ||
|
|
d43084cec6 | ||
|
|
8c4b25426f | ||
|
|
174e26164a | ||
|
|
036473347e | ||
|
|
24436febd6 | ||
|
|
d3976cf38d | ||
|
|
801db3d076 | ||
|
|
eb84ef9c8a | ||
|
|
095f25f9a8 | ||
|
|
0555201384 | ||
|
|
d19039fd7f | ||
|
|
7ff179abe9 | ||
|
|
bc6ac3a3ab | ||
|
|
2ee8bc9791 | ||
|
|
bdc441ebd0 | ||
|
|
eae4ede111 | ||
|
|
c643b3b900 | ||
|
|
7e490693e0 | ||
|
|
9296d5218e | ||
|
|
0deb9a2aca | ||
|
|
7a8ae1ab7a | ||
|
|
fd757f2180 | ||
|
|
fe99de24a8 | ||
|
|
41a68f8f78 | ||
|
|
bbd3c6d5b9 | ||
|
|
53275e3a00 | ||
|
|
8ecf0a9101 | ||
|
|
85c212eaad | ||
|
|
f85e3772f9 | ||
|
|
a7905e6802 | ||
|
|
1b124720fe | ||
|
|
282129f584 | ||
|
|
4a8e3d9aaa | ||
|
|
710d9292af | ||
|
|
8658718791 | ||
|
|
415b01f2c0 | ||
|
|
1c3a95213d | ||
|
|
b6a2c5c2ec | ||
|
|
b1db3a230b | ||
|
|
e22aca94f1 | ||
|
|
ee042e5381 | ||
|
|
a1d448d4e0 | ||
|
|
35b728907c | ||
|
|
dcbcf6ba7e | ||
|
|
81051dd75f | ||
|
|
8d67f0f774 | ||
|
|
929eb7ce3d | ||
|
|
dad0110557 | ||
|
|
e7ed0dea5f | ||
|
|
838f108dd4 | ||
|
|
fbd30f784c | ||
|
|
446e1abd66 | ||
|
|
c0fca5c932 | ||
|
|
ebf885d482 | ||
|
|
be1f64446a | ||
|
|
054af6526c | ||
|
|
1d111c0ec1 | ||
|
|
5a69056ee5 | ||
|
|
7ffe65c262 | ||
|
|
24f452adf6 | ||
|
|
6f4a1baa00 | ||
|
|
d58490911a | ||
|
|
35738cec23 | ||
|
|
e1fd687b9b | ||
|
|
099195e39d | ||
|
|
f2f11b2331 | ||
|
|
7a62bf37fa | ||
|
|
a823cca7f9 | ||
|
|
c3c977da04 | ||
|
|
096f136c36 | ||
|
|
4944e1a098 | ||
|
|
08d58aebb1 | ||
|
|
7c9ec8629f | ||
|
|
6cd53a2305 | ||
|
|
b0617ba0fc | ||
|
|
4e769915d8 | ||
|
|
7d4c48d1d8 | ||
|
|
7fd2df5ba9 | ||
|
|
9bb9af49b2 | ||
|
|
fc27c25436 | ||
|
|
e18355ea9a | ||
|
|
47530cf9ba | ||
|
|
fcf6c1167b | ||
|
|
6e95407dcf | ||
|
|
6e9fe540b6 | ||
|
|
e584c86d88 | ||
|
|
da64c50059 | ||
|
|
7c1137f335 | ||
|
|
934f0e5054 | ||
|
|
4a7e239d7c | ||
|
|
a237601747 | ||
|
|
2e16d00f63 | ||
|
|
76a22479b1 | ||
|
|
394d50987c | ||
|
|
8ceb5cfd65 | ||
|
|
d796a801c5 | ||
|
|
e75b26feb4 | ||
|
|
0cc87b68a9 | ||
|
|
a4404bc325 | ||
|
|
be73cd1ae0 | ||
|
|
5fb84189b2 | ||
|
|
55932ee6f0 | ||
|
|
94d86ca3b3 | ||
|
|
41543b5c0b | ||
|
|
e4476a5eee | ||
|
|
d7c2168f2b | ||
|
|
64e14b7d82 | ||
|
|
2247605d23 | ||
|
|
21115b7fc6 | ||
|
|
e50556b637 | ||
|
|
1e3db41a8d | ||
|
|
e9b88b45e4 | ||
|
|
d3e2088398 | ||
|
|
113e22de2e | ||
|
|
61ff92b5b4 | ||
|
|
2308f555c3 | ||
|
|
0d9d3520ac | ||
|
|
03b2bddc16 | ||
|
|
47f309ffb4 | ||
|
|
2673b3aeff | ||
|
|
c4d6310143 | ||
|
|
31bd1697b1 | ||
|
|
8d4d4d65ce | ||
|
|
26c7316a08 | ||
|
|
2d83f74a7e | ||
|
|
098310abc6 | ||
|
|
d43dc9a021 | ||
|
|
e12d666d36 | ||
|
|
957d919a6a | ||
|
|
3b7ef923c7 | ||
|
|
82a7e62b30 | ||
|
|
ef817df79a | ||
|
|
dec6dbed77 | ||
|
|
e90ade048a | ||
|
|
59a6cd133b | ||
|
|
355b835ae0 | ||
|
|
4868c412b0 | ||
|
|
a7d54cd7ef | ||
|
|
c3d10db873 | ||
|
|
e5d1cf8416 | ||
|
|
6a9280a045 | ||
|
|
5a08c21355 | ||
|
|
32f212469b | ||
|
|
5bf1f98200 | ||
|
|
8fd2739a65 | ||
|
|
fc84c719e9 | ||
|
|
9dfa757dc7 | ||
|
|
8fbfe2cfda | ||
|
|
58c0bb5c02 | ||
|
|
d195f2e8a2 | ||
|
|
c6dcc5e5cf | ||
|
|
8db5a0bc9e | ||
|
|
c7cfe0e2ca | ||
|
|
ab5cc7162e | ||
|
|
c2214091ae | ||
|
|
4e1e03b891 | ||
|
|
934555994d | ||
|
|
922c2a5cd7 | ||
|
|
ee93927fac | ||
|
|
42789f1a0d | ||
|
|
5f12943de5 | ||
|
|
b641bfdf8b | ||
|
|
3f589cc4db | ||
|
|
87edf84bf3 | ||
|
|
b3adebdf2a | ||
|
|
2ebcd1fbd5 | ||
|
|
8fb92415fb | ||
|
|
2ee86e8f47 | ||
|
|
e1c4b3042c | ||
|
|
8ec5dd7d8e | ||
|
|
ec054db317 | ||
|
|
41707760f5 | ||
|
|
fade2b74b5 | ||
|
|
5308898d1c | ||
|
|
4babf37256 | ||
|
|
cd64f9b0e7 | ||
|
|
8f98bde4fb | ||
|
|
6e64383b32 | ||
|
|
ac1f6ad1bb | ||
|
|
4b40c16359 | ||
|
|
bcbb959a34 | ||
|
|
9a13624c2e | ||
|
|
629d987177 | ||
|
|
21f5435420 | ||
|
|
877f25aee5 | ||
|
|
5be0a5c586 | ||
|
|
64e997e9d6 | ||
|
|
01f3183c31 | ||
|
|
e4414752c4 | ||
|
|
e3548f46f3 | ||
|
|
736f916da3 | ||
|
|
c9ef0b6b39 | ||
|
|
b256ca47a0 | ||
|
|
6500e7401a | ||
|
|
da8a31c4e5 | ||
|
|
53cd591956 | ||
|
|
4b04ca8027 | ||
|
|
c9a66b696f | ||
|
|
d4e191610e | ||
|
|
3788fef9fd | ||
|
|
21630d5fbc | ||
|
|
e2f73614c0 | ||
|
|
40fc2bdcbc | ||
|
|
d923f0c1b2 | ||
|
|
6b69246c33 | ||
|
|
c5df142124 | ||
|
|
15293d063f | ||
|
|
aa271104c1 | ||
|
|
25a78c96b5 | ||
|
|
5abfac72d6 | ||
|
|
7c5087d01c | ||
|
|
b5b9b1f2db | ||
|
|
b9cfee0bb3 | ||
|
|
f73f5f6a2e | ||
|
|
cad3772122 | ||
|
|
7981e83db7 | ||
|
|
e21c75793a | ||
|
|
7661f73317 | ||
|
|
cb9d51c026 | ||
|
|
a12dfa5370 | ||
|
|
6b41234ff1 | ||
|
|
1187a6e7e3 | ||
|
|
9aac7ca713 | ||
|
|
576884b199 | ||
|
|
9f5744d4c0 | ||
|
|
634bea21f5 | ||
|
|
42bcb91ca0 | ||
|
|
4709668995 | ||
|
|
79ee0ec264 | ||
|
|
d764b5cca2 | ||
|
|
b72b4c5a5f | ||
|
|
268c89f9a2 | ||
|
|
2907a7c678 | ||
|
|
fcd3e4336b | ||
|
|
48b3f119be | ||
|
|
efd507fb3b | ||
|
|
39238f077d | ||
|
|
5636e2be5e | ||
|
|
d25b42e41b | ||
|
|
3e419abf84 | ||
|
|
a55b148ecc | ||
|
|
cf077902d0 | ||
|
|
82908b3f67 | ||
|
|
b02f79b58b | ||
|
|
2b43d57d42 | ||
|
|
e95712a2ea | ||
|
|
ed4927fcd0 | ||
|
|
555504bd98 | ||
|
|
2ea4635ef7 | ||
|
|
76b63b5a71 | ||
|
|
e791039592 | ||
|
|
98f2f8c745 | ||
|
|
c2f319fa86 | ||
|
|
ebe95aac2f | ||
|
|
52df82917a | ||
|
|
0224d4705e | ||
|
|
123fe287b6 | ||
|
|
85394cf22b | ||
|
|
0c545eb724 | ||
|
|
f2c7a45e47 | ||
|
|
75d721adb9 | ||
|
|
e99ff6c15b | ||
|
|
cbd7865a79 | ||
|
|
a08056ed2a | ||
|
|
c9d110e543 | ||
|
|
7500af78eb | ||
|
|
5be1521294 | ||
|
|
b165cc32e6 | ||
|
|
2d5755d1ef | ||
|
|
90c26c8418 | ||
|
|
692041aa74 | ||
|
|
0618c2abc3 | ||
|
|
b2b76f8006 | ||
|
|
f1a55b3388 | ||
|
|
58a5ccfd6a | ||
|
|
bbd2c704f9 | ||
|
|
298573b45d | ||
|
|
7456acc01c | ||
|
|
a2b6488c01 | ||
|
|
87a521ac14 | ||
|
|
d7abd01bf4 | ||
|
|
b1bddb54d6 | ||
|
|
9aace79718 | ||
|
|
d9b0312897 | ||
|
|
c418eff4e9 | ||
|
|
374cd50f00 | ||
|
|
809cd3dc42 | ||
|
|
4daaf1908d | ||
|
|
0d89236fd4 | ||
|
|
0ab02df9e2 | ||
|
|
b4ab64e5f3 | ||
|
|
76f8fbabae | ||
|
|
51abf151ee | ||
|
|
477d3bfd7c | ||
|
|
051ba521be | ||
|
|
fbafe814dd | ||
|
|
4c3892f268 | ||
|
|
3955eb7a1d | ||
|
|
7bf256c81c | ||
|
|
2f541065fb | ||
|
|
b35a6742fe | ||
|
|
4b4564ff93 | ||
|
|
afe57f8341 | ||
|
|
ff27ccb80e | ||
|
|
7c769211a8 | ||
|
|
12fd78e2be | ||
|
|
be478bd725 | ||
|
|
74e94fa1ec | ||
|
|
03c3b7d341 | ||
|
|
34fd408440 | ||
|
|
954dbf2388 | ||
|
|
c722fafe49 | ||
|
|
1b31f11252 | ||
|
|
7c7f40a634 | ||
|
|
6bb128c055 | ||
|
|
75313cbf1c | ||
|
|
73af5c583c | ||
|
|
464c45034a | ||
|
|
e1b274ef65 | ||
|
|
15584e4f05 | ||
|
|
65c1d787e7 | ||
|
|
2113be6eec | ||
|
|
d1966cc085 | ||
|
|
3d3f2e2cb5 | ||
|
|
b1e9277611 | ||
|
|
d2ced77ae8 | ||
|
|
7cd74cb212 | ||
|
|
7edc02633f | ||
|
|
22c28ccbef | ||
|
|
a0c8bd8be4 | ||
|
|
e74d5884b4 | ||
|
|
ca9ec1b803 | ||
|
|
a6d88abbc9 | ||
|
|
9208888c57 | ||
|
|
4f379803d3 | ||
|
|
1ad34dc13d | ||
|
|
c7698afb4a | ||
|
|
c6a94c9998 | ||
|
|
b8b810f30d | ||
|
|
9dc78da2ee | ||
|
|
275a028935 | ||
|
|
e7ae27137e | ||
|
|
163430daae | ||
|
|
d58d53f2b2 | ||
|
|
7963dbb438 | ||
|
|
48515ad707 | ||
|
|
0fceca6ffe | ||
|
|
dcdafd8732 | ||
|
|
7c25f6dc0a | ||
|
|
37395eefe4 | ||
|
|
6d74256c2d | ||
|
|
4f43abb402 | ||
|
|
38e6672d70 | ||
|
|
4426700e31 | ||
|
|
f86784ee56 | ||
|
|
a37e909db9 | ||
|
|
5988e945ef | ||
|
|
9734186a37 | ||
|
|
e7567332f4 | ||
|
|
ae8e863591 | ||
|
|
35cc5908ee | ||
|
|
8b1137d5ec | ||
|
|
7f00bce5ae | ||
|
|
4acb9c5743 | ||
|
|
86a31172b0 | ||
|
|
2c2269dcb6 | ||
|
|
5e42389b4b | ||
|
|
d6a421ae10 | ||
|
|
ebd23bcc66 | ||
|
|
c1cfb3a131 | ||
|
|
77c737ff72 | ||
|
|
7939dce0aa | ||
|
|
10d4f4a96a | ||
|
|
f8f46bfe5b | ||
|
|
0019936328 | ||
|
|
0f604439f5 | ||
|
|
7048300ab8 | ||
|
|
3ed1c552bd | ||
|
|
9c4158aadb | ||
|
|
7fd594c922 | ||
|
|
e17d19cf26 | ||
|
|
e6112e878d | ||
|
|
81fd04a208 | ||
|
|
c41d9e7bb6 | ||
|
|
a537fa304c | ||
|
|
836e9bd535 | ||
|
|
20e6ee1062 | ||
|
|
09c3ac6b4b | ||
|
|
5dd2534df9 | ||
|
|
bb71232f18 | ||
|
|
00803b0b8d | ||
|
|
a74df25834 | ||
|
|
e3fc059bd7 | ||
|
|
2d5e8aaced | ||
|
|
10a5e13fb3 | ||
|
|
a452c330dd | ||
|
|
872a55a180 | ||
|
|
c7d3498bd8 | ||
|
|
3938dce740 | ||
|
|
26b51a557b | ||
|
|
768b5ccb76 | ||
|
|
9f2dd3ee60 | ||
|
|
45206e49c1 | ||
|
|
bba2df56d5 | ||
|
|
833238cae5 | ||
|
|
dfa9f63886 | ||
|
|
2a5233f56e | ||
|
|
bec89724d5 | ||
|
|
cafd4477d7 | ||
|
|
65cefa4a7d | ||
|
|
c3b6162899 | ||
|
|
6500160fe1 | ||
|
|
b521acb480 | ||
|
|
29c3db5dc6 | ||
|
|
ec454dd78c | ||
|
|
f761531436 | ||
|
|
5cbf239d8a | ||
|
|
b3188669e2 | ||
|
|
da2e2528a7 | ||
|
|
2dce6733a7 | ||
|
|
f08bd79a6e | ||
|
|
756ea89ecd | ||
|
|
150d6eb290 | ||
|
|
90efbdcece | ||
|
|
ec5a48f420 | ||
|
|
a66d78e692 | ||
|
|
010eba1760 | ||
|
|
9b5d3bf528 | ||
|
|
ac9b0d27ee | ||
|
|
63e3387dbb | ||
|
|
1e24e4899c | ||
|
|
2585e10814 | ||
|
|
fa7d744a6c | ||
|
|
7a0f7ab276 | ||
|
|
d09ec41251 | ||
|
|
70743eb48d | ||
|
|
49a73971c4 | ||
|
|
f9bba0ff1a | ||
|
|
ef8a73d6aa | ||
|
|
78f2dd6ffd | ||
|
|
5db46b74b5 | ||
|
|
c5b349e079 | ||
|
|
6c7fce187b | ||
|
|
c3bdb623e8 | ||
|
|
f387898ead | ||
|
|
a186a4df8b | ||
|
|
543de0a73c | ||
|
|
2dcf983290 | ||
|
|
56ed0fed05 | ||
|
|
118a6be361 | ||
|
|
cc9df2d361 | ||
|
|
56170bb32e | ||
|
|
c218c3f514 | ||
|
|
8ad180cc70 | ||
|
|
f524917bef | ||
|
|
1b65cd05cc | ||
|
|
1032f191bf | ||
|
|
6ae28162db | ||
|
|
cb3f893a85 | ||
|
|
d3258d8bcd | ||
|
|
9b1ff1280e | ||
|
|
9a97f0cf6e | ||
|
|
7e15f31706 | ||
|
|
71f9003901 | ||
|
|
3e8457d76c | ||
|
|
dc5d1b112d | ||
|
|
1dfbe6dfb5 | ||
|
|
484bbc4b15 | ||
|
|
aec310d4a7 | ||
|
|
d0ad1017e9 | ||
|
|
a33058b554 | ||
|
|
858c3d9370 | ||
|
|
2300326b7a | ||
|
|
d0316220dd | ||
|
|
1fcde52afd | ||
|
|
ac641a0761 | ||
|
|
c88750332c | ||
|
|
f42bb85785 | ||
|
|
e2ac7a2a75 | ||
|
|
aa74aa33e2 | ||
|
|
84d7d926c9 | ||
|
|
d7c13b0611 | ||
|
|
6699b8a71f | ||
|
|
9a8b7ff0d7 | ||
|
|
1fcdeab53b | ||
|
|
7bb86defcc | ||
|
|
94c9945fe6 | ||
|
|
f0d91ab8a6 | ||
|
|
b824a63cde | ||
|
|
3be08ad944 | ||
|
|
e72c6d4785 | ||
|
|
5a869d1c63 | ||
|
|
2ea9da1415 | ||
|
|
7d88e5cca1 | ||
|
|
7ce3fed611 | ||
|
|
5ddc8de9da | ||
|
|
26b9fe3586 | ||
|
|
73f22b237a | ||
|
|
1bc4e7e942 | ||
|
|
3ad4be7de0 | ||
|
|
b24b65a9c9 | ||
|
|
17cf3767e9 | ||
|
|
582c971f2b | ||
|
|
b4ef7b981f | ||
|
|
047e79a9fc | ||
|
|
6a9b8a5ab2 | ||
|
|
bdfce54c3b | ||
|
|
fe4ad36b73 | ||
|
|
f5e77452f0 | ||
|
|
d062f93bf5 | ||
|
|
dca216f992 | ||
|
|
c859041993 | ||
|
|
438308b3a2 | ||
|
|
11dbbcc12d | ||
|
|
14a41959f8 | ||
|
|
44a551c52e | ||
|
|
59391e25ec | ||
|
|
ae29d984c1 | ||
|
|
fdd5d29071 | ||
|
|
89aaafad2c | ||
|
|
e18a54e8fc | ||
|
|
851a26c2a2 | ||
|
|
c7008f3f6c | ||
|
|
2aea2c3ccc | ||
|
|
3e43553735 | ||
|
|
7a2fe83aaa | ||
|
|
cc05128ae3 | ||
|
|
124dc6ea57 | ||
|
|
3652c708b9 | ||
|
|
e82f5d4d75 | ||
|
|
3d2260acc4 | ||
|
|
e139736a2f | ||
|
|
63eb163e32 | ||
|
|
3dcfa5d84f | ||
|
|
dedcd06207 | ||
|
|
15eea1bc81 | ||
|
|
e40a7a720c | ||
|
|
49f3c454c2 | ||
|
|
1118d6c3db | ||
|
|
2e0bc5e133 | ||
|
|
11a4bb1797 | ||
|
|
f58b2d3d21 | ||
|
|
4958ce6007 | ||
|
|
e1c84da07f | ||
|
|
3550d6a889 | ||
|
|
0317706464 | ||
|
|
66845a9b36 | ||
|
|
88c8fa2973 | ||
|
|
b128312efb | ||
|
|
99bbe380fd | ||
|
|
51b4f32420 | ||
|
|
64cfe358cb | ||
|
|
ec709af62f | ||
|
|
8259ed7f29 | ||
|
|
7a4e1bb327 | ||
|
|
98451267d8 | ||
|
|
7acf987aba | ||
|
|
a35b150b7f | ||
|
|
2ab1e3700f | ||
|
|
11c5ec810d | ||
|
|
9f62014690 |
No files matched your search
+18
-2
@@ -15,7 +15,7 @@ depcomp
|
||||
missing
|
||||
install-sh
|
||||
stamp-h1
|
||||
cpuminer-config.h*
|
||||
ccminer-config.h*
|
||||
compile
|
||||
config.log
|
||||
config.status
|
||||
@@ -25,7 +25,7 @@ config.sub
|
||||
|
||||
mingw32-config.cache
|
||||
|
||||
*/.dirstamp
|
||||
.dirstamp
|
||||
.DS_Store
|
||||
Desktop.ini
|
||||
Thumbs.db
|
||||
@@ -41,6 +41,8 @@ x64/Release/
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.pdb
|
||||
*.VC.opendb
|
||||
*.VC.db
|
||||
|
||||
.settings/
|
||||
.project
|
||||
@@ -52,3 +54,17 @@ x64/Release/
|
||||
|
||||
compat/curl-for-windows/
|
||||
|
||||
*.ptx
|
||||
*.i
|
||||
*.ii
|
||||
*.gpu
|
||||
*.cubin
|
||||
*.stub.c
|
||||
*.module_id
|
||||
*.hash
|
||||
*.fatbin.c
|
||||
*.fatbin
|
||||
*.cudafe1.cpp
|
||||
*.cudafe1.c
|
||||
*.cudafe2.c
|
||||
|
||||
@@ -0,0 +1,599 @@
|
||||
/**
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5/5.2)
|
||||
*
|
||||
* Tanguy Pruvot / SP - Jan 2016
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
}
|
||||
|
||||
/* threads per block */
|
||||
#define TPB 512
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14)
|
||||
{
|
||||
uchar hash[64];
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(rounds);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 80);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
__constant__ uint32_t _ALIGN(32) d_data[12];
|
||||
|
||||
/* 8 adapters max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
/* max count of found nonces in one call */
|
||||
#define NBN 2
|
||||
static __thread uint32_t extra_results[NBN] = { UINT32_MAX };
|
||||
|
||||
#define GSPREC(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ c_u256[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ c_u256[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void blake256_compress_14(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
{
|
||||
uint32_t /*_ALIGN(8)*/ m[16];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = block[0];
|
||||
m[1] = block[1];
|
||||
m[2] = block[2];
|
||||
m[3] = block[3];
|
||||
|
||||
const uint32_t c_u256[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
const uint32_t c_Padding[12] = {
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
#pragma unroll
|
||||
for (uint32_t i = 0; i < 12; i++) {
|
||||
m[i+4] = c_Padding[i];
|
||||
}
|
||||
|
||||
//#pragma unroll 8
|
||||
for(uint32_t i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = c_u256[0];
|
||||
v[ 9] = c_u256[1];
|
||||
v[10] = c_u256[2];
|
||||
v[11] = c_u256[3];
|
||||
|
||||
v[12] = c_u256[4] ^ T0;
|
||||
v[13] = c_u256[5] ^ T0;
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC,0,1);
|
||||
GSPREC(1, 5, 0x9, 0xD,2,3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4,5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6,7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8,9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10,11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12,13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14,15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 6, 15);
|
||||
GSPREC(1, 5, 0x9, 0xD, 14, 9);
|
||||
GSPREC(2, 6, 0xA, 0xE, 11, 3);
|
||||
GSPREC(3, 7, 0xB, 0xF, 0, 8);
|
||||
GSPREC(0, 5, 0xA, 0xF, 12, 2);
|
||||
GSPREC(1, 6, 0xB, 0xC, 13, 7);
|
||||
GSPREC(2, 7, 0x8, 0xD, 1, 4);
|
||||
GSPREC(3, 4, 0x9, 0xE, 10, 5);
|
||||
// { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 10, 2);
|
||||
GSPREC(1, 5, 0x9, 0xD, 8, 4);
|
||||
GSPREC(2, 6, 0xA, 0xE, 7, 6);
|
||||
GSPREC(3, 7, 0xB, 0xF, 1, 5);
|
||||
GSPREC(0, 5, 0xA, 0xF, 15, 11);
|
||||
GSPREC(1, 6, 0xB, 0xC, 9, 14);
|
||||
GSPREC(2, 7, 0x8, 0xD, 3, 12);
|
||||
GSPREC(3, 4, 0x9, 0xE, 13, 0);
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
|
||||
// only compute h6 & 7
|
||||
h[6U] ^= v[6U] ^ v[14U];
|
||||
h[7U] ^= v[7U] ^ v[15U];
|
||||
}
|
||||
|
||||
/* ############################################################################################################################### */
|
||||
/* Precalculated 1st 64-bytes block (midstate) method */
|
||||
|
||||
__global__ __launch_bounds__(1024,1)
|
||||
void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint64_t highTarget)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t _ALIGN(16) h[8];
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0; i < 8; i++) {
|
||||
h[i] = d_data[i];
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t _ALIGN(16) ending[4];
|
||||
ending[0] = d_data[8];
|
||||
ending[1] = d_data[9];
|
||||
ending[2] = d_data[10];
|
||||
ending[3] = nonce; /* our tested value */
|
||||
|
||||
blake256_compress_14(h, ending, 640);
|
||||
|
||||
if (h[7] == 0 && cuda_swab32(h[6]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
if (resNonce[0] != UINT32_MAX)
|
||||
resNonce[1] = nonce;
|
||||
else
|
||||
resNonce[0] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
__launch_bounds__(512, 3) /* 40 regs */
|
||||
#endif
|
||||
void blake256_gpu_hash_16_8(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint64_t highTarget)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t h[8];
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 8; i++) {
|
||||
h[i] = d_data[i];
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t m[16] = {
|
||||
d_data[8], d_data[9], d_data[10], nonce,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
const uint32_t c_u256[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
uint32_t v[16];
|
||||
|
||||
#pragma unroll
|
||||
for (uint32_t i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = c_u256[0];
|
||||
v[9] = c_u256[1];
|
||||
v[10] = c_u256[2];
|
||||
v[11] = c_u256[3];
|
||||
|
||||
v[12] = c_u256[4] ^ 640U;
|
||||
v[13] = c_u256[5] ^ 640U;
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
//GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
|
||||
// only compute h6 & 7
|
||||
//h[6] ^= v[6] ^ v[14];
|
||||
//h[7] ^= v[7] ^ v[15];
|
||||
|
||||
if ((h[7]^v[7]^v[15]) == 0) // h7
|
||||
{
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
if (cuda_swab32(h[6]^v[6]^v[14]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
if (resNonce[0] != UINT32_MAX)
|
||||
resNonce[1] = nonce;
|
||||
else
|
||||
resNonce[0] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
static uint32_t blake256_cpu_hash_16(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint64_t highTarget,
|
||||
const int8_t rounds)
|
||||
{
|
||||
uint32_t result = UINT32_MAX;
|
||||
|
||||
dim3 grid((threads + TPB-1)/TPB);
|
||||
dim3 block(TPB);
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonce[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
if (rounds == 8)
|
||||
blake256_gpu_hash_16_8 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget);
|
||||
else
|
||||
blake256_gpu_hash_16 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget);
|
||||
|
||||
if (cudaSuccess == cudaMemcpy(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
result = h_resNonce[thr_id][0];
|
||||
for (int n=0; n < (NBN-1); n++)
|
||||
extra_results[n] = h_resNonce[thr_id][n+1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
static void blake256mid(uint32_t *output, const uint32_t *input, int8_t rounds = 14)
|
||||
{
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(rounds);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 64);
|
||||
|
||||
memcpy(output, (void*)ctx.H, 32);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_16(uint32_t *penddata, const uint32_t *midstate, const uint32_t *ptarget)
|
||||
{
|
||||
uint32_t _ALIGN(64) data[11];
|
||||
memcpy(data, midstate, 32);
|
||||
data[8] = penddata[0];
|
||||
data[9] = penddata[1];
|
||||
data[10]= penddata[2];
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(d_data, data, 32 + 12, 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_blake256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t _ALIGN(64) midstate[8];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint64_t targetHigh = ((uint64_t*)ptarget)[3];
|
||||
|
||||
int dev_id = device_map[thr_id];
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 30 : 26;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
int rc = 0;
|
||||
|
||||
if (opt_benchmark) {
|
||||
targetHigh = 0x1ULL << 32;
|
||||
ptarget[6] = swab32(0xff);
|
||||
}
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k = 0; k < 16; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
blake256mid(midstate, endiandata, blakerounds);
|
||||
blake256_cpu_setBlock_16(&pdata[16], midstate, ptarget);
|
||||
|
||||
do {
|
||||
// GPU HASH (second block only, first is midstate)
|
||||
work->nonces[0] = blake256_cpu_hash_16(thr_id, throughput, pdata[19], targetHigh, blakerounds);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
uint32_t _ALIGN(64) vhashcpu[8];
|
||||
const uint32_t Htarg = ptarget[6];
|
||||
|
||||
for (int k=16; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
#if NBN > 1
|
||||
if (extra_results[0] != UINT32_MAX) {
|
||||
work->nonces[1] = extra_results[0];
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) {
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
xchg(work->nonces[0], work->nonces[1]);
|
||||
} else {
|
||||
bn_set_target_ratio(work, vhashcpu, 1);
|
||||
}
|
||||
work->valid_nonces = 2;
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
extra_results[0] = UINT32_MAX;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhashcpu[6] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + pdata[19]);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
MyStreamSynchronize(NULL, 0, device_map[thr_id]);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_blake256(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,565 @@
|
||||
/**
|
||||
* Based on the SPH implementation of blake2s
|
||||
* Provos Alexis - 2016
|
||||
*/
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "sph/blake2s.h"
|
||||
#include "sph/sph_types.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t ROR8(const uint32_t a) {
|
||||
return __byte_perm(a, 0, 0x0321);
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t ROL16(const uint32_t a) {
|
||||
return __byte_perm(a, 0, 0x1032);
|
||||
}
|
||||
|
||||
#else
|
||||
#define ROR8(u) (u >> 8)
|
||||
#define ROL16(u) (u << 16)
|
||||
#endif
|
||||
|
||||
__device__ __forceinline__
|
||||
uint32_t xor3x(uint32_t a, uint32_t b, uint32_t c)
|
||||
{
|
||||
uint32_t result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result) : "r"(a), "r"(b),"r"(c)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
#else
|
||||
result = a^b^c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
static const uint32_t blake2s_IV[8] = {
|
||||
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
|
||||
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
|
||||
};
|
||||
|
||||
static const uint8_t blake2s_sigma[10][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
|
||||
};
|
||||
|
||||
#define G(r,i,a,b,c,d) \
|
||||
do { \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
|
||||
d = SPH_ROTR32(d ^ a, 16); \
|
||||
c = c + d; \
|
||||
b = SPH_ROTR32(b ^ c, 12); \
|
||||
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
|
||||
d = SPH_ROTR32(d ^ a, 8); \
|
||||
c = c + d; \
|
||||
b = SPH_ROTR32(b ^ c, 7); \
|
||||
} while(0)
|
||||
#define ROUND(r) \
|
||||
do { \
|
||||
G(r,0,v[0],v[4],v[ 8],v[12]); \
|
||||
G(r,1,v[1],v[5],v[ 9],v[13]); \
|
||||
G(r,2,v[2],v[6],v[10],v[14]); \
|
||||
G(r,3,v[3],v[7],v[11],v[15]); \
|
||||
G(r,4,v[0],v[5],v[10],v[15]); \
|
||||
G(r,5,v[1],v[6],v[11],v[12]); \
|
||||
G(r,6,v[2],v[7],v[ 8],v[13]); \
|
||||
G(r,7,v[3],v[4],v[ 9],v[14]); \
|
||||
} while(0)
|
||||
|
||||
extern "C" void blake2s_hash(void *output, const void *input)
|
||||
{
|
||||
uint32_t m[16];
|
||||
uint32_t v[16];
|
||||
uint32_t h[8];
|
||||
|
||||
uint32_t *in = (uint32_t*)input;
|
||||
// COMPRESS
|
||||
for(int i = 0; i < 16; ++i )
|
||||
m[i] = in[i];
|
||||
|
||||
h[0] = 0x01010020 ^ blake2s_IV[0];
|
||||
h[1] = blake2s_IV[1];
|
||||
h[2] = blake2s_IV[2];
|
||||
h[3] = blake2s_IV[3];
|
||||
h[4] = blake2s_IV[4];
|
||||
h[5] = blake2s_IV[5];
|
||||
h[6] = blake2s_IV[6];
|
||||
h[7] = blake2s_IV[7];
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 64 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
// COMPRESS
|
||||
m[0] = in[16]; m[1] = in[17];
|
||||
m[2] = in[18]; m[3] = in[19];
|
||||
for(size_t i = 4; i < 16; ++i)
|
||||
m[i] = 0;
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 0x50 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = ~blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(size_t i = 0; i < 8; ++i)
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
memcpy(output, h, 32);
|
||||
}
|
||||
|
||||
#define TPB 1024
|
||||
#define NPT 256
|
||||
#define maxResults 16
|
||||
#define NBN 1
|
||||
|
||||
__constant__ uint32_t _ALIGN(32) midstate[20];
|
||||
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
#define GS4(a,b,c,d,e,f,a1,b1,c1,d1,e1,f1,a2,b2,c2,d2,e2,f2,a3,b3,c3,d3,e3,f3){ \
|
||||
a += b + e; a1+= b1 + e1; a2+= b2 + e2; a3+= b3 + e3; \
|
||||
d = ROL16( d ^ a); d1 = ROL16(d1 ^ a1); d2 = ROL16(d2 ^ a2); d3 = ROL16(d3 ^ a3); \
|
||||
c +=d; c1+=d1; c2+=d2; c3+=d3;\
|
||||
b = ROTR32(b ^ c, 12); b1 = ROTR32(b1^c1, 12); b2 = ROTR32(b2^c2, 12); b3 = ROTR32(b3^c3, 12); \
|
||||
a += b + f; a1+= b1 + f1; a2+= b2 + f2; a3+= b3 + f3; \
|
||||
d = ROR8(d ^ a); d1 = ROR8(d1^a1); d2 = ROR8(d2^a2); d3 = ROR8(d3^a3); \
|
||||
c += d; c1 += d1; c2 += d2; c3 += d3;\
|
||||
b = ROTR32(b ^ c, 7); b1 = ROTR32(b1^c1, 7); b2 = ROTR32(b2^c2, 7); b3 = ROTR32(b3^c3, 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void blake2s_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint32_t ptarget7)
|
||||
{
|
||||
const uint32_t step = gridDim.x * blockDim.x;
|
||||
|
||||
uint32_t m[ 3];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = midstate[16];
|
||||
m[1] = midstate[17];
|
||||
m[2] = midstate[18];
|
||||
|
||||
const uint32_t h7 = midstate[19];
|
||||
|
||||
for(uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x ; thread <threads; thread+=step){
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
v[ i] = midstate[ i];
|
||||
}
|
||||
|
||||
uint32_t nonce = cuda_swab32(startNonce + thread);
|
||||
// Round( 0 );
|
||||
v[ 1] += nonce;
|
||||
v[13] = ROR8(v[13] ^ v[ 1]);
|
||||
v[ 9] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[ 9], 7);
|
||||
|
||||
v[ 1]+= v[ 6];
|
||||
v[ 0]+= v[ 5];
|
||||
|
||||
v[12] = ROL16(v[12] ^ v[ 1]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
|
||||
v[11]+= v[12]; v[ 8]+= v[13]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 12); v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 1]+= v[ 6]; v[ 2]+= v[ 7]; v[ 3]+= v[ 4]; v[ 0]+= v[ 5];
|
||||
v[12] = ROR8(v[12] ^ v[ 1]); v[13] = ROR8(v[13] ^ v[ 2]); v[14] = ROR8(v[14] ^ v[ 3]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[ 8]+= v[13]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 7] = ROTR32(v[ 7] ^ v[ 8], 7); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 1],0, v[ 1],v[ 6],v[11],v[12],m[ 0],m[ 2], v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],0,nonce);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,m[ 0], v[ 2],v[ 6],v[10],v[14],0,m[ 2], v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],nonce,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 1], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],nonce,m[ 1], v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 2],0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 0], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 0], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 2],0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 1], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],nonce,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],m[ 2],0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 0],0, v[ 3],v[ 7],v[11],v[15],0,nonce);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 1],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],m[ 1],0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 0],0, v[ 1],v[ 6],v[11],v[12],0,nonce, v[ 2],v[ 7],v[ 8],v[13],0,m[ 2], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,m[ 1], v[ 3],v[ 7],v[11],v[15],nonce,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 0], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 2],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,nonce, v[ 3],v[ 7],v[11],v[15],m[ 0],0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 2], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],m[ 1],0, v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 2], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],m[ 1],0);
|
||||
|
||||
// GS(9,4,v[ 0],v[ 5],v[10],v[15]);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7] + nonce;
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[10] += v[15];
|
||||
v[ 8] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7];
|
||||
v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[13] = ROR8(v[13] ^ v[ 2]);
|
||||
|
||||
v[ 8] += v[13];
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 7);
|
||||
|
||||
if (xor3x(h7,v[7],v[15]) <= ptarget7){
|
||||
uint32_t pos = atomicInc(&resNonce[0],0xffffffff)+1;
|
||||
if(pos < maxResults)
|
||||
resNonce[pos] = nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void blake2s_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce)
|
||||
{
|
||||
const uint32_t step = gridDim.x * blockDim.x;
|
||||
|
||||
uint32_t m[ 3];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = midstate[16];
|
||||
m[1] = midstate[17];
|
||||
m[2] = midstate[18];
|
||||
|
||||
const uint32_t h7 = midstate[19];
|
||||
|
||||
for(uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x ; thread <threads; thread+=step)
|
||||
{
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
v[ i] = midstate[ i];
|
||||
}
|
||||
|
||||
uint32_t nonce = cuda_swab32(startNonce+thread);
|
||||
|
||||
// Round( 0 );
|
||||
v[ 1] += nonce;
|
||||
v[13] = ROR8(v[13] ^ v[ 1]);
|
||||
v[ 9] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[ 9], 7);
|
||||
|
||||
v[ 1]+= v[ 6];
|
||||
v[ 0]+= v[ 5];
|
||||
|
||||
v[13] = ROL16(v[13] ^ v[ 2]); v[12] = ROL16(v[12] ^ v[ 1]); v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
|
||||
v[ 8]+= v[13]; v[11]+= v[12]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12); v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 12); v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 2]+= v[ 7]; v[ 1]+= v[ 6]; v[ 3]+= v[ 4]; v[ 0]+= v[ 5];
|
||||
v[13] = ROR8(v[13] ^ v[ 2]); v[12] = ROR8(v[12] ^ v[ 1]); v[14] = ROR8(v[14] ^ v[ 3]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[ 8]+= v[13]; v[11]+= v[12]; v[ 9]+= v[14]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 7] = ROTR32(v[ 7] ^ v[8], 7); v[ 4] = ROTR32(v[ 4] ^ v[ 9], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 1],0, v[ 1],v[ 6],v[11],v[12],m[ 0],m[ 2], v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],0,nonce);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,m[ 0], v[ 2],v[ 6],v[10],v[14],0,m[ 2], v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],nonce,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 1], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],nonce,m[ 1], v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 2],0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,m[ 0], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 0], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 2],0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 1], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],nonce,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],m[ 2],0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],m[ 0],0, v[ 3],v[ 7],v[11],v[15],0,nonce);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,0, v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 1],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],m[ 1],0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],0,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],m[ 0],0, v[ 1],v[ 6],v[11],v[12],0,nonce, v[ 2],v[ 7],v[ 8],v[13],0,m[ 2], v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,m[ 1], v[ 3],v[ 7],v[11],v[15],nonce,0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 0], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],0,0, v[ 3],v[ 4],v[ 9],v[14],m[ 2],0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,0, v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,nonce, v[ 3],v[ 7],v[11],v[15],m[ 0],0);
|
||||
GS4(v[ 0],v[ 5],v[10],v[15],0,m[ 2], v[ 1],v[ 6],v[11],v[12],0,0, v[ 2],v[ 7],v[ 8],v[13],m[ 1],0, v[ 3],v[ 4],v[ 9],v[14],0,0);
|
||||
GS4(v[ 0],v[ 4],v[ 8],v[12],0,m[ 2], v[ 1],v[ 5],v[ 9],v[13],0,0, v[ 2],v[ 6],v[10],v[14],0,0, v[ 3],v[ 7],v[11],v[15],m[ 1],0);
|
||||
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7] + nonce;
|
||||
v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[13] = ROL16(v[13] ^ v[ 2]);
|
||||
v[10] += v[15];
|
||||
v[ 8] += v[13];
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
v[ 0] += v[ 5];
|
||||
v[ 2] += v[ 7];
|
||||
v[15] = ROTR32(v[15] ^ v[ 0],1);
|
||||
v[13] = ROR8(v[13] ^ v[ 2]);
|
||||
|
||||
v[ 8] += v[13];
|
||||
|
||||
if(xor3x(v[ 7],h7,v[ 8])==v[15]){
|
||||
uint32_t pos = atomicInc(&resNonce[0],0xffffffff)+1;
|
||||
if(pos < maxResults)
|
||||
resNonce[pos]=nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void blake2s_setBlock(const uint32_t* input,const uint32_t ptarget7)
|
||||
{
|
||||
uint32_t _ALIGN(64) m[16];
|
||||
uint32_t _ALIGN(64) v[16];
|
||||
uint32_t _ALIGN(64) h[21];
|
||||
|
||||
// COMPRESS
|
||||
for(int i = 0; i < 16; ++i )
|
||||
m[i] = input[i];
|
||||
|
||||
h[0] = 0x01010020 ^ blake2s_IV[0];
|
||||
h[1] = blake2s_IV[1];
|
||||
h[2] = blake2s_IV[2]; h[3] = blake2s_IV[3];
|
||||
h[4] = blake2s_IV[4]; h[5] = blake2s_IV[5];
|
||||
h[6] = blake2s_IV[6]; h[7] = blake2s_IV[7];
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = blake2s_IV[0]; v[ 9] = blake2s_IV[1];
|
||||
v[10] = blake2s_IV[2]; v[11] = blake2s_IV[3];
|
||||
v[12] = 64 ^ blake2s_IV[4]; v[13] = blake2s_IV[5];
|
||||
v[14] = blake2s_IV[6]; v[15] = blake2s_IV[7];
|
||||
|
||||
ROUND( 0 ); ROUND( 1 );
|
||||
ROUND( 2 ); ROUND( 3 );
|
||||
ROUND( 4 ); ROUND( 5 );
|
||||
ROUND( 6 ); ROUND( 7 );
|
||||
ROUND( 8 ); ROUND( 9 );
|
||||
|
||||
for(int i = 0; i < 8; ++i )
|
||||
h[i] ^= v[i] ^ v[i + 8];
|
||||
|
||||
h[16] = input[16];
|
||||
h[17] = input[17];
|
||||
h[18] = input[18];
|
||||
|
||||
h[ 8] = 0x6A09E667; h[ 9] = 0xBB67AE85;
|
||||
h[10] = 0x3C6EF372; h[11] = 0xA54FF53A;
|
||||
h[12] = 0x510E522F; h[13] = 0x9B05688C;
|
||||
h[14] =~0x1F83D9AB; h[15] = 0x5BE0CD19;
|
||||
|
||||
h[ 0]+= h[ 4] + h[16];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[ 0],16);
|
||||
h[ 8]+= h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8],12);
|
||||
h[ 0]+= h[ 4] + h[17];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[ 0],8);
|
||||
h[ 8]+= h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8],7);
|
||||
|
||||
h[ 1]+= h[ 5] + h[18];
|
||||
h[13] = SPH_ROTR32(h[13] ^ h[ 1], 16);
|
||||
h[ 9]+= h[13];
|
||||
h[ 5] = ROTR32(h[ 5] ^ h[ 9], 12);
|
||||
|
||||
h[ 2]+= h[ 6];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 2],16);
|
||||
h[10]+= h[14];
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10], 12);
|
||||
h[ 2]+= h[ 6];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 2],8);
|
||||
h[10]+= h[14];
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10], 7);
|
||||
|
||||
h[19] = h[7]; //constant h[7] for nonce check
|
||||
|
||||
h[ 3]+= h[ 7];
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],16);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = SPH_ROTR32(h[ 7] ^ h[11], 12);
|
||||
h[ 3]+= h[ 7];
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],8);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = SPH_ROTR32(h[ 7] ^ h[11], 7);
|
||||
|
||||
h[ 1]+= h[ 5];
|
||||
h[ 3]+= h[ 4];
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[ 3],16);
|
||||
|
||||
h[ 2]+= h[ 7];
|
||||
if(ptarget7==0){
|
||||
h[19] = SPH_ROTL32(h[19],7); //align the rotation with v[7] v[15];
|
||||
}
|
||||
cudaMemcpyToSymbol(midstate, h, 20*sizeof(uint32_t), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_blake2s(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t *resNonces;
|
||||
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
|
||||
const int dev_id = device_map[thr_id];
|
||||
int rc = 0;
|
||||
int intensity = is_windows() ? 25 : 28;
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
const dim3 grid((throughput + (NPT*TPB)-1)/(NPT*TPB));
|
||||
const dim3 block(TPB);
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], maxResults * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], maxResults * sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
resNonces = h_resNonce[thr_id];
|
||||
|
||||
for (int i=0; i < 19; i++) {
|
||||
be32enc(&endiandata[i], pdata[i]);
|
||||
}
|
||||
blake2s_setBlock(endiandata,ptarget[7]);
|
||||
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, maxResults*sizeof(uint32_t));
|
||||
|
||||
do {
|
||||
if(ptarget[7]) {
|
||||
blake2s_gpu_hash_nonce<<<grid, block>>>(throughput,pdata[19],d_resNonce[thr_id],ptarget[7]);
|
||||
} else {
|
||||
blake2s_gpu_hash_nonce<<<grid, block>>>(throughput,pdata[19],d_resNonce[thr_id]);
|
||||
}
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
if(resNonces[0])
|
||||
{
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], maxResults*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
if(resNonces[0] >= maxResults) {
|
||||
gpulog(LOG_WARNING, thr_id, "candidates flood: %u", resNonces[0]);
|
||||
resNonces[0] = maxResults-1;
|
||||
}
|
||||
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t nonce = sph_bswap32(resNonces[1]);
|
||||
be32enc(&endiandata[19], nonce);
|
||||
blake2s_hash(vhashcpu, endiandata);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if(vhashcpu[6] <= ptarget[6] && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
work->nonces[0] = nonce;
|
||||
rc = work->valid_nonces = 1;
|
||||
|
||||
// search for 2nd best nonce
|
||||
for(uint32_t j=2; j <= resNonces[0]; j++)
|
||||
{
|
||||
nonce = sph_bswap32(resNonces[j]);
|
||||
be32enc(&endiandata[19], nonce);
|
||||
blake2s_hash(vhashcpu, endiandata);
|
||||
if(vhashcpu[6] <= ptarget[6] && fulltest(vhashcpu, ptarget))
|
||||
{
|
||||
gpulog(LOG_DEBUG, thr_id, "Multiple nonces: 1/%08x - %u/%08x", work->nonces[0], j, nonce);
|
||||
|
||||
work->nonces[1] = nonce;
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work->shareratio[1] = work->shareratio[0];
|
||||
work->sharediff[1] = work->sharediff[0];
|
||||
xchg(work->nonces[1], work->nonces[0]);
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
} else if (work->valid_nonces == 1) {
|
||||
bn_set_target_ratio(work, vhashcpu, 1);
|
||||
}
|
||||
|
||||
work->valid_nonces++;
|
||||
rc = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]); // next scan start
|
||||
return rc;
|
||||
} else if (vhashcpu[7] > ptarget[7]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", resNonces[0]);
|
||||
}
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && (uint64_t)max_nonce > (uint64_t)throughput + pdata[19]);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_blake2s(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* bmw-256 MDT
|
||||
* tpruvot - 2015
|
||||
*/
|
||||
extern "C" {
|
||||
#include "sph/sph_bmw.h"
|
||||
}
|
||||
|
||||
#include <miner.h>
|
||||
#include <cuda_helper.h>
|
||||
|
||||
static uint32_t *d_hash[MAX_GPUS];
|
||||
|
||||
extern void bmw256_midstate_init(int thr_id, uint32_t threads);
|
||||
extern void bmw256_midstate_free(int thr_id);
|
||||
extern void bmw256_setBlock_80(int thr_id, void *pdata);
|
||||
extern void bmw256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_outputHash, int swap);
|
||||
|
||||
extern uint32_t cuda_check_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_inputHash);
|
||||
|
||||
// CPU Hash
|
||||
extern "C" void bmw_hash(void *state, const void *input)
|
||||
{
|
||||
uint32_t _ALIGN(64) hash[16];
|
||||
sph_bmw256_context ctx;
|
||||
|
||||
sph_bmw256_init(&ctx);
|
||||
sph_bmw256(&ctx, input, 80);
|
||||
sph_bmw256_close(&ctx, (void*) hash);
|
||||
|
||||
memcpy(state, hash, 32);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_bmw(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 21);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x0005;
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
bmw256_midstate_init(thr_id, throughput);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t)32 * throughput));
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 20; k++) {
|
||||
be32enc(&endiandata[k], ((uint32_t*)pdata)[k]);
|
||||
}
|
||||
|
||||
cudaGetLastError();
|
||||
bmw256_setBlock_80(thr_id, (void*)endiandata);
|
||||
|
||||
cuda_check_cpu_setTarget(ptarget);
|
||||
|
||||
do {
|
||||
bmw256_cpu_hash_80(thr_id, (int) throughput, pdata[19], d_hash[thr_id], 1);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
work->nonces[0] = cuda_check_hash_32(thr_id, throughput, pdata[19], d_hash[thr_id]);
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
bmw_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= Htarg && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
bmw_hash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_bmw(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
bmw256_midstate_free(thr_id);
|
||||
cuda_check_cpu_free(thr_id);
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
/**
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5.0)
|
||||
*
|
||||
* Tanguy Pruvot - Nov. 2014
|
||||
*
|
||||
* + merged blake+keccak kernel for lyra2v2
|
||||
*/
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* just for vstudio code colors */
|
||||
__device__ uint32_t __byte_perm(uint32_t a, uint32_t b, uint32_t c);
|
||||
#endif
|
||||
|
||||
#define UINT2(x,y) make_uint2(x,y)
|
||||
|
||||
__device__ __inline__ uint2 ROR8(const uint2 a) {
|
||||
uint2 result;
|
||||
result.x = __byte_perm(a.y, a.x, 0x0765);
|
||||
result.y = __byte_perm(a.x, a.y, 0x0765);
|
||||
return result;
|
||||
}
|
||||
|
||||
static __device__ uint64_t cuda_swab32ll(uint64_t x) {
|
||||
return MAKE_ULONGLONG(cuda_swab32(_LODWORD(x)), cuda_swab32(_HIDWORD(x)));
|
||||
}
|
||||
|
||||
__constant__ static uint32_t c_data[3 + 1];
|
||||
|
||||
__constant__ static uint32_t sigma[16][16];
|
||||
static uint32_t c_sigma[16][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }
|
||||
};
|
||||
|
||||
static const uint32_t c_IV256[8] = {
|
||||
0x6A09E667, 0xBB67AE85,
|
||||
0x3C6EF372, 0xA54FF53A,
|
||||
0x510E527F, 0x9B05688C,
|
||||
0x1F83D9AB, 0x5BE0CD19
|
||||
};
|
||||
|
||||
__device__ __constant__ static uint32_t cpu_h[8];
|
||||
|
||||
__device__ __constant__ static uint32_t u256[16];
|
||||
static const uint32_t c_u256[16] = {
|
||||
0x243F6A88, 0x85A308D3,
|
||||
0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0,
|
||||
0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377,
|
||||
0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD,
|
||||
0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
__constant__ uint2 keccak_round_constants35[24] = {
|
||||
{ 0x00000001ul, 0x00000000 }, { 0x00008082ul, 0x00000000 },
|
||||
{ 0x0000808aul, 0x80000000 }, { 0x80008000ul, 0x80000000 },
|
||||
{ 0x0000808bul, 0x00000000 }, { 0x80000001ul, 0x00000000 },
|
||||
{ 0x80008081ul, 0x80000000 }, { 0x00008009ul, 0x80000000 },
|
||||
{ 0x0000008aul, 0x00000000 }, { 0x00000088ul, 0x00000000 },
|
||||
{ 0x80008009ul, 0x00000000 }, { 0x8000000aul, 0x00000000 },
|
||||
{ 0x8000808bul, 0x00000000 }, { 0x0000008bul, 0x80000000 },
|
||||
{ 0x00008089ul, 0x80000000 }, { 0x00008003ul, 0x80000000 },
|
||||
{ 0x00008002ul, 0x80000000 }, { 0x00000080ul, 0x80000000 },
|
||||
{ 0x0000800aul, 0x00000000 }, { 0x8000000aul, 0x80000000 },
|
||||
{ 0x80008081ul, 0x80000000 }, { 0x00008080ul, 0x80000000 },
|
||||
{ 0x80000001ul, 0x00000000 }, { 0x80008008ul, 0x80000000 }
|
||||
};
|
||||
|
||||
|
||||
#define GS2(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = sigma[r][x]; \
|
||||
const uint32_t idx2 = sigma[r][(x)+1]; \
|
||||
v[a] += (m[idx1] ^ u256[idx2]) + v[b]; \
|
||||
v[d] = SPH_ROTL32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
\
|
||||
v[a] += (m[idx2] ^ u256[idx1]) + v[b]; \
|
||||
v[d] = SPH_ROTR32(v[d] ^ v[a], 8); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
//#define ROTL32(x, n) ((x) << (n)) | ((x) >> (32 - (n)))
|
||||
//#define ROTR32(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
|
||||
#define hostGS(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = c_sigma[r][x]; \
|
||||
const uint32_t idx2 = c_sigma[r][(x)+1]; \
|
||||
v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
|
||||
v[d] = ROTR32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 12); \
|
||||
\
|
||||
v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \
|
||||
v[d] = ROTR32(v[d] ^ v[a], 8); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
#define GSPREC(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ u256[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ u256[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
/* Second part (64-80) msg never change, store it */
|
||||
__device__ __constant__ static const uint32_t c_Padding[16] = {
|
||||
0, 0, 0, 0,
|
||||
0x80000000, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
__host__ __forceinline__
|
||||
static void blake256_compress1st(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
{
|
||||
uint32_t m[16];
|
||||
uint32_t v[16];
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
m[i] = block[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = c_u256[0];
|
||||
v[9] = c_u256[1];
|
||||
v[10] = c_u256[2];
|
||||
v[11] = c_u256[3];
|
||||
|
||||
v[12] = c_u256[4] ^ T0;
|
||||
v[13] = c_u256[5] ^ T0;
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
for (int r = 0; r < 14; r++) {
|
||||
/* column step */
|
||||
hostGS(0, 4, 0x8, 0xC, 0x0);
|
||||
hostGS(1, 5, 0x9, 0xD, 0x2);
|
||||
hostGS(2, 6, 0xA, 0xE, 0x4);
|
||||
hostGS(3, 7, 0xB, 0xF, 0x6);
|
||||
/* diagonal step */
|
||||
hostGS(0, 5, 0xA, 0xF, 0x8);
|
||||
hostGS(1, 6, 0xB, 0xC, 0xA);
|
||||
hostGS(2, 7, 0x8, 0xD, 0xC);
|
||||
hostGS(3, 4, 0x9, 0xE, 0xE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int j = i & 7;
|
||||
h[j] ^= v[i];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
static void blake256_compress2nd(uint32_t *h, const uint32_t *block, const uint32_t T0)
|
||||
{
|
||||
uint32_t m[16];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = block[0];
|
||||
m[1] = block[1];
|
||||
m[2] = block[2];
|
||||
m[3] = block[3];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 4; i < 16; i++) {
|
||||
m[i] = c_Padding[i];
|
||||
}
|
||||
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = u256[0];
|
||||
v[9] = u256[1];
|
||||
v[10] = u256[2];
|
||||
v[11] = u256[3];
|
||||
|
||||
v[12] = u256[4] ^ T0;
|
||||
v[13] = u256[5] ^ T0;
|
||||
v[14] = u256[6];
|
||||
v[15] = u256[7];
|
||||
|
||||
#pragma unroll 14
|
||||
for (int r = 0; r < 14; r++) {
|
||||
/* column step */
|
||||
GS2(0, 4, 0x8, 0xC, 0x0);
|
||||
GS2(1, 5, 0x9, 0xD, 0x2);
|
||||
GS2(2, 6, 0xA, 0xE, 0x4);
|
||||
GS2(3, 7, 0xB, 0xF, 0x6);
|
||||
/* diagonal step */
|
||||
GS2(0, 5, 0xA, 0xF, 0x8);
|
||||
GS2(1, 6, 0xB, 0xC, 0xA);
|
||||
GS2(2, 7, 0x8, 0xD, 0xC);
|
||||
GS2(3, 4, 0x9, 0xE, 0xE);
|
||||
}
|
||||
|
||||
#pragma unroll 16
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int j = i & 7;
|
||||
h[j] ^= v[i];
|
||||
}
|
||||
}
|
||||
|
||||
static void __forceinline__ __device__ keccak_block(uint2 *s)
|
||||
{
|
||||
uint2 bc[5], tmpxor[5], u, v;
|
||||
// uint2 s[25];
|
||||
|
||||
#pragma unroll 1
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
#pragma unroll
|
||||
for (uint32_t x = 0; x < 5; x++)
|
||||
tmpxor[x] = s[x] ^ s[x + 5] ^ s[x + 10] ^ s[x + 15] ^ s[x + 20];
|
||||
|
||||
bc[0] = tmpxor[0] ^ ROL2(tmpxor[2], 1);
|
||||
bc[1] = tmpxor[1] ^ ROL2(tmpxor[3], 1);
|
||||
bc[2] = tmpxor[2] ^ ROL2(tmpxor[4], 1);
|
||||
bc[3] = tmpxor[3] ^ ROL2(tmpxor[0], 1);
|
||||
bc[4] = tmpxor[4] ^ ROL2(tmpxor[1], 1);
|
||||
|
||||
u = s[1] ^ bc[0];
|
||||
|
||||
s[0] ^= bc[4];
|
||||
s[1] = ROL2(s[6] ^ bc[0], 44);
|
||||
s[6] = ROL2(s[9] ^ bc[3], 20);
|
||||
s[9] = ROL2(s[22] ^ bc[1], 61);
|
||||
s[22] = ROL2(s[14] ^ bc[3], 39);
|
||||
s[14] = ROL2(s[20] ^ bc[4], 18);
|
||||
s[20] = ROL2(s[2] ^ bc[1], 62);
|
||||
s[2] = ROL2(s[12] ^ bc[1], 43);
|
||||
s[12] = ROL2(s[13] ^ bc[2], 25);
|
||||
s[13] = ROL8(s[19] ^ bc[3]);
|
||||
s[19] = ROR8(s[23] ^ bc[2]);
|
||||
s[23] = ROL2(s[15] ^ bc[4], 41);
|
||||
s[15] = ROL2(s[4] ^ bc[3], 27);
|
||||
s[4] = ROL2(s[24] ^ bc[3], 14);
|
||||
s[24] = ROL2(s[21] ^ bc[0], 2);
|
||||
s[21] = ROL2(s[8] ^ bc[2], 55);
|
||||
s[8] = ROL2(s[16] ^ bc[0], 45);
|
||||
s[16] = ROL2(s[5] ^ bc[4], 36);
|
||||
s[5] = ROL2(s[3] ^ bc[2], 28);
|
||||
s[3] = ROL2(s[18] ^ bc[2], 21);
|
||||
s[18] = ROL2(s[17] ^ bc[1], 15);
|
||||
s[17] = ROL2(s[11] ^ bc[0], 10);
|
||||
s[11] = ROL2(s[7] ^ bc[1], 6);
|
||||
s[7] = ROL2(s[10] ^ bc[4], 3);
|
||||
s[10] = ROL2(u, 1);
|
||||
|
||||
u = s[0]; v = s[1]; s[0] ^= (~v) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & u; s[4] ^= (~u) & v;
|
||||
u = s[5]; v = s[6]; s[5] ^= (~v) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & u; s[9] ^= (~u) & v;
|
||||
u = s[10]; v = s[11]; s[10] ^= (~v) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & u; s[14] ^= (~u) & v;
|
||||
u = s[15]; v = s[16]; s[15] ^= (~v) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & u; s[19] ^= (~u) & v;
|
||||
u = s[20]; v = s[21]; s[20] ^= (~v) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & u; s[24] ^= (~u) & v;
|
||||
s[0] ^= keccak_round_constants35[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//__launch_bounds__(256)
|
||||
__global__
|
||||
void blakeKeccak256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint32_t * Hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
const uint32_t T0 = 640;
|
||||
|
||||
uint32_t h[8];
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i<8; i++) { h[i] = cpu_h[i]; }
|
||||
|
||||
uint32_t v[16];
|
||||
|
||||
const uint32_t c_Padding[12] = {
|
||||
0x80000000, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640
|
||||
};
|
||||
|
||||
const uint32_t u256[16] = {
|
||||
0x243F6A88, 0x85A308D3,
|
||||
0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0,
|
||||
0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377,
|
||||
0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD,
|
||||
0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
uint32_t m[16] = {
|
||||
c_data[0], c_data[1], c_data[2], nonce,
|
||||
c_Padding[0], c_Padding[1], c_Padding[2], c_Padding[3],
|
||||
c_Padding[4], c_Padding[5], c_Padding[6], c_Padding[7],
|
||||
c_Padding[8], c_Padding[9], c_Padding[10], c_Padding[11]
|
||||
};
|
||||
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[8] = u256[0];
|
||||
v[9] = u256[1];
|
||||
v[10] = u256[2];
|
||||
v[11] = u256[3];
|
||||
v[12] = u256[4] ^ T0;
|
||||
v[13] = u256[5] ^ T0;
|
||||
v[14] = u256[6];
|
||||
v[15] = u256[7];
|
||||
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
// { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 9, 0);
|
||||
GSPREC(1, 5, 0x9, 0xD, 5, 7);
|
||||
GSPREC(2, 6, 0xA, 0xE, 2, 4);
|
||||
GSPREC(3, 7, 0xB, 0xF, 10, 15);
|
||||
GSPREC(0, 5, 0xA, 0xF, 14, 1);
|
||||
GSPREC(1, 6, 0xB, 0xC, 11, 12);
|
||||
GSPREC(2, 7, 0x8, 0xD, 6, 8);
|
||||
GSPREC(3, 4, 0x9, 0xE, 3, 13);
|
||||
// { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 2, 12);
|
||||
GSPREC(1, 5, 0x9, 0xD, 6, 10);
|
||||
GSPREC(2, 6, 0xA, 0xE, 0, 11);
|
||||
GSPREC(3, 7, 0xB, 0xF, 8, 3);
|
||||
GSPREC(0, 5, 0xA, 0xF, 4, 13);
|
||||
GSPREC(1, 6, 0xB, 0xC, 7, 5);
|
||||
GSPREC(2, 7, 0x8, 0xD, 15, 14);
|
||||
GSPREC(3, 4, 0x9, 0xE, 1, 9);
|
||||
// { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 12, 5);
|
||||
GSPREC(1, 5, 0x9, 0xD, 1, 15);
|
||||
GSPREC(2, 6, 0xA, 0xE, 14, 13);
|
||||
GSPREC(3, 7, 0xB, 0xF, 4, 10);
|
||||
GSPREC(0, 5, 0xA, 0xF, 0, 7);
|
||||
GSPREC(1, 6, 0xB, 0xC, 6, 3);
|
||||
GSPREC(2, 7, 0x8, 0xD, 9, 2);
|
||||
GSPREC(3, 4, 0x9, 0xE, 8, 11);
|
||||
// { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 13, 11);
|
||||
GSPREC(1, 5, 0x9, 0xD, 7, 14);
|
||||
GSPREC(2, 6, 0xA, 0xE, 12, 1);
|
||||
GSPREC(3, 7, 0xB, 0xF, 3, 9);
|
||||
GSPREC(0, 5, 0xA, 0xF, 5, 0);
|
||||
GSPREC(1, 6, 0xB, 0xC, 15, 4);
|
||||
GSPREC(2, 7, 0x8, 0xD, 8, 6);
|
||||
GSPREC(3, 4, 0x9, 0xE, 2, 10);
|
||||
// { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 6, 15);
|
||||
GSPREC(1, 5, 0x9, 0xD, 14, 9);
|
||||
GSPREC(2, 6, 0xA, 0xE, 11, 3);
|
||||
GSPREC(3, 7, 0xB, 0xF, 0, 8);
|
||||
GSPREC(0, 5, 0xA, 0xF, 12, 2);
|
||||
GSPREC(1, 6, 0xB, 0xC, 13, 7);
|
||||
GSPREC(2, 7, 0x8, 0xD, 1, 4);
|
||||
GSPREC(3, 4, 0x9, 0xE, 10, 5);
|
||||
// { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 10, 2);
|
||||
GSPREC(1, 5, 0x9, 0xD, 8, 4);
|
||||
GSPREC(2, 6, 0xA, 0xE, 7, 6);
|
||||
GSPREC(3, 7, 0xB, 0xF, 1, 5);
|
||||
GSPREC(0, 5, 0xA, 0xF, 15, 11);
|
||||
GSPREC(1, 6, 0xB, 0xC, 9, 14);
|
||||
GSPREC(2, 7, 0x8, 0xD, 3, 12);
|
||||
GSPREC(3, 4, 0x9, 0xE, 13, 0);
|
||||
// { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 0, 1);
|
||||
GSPREC(1, 5, 0x9, 0xD, 2, 3);
|
||||
GSPREC(2, 6, 0xA, 0xE, 4, 5);
|
||||
GSPREC(3, 7, 0xB, 0xF, 6, 7);
|
||||
GSPREC(0, 5, 0xA, 0xF, 8, 9);
|
||||
GSPREC(1, 6, 0xB, 0xC, 10, 11);
|
||||
GSPREC(2, 7, 0x8, 0xD, 12, 13);
|
||||
GSPREC(3, 4, 0x9, 0xE, 14, 15);
|
||||
// { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 14, 10);
|
||||
GSPREC(1, 5, 0x9, 0xD, 4, 8);
|
||||
GSPREC(2, 6, 0xA, 0xE, 9, 15);
|
||||
GSPREC(3, 7, 0xB, 0xF, 13, 6);
|
||||
GSPREC(0, 5, 0xA, 0xF, 1, 12);
|
||||
GSPREC(1, 6, 0xB, 0xC, 0, 2);
|
||||
GSPREC(2, 7, 0x8, 0xD, 11, 7);
|
||||
GSPREC(3, 4, 0x9, 0xE, 5, 3);
|
||||
// { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 11, 8);
|
||||
GSPREC(1, 5, 0x9, 0xD, 12, 0);
|
||||
GSPREC(2, 6, 0xA, 0xE, 5, 2);
|
||||
GSPREC(3, 7, 0xB, 0xF, 15, 13);
|
||||
GSPREC(0, 5, 0xA, 0xF, 10, 14);
|
||||
GSPREC(1, 6, 0xB, 0xC, 3, 6);
|
||||
GSPREC(2, 7, 0x8, 0xD, 7, 1);
|
||||
GSPREC(3, 4, 0x9, 0xE, 9, 4);
|
||||
// { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
GSPREC(0, 4, 0x8, 0xC, 7, 9);
|
||||
GSPREC(1, 5, 0x9, 0xD, 3, 1);
|
||||
GSPREC(2, 6, 0xA, 0xE, 13, 12);
|
||||
GSPREC(3, 7, 0xB, 0xF, 11, 14);
|
||||
GSPREC(0, 5, 0xA, 0xF, 2, 6);
|
||||
GSPREC(1, 6, 0xB, 0xC, 5, 10);
|
||||
GSPREC(2, 7, 0x8, 0xD, 4, 0);
|
||||
GSPREC(3, 4, 0x9, 0xE, 15, 8);
|
||||
|
||||
h[0] = cuda_swab32(h[0] ^ v[0] ^ v[8]);
|
||||
h[1] = cuda_swab32(h[1] ^ v[1] ^ v[9]);
|
||||
h[2] = cuda_swab32(h[2] ^ v[2] ^ v[10]);
|
||||
h[3] = cuda_swab32(h[3] ^ v[3] ^ v[11]);
|
||||
h[4] = cuda_swab32(h[4] ^ v[4] ^ v[12]);
|
||||
h[5] = cuda_swab32(h[5] ^ v[5] ^ v[13]);
|
||||
h[6] = cuda_swab32(h[6] ^ v[6] ^ v[14]);
|
||||
h[7] = cuda_swab32(h[7] ^ v[7] ^ v[15]);
|
||||
|
||||
uint2 keccak_gpu_state[25] = { 0 };
|
||||
keccak_gpu_state[0].x = h[0];
|
||||
keccak_gpu_state[0].y = h[1];
|
||||
keccak_gpu_state[1].x = h[2];
|
||||
keccak_gpu_state[1].y = h[3];
|
||||
keccak_gpu_state[2].x = h[4];
|
||||
keccak_gpu_state[2].y = h[5];
|
||||
keccak_gpu_state[3].x = h[6];
|
||||
keccak_gpu_state[3].y = h[7];
|
||||
keccak_gpu_state[4] = UINT2(1, 0);
|
||||
|
||||
keccak_gpu_state[16] = UINT2(0, 0x80000000);
|
||||
keccak_block(keccak_gpu_state);
|
||||
|
||||
uint64_t *outputHash = (uint64_t *)Hash;
|
||||
#pragma unroll 4
|
||||
for (int i = 0; i<4; i++)
|
||||
outputHash[i*threads + thread] = devectorize(keccak_gpu_state[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256, 3)
|
||||
void blake256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint64_t * Hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t h[8];
|
||||
uint32_t input[4];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 8; i++) h[i] = cpu_h[i];
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 3; ++i) input[i] = c_data[i];
|
||||
|
||||
input[3] = startNonce + thread;
|
||||
blake256_compress2nd(h, input, 640);
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i<4; i++) {
|
||||
Hash[i*threads + thread] = cuda_swab32ll(MAKE_ULONGLONG(h[2 * i], h[2 * i + 1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, uint64_t *Hash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blake256_gpu_hash_80 << <grid, block >> > (threads, startNonce, Hash);
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_80(uint32_t *pdata)
|
||||
{
|
||||
uint32_t h[8], data[20];
|
||||
|
||||
memcpy(data, pdata, 80);
|
||||
memcpy(h, c_IV256, sizeof(c_IV256));
|
||||
blake256_compress1st(h, pdata, 512);
|
||||
|
||||
cudaMemcpyToSymbol(cpu_h, h, sizeof(h), 0, cudaMemcpyHostToDevice);
|
||||
cudaMemcpyToSymbol(c_data, &data[16], sizeof(c_data), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMemcpyToSymbol(u256, c_u256, sizeof(c_u256), 0, cudaMemcpyHostToDevice);
|
||||
cudaMemcpyToSymbol(sigma, c_sigma, sizeof(c_sigma), 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
|
||||
/** for lyra2v2 **/
|
||||
|
||||
__host__
|
||||
void blakeKeccak256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, uint64_t *Hash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blakeKeccak256_gpu_hash_80 <<<grid, block>>> (threads, startNonce, (uint32_t *)Hash);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blakeKeccak256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, uint64_t *Hash, int order, cudaStream_t stream)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
blakeKeccak256_gpu_hash_80 <<<grid, block, 0, stream>>> (threads, startNonce, (uint32_t *)Hash);
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
/**
|
||||
* BMW-256 CUDA Implementation - tpruvot 2015
|
||||
*
|
||||
* Not optimal but close to the sph version and easier to adapt.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#define SPH_64 1
|
||||
#define USE_MIDSTATE
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_bmw.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
__constant__ uint64_t c_PaddedMessage80[16]; // padded message (80 bytes + padding)
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
__constant__ static sph_u32 IV256[16] = {
|
||||
0x40414243, 0x44454647, 0x48494A4B, 0x4C4D4E4F,
|
||||
0x50515253, 0x54555657, 0x58595A5B, 0x5C5D5E5F,
|
||||
0x60616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F,
|
||||
0x70717273, 0x74757677, 0x78797A7B, 0x7C7D7E7F
|
||||
};
|
||||
#endif
|
||||
|
||||
__constant__ static sph_u32 final_s[16] = {
|
||||
0xaaaaaaa0, 0xaaaaaaa1, 0xaaaaaaa2, 0xaaaaaaa3,
|
||||
0xaaaaaaa4, 0xaaaaaaa5, 0xaaaaaaa6, 0xaaaaaaa7,
|
||||
0xaaaaaaa8, 0xaaaaaaa9, 0xaaaaaaaa, 0xaaaaaaab,
|
||||
0xaaaaaaac, 0xaaaaaaad, 0xaaaaaaae, 0xaaaaaaaf
|
||||
};
|
||||
|
||||
static sph_bmw_small_context* d_midstate[MAX_GPUS];
|
||||
|
||||
#define I16_16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
|
||||
#define I16_17 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|
||||
#define I16_18 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
|
||||
#define I16_19 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
|
||||
#define I16_20 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||
#define I16_21 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
|
||||
#define I16_22 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
|
||||
#define I16_23 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
|
||||
#define I16_24 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
|
||||
#define I16_25 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
|
||||
#define I16_26 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
|
||||
#define I16_27 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
|
||||
#define I16_28 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
|
||||
#define I16_29 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
|
||||
#define I16_30 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
|
||||
#define I16_31 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
|
||||
|
||||
//#define M16_16 0, 1, 3, 4, 7, 10, 11
|
||||
//#define M16_17 1, 2, 4, 5, 8, 11, 12
|
||||
#define M16_18 2, 3, 5, 6, 9, 12, 13
|
||||
#define M16_19 3, 4, 6, 7, 10, 13, 14
|
||||
#define M16_20 4, 5, 7, 8, 11, 14, 15
|
||||
#define M16_21 5, 6, 8, 9, 12, 15, 16
|
||||
#define M16_22 6, 7, 9, 10, 13, 0, 1
|
||||
#define M16_23 7, 8, 10, 11, 14, 1, 2
|
||||
#define M16_24 8, 9, 11, 12, 15, 2, 3
|
||||
#define M16_25 9, 10, 12, 13, 0, 3, 4
|
||||
#define M16_26 10, 11, 13, 14, 1, 4, 5
|
||||
#define M16_27 11, 12, 14, 15, 2, 5, 6
|
||||
#define M16_28 12, 13, 15, 16, 3, 6, 7
|
||||
#define M16_29 13, 14, 0, 1, 4, 7, 8
|
||||
#define M16_30 14, 15, 1, 2, 5, 8, 9
|
||||
#define M16_31 15, 16, 2, 3, 6, 9, 10
|
||||
|
||||
#define ss0(x) (((x) >> 1) ^ ((x) << 3) ^ ROTL32(x, 4) ^ ROTL32(x, 19))
|
||||
#define ss1(x) (((x) >> 1) ^ ((x) << 2) ^ ROTL32(x, 8) ^ ROTL32(x, 23))
|
||||
#define ss2(x) (((x) >> 2) ^ ((x) << 1) ^ ROTL32(x, 12) ^ ROTL32(x, 25))
|
||||
#define ss3(x) (((x) >> 2) ^ ((x) << 2) ^ ROTL32(x, 15) ^ ROTL32(x, 29))
|
||||
#define ss4(x) (((x) >> 1) ^ (x))
|
||||
#define ss5(x) (((x) >> 2) ^ (x))
|
||||
|
||||
#define rs1(x) ROTL32(x, 3)
|
||||
#define rs2(x) ROTL32(x, 7)
|
||||
#define rs3(x) ROTL32(x, 13)
|
||||
#define rs4(x) ROTL32(x, 16)
|
||||
#define rs5(x) ROTL32(x, 19)
|
||||
#define rs6(x) ROTL32(x, 23)
|
||||
#define rs7(x) ROTL32(x, 27)
|
||||
|
||||
#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4) \
|
||||
tt((data[i0] ^ h[i0]) op01 (data[i1] ^ h[i1]) op12 (data[i2] ^ h[i2]) op23 (data[i3] ^ h[i3]) op34 (data[i4] ^ h[i4]))
|
||||
//#define Ws0 MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14)
|
||||
//#define Ws1 MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15)
|
||||
//#define Ws2 MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15)
|
||||
//#define Ws3 MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13)
|
||||
//#define Ws4 MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14)
|
||||
//#define Ws5 MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15)
|
||||
//#define Ws6 MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13)
|
||||
//#define Ws7 MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14)
|
||||
//#define Ws8 MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15)
|
||||
//#define Ws9 MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14)
|
||||
//#define Ws10 MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15)
|
||||
//#define Ws11 MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9)
|
||||
//#define Ws12 MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10)
|
||||
//#define Ws13 MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11)
|
||||
//#define Ws14 MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12)
|
||||
//#define Ws15 MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13)
|
||||
|
||||
__device__
|
||||
static void gpu_compress_small(const sph_u32 *data, const sph_u32 h[16], sph_u32 dh[16])
|
||||
{
|
||||
// FOLD MAKE_Qas;
|
||||
|
||||
sph_u32 dx[16];
|
||||
for (int i=0; i<16; i++)
|
||||
dx[i] = data[i] ^ h[i];
|
||||
|
||||
sph_u32 qt[32];
|
||||
qt[ 0] = dx[ 5] - dx[7] + dx[10] + dx[13] + dx[14]; // Ws0
|
||||
qt[ 1] = dx[ 6] - dx[8] + dx[11] + dx[14] - dx[15]; // Ws1
|
||||
qt[ 2] = dx[ 0] + dx[7] + dx[ 9] - dx[12] + dx[15]; // Ws2
|
||||
qt[ 3] = dx[ 0] - dx[1] + dx[ 8] - dx[10] + dx[13]; // Ws3
|
||||
qt[ 4] = dx[ 1] + dx[2] + dx[ 9] - dx[11] - dx[14]; // Ws4;
|
||||
qt[ 5] = dx[ 3] - dx[2] + dx[10] - dx[12] + dx[15]; // Ws5;
|
||||
qt[ 6] = dx[ 4] - dx[0] - dx[ 3] - dx[11] + dx[13]; // Ws6;
|
||||
qt[ 7] = dx[ 1] - dx[4] - dx[ 5] - dx[12] - dx[14]; // Ws7;
|
||||
qt[ 8] = dx[ 2] - dx[5] - dx[ 6] + dx[13] - dx[15]; // Ws8;
|
||||
qt[ 9] = dx[ 0] - dx[3] + dx[ 6] - dx[ 7] + dx[14]; // Ws9;
|
||||
qt[10] = dx[ 8] - dx[1] - dx[ 4] - dx[ 7] + dx[15]; // Ws10;
|
||||
qt[11] = dx[ 8] - dx[0] - dx[ 2] - dx[ 5] + dx[ 9]; // Ws11;
|
||||
qt[12] = dx[ 1] + dx[3] - dx[ 6] - dx[ 9] + dx[10]; // Ws12;
|
||||
qt[13] = dx[ 2] + dx[4] + dx[ 7] + dx[10] + dx[11]; // Ws13;
|
||||
qt[14] = dx[ 3] - dx[5] + dx[ 8] - dx[11] - dx[12]; // Ws14;
|
||||
qt[15] = dx[12] - dx[4] - dx[ 6] - dx[ 9] + dx[13]; // Ws15;
|
||||
|
||||
qt[ 0] = ss0(qt[ 0]) + h[ 1];
|
||||
qt[ 1] = ss1(qt[ 1]) + h[ 2];
|
||||
qt[ 2] = ss2(qt[ 2]) + h[ 3];
|
||||
qt[ 3] = ss3(qt[ 3]) + h[ 4];
|
||||
qt[ 4] = ss4(qt[ 4]) + h[ 5];
|
||||
|
||||
qt[ 5] = ss0(qt[ 5]) + h[ 6];
|
||||
qt[ 6] = ss1(qt[ 6]) + h[ 7];
|
||||
qt[ 7] = ss2(qt[ 7]) + h[ 8];
|
||||
qt[ 8] = ss3(qt[ 8]) + h[ 9];
|
||||
qt[ 9] = ss4(qt[ 9]) + h[10];
|
||||
|
||||
qt[10] = ss0(qt[10]) + h[11];
|
||||
qt[11] = ss1(qt[11]) + h[12];
|
||||
qt[12] = ss2(qt[12]) + h[13];
|
||||
qt[13] = ss3(qt[13]) + h[14];
|
||||
qt[14] = ss4(qt[14]) + h[15];
|
||||
|
||||
qt[15] = ss0(qt[15]) + h[ 0];
|
||||
|
||||
//MAKE_Qbs;
|
||||
#define Ks(j) ((sph_u32)(0x05555555UL * j))
|
||||
#define Qs(j) (qt[j])
|
||||
|
||||
#define expand1s_in(i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
(ss1(qt[i0]) + ss2(qt[i1]) + ss3(qt[i2]) + ss0(qt[i3]) + ss1(qt[i4]) + ss2(qt[i5]) + ss3(qt[i6]) + ss0(qt[i7]) \
|
||||
+ ss1(qt[i8]) + ss2(qt[i9]) + ss3(qt[i10]) + ss0(qt[i11]) + ss1(qt[i12]) + ss2(qt[i13]) + ss3(qt[i14]) + ss0(qt[i15]) \
|
||||
+ ((ROTL32(data[i0m], i1m) + ROTL32(data[i3m], i4m) - ROTL32(data[i10m], i11m) + Ks(i16)) ^ h[i7m]))
|
||||
|
||||
qt[16] = expand1s_in(16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 3, 4, 7, 10, 11);
|
||||
qt[17] = expand1s_in(17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 4, 5, 8, 11, 12);
|
||||
|
||||
#define expand2s_inner(qf, i16, \
|
||||
i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, \
|
||||
i0m, i1m, i3m, i4m, i7m, i10m, i11m) \
|
||||
(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \
|
||||
+ qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) + qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \
|
||||
+ qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \
|
||||
+ ((ROTL32(data[i0m], i1m) + ROTL32(data[i3m], i4m) - ROTL32(data[i10m], i11m) + Ks(i16)) ^ h[i7m]))
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define LPAR (
|
||||
#define expand2s(i16) \
|
||||
expand2s_(Qs, i16, I16_ ## i16, M16_ ## i16)
|
||||
#define expand2s_(qf, i16, ix, iy) \
|
||||
expand2s_inner LPAR qf, i16, ix, iy)
|
||||
#else
|
||||
#define expand2s_(i16, ix, iy) \
|
||||
expand2s_inner(Qs, i16, ix, iy)
|
||||
#define expand2s(i16) \
|
||||
expand2s_(i16, I16_ ## i16, M16_ ## i16)
|
||||
#endif
|
||||
|
||||
qt[18] = expand2s(18);
|
||||
qt[19] = expand2s(19);
|
||||
qt[20] = expand2s(20);
|
||||
qt[21] = expand2s(21);
|
||||
qt[22] = expand2s(22);
|
||||
qt[23] = expand2s(23);
|
||||
qt[24] = expand2s(24);
|
||||
qt[25] = expand2s(25);
|
||||
qt[26] = expand2s(26);
|
||||
qt[27] = expand2s(27);
|
||||
qt[28] = expand2s(28);
|
||||
qt[29] = expand2s(29);
|
||||
qt[30] = expand2s(30);
|
||||
qt[31] = expand2s(31);
|
||||
|
||||
sph_u32 xl, xh;
|
||||
xl = Qs(16) ^ Qs(17) ^ Qs(18) ^ Qs(19) ^ Qs(20) ^ Qs(21) ^ Qs(22) ^ Qs(23);
|
||||
|
||||
xh = xl ^ Qs(24) ^ Qs(25) ^ Qs(26) ^ Qs(27) ^ Qs(28) ^ Qs(29) ^ Qs(30) ^ Qs(31);
|
||||
|
||||
dh[ 0] = ((xh << 5) ^ (Qs(16) >> 5) ^ data[ 0]) + (xl ^ Qs(24) ^ Qs(0));
|
||||
dh[ 1] = ((xh >> 7) ^ (Qs(17) << 8) ^ data[ 1]) + (xl ^ Qs(25) ^ Qs(1));
|
||||
dh[ 2] = ((xh >> 5) ^ (Qs(18) << 5) ^ data[ 2]) + (xl ^ Qs(26) ^ Qs(2));
|
||||
dh[ 3] = ((xh >> 1) ^ (Qs(19) << 5) ^ data[ 3]) + (xl ^ Qs(27) ^ Qs(3));
|
||||
dh[ 4] = ((xh >> 3) ^ (Qs(20) << 0) ^ data[ 4]) + (xl ^ Qs(28) ^ Qs(4));
|
||||
dh[ 5] = ((xh << 6) ^ (Qs(21) >> 6) ^ data[ 5]) + (xl ^ Qs(29) ^ Qs(5));
|
||||
dh[ 6] = ((xh >> 4) ^ (Qs(22) << 6) ^ data[ 6]) + (xl ^ Qs(30) ^ Qs(6));
|
||||
dh[ 7] = ((xh >> 11) ^ (Qs(23) << 2) ^ data[ 7]) + (xl ^ Qs(31) ^ Qs(7));
|
||||
|
||||
dh[ 8] = ROTL32(dh[4], 9) + (xh ^ Qs(24) ^ data[ 8]) + ((xl << 8) ^ Qs(23) ^ Qs( 8));
|
||||
dh[ 9] = ROTL32(dh[5], 10) + (xh ^ Qs(25) ^ data[ 9]) + ((xl >> 6) ^ Qs(16) ^ Qs( 9));
|
||||
dh[10] = ROTL32(dh[6], 11) + (xh ^ Qs(26) ^ data[10]) + ((xl << 6) ^ Qs(17) ^ Qs(10));
|
||||
dh[11] = ROTL32(dh[7], 12) + (xh ^ Qs(27) ^ data[11]) + ((xl << 4) ^ Qs(18) ^ Qs(11));
|
||||
dh[12] = ROTL32(dh[0], 13) + (xh ^ Qs(28) ^ data[12]) + ((xl >> 3) ^ Qs(19) ^ Qs(12));
|
||||
dh[13] = ROTL32(dh[1], 14) + (xh ^ Qs(29) ^ data[13]) + ((xl >> 4) ^ Qs(20) ^ Qs(13));
|
||||
dh[14] = ROTL32(dh[2], 15) + (xh ^ Qs(30) ^ data[14]) + ((xl >> 7) ^ Qs(21) ^ Qs(14));
|
||||
dh[15] = ROTL32(dh[3], 16) + (xh ^ Qs(31) ^ data[15]) + ((xl >> 2) ^ Qs(22) ^ Qs(15));
|
||||
}
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256_init(sph_bmw_small_context *sc)
|
||||
{
|
||||
memcpy(sc->H, IV256, sizeof sc->H);
|
||||
sc->ptr = 0;
|
||||
sc->bit_count = 0;
|
||||
}
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256(sph_bmw_small_context *sc, const void *data, size_t len)
|
||||
{
|
||||
sph_u32 htmp[16];
|
||||
sph_u32 *h1, *h2;
|
||||
unsigned char *buf = sc->buf;
|
||||
size_t ptr = sc->ptr;
|
||||
|
||||
sc->bit_count += (sph_u64)len << 3;
|
||||
|
||||
h1 = sc->H;
|
||||
h2 = htmp;
|
||||
while (len > 0) {
|
||||
size_t clen;
|
||||
|
||||
clen = (sizeof sc->buf) - ptr;
|
||||
if (clen > len)
|
||||
clen = len;
|
||||
memcpy(buf + ptr, data, clen);
|
||||
data = (const unsigned char *)data + clen;
|
||||
len -= clen;
|
||||
ptr += clen;
|
||||
if (ptr == sizeof sc->buf) {
|
||||
sph_u32 *ht;
|
||||
|
||||
gpu_compress_small((sph_u32 *) buf, h1, h2);
|
||||
ht = h1;
|
||||
h1 = h2;
|
||||
h2 = ht;
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
sc->ptr = ptr;
|
||||
if (h1 != sc->H)
|
||||
memcpy(sc->H, h1, sizeof sc->H);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define sph_enc64le(ptr, x) \
|
||||
*((uint64_t*)(ptr)) = x
|
||||
#define sph_enc64le_aligned sph_enc64le
|
||||
|
||||
__device__
|
||||
static void gpu_bmw256_close(sph_bmw_small_context *sc, uint2 *out)
|
||||
{
|
||||
unsigned char *buf = sc->buf;
|
||||
size_t ptr = sc->ptr;
|
||||
|
||||
buf[ptr ++] = 0x80;
|
||||
sph_u32 *h = sc->H;
|
||||
|
||||
sph_u32 h1[16];
|
||||
if (ptr > (sizeof sc->buf) - 8) {
|
||||
memset(buf + ptr, 0, (sizeof sc->buf) - ptr);
|
||||
gpu_compress_small((sph_u32 *) buf, h, h1);
|
||||
ptr = 0;
|
||||
h = h1;
|
||||
}
|
||||
memset(buf + ptr, 0, sizeof(sc->buf) - 8 - ptr);
|
||||
|
||||
sph_enc64le_aligned(buf + sizeof(sc->buf) - 8, SPH_T64(sc->bit_count));
|
||||
|
||||
sph_u32 h2[16];
|
||||
gpu_compress_small((sph_u32 *) buf, h, h2);
|
||||
gpu_compress_small(h2, final_s, h1);
|
||||
|
||||
uint64_t* h64 = (uint64_t*) (&h1[8]);
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 4; i++) {
|
||||
out[i] = vectorize(h64[i]);
|
||||
}
|
||||
}
|
||||
|
||||
__global__ /* __launch_bounds__(256, 3) */
|
||||
void bmw256_gpu_hash_80(uint32_t threads, uint32_t startNonce, uint64_t *g_hash, sph_bmw256_context *d_midstate, int swap)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t nonce = startNonce + thread;
|
||||
nonce = swap ? cuda_swab32(nonce): nonce;
|
||||
|
||||
#ifndef USE_MIDSTATE
|
||||
uint2 hash[10];
|
||||
#pragma unroll
|
||||
for(int i=0;i<9;i++)
|
||||
hash[i] = vectorize(c_PaddedMessage80[i]);
|
||||
hash[9] = make_uint2(c_PaddedMessage80[9], nonce);
|
||||
|
||||
sph_bmw256_context ctx;
|
||||
gpu_bmw256_init(&ctx);
|
||||
gpu_bmw256(&ctx, (void*) hash, 80);
|
||||
#else
|
||||
sph_bmw256_context ctx;
|
||||
ctx.ptr = 16; ctx.bit_count = 640;
|
||||
uint2 *buf = (uint2 *) ctx.buf;
|
||||
buf[0] = vectorize(c_PaddedMessage80[8]);
|
||||
buf[1] = make_uint2(c_PaddedMessage80[9], nonce);
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++)
|
||||
ctx.H[i] = d_midstate->H[i];
|
||||
#endif
|
||||
gpu_bmw256_close(&ctx, (uint2*) &g_hash[thread << 2]);
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t *d_outputHash, int swap)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
bmw256_gpu_hash_80<<<grid, block>>>(threads, startNonce, (uint64_t*)d_outputHash, d_midstate[thr_id], swap);
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_setBlock_80(int thr_id, void *pdata)
|
||||
{
|
||||
uint64_t PaddedMessage[16];
|
||||
memcpy(PaddedMessage, pdata, 80);
|
||||
memset(&PaddedMessage[10], 0, 48);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_PaddedMessage80, PaddedMessage, sizeof(PaddedMessage), 0, cudaMemcpyHostToDevice));
|
||||
|
||||
sph_bmw256_context ctx;
|
||||
sph_bmw256_init(&ctx);
|
||||
sph_bmw256(&ctx, (void*) PaddedMessage, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpy(d_midstate[thr_id], &ctx, sizeof(sph_bmw256_context), cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_midstate_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMalloc(&d_midstate[thr_id], sizeof(sph_bmw256_context));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_midstate_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_midstate[thr_id]);
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#undef SPH_ROTL32
|
||||
#define SPH_ROTL32 ROTL32
|
||||
|
||||
static uint32_t *d_gnounce[MAX_GPUS];
|
||||
static uint32_t *d_GNonce[MAX_GPUS];
|
||||
|
||||
__constant__ uint64_t pTarget[4];
|
||||
|
||||
#define shl(x, n) ((x) << (n))
|
||||
#define shr(x, n) ((x) >> (n))
|
||||
|
||||
#define ss0(x) (shr((x), 1) ^ shl((x), 3) ^ SPH_ROTL32((x), 4) ^ SPH_ROTL32((x), 19))
|
||||
#define ss1(x) (shr((x), 1) ^ shl((x), 2) ^ SPH_ROTL32((x), 8) ^ SPH_ROTL32((x), 23))
|
||||
#define ss2(x) (shr((x), 2) ^ shl((x), 1) ^ SPH_ROTL32((x), 12) ^ SPH_ROTL32((x), 25))
|
||||
#define ss3(x) (shr((x), 2) ^ shl((x), 2) ^ SPH_ROTL32((x), 15) ^ SPH_ROTL32((x), 29))
|
||||
#define ss4(x) (shr((x), 1) ^ (x))
|
||||
#define ss5(x) (shr((x), 2) ^ (x))
|
||||
|
||||
#define rs1(x) SPH_ROTL32((x), 3)
|
||||
#define rs2(x) SPH_ROTL32((x), 7)
|
||||
#define rs3(x) SPH_ROTL32((x), 13)
|
||||
#define rs4(x) SPH_ROTL32((x), 16)
|
||||
#define rs5(x) SPH_ROTL32((x), 19)
|
||||
#define rs6(x) SPH_ROTL32((x), 23)
|
||||
#define rs7(x) SPH_ROTL32((x), 27)
|
||||
|
||||
/* Message expansion function 1 */
|
||||
__forceinline__ __device__
|
||||
uint32_t expand32_1(int i, uint32_t *M32, const uint32_t *H, uint32_t *Q)
|
||||
{
|
||||
return (ss1(Q[i - 16]) + ss2(Q[i - 15]) + ss3(Q[i - 14]) + ss0(Q[i - 13])
|
||||
+ ss1(Q[i - 12]) + ss2(Q[i - 11]) + ss3(Q[i - 10]) + ss0(Q[i - 9])
|
||||
+ ss1(Q[i - 8]) + ss2(Q[i - 7]) + ss3(Q[i - 6]) + ss0(Q[i - 5])
|
||||
+ ss1(Q[i - 4]) + ss2(Q[i - 3]) + ss3(Q[i - 2]) + ss0(Q[i - 1])
|
||||
+ ((i*(0x05555555ul) + SPH_ROTL32(M32[(i - 16) % 16], ((i - 16) % 16) + 1)
|
||||
+ SPH_ROTL32(M32[(i - 13) % 16], ((i - 13) % 16) + 1)
|
||||
- SPH_ROTL32(M32[(i - 6) % 16], ((i - 6) % 16) + 1)) ^ H[(i - 16 + 7) % 16]));
|
||||
}
|
||||
|
||||
/* Message expansion function 2 */
|
||||
__forceinline__ __device__
|
||||
uint32_t expand32_2(int i, uint32_t *M32, const uint32_t *H, uint32_t *Q)
|
||||
{
|
||||
return (Q[i - 16] + rs1(Q[i - 15]) + Q[i - 14] + rs2(Q[i - 13])
|
||||
+ Q[i - 12] + rs3(Q[i - 11]) + Q[i - 10] + rs4(Q[i - 9])
|
||||
+ Q[i - 8] + rs5(Q[i - 7]) + Q[i - 6] + rs6(Q[i - 5])
|
||||
+ Q[i - 4] + rs7(Q[i - 3]) + ss4(Q[i - 2]) + ss5(Q[i - 1])
|
||||
+ ((i*(0x05555555ul) + SPH_ROTL32(M32[(i - 16) % 16], ((i - 16) % 16) + 1)
|
||||
+ SPH_ROTL32(M32[(i - 13) % 16], ((i - 13) % 16) + 1)
|
||||
- SPH_ROTL32(M32[(i - 6) % 16], ((i - 6) % 16) + 1)) ^ H[(i - 16 + 7) % 16]));
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Compression256(uint32_t * M32)
|
||||
{
|
||||
uint32_t Q[32], XL32, XH32;
|
||||
|
||||
const uint32_t H[16] = {
|
||||
0x40414243, 0x44454647, 0x48494A4B, 0x4C4D4E4F,
|
||||
0x50515253, 0x54555657, 0x58595A5B, 0x5C5D5E5F,
|
||||
0x60616263, 0x64656667, 0x68696A6B, 0x6C6D6E6F,
|
||||
0x70717273, 0x74757677, 0x78797A7B, 0x7C7D7E7F
|
||||
};
|
||||
|
||||
Q[0] = (M32[5] ^ H[5]) - (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[13] ^ H[13]) + (M32[14] ^ H[14]);
|
||||
Q[1] = (M32[6] ^ H[6]) - (M32[8] ^ H[8]) + (M32[11] ^ H[11]) + (M32[14] ^ H[14]) - (M32[15] ^ H[15]);
|
||||
Q[2] = (M32[0] ^ H[0]) + (M32[7] ^ H[7]) + (M32[9] ^ H[9]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[3] = (M32[0] ^ H[0]) - (M32[1] ^ H[1]) + (M32[8] ^ H[8]) - (M32[10] ^ H[10]) + (M32[13] ^ H[13]);
|
||||
Q[4] = (M32[1] ^ H[1]) + (M32[2] ^ H[2]) + (M32[9] ^ H[9]) - (M32[11] ^ H[11]) - (M32[14] ^ H[14]);
|
||||
Q[5] = (M32[3] ^ H[3]) - (M32[2] ^ H[2]) + (M32[10] ^ H[10]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[6] = (M32[4] ^ H[4]) - (M32[0] ^ H[0]) - (M32[3] ^ H[3]) - (M32[11] ^ H[11]) + (M32[13] ^ H[13]);
|
||||
Q[7] = (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[5] ^ H[5]) - (M32[12] ^ H[12]) - (M32[14] ^ H[14]);
|
||||
Q[8] = (M32[2] ^ H[2]) - (M32[5] ^ H[5]) - (M32[6] ^ H[6]) + (M32[13] ^ H[13]) - (M32[15] ^ H[15]);
|
||||
Q[9] = (M32[0] ^ H[0]) - (M32[3] ^ H[3]) + (M32[6] ^ H[6]) - (M32[7] ^ H[7]) + (M32[14] ^ H[14]);
|
||||
Q[10] = (M32[8] ^ H[8]) - (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[7] ^ H[7]) + (M32[15] ^ H[15]);
|
||||
Q[11] = (M32[8] ^ H[8]) - (M32[0] ^ H[0]) - (M32[2] ^ H[2]) - (M32[5] ^ H[5]) + (M32[9] ^ H[9]);
|
||||
Q[12] = (M32[1] ^ H[1]) + (M32[3] ^ H[3]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[10] ^ H[10]);
|
||||
Q[13] = (M32[2] ^ H[2]) + (M32[4] ^ H[4]) + (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[11] ^ H[11]);
|
||||
Q[14] = (M32[3] ^ H[3]) - (M32[5] ^ H[5]) + (M32[8] ^ H[8]) - (M32[11] ^ H[11]) - (M32[12] ^ H[12]);
|
||||
Q[15] = (M32[12] ^ H[12]) - (M32[4] ^ H[4]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[13] ^ H[13]);
|
||||
|
||||
/* Diffuse the differences in every word in a bijective manner with ssi, and then add the values of the previous double pipe. */
|
||||
Q[0] = ss0(Q[0]) + H[1];
|
||||
Q[1] = ss1(Q[1]) + H[2];
|
||||
Q[2] = ss2(Q[2]) + H[3];
|
||||
Q[3] = ss3(Q[3]) + H[4];
|
||||
Q[4] = ss4(Q[4]) + H[5];
|
||||
Q[5] = ss0(Q[5]) + H[6];
|
||||
Q[6] = ss1(Q[6]) + H[7];
|
||||
Q[7] = ss2(Q[7]) + H[8];
|
||||
Q[8] = ss3(Q[8]) + H[9];
|
||||
Q[9] = ss4(Q[9]) + H[10];
|
||||
Q[10] = ss0(Q[10]) + H[11];
|
||||
Q[11] = ss1(Q[11]) + H[12];
|
||||
Q[12] = ss2(Q[12]) + H[13];
|
||||
Q[13] = ss3(Q[13]) + H[14];
|
||||
Q[14] = ss4(Q[14]) + H[15];
|
||||
Q[15] = ss0(Q[15]) + H[0];
|
||||
|
||||
/* This is the Message expansion or f_1 in the documentation. */
|
||||
/* It has 16 rounds. */
|
||||
/* Blue Midnight Wish has two tunable security parameters. */
|
||||
/* The parameters are named EXPAND_1_ROUNDS and EXPAND_2_ROUNDS. */
|
||||
/* The following relation for these parameters should is satisfied: */
|
||||
/* EXPAND_1_ROUNDS + EXPAND_2_ROUNDS = 16 */
|
||||
|
||||
#pragma unroll
|
||||
for (int i=16; i<18; i++)
|
||||
Q[i] = expand32_1(i, M32, H, Q);
|
||||
|
||||
#pragma nounroll
|
||||
for (int i=18; i<32; i++)
|
||||
Q[i] = expand32_2(i, M32, H, Q);
|
||||
|
||||
/* Blue Midnight Wish has two temporary cummulative variables that accumulate via XORing */
|
||||
/* 16 new variables that are prooduced in the Message Expansion part. */
|
||||
XL32 = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ Q[20] ^ Q[21] ^ Q[22] ^ Q[23];
|
||||
XH32 = XL32^Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ Q[28] ^ Q[29] ^ Q[30] ^ Q[31];
|
||||
|
||||
|
||||
/* This part is the function f_2 - in the documentation */
|
||||
|
||||
/* Compute the double chaining pipe for the next message block. */
|
||||
M32[0] = (shl(XH32, 5) ^ shr(Q[16], 5) ^ M32[0]) + (XL32 ^ Q[24] ^ Q[0]);
|
||||
M32[1] = (shr(XH32, 7) ^ shl(Q[17], 8) ^ M32[1]) + (XL32 ^ Q[25] ^ Q[1]);
|
||||
M32[2] = (shr(XH32, 5) ^ shl(Q[18], 5) ^ M32[2]) + (XL32 ^ Q[26] ^ Q[2]);
|
||||
M32[3] = (shr(XH32, 1) ^ shl(Q[19], 5) ^ M32[3]) + (XL32 ^ Q[27] ^ Q[3]);
|
||||
M32[4] = (shr(XH32, 3) ^ Q[20] ^ M32[4]) + (XL32 ^ Q[28] ^ Q[4]);
|
||||
M32[5] = (shl(XH32, 6) ^ shr(Q[21], 6) ^ M32[5]) + (XL32 ^ Q[29] ^ Q[5]);
|
||||
M32[6] = (shr(XH32, 4) ^ shl(Q[22], 6) ^ M32[6]) + (XL32 ^ Q[30] ^ Q[6]);
|
||||
M32[7] = (shr(XH32, 11) ^ shl(Q[23], 2) ^ M32[7]) + (XL32 ^ Q[31] ^ Q[7]);
|
||||
|
||||
M32[8] = SPH_ROTL32(M32[4], 9) + (XH32 ^ Q[24] ^ M32[8]) + (shl(XL32, 8) ^ Q[23] ^ Q[8]);
|
||||
M32[9] = SPH_ROTL32(M32[5], 10) + (XH32 ^ Q[25] ^ M32[9]) + (shr(XL32, 6) ^ Q[16] ^ Q[9]);
|
||||
M32[10] = SPH_ROTL32(M32[6], 11) + (XH32 ^ Q[26] ^ M32[10]) + (shl(XL32, 6) ^ Q[17] ^ Q[10]);
|
||||
M32[11] = SPH_ROTL32(M32[7], 12) + (XH32 ^ Q[27] ^ M32[11]) + (shl(XL32, 4) ^ Q[18] ^ Q[11]);
|
||||
M32[12] = SPH_ROTL32(M32[0], 13) + (XH32 ^ Q[28] ^ M32[12]) + (shr(XL32, 3) ^ Q[19] ^ Q[12]);
|
||||
M32[13] = SPH_ROTL32(M32[1], 14) + (XH32 ^ Q[29] ^ M32[13]) + (shr(XL32, 4) ^ Q[20] ^ Q[13]);
|
||||
M32[14] = SPH_ROTL32(M32[2], 15) + (XH32 ^ Q[30] ^ M32[14]) + (shr(XL32, 7) ^ Q[21] ^ Q[14]);
|
||||
M32[15] = SPH_ROTL32(M32[3], 16) + (XH32 ^ Q[31] ^ M32[15]) + (shr(XL32, 2) ^ Q[22] ^ Q[15]);
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Compression256_2(uint32_t * M32)
|
||||
{
|
||||
uint32_t XL32, XH32, Q[32];
|
||||
|
||||
const uint32_t H[16] = {
|
||||
0xaaaaaaa0, 0xaaaaaaa1, 0xaaaaaaa2, 0xaaaaaaa3,
|
||||
0xaaaaaaa4, 0xaaaaaaa5, 0xaaaaaaa6, 0xaaaaaaa7,
|
||||
0xaaaaaaa8, 0xaaaaaaa9, 0xaaaaaaaa, 0xaaaaaaab,
|
||||
0xaaaaaaac, 0xaaaaaaad, 0xaaaaaaae, 0xaaaaaaaf
|
||||
};
|
||||
|
||||
Q[0] = (M32[5] ^ H[5]) - (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[13] ^ H[13]) + (M32[14] ^ H[14]);
|
||||
Q[1] = (M32[6] ^ H[6]) - (M32[8] ^ H[8]) + (M32[11] ^ H[11]) + (M32[14] ^ H[14]) - (M32[15] ^ H[15]);
|
||||
Q[2] = (M32[0] ^ H[0]) + (M32[7] ^ H[7]) + (M32[9] ^ H[9]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[3] = (M32[0] ^ H[0]) - (M32[1] ^ H[1]) + (M32[8] ^ H[8]) - (M32[10] ^ H[10]) + (M32[13] ^ H[13]);
|
||||
Q[4] = (M32[1] ^ H[1]) + (M32[2] ^ H[2]) + (M32[9] ^ H[9]) - (M32[11] ^ H[11]) - (M32[14] ^ H[14]);
|
||||
Q[5] = (M32[3] ^ H[3]) - (M32[2] ^ H[2]) + (M32[10] ^ H[10]) - (M32[12] ^ H[12]) + (M32[15] ^ H[15]);
|
||||
Q[6] = (M32[4] ^ H[4]) - (M32[0] ^ H[0]) - (M32[3] ^ H[3]) - (M32[11] ^ H[11]) + (M32[13] ^ H[13]);
|
||||
Q[7] = (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[5] ^ H[5]) - (M32[12] ^ H[12]) - (M32[14] ^ H[14]);
|
||||
Q[8] = (M32[2] ^ H[2]) - (M32[5] ^ H[5]) - (M32[6] ^ H[6]) + (M32[13] ^ H[13]) - (M32[15] ^ H[15]);
|
||||
Q[9] = (M32[0] ^ H[0]) - (M32[3] ^ H[3]) + (M32[6] ^ H[6]) - (M32[7] ^ H[7]) + (M32[14] ^ H[14]);
|
||||
Q[10] = (M32[8] ^ H[8]) - (M32[1] ^ H[1]) - (M32[4] ^ H[4]) - (M32[7] ^ H[7]) + (M32[15] ^ H[15]);
|
||||
Q[11] = (M32[8] ^ H[8]) - (M32[0] ^ H[0]) - (M32[2] ^ H[2]) - (M32[5] ^ H[5]) + (M32[9] ^ H[9]);
|
||||
Q[12] = (M32[1] ^ H[1]) + (M32[3] ^ H[3]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[10] ^ H[10]);
|
||||
Q[13] = (M32[2] ^ H[2]) + (M32[4] ^ H[4]) + (M32[7] ^ H[7]) + (M32[10] ^ H[10]) + (M32[11] ^ H[11]);
|
||||
Q[14] = (M32[3] ^ H[3]) - (M32[5] ^ H[5]) + (M32[8] ^ H[8]) - (M32[11] ^ H[11]) - (M32[12] ^ H[12]);
|
||||
Q[15] = (M32[12] ^ H[12]) - (M32[4] ^ H[4]) - (M32[6] ^ H[6]) - (M32[9] ^ H[9]) + (M32[13] ^ H[13]);
|
||||
|
||||
/* Diffuse the differences in every word in a bijective manner with ssi, and then add the values of the previous double pipe.*/
|
||||
Q[0] = ss0(Q[0]) + H[1];
|
||||
Q[1] = ss1(Q[1]) + H[2];
|
||||
Q[2] = ss2(Q[2]) + H[3];
|
||||
Q[3] = ss3(Q[3]) + H[4];
|
||||
Q[4] = ss4(Q[4]) + H[5];
|
||||
Q[5] = ss0(Q[5]) + H[6];
|
||||
Q[6] = ss1(Q[6]) + H[7];
|
||||
Q[7] = ss2(Q[7]) + H[8];
|
||||
Q[8] = ss3(Q[8]) + H[9];
|
||||
Q[9] = ss4(Q[9]) + H[10];
|
||||
Q[10] = ss0(Q[10]) + H[11];
|
||||
Q[11] = ss1(Q[11]) + H[12];
|
||||
Q[12] = ss2(Q[12]) + H[13];
|
||||
Q[13] = ss3(Q[13]) + H[14];
|
||||
Q[14] = ss4(Q[14]) + H[15];
|
||||
Q[15] = ss0(Q[15]) + H[0];
|
||||
|
||||
/* This is the Message expansion or f_1 in the documentation. */
|
||||
/* It has 16 rounds. */
|
||||
/* Blue Midnight Wish has two tunable security parameters. */
|
||||
/* The parameters are named EXPAND_1_ROUNDS and EXPAND_2_ROUNDS. */
|
||||
/* The following relation for these parameters should is satisfied: */
|
||||
/* EXPAND_1_ROUNDS + EXPAND_2_ROUNDS = 16 */
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 16; i<18; i++)
|
||||
Q[i] = expand32_1(i, M32, H, Q);
|
||||
|
||||
#pragma nounroll
|
||||
for (int i = 18; i<32; i++)
|
||||
Q[i] = expand32_2(i, M32, H, Q);
|
||||
|
||||
/* Blue Midnight Wish has two temporary cummulative variables that accumulate via XORing */
|
||||
/* 16 new variables that are prooduced in the Message Expansion part. */
|
||||
XL32 = Q[16] ^ Q[17] ^ Q[18] ^ Q[19] ^ Q[20] ^ Q[21] ^ Q[22] ^ Q[23];
|
||||
XH32 = XL32 ^ Q[24] ^ Q[25] ^ Q[26] ^ Q[27] ^ Q[28] ^ Q[29] ^ Q[30] ^ Q[31];
|
||||
|
||||
M32[2] = (shr(XH32, 5) ^ shl(Q[18], 5) ^ M32[2]) + (XL32 ^ Q[26] ^ Q[2]);
|
||||
M32[3] = (shr(XH32, 1) ^ shl(Q[19], 5) ^ M32[3]) + (XL32 ^ Q[27] ^ Q[3]);
|
||||
M32[14] = SPH_ROTL32(M32[2], 15) + (XH32 ^ Q[30] ^ M32[14]) + (shr(XL32, 7) ^ Q[21] ^ Q[14]);
|
||||
M32[15] = SPH_ROTL32(M32[3], 16) + (XH32 ^ Q[31] ^ M32[15]) + (shr(XL32, 2) ^ Q[22] ^ Q[15]);
|
||||
}
|
||||
|
||||
#define TPB 512
|
||||
__global__ __launch_bounds__(TPB, 2)
|
||||
void bmw256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *g_hash, uint32_t *const __restrict__ nonceVector)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t message[16] = { 0 };
|
||||
|
||||
LOHI(message[0], message[1], __ldg(&g_hash[thread]));
|
||||
LOHI(message[2], message[3], __ldg(&g_hash[thread + 1 * threads]));
|
||||
LOHI(message[4], message[5], __ldg(&g_hash[thread + 2 * threads]));
|
||||
LOHI(message[6], message[7], __ldg(&g_hash[thread + 3 * threads]));
|
||||
|
||||
message[8]=0x80;
|
||||
message[14]=0x100;
|
||||
Compression256(message);
|
||||
Compression256_2(message);
|
||||
|
||||
if (((uint64_t*)message)[7] <= pTarget[3])
|
||||
{
|
||||
uint32_t tmp = atomicExch(&nonceVector[0], startNounce + thread);
|
||||
if (tmp != 0)
|
||||
nonceVector[1] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *g_hash, uint32_t *resultnonces)
|
||||
{
|
||||
const uint32_t threadsperblock = TPB;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
cudaMemset(d_GNonce[thr_id], 0, 2 * sizeof(uint32_t));
|
||||
|
||||
bmw256_gpu_hash_32 << <grid, block >> >(threads, startNounce, g_hash, d_GNonce[thr_id]);
|
||||
cudaMemcpy(d_gnounce[thr_id], d_GNonce[thr_id], 2 * sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
resultnonces[0] = *(d_gnounce[thr_id]);
|
||||
resultnonces[1] = *(d_gnounce[thr_id] + 1);
|
||||
}
|
||||
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaMalloc(&d_GNonce[thr_id], 2 * sizeof(uint32_t));
|
||||
cudaMallocHost(&d_gnounce[thr_id], 2 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_GNonce[thr_id]);
|
||||
cudaFreeHost(d_gnounce[thr_id]);
|
||||
}
|
||||
|
||||
__host__
|
||||
void bmw256_setTarget(const void *pTargetIn)
|
||||
{
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32, 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
@@ -0,0 +1,370 @@
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#define CUBEHASH_ROUNDS 16 /* this is r for CubeHashr/b */
|
||||
#define CUBEHASH_BLOCKBYTES 32 /* this is b for CubeHashr/b */
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
/* just for vstudio code colors */
|
||||
#define __CUDA_ARCH__ 520
|
||||
#endif
|
||||
|
||||
#if __CUDA_ARCH__ < 350
|
||||
#define LROT(x,bits) ((x << bits) | (x >> (32 - bits)))
|
||||
#else
|
||||
#define LROT(x, bits) __funnelshift_l(x, x, bits)
|
||||
#endif
|
||||
|
||||
#define TPB35 576
|
||||
#define TPB50 1024
|
||||
|
||||
#define ROTATEUPWARDS7(a) LROT(a,7)
|
||||
#define ROTATEUPWARDS11(a) LROT(a,11)
|
||||
|
||||
__device__ __forceinline__ void rrounds(uint32_t x[2][2][2][2][2])
|
||||
{
|
||||
int r;
|
||||
|
||||
uint32_t x0[2][2][2][2];
|
||||
uint32_t x1[2][2][2][2];
|
||||
|
||||
for (r = 0; r < CUBEHASH_ROUNDS; r += 2) {
|
||||
/* "rotate x_0jklm upwards by 7 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS7(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS7(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS7(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS7(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS7(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS7(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS7(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS7(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS7(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS7(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS7(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS7(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS7(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS7(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS7(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS7(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1jklm modulo 2^32" */
|
||||
x1[0][0][0][0] = x[1][0][0][0][0] + x[0][0][0][0][0];
|
||||
x1[0][0][0][1] = x[1][0][0][0][1] + x[0][0][0][0][1];
|
||||
x1[0][0][1][0] = x[1][0][0][1][0] + x[0][0][0][1][0];
|
||||
x1[0][0][1][1] = x[1][0][0][1][1] + x[0][0][0][1][1];
|
||||
x1[0][1][0][0] = x[1][0][1][0][0] + x[0][0][1][0][0];
|
||||
x1[0][1][0][1] = x[1][0][1][0][1] + x[0][0][1][0][1];
|
||||
x1[0][1][1][0] = x[1][0][1][1][0] + x[0][0][1][1][0];
|
||||
x1[0][1][1][1] = x[1][0][1][1][1] + x[0][0][1][1][1];
|
||||
x1[1][0][0][0] = x[1][1][0][0][0] + x[0][1][0][0][0];
|
||||
x1[1][0][0][1] = x[1][1][0][0][1] + x[0][1][0][0][1];
|
||||
x1[1][0][1][0] = x[1][1][0][1][0] + x[0][1][0][1][0];
|
||||
x1[1][0][1][1] = x[1][1][0][1][1] + x[0][1][0][1][1];
|
||||
x1[1][1][0][0] = x[1][1][1][0][0] + x[0][1][1][0][0];
|
||||
x1[1][1][0][1] = x[1][1][1][0][1] + x[0][1][1][0][1];
|
||||
x1[1][1][1][0] = x[1][1][1][1][0] + x[0][1][1][1][0];
|
||||
x1[1][1][1][1] = x[1][1][1][1][1] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1~jklm into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x1[1][0][0][0];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x1[1][0][0][1];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x1[1][0][1][0];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x1[1][0][1][1];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x1[1][1][0][0];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x1[1][1][0][1];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x1[1][1][1][0];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x1[1][1][1][1];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x1[0][0][0][0];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x1[0][0][0][1];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x1[0][0][1][0];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x1[0][0][1][1];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x1[0][1][0][0];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x1[0][1][0][1];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x1[0][1][1][0];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x1[0][1][1][1];
|
||||
|
||||
/* "rotate x_0jklm upwards by 11 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS11(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS11(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS11(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS11(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS11(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS11(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS11(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS11(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS11(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS11(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS11(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS11(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS11(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS11(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS11(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS11(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1~jk~lm modulo 2^32" */
|
||||
x[1][1][0][1][0] = x1[1][0][1][0] + x[0][0][0][0][0];
|
||||
x[1][1][0][1][1] = x1[1][0][1][1] + x[0][0][0][0][1];
|
||||
x[1][1][0][0][0] = x1[1][0][0][0] + x[0][0][0][1][0];
|
||||
x[1][1][0][0][1] = x1[1][0][0][1] + x[0][0][0][1][1];
|
||||
x[1][1][1][1][0] = x1[1][1][1][0] + x[0][0][1][0][0];
|
||||
x[1][1][1][1][1] = x1[1][1][1][1] + x[0][0][1][0][1];
|
||||
x[1][1][1][0][0] = x1[1][1][0][0] + x[0][0][1][1][0];
|
||||
x[1][1][1][0][1] = x1[1][1][0][1] + x[0][0][1][1][1];
|
||||
x[1][0][0][1][0] = x1[0][0][1][0] + x[0][1][0][0][0];
|
||||
x[1][0][0][1][1] = x1[0][0][1][1] + x[0][1][0][0][1];
|
||||
x[1][0][0][0][0] = x1[0][0][0][0] + x[0][1][0][1][0];
|
||||
x[1][0][0][0][1] = x1[0][0][0][1] + x[0][1][0][1][1];
|
||||
x[1][0][1][1][0] = x1[0][1][1][0] + x[0][1][1][0][0];
|
||||
x[1][0][1][1][1] = x1[0][1][1][1] + x[0][1][1][0][1];
|
||||
x[1][0][1][0][0] = x1[0][1][0][0] + x[0][1][1][1][0];
|
||||
x[1][0][1][0][1] = x1[0][1][0][1] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1~j~k~lm into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x[1][1][1][1][0];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x[1][1][1][1][1];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x[1][1][1][0][0];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x[1][1][1][0][1];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x[1][1][0][1][0];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x[1][1][0][1][1];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x[1][1][0][0][0];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x[1][1][0][0][1];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x[1][0][1][1][0];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x[1][0][1][1][1];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x[1][0][1][0][0];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x[1][0][1][0][1];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x[1][0][0][1][0];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x[1][0][0][1][1];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x[1][0][0][0][0];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x[1][0][0][0][1];
|
||||
|
||||
/* "rotate x_0jklm upwards by 7 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS7(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS7(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS7(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS7(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS7(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS7(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS7(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS7(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS7(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS7(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS7(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS7(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS7(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS7(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS7(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS7(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1~j~k~l~m modulo 2^32" */
|
||||
x1[1][1][1][1] = x[1][1][1][1][1] + x[0][0][0][0][0];
|
||||
x1[1][1][1][0] = x[1][1][1][1][0] + x[0][0][0][0][1];
|
||||
x1[1][1][0][1] = x[1][1][1][0][1] + x[0][0][0][1][0];
|
||||
x1[1][1][0][0] = x[1][1][1][0][0] + x[0][0][0][1][1];
|
||||
x1[1][0][1][1] = x[1][1][0][1][1] + x[0][0][1][0][0];
|
||||
x1[1][0][1][0] = x[1][1][0][1][0] + x[0][0][1][0][1];
|
||||
x1[1][0][0][1] = x[1][1][0][0][1] + x[0][0][1][1][0];
|
||||
x1[1][0][0][0] = x[1][1][0][0][0] + x[0][0][1][1][1];
|
||||
x1[0][1][1][1] = x[1][0][1][1][1] + x[0][1][0][0][0];
|
||||
x1[0][1][1][0] = x[1][0][1][1][0] + x[0][1][0][0][1];
|
||||
x1[0][1][0][1] = x[1][0][1][0][1] + x[0][1][0][1][0];
|
||||
x1[0][1][0][0] = x[1][0][1][0][0] + x[0][1][0][1][1];
|
||||
x1[0][0][1][1] = x[1][0][0][1][1] + x[0][1][1][0][0];
|
||||
x1[0][0][1][0] = x[1][0][0][1][0] + x[0][1][1][0][1];
|
||||
x1[0][0][0][1] = x[1][0][0][0][1] + x[0][1][1][1][0];
|
||||
x1[0][0][0][0] = x[1][0][0][0][0] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1j~k~l~m into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x1[0][1][1][1];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x1[0][1][1][0];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x1[0][1][0][1];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x1[0][1][0][0];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x1[0][0][1][1];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x1[0][0][1][0];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x1[0][0][0][1];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x1[0][0][0][0];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x1[1][1][1][1];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x1[1][1][1][0];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x1[1][1][0][1];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x1[1][1][0][0];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x1[1][0][1][1];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x1[1][0][1][0];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x1[1][0][0][1];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x1[1][0][0][0];
|
||||
|
||||
/* "rotate x_0jklm upwards by 11 bits" */
|
||||
x0[0][0][0][0] = ROTATEUPWARDS11(x[0][0][0][0][0]);
|
||||
x0[0][0][0][1] = ROTATEUPWARDS11(x[0][0][0][0][1]);
|
||||
x0[0][0][1][0] = ROTATEUPWARDS11(x[0][0][0][1][0]);
|
||||
x0[0][0][1][1] = ROTATEUPWARDS11(x[0][0][0][1][1]);
|
||||
x0[0][1][0][0] = ROTATEUPWARDS11(x[0][0][1][0][0]);
|
||||
x0[0][1][0][1] = ROTATEUPWARDS11(x[0][0][1][0][1]);
|
||||
x0[0][1][1][0] = ROTATEUPWARDS11(x[0][0][1][1][0]);
|
||||
x0[0][1][1][1] = ROTATEUPWARDS11(x[0][0][1][1][1]);
|
||||
x0[1][0][0][0] = ROTATEUPWARDS11(x[0][1][0][0][0]);
|
||||
x0[1][0][0][1] = ROTATEUPWARDS11(x[0][1][0][0][1]);
|
||||
x0[1][0][1][0] = ROTATEUPWARDS11(x[0][1][0][1][0]);
|
||||
x0[1][0][1][1] = ROTATEUPWARDS11(x[0][1][0][1][1]);
|
||||
x0[1][1][0][0] = ROTATEUPWARDS11(x[0][1][1][0][0]);
|
||||
x0[1][1][0][1] = ROTATEUPWARDS11(x[0][1][1][0][1]);
|
||||
x0[1][1][1][0] = ROTATEUPWARDS11(x[0][1][1][1][0]);
|
||||
x0[1][1][1][1] = ROTATEUPWARDS11(x[0][1][1][1][1]);
|
||||
|
||||
/* "add x_0jklm into x_1j~kl~m modulo 2^32" */
|
||||
x[1][0][1][0][1] = x1[0][1][0][1] + x[0][0][0][0][0];
|
||||
x[1][0][1][0][0] = x1[0][1][0][0] + x[0][0][0][0][1];
|
||||
x[1][0][1][1][1] = x1[0][1][1][1] + x[0][0][0][1][0];
|
||||
x[1][0][1][1][0] = x1[0][1][1][0] + x[0][0][0][1][1];
|
||||
x[1][0][0][0][1] = x1[0][0][0][1] + x[0][0][1][0][0];
|
||||
x[1][0][0][0][0] = x1[0][0][0][0] + x[0][0][1][0][1];
|
||||
x[1][0][0][1][1] = x1[0][0][1][1] + x[0][0][1][1][0];
|
||||
x[1][0][0][1][0] = x1[0][0][1][0] + x[0][0][1][1][1];
|
||||
x[1][1][1][0][1] = x1[1][1][0][1] + x[0][1][0][0][0];
|
||||
x[1][1][1][0][0] = x1[1][1][0][0] + x[0][1][0][0][1];
|
||||
x[1][1][1][1][1] = x1[1][1][1][1] + x[0][1][0][1][0];
|
||||
x[1][1][1][1][0] = x1[1][1][1][0] + x[0][1][0][1][1];
|
||||
x[1][1][0][0][1] = x1[1][0][0][1] + x[0][1][1][0][0];
|
||||
x[1][1][0][0][0] = x1[1][0][0][0] + x[0][1][1][0][1];
|
||||
x[1][1][0][1][1] = x1[1][0][1][1] + x[0][1][1][1][0];
|
||||
x[1][1][0][1][0] = x1[1][0][1][0] + x[0][1][1][1][1];
|
||||
|
||||
/* "xor x_1jkl~m into x_0jklm" */
|
||||
x[0][0][0][0][0] = x0[0][0][0][0] ^ x[1][0][0][0][1];
|
||||
x[0][0][0][0][1] = x0[0][0][0][1] ^ x[1][0][0][0][0];
|
||||
x[0][0][0][1][0] = x0[0][0][1][0] ^ x[1][0][0][1][1];
|
||||
x[0][0][0][1][1] = x0[0][0][1][1] ^ x[1][0][0][1][0];
|
||||
x[0][0][1][0][0] = x0[0][1][0][0] ^ x[1][0][1][0][1];
|
||||
x[0][0][1][0][1] = x0[0][1][0][1] ^ x[1][0][1][0][0];
|
||||
x[0][0][1][1][0] = x0[0][1][1][0] ^ x[1][0][1][1][1];
|
||||
x[0][0][1][1][1] = x0[0][1][1][1] ^ x[1][0][1][1][0];
|
||||
x[0][1][0][0][0] = x0[1][0][0][0] ^ x[1][1][0][0][1];
|
||||
x[0][1][0][0][1] = x0[1][0][0][1] ^ x[1][1][0][0][0];
|
||||
x[0][1][0][1][0] = x0[1][0][1][0] ^ x[1][1][0][1][1];
|
||||
x[0][1][0][1][1] = x0[1][0][1][1] ^ x[1][1][0][1][0];
|
||||
x[0][1][1][0][0] = x0[1][1][0][0] ^ x[1][1][1][0][1];
|
||||
x[0][1][1][0][1] = x0[1][1][0][1] ^ x[1][1][1][0][0];
|
||||
x[0][1][1][1][0] = x0[1][1][1][0] ^ x[1][1][1][1][1];
|
||||
x[0][1][1][1][1] = x0[1][1][1][1] ^ x[1][1][1][1][0];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void Final(uint32_t x[2][2][2][2][2], uint32_t *hashval)
|
||||
{
|
||||
/* "the integer 1 is xored into the last state word x_11111" */
|
||||
x[1][1][1][1][1] ^= 1U;
|
||||
|
||||
/* "the state is then transformed invertibly through 10r identical rounds" */
|
||||
for (int i = 0; i < 10; ++i) rrounds(x);
|
||||
|
||||
/* "output the first h/8 bytes of the state" */
|
||||
hashval[0] = x[0][0][0][0][0];
|
||||
hashval[1] = x[0][0][0][0][1];
|
||||
hashval[2] = x[0][0][0][1][0];
|
||||
hashval[3] = x[0][0][0][1][1];
|
||||
hashval[4] = x[0][0][1][0][0];
|
||||
hashval[5] = x[0][0][1][0][1];
|
||||
hashval[6] = x[0][0][1][1][0];
|
||||
hashval[7] = x[0][0][1][1][1];
|
||||
}
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
__global__ __launch_bounds__(TPB50, 1)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB35, 1)
|
||||
#endif
|
||||
void cubehash256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint2 *g_hash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
uint2 Hash[4];
|
||||
|
||||
Hash[0] = __ldg(&g_hash[thread]);
|
||||
Hash[1] = __ldg(&g_hash[thread + 1 * threads]);
|
||||
Hash[2] = __ldg(&g_hash[thread + 2 * threads]);
|
||||
Hash[3] = __ldg(&g_hash[thread + 3 * threads]);
|
||||
#else
|
||||
uint32_t Hash[8];
|
||||
|
||||
LOHI(Hash[0], Hash[1], __ldg(&((uint64_t*)g_hash)[thread]));
|
||||
LOHI(Hash[2], Hash[3], __ldg(&((uint64_t*)g_hash)[thread + 1 * threads]));
|
||||
LOHI(Hash[4], Hash[5], __ldg(&((uint64_t*)g_hash)[thread + 2 * threads]));
|
||||
LOHI(Hash[6], Hash[7], __ldg(&((uint64_t*)g_hash)[thread + 3 * threads]));
|
||||
#endif
|
||||
|
||||
uint32_t x[2][2][2][2][2] =
|
||||
{
|
||||
0xEA2BD4B4, 0xCCD6F29F, 0x63117E71, 0x35481EAE,
|
||||
0x22512D5B, 0xE5D94E63, 0x7E624131, 0xF4CC12BE,
|
||||
0xC2D0B696, 0x42AF2070, 0xD0720C35, 0x3361DA8C,
|
||||
0x28CCECA4, 0x8EF8AD83, 0x4680AC00, 0x40E5FBAB,
|
||||
0xD89041C3, 0x6107FBD5, 0x6C859D41, 0xF0B26679,
|
||||
0x09392549, 0x5FA25603, 0x65C892FD, 0x93CB6285,
|
||||
0x2AF2B5AE, 0x9E4B4E60, 0x774ABFDD, 0x85254725,
|
||||
0x15815AEB, 0x4AB6AAD6, 0x9CDAF8AF, 0xD6032C0A
|
||||
};
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
x[0][0][0][0][0] ^= Hash[0].x;
|
||||
x[0][0][0][0][1] ^= Hash[0].y;
|
||||
x[0][0][0][1][0] ^= Hash[1].x;
|
||||
x[0][0][0][1][1] ^= Hash[1].y;
|
||||
x[0][0][1][0][0] ^= Hash[2].x;
|
||||
x[0][0][1][0][1] ^= Hash[2].y;
|
||||
x[0][0][1][1][0] ^= Hash[3].x;
|
||||
x[0][0][1][1][1] ^= Hash[3].y;
|
||||
#else
|
||||
x[0][0][0][0][0] ^= Hash[0];
|
||||
x[0][0][0][0][1] ^= Hash[1];
|
||||
x[0][0][0][1][0] ^= Hash[2];
|
||||
x[0][0][0][1][1] ^= Hash[3];
|
||||
x[0][0][1][0][0] ^= Hash[4];
|
||||
x[0][0][1][0][1] ^= Hash[5];
|
||||
x[0][0][1][1][0] ^= Hash[6];
|
||||
x[0][0][1][1][1] ^= Hash[7];
|
||||
#endif
|
||||
rrounds(x);
|
||||
x[0][0][0][0][0] ^= 0x80U;
|
||||
rrounds(x);
|
||||
|
||||
#if __CUDA_ARCH__ >= 500
|
||||
Final(x, (uint32_t*)Hash);
|
||||
|
||||
g_hash[thread] = Hash[0];
|
||||
g_hash[1 * threads + thread] = Hash[1];
|
||||
g_hash[2 * threads + thread] = Hash[2];
|
||||
g_hash[3 * threads + thread] = Hash[3];
|
||||
#else
|
||||
Final(x, Hash);
|
||||
|
||||
((uint64_t*)g_hash)[thread] = ((uint64_t*)Hash)[0];
|
||||
((uint64_t*)g_hash)[1 * threads + thread] = ((uint64_t*)Hash)[1];
|
||||
((uint64_t*)g_hash)[2 * threads + thread] = ((uint64_t*)Hash)[2];
|
||||
((uint64_t*)g_hash)[3 * threads + thread] = ((uint64_t*)Hash)[3];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void cubehash256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_hash, int order)
|
||||
{
|
||||
uint32_t tpb = TPB35;
|
||||
if (cuda_arch[thr_id] >= 500) tpb = TPB50;
|
||||
|
||||
dim3 grid((threads + tpb - 1) / tpb);
|
||||
dim3 block(tpb);
|
||||
|
||||
cubehash256_gpu_hash_32 <<<grid, block >>> (threads, startNounce, (uint2*)d_hash);
|
||||
}
|
||||
|
||||
__host__
|
||||
void cubehash256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_hash, int order, cudaStream_t stream)
|
||||
{
|
||||
uint32_t tpb = TPB35;
|
||||
if (cuda_arch[thr_id] >= 500) tpb = TPB50;
|
||||
|
||||
dim3 grid((threads + tpb - 1) / tpb);
|
||||
dim3 block(tpb);
|
||||
|
||||
cubehash256_gpu_hash_32 <<<grid, block, 0, stream >>> (threads, startNounce, (uint2*)d_hash);
|
||||
}
|
||||
@@ -8,22 +8,17 @@
|
||||
|
||||
#define USE_SHARED 1
|
||||
|
||||
// aus cpu-miner.c
|
||||
extern int device_map[8];
|
||||
|
||||
// aus heavy.cu
|
||||
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);
|
||||
|
||||
uint32_t *d_fugue256_hashoutput[8];
|
||||
uint32_t *d_resultNonce[8];
|
||||
uint32_t *d_fugue256_hashoutput[MAX_GPUS];
|
||||
static uint32_t *d_resultNonce[MAX_GPUS];
|
||||
static unsigned int* d_textures[MAX_GPUS][8];
|
||||
|
||||
__constant__ uint32_t GPUstate[30]; // Single GPU
|
||||
__constant__ uint32_t pTarget[8]; // Single GPU
|
||||
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab0Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab1Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab2Tex;
|
||||
texture<unsigned int, 1, cudaReadModeElementType> mixTab3Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab0Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab1Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab2Tex;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> mixTab3Tex;
|
||||
|
||||
#if USE_SHARED
|
||||
#define mixtab0(x) (*((uint32_t*)mixtabs + ( (x))))
|
||||
@@ -554,7 +549,7 @@ __global__ void __launch_bounds__(256)
|
||||
#else
|
||||
__global__ void
|
||||
#endif
|
||||
fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHash, uint32_t *resNounce)
|
||||
fugue256_gpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHash, uint32_t *resNounce)
|
||||
{
|
||||
#if USE_SHARED
|
||||
extern __shared__ char mixtabs[];
|
||||
@@ -567,7 +562,7 @@ fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHas
|
||||
__syncthreads();
|
||||
#endif
|
||||
|
||||
int thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
/* Nimm den State und verarbeite das letztenByte (die Nounce) */
|
||||
@@ -577,7 +572,7 @@ fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHas
|
||||
for(int i=0;i<30;i++)
|
||||
sc[i] = GPUstate[i];
|
||||
|
||||
uint32_t nounce = startNounce + thread; // muss noch ermittelt werden
|
||||
uint32_t nounce = startNounce + thread; // muss noch ermittelt werden
|
||||
uint32_t q;
|
||||
|
||||
|
||||
@@ -693,7 +688,7 @@ fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHas
|
||||
|
||||
int i;
|
||||
bool rc = true;
|
||||
|
||||
|
||||
for (i = 7; i >= 0; i--) {
|
||||
if (hash[i] > pTarget[i]) {
|
||||
rc = false;
|
||||
@@ -713,56 +708,62 @@ fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHas
|
||||
}
|
||||
}
|
||||
|
||||
#define texDef(texname, texmem, texsource, texsize) \
|
||||
#define texDef(id, texname, texmem, texsource, texsize) { \
|
||||
unsigned int *texmem; \
|
||||
cudaMalloc(&texmem, texsize); \
|
||||
d_textures[thr_id][id] = texmem; \
|
||||
cudaMemcpy(texmem, texsource, texsize, cudaMemcpyHostToDevice); \
|
||||
texname.normalized = 0; \
|
||||
texname.filterMode = cudaFilterModePoint; \
|
||||
texname.addressMode[0] = cudaAddressModeClamp; \
|
||||
{ cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<unsigned int>(); \
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); }
|
||||
|
||||
|
||||
void fugue256_cpu_init(int thr_id, int threads)
|
||||
{
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
|
||||
// Kopiere die Hash-Tabellen in den GPU-Speicher
|
||||
texDef(mixTab0Tex, mixTab0m, mixtab0_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab1Tex, mixTab1m, mixtab1_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab2Tex, mixTab2m, mixtab2_cpu, sizeof(uint32_t)*256);
|
||||
texDef(mixTab3Tex, mixTab3m, mixtab3_cpu, sizeof(uint32_t)*256);
|
||||
|
||||
// Speicher für alle Ergebnisse belegen
|
||||
cudaMalloc(&d_fugue256_hashoutput[thr_id], 8 * sizeof(uint32_t) * threads);
|
||||
cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t));
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); \
|
||||
} \
|
||||
}
|
||||
|
||||
__host__ void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
|
||||
__host__
|
||||
void fugue256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
// Link the hash tables in the GPU
|
||||
texDef(0, mixTab0Tex, mixTab0m, mixtab0_cpu, sizeof(uint32_t)*256);
|
||||
texDef(1, mixTab1Tex, mixTab1m, mixtab1_cpu, sizeof(uint32_t)*256);
|
||||
texDef(2, mixTab2Tex, mixTab2m, mixtab2_cpu, sizeof(uint32_t)*256);
|
||||
texDef(3, mixTab3Tex, mixTab3m, mixtab3_cpu, sizeof(uint32_t)*256);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_fugue256_hashoutput[thr_id], (size_t) 32 * threads));
|
||||
cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_fugue256_hashoutput[thr_id]);
|
||||
cudaFree(d_resultNonce[thr_id]);
|
||||
|
||||
for (int i=0; i<4; i++)
|
||||
cudaFree(d_textures[thr_id][i]);
|
||||
}
|
||||
|
||||
__host__
|
||||
void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
|
||||
{
|
||||
// CPU-Vorbereitungen treffen
|
||||
sph_fugue256_context ctx_fugue_const;
|
||||
sph_fugue256_init(&ctx_fugue_const);
|
||||
sph_fugue256 (&ctx_fugue_const, data, 80); // State speichern
|
||||
sph_fugue256 (&ctx_fugue_const, data, 80);
|
||||
cudaMemcpyToSymbol(GPUstate, ctx_fugue_const.S, sizeof(uint32_t) * 30);
|
||||
|
||||
cudaMemcpyToSymbol( GPUstate,
|
||||
ctx_fugue_const.S,
|
||||
sizeof(uint32_t) * 30 );
|
||||
|
||||
cudaMemcpyToSymbol( pTarget,
|
||||
pTargetIn,
|
||||
sizeof(uint32_t) * 8 );
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32);
|
||||
|
||||
cudaMemset(d_resultNonce[thr_id], 0xFF, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__ void fugue256_cpu_hash(int thr_id, int threads, int startNounce, void *outputHashes, uint32_t *nounce)
|
||||
__host__
|
||||
void fugue256_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, void *outputHashes, uint32_t *nounce)
|
||||
{
|
||||
#if USE_SHARED
|
||||
const int threadsperblock = 256; // Alignment mit mixtab Grösse. NICHT ÄNDERN
|
||||
const uint32_t threadsperblock = 256; // Alignment mit mixtab Grösse. NICHT ÄNDERN
|
||||
#else
|
||||
const int threadsperblock = 512; // so einstellen wie gewünscht ;-)
|
||||
const uint32_t threadsperblock = 512; // so einstellen wie gewünscht ;-)
|
||||
#endif
|
||||
// berechne wie viele Thread Blocks wir brauchen
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
@@ -0,0 +1,335 @@
|
||||
#include <memory.h>
|
||||
|
||||
#define SPH_C32(x) ((uint32_t)(x ## U))
|
||||
#define SPH_T32(x) ((x) & SPH_C32(0xFFFFFFFF))
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
static uint32_t *h_GNonces[MAX_GPUS];
|
||||
static uint32_t *d_GNonces[MAX_GPUS];
|
||||
static unsigned int* d_textures[MAX_GPUS][8];
|
||||
|
||||
__constant__ uint32_t pTarget[8];
|
||||
|
||||
#define C32e(x) \
|
||||
((SPH_C32(x) >> 24) \
|
||||
| ((SPH_C32(x) >> 8) & SPH_C32(0x0000FF00)) \
|
||||
| ((SPH_C32(x) << 8) & SPH_C32(0x00FF0000)) \
|
||||
| ((SPH_C32(x) << 24) & SPH_C32(0xFF000000)))
|
||||
|
||||
#define PC32up(j, r) ((uint32_t)((j) + (r)))
|
||||
#define PC32dn(j, r) 0
|
||||
#define QC32up(j, r) 0xFFFFFFFF
|
||||
#define QC32dn(j, r) (((uint32_t)(r) << 24) ^ SPH_T32(~((uint32_t)(j) << 24)))
|
||||
|
||||
#define B32_0(x) __byte_perm(x, 0, 0x4440)
|
||||
//((x) & 0xFF)
|
||||
#define B32_1(x) __byte_perm(x, 0, 0x4441)
|
||||
//(((x) >> 8) & 0xFF)
|
||||
#define B32_2(x) __byte_perm(x, 0, 0x4442)
|
||||
//(((x) >> 16) & 0xFF)
|
||||
#define B32_3(x) __byte_perm(x, 0, 0x4443)
|
||||
//((x) >> 24)
|
||||
|
||||
#define MAXWELL_OR_FERMI 1
|
||||
#if MAXWELL_OR_FERMI
|
||||
#define USE_SHARED 1
|
||||
// Maxwell and Fermi cards get the best speed with SHARED access it seems.
|
||||
#if USE_SHARED
|
||||
#define T0up(x) (*((uint32_t*)mixtabs + ( (x))))
|
||||
#define T0dn(x) (*((uint32_t*)mixtabs + (256+(x))))
|
||||
#define T1up(x) (*((uint32_t*)mixtabs + (512+(x))))
|
||||
#define T1dn(x) (*((uint32_t*)mixtabs + (768+(x))))
|
||||
#define T2up(x) (*((uint32_t*)mixtabs + (1024+(x))))
|
||||
#define T2dn(x) (*((uint32_t*)mixtabs + (1280+(x))))
|
||||
#define T3up(x) (*((uint32_t*)mixtabs + (1536+(x))))
|
||||
#define T3dn(x) (*((uint32_t*)mixtabs + (1792+(x))))
|
||||
#else
|
||||
#define T0up(x) tex1Dfetch(t0up2, x)
|
||||
#define T0dn(x) tex1Dfetch(t0dn2, x)
|
||||
#define T1up(x) tex1Dfetch(t1up2, x)
|
||||
#define T1dn(x) tex1Dfetch(t1dn2, x)
|
||||
#define T2up(x) tex1Dfetch(t2up2, x)
|
||||
#define T2dn(x) tex1Dfetch(t2dn2, x)
|
||||
#define T3up(x) tex1Dfetch(t3up2, x)
|
||||
#define T3dn(x) tex1Dfetch(t3dn2, x)
|
||||
#endif
|
||||
#else
|
||||
#define USE_SHARED 1
|
||||
// a healthy mix between shared and textured access provides the highest speed on Compute 3.0 and 3.5!
|
||||
#define T0up(x) (*((uint32_t*)mixtabs + ( (x))))
|
||||
#define T0dn(x) tex1Dfetch(t0dn2, x)
|
||||
#define T1up(x) tex1Dfetch(t1up2, x)
|
||||
#define T1dn(x) (*((uint32_t*)mixtabs + (768+(x))))
|
||||
#define T2up(x) tex1Dfetch(t2up2, x)
|
||||
#define T2dn(x) (*((uint32_t*)mixtabs + (1280+(x))))
|
||||
#define T3up(x) (*((uint32_t*)mixtabs + (1536+(x))))
|
||||
#define T3dn(x) tex1Dfetch(t3dn2, x)
|
||||
#endif
|
||||
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t0up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t0dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t1up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t1dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t2up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t2dn2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t3up2;
|
||||
static texture<unsigned int, 1, cudaReadModeElementType> t3dn2;
|
||||
|
||||
#define RSTT(d0, d1, a, b0, b1, b2, b3, b4, b5, b6, b7) do { \
|
||||
t[d0] = T0up(B32_0(a[b0])) \
|
||||
^ T1up(B32_1(a[b1])) \
|
||||
^ T2up(B32_2(a[b2])) \
|
||||
^ T3up(B32_3(a[b3])) \
|
||||
^ T0dn(B32_0(a[b4])) \
|
||||
^ T1dn(B32_1(a[b5])) \
|
||||
^ T2dn(B32_2(a[b6])) \
|
||||
^ T3dn(B32_3(a[b7])); \
|
||||
t[d1] = T0dn(B32_0(a[b0])) \
|
||||
^ T1dn(B32_1(a[b1])) \
|
||||
^ T2dn(B32_2(a[b2])) \
|
||||
^ T3dn(B32_3(a[b3])) \
|
||||
^ T0up(B32_0(a[b4])) \
|
||||
^ T1up(B32_1(a[b5])) \
|
||||
^ T2up(B32_2(a[b6])) \
|
||||
^ T3up(B32_3(a[b7])); \
|
||||
} while (0)
|
||||
|
||||
|
||||
extern uint32_t T0up_cpu[];
|
||||
extern uint32_t T0dn_cpu[];
|
||||
extern uint32_t T1up_cpu[];
|
||||
extern uint32_t T1dn_cpu[];
|
||||
extern uint32_t T2up_cpu[];
|
||||
extern uint32_t T2dn_cpu[];
|
||||
extern uint32_t T3up_cpu[];
|
||||
extern uint32_t T3dn_cpu[];
|
||||
|
||||
__device__ __forceinline__
|
||||
void groestl256_perm_P(uint32_t thread,uint32_t *a, char *mixtabs)
|
||||
{
|
||||
#pragma unroll 10
|
||||
for (int r = 0; r<10; r++)
|
||||
{
|
||||
uint32_t t[16];
|
||||
|
||||
a[0x0] ^= PC32up(0x00, r);
|
||||
a[0x2] ^= PC32up(0x10, r);
|
||||
a[0x4] ^= PC32up(0x20, r);
|
||||
a[0x6] ^= PC32up(0x30, r);
|
||||
a[0x8] ^= PC32up(0x40, r);
|
||||
a[0xA] ^= PC32up(0x50, r);
|
||||
a[0xC] ^= PC32up(0x60, r);
|
||||
a[0xE] ^= PC32up(0x70, r);
|
||||
RSTT(0x0, 0x1, a, 0x0, 0x2, 0x4, 0x6, 0x9, 0xB, 0xD, 0xF);
|
||||
RSTT(0x2, 0x3, a, 0x2, 0x4, 0x6, 0x8, 0xB, 0xD, 0xF, 0x1);
|
||||
RSTT(0x4, 0x5, a, 0x4, 0x6, 0x8, 0xA, 0xD, 0xF, 0x1, 0x3);
|
||||
RSTT(0x6, 0x7, a, 0x6, 0x8, 0xA, 0xC, 0xF, 0x1, 0x3, 0x5);
|
||||
RSTT(0x8, 0x9, a, 0x8, 0xA, 0xC, 0xE, 0x1, 0x3, 0x5, 0x7);
|
||||
RSTT(0xA, 0xB, a, 0xA, 0xC, 0xE, 0x0, 0x3, 0x5, 0x7, 0x9);
|
||||
RSTT(0xC, 0xD, a, 0xC, 0xE, 0x0, 0x2, 0x5, 0x7, 0x9, 0xB);
|
||||
RSTT(0xE, 0xF, a, 0xE, 0x0, 0x2, 0x4, 0x7, 0x9, 0xB, 0xD);
|
||||
|
||||
#pragma unroll 16
|
||||
for (int k = 0; k<16; k++)
|
||||
a[k] = t[k];
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void groestl256_perm_Q(uint32_t thread, uint32_t *a, char *mixtabs)
|
||||
{
|
||||
#pragma unroll
|
||||
for (int r = 0; r<10; r++)
|
||||
{
|
||||
uint32_t t[16];
|
||||
|
||||
a[0x0] ^= QC32up(0x00, r);
|
||||
a[0x1] ^= QC32dn(0x00, r);
|
||||
a[0x2] ^= QC32up(0x10, r);
|
||||
a[0x3] ^= QC32dn(0x10, r);
|
||||
a[0x4] ^= QC32up(0x20, r);
|
||||
a[0x5] ^= QC32dn(0x20, r);
|
||||
a[0x6] ^= QC32up(0x30, r);
|
||||
a[0x7] ^= QC32dn(0x30, r);
|
||||
a[0x8] ^= QC32up(0x40, r);
|
||||
a[0x9] ^= QC32dn(0x40, r);
|
||||
a[0xA] ^= QC32up(0x50, r);
|
||||
a[0xB] ^= QC32dn(0x50, r);
|
||||
a[0xC] ^= QC32up(0x60, r);
|
||||
a[0xD] ^= QC32dn(0x60, r);
|
||||
a[0xE] ^= QC32up(0x70, r);
|
||||
a[0xF] ^= QC32dn(0x70, r);
|
||||
RSTT(0x0, 0x1, a, 0x2, 0x6, 0xA, 0xE, 0x1, 0x5, 0x9, 0xD);
|
||||
RSTT(0x2, 0x3, a, 0x4, 0x8, 0xC, 0x0, 0x3, 0x7, 0xB, 0xF);
|
||||
RSTT(0x4, 0x5, a, 0x6, 0xA, 0xE, 0x2, 0x5, 0x9, 0xD, 0x1);
|
||||
RSTT(0x6, 0x7, a, 0x8, 0xC, 0x0, 0x4, 0x7, 0xB, 0xF, 0x3);
|
||||
RSTT(0x8, 0x9, a, 0xA, 0xE, 0x2, 0x6, 0x9, 0xD, 0x1, 0x5);
|
||||
RSTT(0xA, 0xB, a, 0xC, 0x0, 0x4, 0x8, 0xB, 0xF, 0x3, 0x7);
|
||||
RSTT(0xC, 0xD, a, 0xE, 0x2, 0x6, 0xA, 0xD, 0x1, 0x5, 0x9);
|
||||
RSTT(0xE, 0xF, a, 0x0, 0x4, 0x8, 0xC, 0xF, 0x3, 0x7, 0xB);
|
||||
|
||||
#pragma unroll
|
||||
for (int k = 0; k<16; k++)
|
||||
a[k] = t[k];
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256,1)
|
||||
void groestl256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash, uint32_t *resNonces)
|
||||
{
|
||||
#if USE_SHARED
|
||||
extern __shared__ char mixtabs[];
|
||||
|
||||
if (threadIdx.x < 256) {
|
||||
*((uint32_t*)mixtabs + (threadIdx.x)) = tex1Dfetch(t0up2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (256 + threadIdx.x)) = tex1Dfetch(t0dn2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (512 + threadIdx.x)) = tex1Dfetch(t1up2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (768 + threadIdx.x)) = tex1Dfetch(t1dn2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (1024 + threadIdx.x)) = tex1Dfetch(t2up2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (1280 + threadIdx.x)) = tex1Dfetch(t2dn2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (1536 + threadIdx.x)) = tex1Dfetch(t3up2, threadIdx.x);
|
||||
*((uint32_t*)mixtabs + (1792 + threadIdx.x)) = tex1Dfetch(t3dn2, threadIdx.x);
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
#endif
|
||||
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
// GROESTL
|
||||
uint32_t message[16];
|
||||
uint32_t state[16];
|
||||
|
||||
#pragma unroll
|
||||
for (int k = 0; k<4; k++)
|
||||
LOHI(message[2*k], message[2*k+1], outputHash[k*threads+thread]);
|
||||
|
||||
#pragma unroll
|
||||
for (int k = 9; k<15; k++)
|
||||
message[k] = 0;
|
||||
|
||||
message[8] = 0x80;
|
||||
message[15] = 0x01000000;
|
||||
|
||||
#pragma unroll 16
|
||||
for (int u = 0; u<16; u++)
|
||||
state[u] = message[u];
|
||||
|
||||
state[15] ^= 0x10000;
|
||||
|
||||
// Perm
|
||||
|
||||
#if USE_SHARED
|
||||
groestl256_perm_P(thread, state, mixtabs);
|
||||
state[15] ^= 0x10000;
|
||||
groestl256_perm_Q(thread, message, mixtabs);
|
||||
#else
|
||||
groestl256_perm_P(thread, state, NULL);
|
||||
state[15] ^= 0x10000;
|
||||
groestl256_perm_P(thread, message, NULL);
|
||||
#endif
|
||||
#pragma unroll 16
|
||||
for (int u = 0; u<16; u++) state[u] ^= message[u];
|
||||
#pragma unroll 16
|
||||
for (int u = 0; u<16; u++) message[u] = state[u];
|
||||
#if USE_SHARED
|
||||
groestl256_perm_P(thread, message, mixtabs);
|
||||
#else
|
||||
groestl256_perm_P(thread, message, NULL);
|
||||
#endif
|
||||
state[14] ^= message[14];
|
||||
state[15] ^= message[15];
|
||||
|
||||
uint32_t nonce = startNounce + thread;
|
||||
if (state[15] <= pTarget[7]) {
|
||||
atomicMin(&resNonces[1], resNonces[0]);
|
||||
atomicMin(&resNonces[0], nonce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define texDef(id, texname, texmem, texsource, texsize) { \
|
||||
unsigned int *texmem; \
|
||||
cudaMalloc(&texmem, texsize); \
|
||||
d_textures[thr_id][id] = texmem; \
|
||||
cudaMemcpy(texmem, texsource, texsize, cudaMemcpyHostToDevice); \
|
||||
texname.normalized = 0; \
|
||||
texname.filterMode = cudaFilterModePoint; \
|
||||
texname.addressMode[0] = cudaAddressModeClamp; \
|
||||
{ cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<unsigned int>(); \
|
||||
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); \
|
||||
} \
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestl256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
// Texturen mit obigem Makro initialisieren
|
||||
texDef(0, t0up2, d_T0up, T0up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(1, t0dn2, d_T0dn, T0dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(2, t1up2, d_T1up, T1up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(3, t1dn2, d_T1dn, T1dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(4, t2up2, d_T2up, T2up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(5, t2dn2, d_T2dn, T2dn_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(6, t3up2, d_T3up, T3up_cpu, sizeof(uint32_t) * 256);
|
||||
texDef(7, t3dn2, d_T3dn, T3dn_cpu, sizeof(uint32_t) * 256);
|
||||
|
||||
cudaMalloc(&d_GNonces[thr_id], 2*sizeof(uint32_t));
|
||||
cudaMallocHost(&h_GNonces[thr_id], 2*sizeof(uint32_t));
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestl256_cpu_free(int thr_id)
|
||||
{
|
||||
for (int i=0; i<8; i++)
|
||||
cudaFree(d_textures[thr_id][i]);
|
||||
|
||||
cudaFree(d_GNonces[thr_id]);
|
||||
cudaFreeHost(h_GNonces[thr_id]);
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t groestl256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
uint32_t result = UINT32_MAX;
|
||||
cudaMemset(d_GNonces[thr_id], 0xff, 2*sizeof(uint32_t));
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
// berechne wie viele Thread Blocks wir brauchen
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
#if USE_SHARED
|
||||
size_t shared_size = 8 * 256 * sizeof(uint32_t);
|
||||
#else
|
||||
size_t shared_size = 0;
|
||||
#endif
|
||||
groestl256_gpu_hash_32<<<grid, block, shared_size>>>(threads, startNounce, d_outputHash, d_GNonces[thr_id]);
|
||||
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
|
||||
// get first found nonce
|
||||
cudaMemcpy(h_GNonces[thr_id], d_GNonces[thr_id], 1*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
result = *h_GNonces[thr_id];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t groestl256_getSecNonce(int thr_id, int num)
|
||||
{
|
||||
uint32_t results[2];
|
||||
memset(results, 0xFF, sizeof(results));
|
||||
cudaMemcpy(results, d_GNonces[thr_id], sizeof(results), cudaMemcpyDeviceToHost);
|
||||
if (results[1] == results[0])
|
||||
return UINT32_MAX;
|
||||
return results[num];
|
||||
}
|
||||
|
||||
__host__
|
||||
void groestl256_setTarget(const void *pTargetIn)
|
||||
{
|
||||
cudaMemcpyToSymbol(pTarget, pTargetIn, 32, 0, cudaMemcpyHostToDevice);
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
* KECCAK-256 CUDA optimised implementation, based on ccminer-alexis code
|
||||
*/
|
||||
|
||||
#include <miner.h>
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
#include <cuda_helper.h>
|
||||
#include <cuda_vectors.h>
|
||||
|
||||
#define TPB52 1024
|
||||
#define TPB50 384
|
||||
#define NPT 2
|
||||
#define NBN 2
|
||||
|
||||
static uint32_t *d_nonces[MAX_GPUS];
|
||||
static uint32_t *h_nonces[MAX_GPUS];
|
||||
|
||||
__constant__ uint2 c_message48[6];
|
||||
__constant__ uint2 c_mid[17];
|
||||
|
||||
__constant__ uint2 keccak_round_constants[24] = {
|
||||
{ 0x00000001, 0x00000000 }, { 0x00008082, 0x00000000 }, { 0x0000808a, 0x80000000 }, { 0x80008000, 0x80000000 },
|
||||
{ 0x0000808b, 0x00000000 }, { 0x80000001, 0x00000000 }, { 0x80008081, 0x80000000 }, { 0x00008009, 0x80000000 },
|
||||
{ 0x0000008a, 0x00000000 }, { 0x00000088, 0x00000000 }, { 0x80008009, 0x00000000 }, { 0x8000000a, 0x00000000 },
|
||||
{ 0x8000808b, 0x00000000 }, { 0x0000008b, 0x80000000 }, { 0x00008089, 0x80000000 }, { 0x00008003, 0x80000000 },
|
||||
{ 0x00008002, 0x80000000 }, { 0x00000080, 0x80000000 }, { 0x0000800a, 0x00000000 }, { 0x8000000a, 0x80000000 },
|
||||
{ 0x80008081, 0x80000000 }, { 0x00008080, 0x80000000 }, { 0x80000001, 0x00000000 }, { 0x80008008, 0x80000000 }
|
||||
};
|
||||
|
||||
__device__ __forceinline__
|
||||
uint2 xor3x(const uint2 a,const uint2 b,const uint2 c) {
|
||||
uint2 result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result.x) : "r"(a.x), "r"(b.x),"r"(c.x)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0x96;" : "=r"(result.y) : "r"(a.y), "r"(b.y),"r"(c.y)); //0x96 = 0xF0 ^ 0xCC ^ 0xAA
|
||||
#else
|
||||
result = a^b^c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
uint2 chi(const uint2 a,const uint2 b,const uint2 c) { // keccak chi
|
||||
uint2 result;
|
||||
#if __CUDA_ARCH__ >= 500 && CUDA_VERSION >= 7050
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0xD2;" : "=r"(result.x) : "r"(a.x), "r"(b.x),"r"(c.x)); //0xD2 = 0xF0 ^ ((~0xCC) & 0xAA)
|
||||
asm ("lop3.b32 %0, %1, %2, %3, 0xD2;" : "=r"(result.y) : "r"(a.y), "r"(b.y),"r"(c.y)); //0xD2 = 0xF0 ^ ((~0xCC) & 0xAA)
|
||||
#else
|
||||
result = a ^ (~b) & c;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
uint64_t xor5(uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e)
|
||||
{
|
||||
uint64_t result;
|
||||
asm("xor.b64 %0, %1, %2;" : "=l"(result) : "l"(d) ,"l"(e));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(c));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(b));
|
||||
asm("xor.b64 %0, %0, %1;" : "+l"(result) : "l"(a));
|
||||
return result;
|
||||
}
|
||||
|
||||
#if __CUDA_ARCH__ <= 500
|
||||
__global__ __launch_bounds__(TPB50, 2)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB52, 1)
|
||||
#endif
|
||||
void keccak256_gpu_hash_80(uint32_t threads, uint32_t startNonce, uint32_t *resNounce, const uint2 highTarget)
|
||||
{
|
||||
uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
uint2 s[25], t[5], v, w, u[5];
|
||||
#if __CUDA_ARCH__ > 500
|
||||
uint64_t step = gridDim.x * blockDim.x;
|
||||
uint64_t maxNonce = startNonce + threads;
|
||||
for(uint64_t nounce = startNonce + thread; nounce<maxNonce;nounce+=step) {
|
||||
#else
|
||||
uint32_t nounce = startNonce+thread;
|
||||
if(thread<threads) {
|
||||
#endif
|
||||
s[ 9] = make_uint2(c_message48[0].x,cuda_swab32(nounce));
|
||||
s[10] = keccak_round_constants[0];
|
||||
|
||||
t[ 4] = c_message48[1]^s[ 9];
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[ 0] = t[4] ^ c_mid[ 0];
|
||||
u[ 1] = c_mid[ 1] ^ ROL2(t[4],1);
|
||||
u[ 2] = c_mid[ 2];
|
||||
/* thetarho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
s[ 7] = ROL2(s[10]^u[0], 3);
|
||||
s[10] = c_mid[ 3];
|
||||
w = c_mid[ 4];
|
||||
s[20] = c_mid[ 5];
|
||||
s[ 6] = ROL2(s[ 9]^u[2],20);
|
||||
s[ 9] = c_mid[ 6];
|
||||
s[22] = c_mid[ 7];
|
||||
s[14] = ROL2(u[0],18);
|
||||
s[ 2] = c_mid[ 8];
|
||||
s[12] = ROL2(u[1],25);
|
||||
s[13] = c_mid[ 9];
|
||||
s[19] = ROR8(u[1]);
|
||||
s[23] = ROR2(u[0],23);
|
||||
s[15] = c_mid[10];
|
||||
s[ 4] = c_mid[11];
|
||||
s[24] = c_mid[12];
|
||||
s[21] = ROR2(c_message48[2]^u[1], 9);
|
||||
s[ 8] = c_mid[13];
|
||||
s[16] = ROR2(c_message48[3]^u[0],28);
|
||||
s[ 5] = ROL2(c_message48[4]^u[1],28);
|
||||
s[ 3] = ROL2(u[1],21);
|
||||
s[18] = c_mid[14];
|
||||
s[17] = c_mid[15];
|
||||
s[11] = c_mid[16];
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = c_message48[5]^u[0];
|
||||
s[ 0] = chi(v,w,s[ 2]);
|
||||
s[ 1] = chi(w,s[ 2],s[ 3]);
|
||||
s[ 2] = chi(s[ 2],s[ 3],s[ 4]);
|
||||
s[ 3] = chi(s[ 3],s[ 4],v);
|
||||
s[ 4] = chi(s[ 4],v,w);
|
||||
v = s[ 5]; w = s[ 6]; s[ 5] = chi(v,w,s[ 7]); s[ 6] = chi(w,s[ 7],s[ 8]); s[ 7] = chi(s[ 7],s[ 8],s[ 9]); s[ 8] = chi(s[ 8],s[ 9],v);s[ 9] = chi(s[ 9],v,w);
|
||||
v = s[10]; w = s[11]; s[10] = chi(v,w,s[12]); s[11] = chi(w,s[12],s[13]); s[12] = chi(s[12],s[13],s[14]); s[13] = chi(s[13],s[14],v);s[14] = chi(s[14],v,w);
|
||||
v = s[15]; w = s[16]; s[15] = chi(v,w,s[17]); s[16] = chi(w,s[17],s[18]); s[17] = chi(s[17],s[18],s[19]); s[18] = chi(s[18],s[19],v);s[19] = chi(s[19],v,w);
|
||||
v = s[20]; w = s[21]; s[20] = chi(v,w,s[22]); s[21] = chi(w,s[22],s[23]); s[22] = chi(s[22],s[23],s[24]); s[23] = chi(s[23],s[24],v);s[24] = chi(s[24],v,w);
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ 0];
|
||||
|
||||
#if __CUDA_ARCH__ > 500
|
||||
#pragma unroll 22
|
||||
#else
|
||||
#pragma unroll 4
|
||||
#endif
|
||||
for (int i = 1; i < 23; i++) {
|
||||
#pragma unroll
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = vectorize(xor5(devectorize(s[ j]),devectorize(s[j+5]),devectorize(s[j+10]),devectorize(s[j+15]),devectorize(s[j+20])));
|
||||
}
|
||||
/*theta*/
|
||||
#pragma unroll
|
||||
for(int j=0;j<5;j++) {
|
||||
u[j] = ROL2(t[j], 1);
|
||||
}
|
||||
s[ 4] = xor3x(s[ 4], t[3], u[0]);s[ 9] = xor3x(s[ 9], t[3], u[0]);s[14] = xor3x(s[14], t[3], u[0]);s[19] = xor3x(s[19], t[3], u[0]);s[24] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);s[ 5] = xor3x(s[ 5], t[4], u[1]);s[10] = xor3x(s[10], t[4], u[1]);s[15] = xor3x(s[15], t[4], u[1]);s[20] = xor3x(s[20], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 1], t[0], u[2]);s[ 6] = xor3x(s[ 6], t[0], u[2]);s[11] = xor3x(s[11], t[0], u[2]);s[16] = xor3x(s[16], t[0], u[2]);s[21] = xor3x(s[21], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[ 2], t[1], u[3]);s[ 7] = xor3x(s[ 7], t[1], u[3]);s[12] = xor3x(s[12], t[1], u[3]);s[17] = xor3x(s[17], t[1], u[3]);s[22] = xor3x(s[22], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[ 3], t[2], u[4]);s[ 8] = xor3x(s[ 8], t[2], u[4]);s[13] = xor3x(s[13], t[2], u[4]);s[18] = xor3x(s[18], t[2], u[4]);s[23] = xor3x(s[23], t[2], u[4]);
|
||||
/*rho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
v = s[ 1];
|
||||
s[ 1] = ROL2(s[ 6],44); s[ 6] = ROL2(s[ 9],20); s[ 9] = ROL2(s[22],61); s[22] = ROL2(s[14],39);
|
||||
s[14] = ROL2(s[20],18); s[20] = ROL2(s[ 2],62); s[ 2] = ROL2(s[12],43); s[12] = ROL2(s[13],25);
|
||||
s[13] = ROL8(s[19]); s[19] = ROR8(s[23]); s[23] = ROL2(s[15],41); s[15] = ROL2(s[ 4],27);
|
||||
s[ 4] = ROL2(s[24],14); s[24] = ROL2(s[21], 2); s[21] = ROL2(s[ 8],55); s[ 8] = ROL2(s[16],45);
|
||||
s[16] = ROL2(s[ 5],36); s[ 5] = ROL2(s[ 3],28); s[ 3] = ROL2(s[18],21); s[18] = ROL2(s[17],15);
|
||||
s[17] = ROL2(s[11],10); s[11] = ROL2(s[ 7], 6); s[ 7] = ROL2(s[10], 3); s[10] = ROL2(v, 1);
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
#pragma unroll
|
||||
for(int j=0;j<25;j+=5) {
|
||||
v=s[j];w=s[j + 1];s[j] = chi(s[j],s[j+1],s[j+2]);s[j+1] = chi(s[j+1],s[j+2],s[j+3]);s[j+2]=chi(s[j+2],s[j+3],s[j+4]);s[j+3]=chi(s[j+3],s[j+4],v);s[j+4]=chi(s[j+4],v,w);
|
||||
}
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ i];
|
||||
}
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = xor3x(xor3x(s[j+0],s[j+5],s[j+10]), s[j+15], s[j+20]);
|
||||
}
|
||||
s[24] = xor3x(s[24],t[3],ROL2(t[0],1));
|
||||
s[18] = xor3x(s[18],t[2],ROL2(t[4],1));
|
||||
s[ 0] = xor3x(s[ 0],t[4],ROL2(t[1],1));
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
s[24] = ROL2(s[24],14);
|
||||
s[18] = ROL2(s[18],21);
|
||||
if (devectorize(chi(s[18],s[24],s[ 0])) <= devectorize(highTarget)) {
|
||||
// if(chi(s[18].x,s[24].x,s[0].x)<=highTarget.x) {
|
||||
// if(chi(s[18].y,s[24].y,s[0].y)<=highTarget.y) {
|
||||
const uint32_t tmp = atomicExch(&resNounce[0], nounce);
|
||||
if (tmp != UINT32_MAX)
|
||||
resNounce[1] = tmp;
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, const uint2 highTarget)
|
||||
{
|
||||
uint32_t tpb;
|
||||
dim3 grid;
|
||||
if (device_sm[device_map[thr_id]] <= 500) {
|
||||
tpb = TPB50;
|
||||
grid.x = (threads + tpb-1)/tpb;
|
||||
} else {
|
||||
tpb = TPB52;
|
||||
grid.x = (threads + (NPT*tpb)-1)/(NPT*tpb);
|
||||
}
|
||||
const dim3 block(tpb);
|
||||
|
||||
keccak256_gpu_hash_80<<<grid, block>>>(threads, startNonce, d_nonces[thr_id], highTarget);
|
||||
// cudaThreadSynchronize();
|
||||
cudaMemcpy(h_nonces[thr_id], d_nonces[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
memcpy(resNonces, h_nonces[thr_id], NBN*sizeof(uint32_t));
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if __CUDA_ARCH__ <= 500
|
||||
__global__ __launch_bounds__(TPB50, 2)
|
||||
#else
|
||||
__global__ __launch_bounds__(TPB52, 1)
|
||||
#endif
|
||||
void keccak256_gpu_hash_32(uint32_t threads, uint2* outputHash)
|
||||
{
|
||||
uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
uint2 s[25], t[5], v, w, u[5];
|
||||
|
||||
if(thread < threads) {
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4) s[i] = __ldg(&outputHash[i*threads+thread]);
|
||||
else s[i] = make_uint2(0, 0);
|
||||
}
|
||||
s[4] = keccak_round_constants[ 0];
|
||||
s[16] = make_uint2(0, 0x80000000);
|
||||
#if __CUDA_ARCH__ > 500
|
||||
#pragma unroll
|
||||
#else
|
||||
#pragma unroll 4
|
||||
#endif
|
||||
for (uint32_t i = 0; i < 23; i++) {
|
||||
/*theta*/
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<5; j++) {
|
||||
t[ j] = vectorize(xor5(devectorize(s[ j]),devectorize(s[j+5]),devectorize(s[j+10]),devectorize(s[j+15]),devectorize(s[j+20])));
|
||||
}
|
||||
/*theta*/
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<5; j++) {
|
||||
u[j] = ROL2(t[j], 1);
|
||||
}
|
||||
s[ 4] = xor3x(s[ 4], t[3], u[0]);s[ 9] = xor3x(s[ 9], t[3], u[0]);s[14] = xor3x(s[14], t[3], u[0]);s[19] = xor3x(s[19], t[3], u[0]);s[24] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);s[ 5] = xor3x(s[ 5], t[4], u[1]);s[10] = xor3x(s[10], t[4], u[1]);s[15] = xor3x(s[15], t[4], u[1]);s[20] = xor3x(s[20], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 1], t[0], u[2]);s[ 6] = xor3x(s[ 6], t[0], u[2]);s[11] = xor3x(s[11], t[0], u[2]);s[16] = xor3x(s[16], t[0], u[2]);s[21] = xor3x(s[21], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[ 2], t[1], u[3]);s[ 7] = xor3x(s[ 7], t[1], u[3]);s[12] = xor3x(s[12], t[1], u[3]);s[17] = xor3x(s[17], t[1], u[3]);s[22] = xor3x(s[22], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[ 3], t[2], u[4]);s[ 8] = xor3x(s[ 8], t[2], u[4]);s[13] = xor3x(s[13], t[2], u[4]);s[18] = xor3x(s[18], t[2], u[4]);s[23] = xor3x(s[23], t[2], u[4]);
|
||||
/*rho pi: b[..] = rotl(a[..] ^ d[...], ..)*/
|
||||
v = s[ 1];
|
||||
s[ 1] = ROL2(s[ 6],44); s[ 6] = ROL2(s[ 9],20); s[ 9] = ROL2(s[22],61); s[22] = ROL2(s[14],39);
|
||||
s[14] = ROL2(s[20],18); s[20] = ROL2(s[ 2],62); s[ 2] = ROL2(s[12],43); s[12] = ROL2(s[13],25);
|
||||
s[13] = ROL8(s[19]); s[19] = ROR8(s[23]); s[23] = ROL2(s[15],41); s[15] = ROL2(s[ 4],27);
|
||||
s[ 4] = ROL2(s[24],14); s[24] = ROL2(s[21], 2); s[21] = ROL2(s[ 8],55); s[ 8] = ROL2(s[16],45);
|
||||
s[16] = ROL2(s[ 5],36); s[ 5] = ROL2(s[ 3],28); s[ 3] = ROL2(s[18],21); s[18] = ROL2(s[17],15);
|
||||
s[17] = ROL2(s[11],10); s[11] = ROL2(s[ 7], 6); s[ 7] = ROL2(s[10], 3); s[10] = ROL2(v, 1);
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
#pragma unroll 5
|
||||
for(int j=0; j<25; j+=5) {
|
||||
v=s[j];w=s[j + 1]; s[j] = chi(v,w,s[j+2]); s[j+1] = chi(w,s[j+2],s[j+3]); s[j+2]=chi(s[j+2],s[j+3],s[j+4]); s[j+3]=chi(s[j+3],s[j+4],v); s[j+4]=chi(s[j+4],v,w);
|
||||
}
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[ 0] ^=keccak_round_constants[ i];
|
||||
}
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
t[ j] = xor3x(xor3x(s[j+0],s[j+5],s[j+10]), s[j+15], s[j+20]);
|
||||
}
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
#pragma unroll 5
|
||||
for(int j=0;j<5;j++) {
|
||||
u[j] = ROL2(t[j],1);
|
||||
}
|
||||
/* thetarho pi: b[..] = rotl(a[..] ^ d[...], ..) //There's no need to perform theta and -store- the result since it's unique for each a[..]*/
|
||||
s[ 4] = xor3x(s[24], t[3], u[0]);
|
||||
s[ 0] = xor3x(s[ 0], t[4], u[1]);
|
||||
s[ 1] = xor3x(s[ 6], t[0], u[2]);
|
||||
s[ 2] = xor3x(s[12], t[1], u[3]);
|
||||
s[ 3] = xor3x(s[18], t[2], u[4]);
|
||||
s[ 1] = ROR2(s[ 1],20);
|
||||
s[ 2] = ROR2(s[ 2],21);
|
||||
s[ 3] = ROL2(s[ 3],21);
|
||||
s[ 4] = ROL2(s[ 4],14);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
outputHash[0*threads+thread] = chi(s[ 0],s[ 1],s[ 2]) ^ keccak_round_constants[23];
|
||||
outputHash[1*threads+thread] = chi(s[ 1],s[ 2],s[ 3]);
|
||||
outputHash[2*threads+thread] = chi(s[ 2],s[ 3],s[ 4]);
|
||||
outputHash[3*threads+thread] = chi(s[ 3],s[ 4],s[ 0]);
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_hash_32(const int thr_id,const uint32_t threads, uint2* d_hash)
|
||||
{
|
||||
uint32_t tpb = TPB52;
|
||||
if (device_sm[device_map[thr_id]] == 500) tpb = TPB50;
|
||||
const dim3 grid((threads + tpb-1)/tpb);
|
||||
const dim3 block(tpb);
|
||||
|
||||
keccak256_gpu_hash_32 <<<grid, block>>> (threads, d_hash);
|
||||
}
|
||||
#endif
|
||||
|
||||
__host__
|
||||
void keccak256_setBlock_80(uint64_t *endiandata)
|
||||
{
|
||||
uint64_t midstate[17], s[25];
|
||||
uint64_t t[5], u[5];
|
||||
|
||||
s[10] = 1; //(uint64_t)make_uint2(1, 0);
|
||||
s[16] = ((uint64_t)1)<<63; //(uint64_t)make_uint2(0, 0x80000000);
|
||||
|
||||
t[0] = endiandata[0] ^ endiandata[5] ^ s[10];
|
||||
t[1] = endiandata[1] ^ endiandata[6] ^ s[16];
|
||||
t[2] = endiandata[2] ^ endiandata[7];
|
||||
t[3] = endiandata[3] ^ endiandata[8];
|
||||
|
||||
midstate[ 0] = ROTL64(t[1], 1); //u[0] -partial
|
||||
u[1] = t[ 0] ^ ROTL64(t[2], 1); //u[1]
|
||||
u[2] = t[ 1] ^ ROTL64(t[3], 1); //u[2]
|
||||
midstate[ 1] = t[ 2]; //u[3] -partial
|
||||
midstate[ 2] = t[ 3] ^ ROTL64(t[0], 1); //u[4]
|
||||
midstate[ 3] = ROTL64(endiandata[1]^u[1], 1); //v
|
||||
midstate[ 4] = ROTL64(endiandata[6]^u[1], 44);
|
||||
midstate[ 5] = ROTL64(endiandata[2]^u[2], 62);
|
||||
midstate[ 6] = ROTL64(u[2], 61);
|
||||
midstate[ 7] = ROTL64(midstate[2], 39);
|
||||
midstate[ 8] = ROTL64(u[2], 43);
|
||||
midstate[ 9] = ROTL64(midstate[2], 8);
|
||||
midstate[10] = ROTL64(endiandata[4]^midstate[ 2],27);
|
||||
midstate[11] = ROTL64(midstate[2], 14);
|
||||
midstate[12] = ROTL64(u[1], 2);
|
||||
midstate[13] = ROTL64(s[16] ^ u[1], 45);
|
||||
midstate[14] = ROTL64(u[2],15);
|
||||
midstate[15] = ROTL64(u[1],10);
|
||||
midstate[16] = ROTL64(endiandata[7]^u[2], 6);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_mid, midstate,17*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
|
||||
// pass only what's needed
|
||||
uint64_t message48[6];
|
||||
message48[0] = endiandata[9];
|
||||
message48[1] = endiandata[4];
|
||||
message48[2] = endiandata[8];
|
||||
message48[3] = endiandata[5];
|
||||
message48[4] = endiandata[3];
|
||||
message48[5] = endiandata[0];
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_message48, message48, 6*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_init(int thr_id)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_nonces[thr_id], NBN*sizeof(uint32_t)));
|
||||
//CUDA_SAFE_CALL(cudaMallocHost(&h_nonces[thr_id], NBN*sizeof(uint32_t)));
|
||||
h_nonces[thr_id] = (uint32_t*) malloc(NBN * sizeof(uint32_t));
|
||||
if(h_nonces[thr_id] == NULL) {
|
||||
gpulog(LOG_ERR,thr_id,"Host memory allocation failed");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_setOutput(int thr_id)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemset(d_nonces[thr_id], 0xff, NBN*sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_nonces[thr_id]);
|
||||
//cudaFreeHost(h_nonces[thr_id]);
|
||||
free(h_nonces[thr_id]);
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
static const uint64_t host_keccak_round_constants[24] = {
|
||||
0x0000000000000001ull, 0x0000000000008082ull,
|
||||
0x800000000000808aull, 0x8000000080008000ull,
|
||||
0x000000000000808bull, 0x0000000080000001ull,
|
||||
0x8000000080008081ull, 0x8000000000008009ull,
|
||||
0x000000000000008aull, 0x0000000000000088ull,
|
||||
0x0000000080008009ull, 0x000000008000000aull,
|
||||
0x000000008000808bull, 0x800000000000008bull,
|
||||
0x8000000000008089ull, 0x8000000000008003ull,
|
||||
0x8000000000008002ull, 0x8000000000000080ull,
|
||||
0x000000000000800aull, 0x800000008000000aull,
|
||||
0x8000000080008081ull, 0x8000000000008080ull,
|
||||
0x0000000080000001ull, 0x8000000080008008ull
|
||||
};
|
||||
|
||||
static uint32_t *d_KNonce[MAX_GPUS];
|
||||
|
||||
__constant__ uint32_t pTarget[8];
|
||||
__constant__ uint64_t keccak_round_constants[24];
|
||||
__constant__ uint64_t c_PaddedMessage80[10]; // padded message (80 bytes + padding?)
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
__device__ __forceinline__
|
||||
static void keccak_blockv35(uint2 *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
size_t i;
|
||||
uint2 t[5], u[5], v, w;
|
||||
|
||||
#pragma unroll
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[0] = t[4] ^ ROL2(t[1], 1);
|
||||
u[1] = t[0] ^ ROL2(t[2], 1);
|
||||
u[2] = t[1] ^ ROL2(t[3], 1);
|
||||
u[3] = t[2] ^ ROL2(t[4], 1);
|
||||
u[4] = t[3] ^ ROL2(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[1];
|
||||
s[1] = ROL2(s[6], 44);
|
||||
s[6] = ROL2(s[9], 20);
|
||||
s[9] = ROL2(s[22], 61);
|
||||
s[22] = ROL2(s[14], 39);
|
||||
s[14] = ROL2(s[20], 18);
|
||||
s[20] = ROL2(s[2], 62);
|
||||
s[2] = ROL2(s[12], 43);
|
||||
s[12] = ROL2(s[13], 25);
|
||||
s[13] = ROL2(s[19], 8);
|
||||
s[19] = ROL2(s[23], 56);
|
||||
s[23] = ROL2(s[15], 41);
|
||||
s[15] = ROL2(s[4], 27);
|
||||
s[4] = ROL2(s[24], 14);
|
||||
s[24] = ROL2(s[21], 2);
|
||||
s[21] = ROL2(s[8], 55);
|
||||
s[8] = ROL2(s[16], 45);
|
||||
s[16] = ROL2(s[5], 36);
|
||||
s[5] = ROL2(s[3], 28);
|
||||
s[3] = ROL2(s[18], 21);
|
||||
s[18] = ROL2(s[17], 15);
|
||||
s[17] = ROL2(s[11], 10);
|
||||
s[11] = ROL2(s[7], 6);
|
||||
s[7] = ROL2(s[10], 3);
|
||||
s[10] = ROL2(v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = s[0]; w = s[1]; s[0] ^= (~w) & s[2]; s[1] ^= (~s[2]) & s[3]; s[2] ^= (~s[3]) & s[4]; s[3] ^= (~s[4]) & v; s[4] ^= (~v) & w;
|
||||
v = s[5]; w = s[6]; s[5] ^= (~w) & s[7]; s[6] ^= (~s[7]) & s[8]; s[7] ^= (~s[8]) & s[9]; s[8] ^= (~s[9]) & v; s[9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[0] ^= vectorize(keccak_round_constants[i]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
__device__ __forceinline__
|
||||
static void keccak_blockv30(uint64_t *s, const uint64_t *keccak_round_constants)
|
||||
{
|
||||
size_t i;
|
||||
uint64_t t[5], u[5], v, w;
|
||||
|
||||
/* absorb input */
|
||||
|
||||
for (i = 0; i < 24; i++) {
|
||||
/* theta: c = a[0,i] ^ a[1,i] ^ .. a[4,i] */
|
||||
t[0] = s[0] ^ s[5] ^ s[10] ^ s[15] ^ s[20];
|
||||
t[1] = s[1] ^ s[6] ^ s[11] ^ s[16] ^ s[21];
|
||||
t[2] = s[2] ^ s[7] ^ s[12] ^ s[17] ^ s[22];
|
||||
t[3] = s[3] ^ s[8] ^ s[13] ^ s[18] ^ s[23];
|
||||
t[4] = s[4] ^ s[9] ^ s[14] ^ s[19] ^ s[24];
|
||||
|
||||
/* theta: d[i] = c[i+4] ^ rotl(c[i+1],1) */
|
||||
u[0] = t[4] ^ ROTL64(t[1], 1);
|
||||
u[1] = t[0] ^ ROTL64(t[2], 1);
|
||||
u[2] = t[1] ^ ROTL64(t[3], 1);
|
||||
u[3] = t[2] ^ ROTL64(t[4], 1);
|
||||
u[4] = t[3] ^ ROTL64(t[0], 1);
|
||||
|
||||
/* theta: a[0,i], a[1,i], .. a[4,i] ^= d[i] */
|
||||
s[0] ^= u[0]; s[5] ^= u[0]; s[10] ^= u[0]; s[15] ^= u[0]; s[20] ^= u[0];
|
||||
s[1] ^= u[1]; s[6] ^= u[1]; s[11] ^= u[1]; s[16] ^= u[1]; s[21] ^= u[1];
|
||||
s[2] ^= u[2]; s[7] ^= u[2]; s[12] ^= u[2]; s[17] ^= u[2]; s[22] ^= u[2];
|
||||
s[3] ^= u[3]; s[8] ^= u[3]; s[13] ^= u[3]; s[18] ^= u[3]; s[23] ^= u[3];
|
||||
s[4] ^= u[4]; s[9] ^= u[4]; s[14] ^= u[4]; s[19] ^= u[4]; s[24] ^= u[4];
|
||||
|
||||
/* rho pi: b[..] = rotl(a[..], ..) */
|
||||
v = s[ 1];
|
||||
s[ 1] = ROTL64(s[ 6], 44);
|
||||
s[ 6] = ROTL64(s[ 9], 20);
|
||||
s[ 9] = ROTL64(s[22], 61);
|
||||
s[22] = ROTL64(s[14], 39);
|
||||
s[14] = ROTL64(s[20], 18);
|
||||
s[20] = ROTL64(s[ 2], 62);
|
||||
s[ 2] = ROTL64(s[12], 43);
|
||||
s[12] = ROTL64(s[13], 25);
|
||||
s[13] = ROTL64(s[19], 8);
|
||||
s[19] = ROTL64(s[23], 56);
|
||||
s[23] = ROTL64(s[15], 41);
|
||||
s[15] = ROTL64(s[ 4], 27);
|
||||
s[ 4] = ROTL64(s[24], 14);
|
||||
s[24] = ROTL64(s[21], 2);
|
||||
s[21] = ROTL64(s[ 8], 55);
|
||||
s[ 8] = ROTL64(s[16], 45);
|
||||
s[16] = ROTL64(s[ 5], 36);
|
||||
s[ 5] = ROTL64(s[ 3], 28);
|
||||
s[ 3] = ROTL64(s[18], 21);
|
||||
s[18] = ROTL64(s[17], 15);
|
||||
s[17] = ROTL64(s[11], 10);
|
||||
s[11] = ROTL64(s[ 7], 6);
|
||||
s[ 7] = ROTL64(s[10], 3);
|
||||
s[10] = ROTL64( v, 1);
|
||||
|
||||
/* chi: a[i,j] ^= ~b[i,j+1] & b[i,j+2] */
|
||||
v = s[ 0]; w = s[ 1]; s[ 0] ^= (~w) & s[ 2]; s[ 1] ^= (~s[ 2]) & s[ 3]; s[ 2] ^= (~s[ 3]) & s[ 4]; s[ 3] ^= (~s[ 4]) & v; s[ 4] ^= (~v) & w;
|
||||
v = s[ 5]; w = s[ 6]; s[ 5] ^= (~w) & s[ 7]; s[ 6] ^= (~s[ 7]) & s[ 8]; s[ 7] ^= (~s[ 8]) & s[ 9]; s[ 8] ^= (~s[ 9]) & v; s[ 9] ^= (~v) & w;
|
||||
v = s[10]; w = s[11]; s[10] ^= (~w) & s[12]; s[11] ^= (~s[12]) & s[13]; s[12] ^= (~s[13]) & s[14]; s[13] ^= (~s[14]) & v; s[14] ^= (~v) & w;
|
||||
v = s[15]; w = s[16]; s[15] ^= (~w) & s[17]; s[16] ^= (~s[17]) & s[18]; s[17] ^= (~s[18]) & s[19]; s[18] ^= (~s[19]) & v; s[19] ^= (~v) & w;
|
||||
v = s[20]; w = s[21]; s[20] ^= (~w) & s[22]; s[21] ^= (~s[22]) & s[23]; s[22] ^= (~s[23]) & s[24]; s[23] ^= (~s[24]) & v; s[24] ^= (~v) & w;
|
||||
|
||||
/* iota: a[0,0] ^= round constant */
|
||||
s[0] ^= keccak_round_constants[i];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
__global__ __launch_bounds__(128,5)
|
||||
void keccak256_sm3_gpu_hash_80(uint32_t threads, uint32_t startNounce, uint32_t *resNounce)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t nounce = startNounce + thread;
|
||||
|
||||
#if __CUDA_ARCH__ >= 350
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = vectorize(c_PaddedMessage80[i]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
|
||||
keccak_gpu_state[9]= vectorize(c_PaddedMessage80[9]);
|
||||
keccak_gpu_state[9].y = cuda_swab32(nounce);
|
||||
keccak_gpu_state[10] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
|
||||
keccak_blockv35(keccak_gpu_state,keccak_round_constants);
|
||||
if (devectorize(keccak_gpu_state[3]) <= ((uint64_t*)pTarget)[3]) {resNounce[0] = nounce;}
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i=0; i<25; i++) {
|
||||
if (i<9) keccak_gpu_state[i] = c_PaddedMessage80[i];
|
||||
else keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[9] = REPLACE_HIDWORD(c_PaddedMessage80[9], cuda_swab32(nounce));
|
||||
keccak_gpu_state[10] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
if (keccak_gpu_state[3] <= ((uint64_t*)pTarget)[3]) { resNounce[0] = nounce; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *resNonces, int order)
|
||||
{
|
||||
cudaMemset(d_KNonce[thr_id], 0xff, 2*sizeof(uint32_t));
|
||||
const uint32_t threadsperblock = 128;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
size_t shared_size = 0;
|
||||
|
||||
keccak256_sm3_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNounce, d_KNonce[thr_id]);
|
||||
|
||||
cudaMemcpy(resNonces, d_KNonce[thr_id], 2*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
cudaThreadSynchronize();
|
||||
}
|
||||
|
||||
#if 0
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void keccak256_sm3_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
#if __CUDA_ARCH__ >= 350 /* tpr: to double check if faster on SM5+ */
|
||||
uint2 keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4) keccak_gpu_state[i] = vectorize(outputHash[i*threads+thread]);
|
||||
else keccak_gpu_state[i] = make_uint2(0, 0);
|
||||
}
|
||||
keccak_gpu_state[4] = make_uint2(1, 0);
|
||||
keccak_gpu_state[16] = make_uint2(0, 0x80000000);
|
||||
keccak_blockv35(keccak_gpu_state, keccak_round_constants);
|
||||
|
||||
#pragma unroll 4
|
||||
for (int i=0; i<4; i++)
|
||||
outputHash[i*threads+thread] = devectorize(keccak_gpu_state[i]);
|
||||
#else
|
||||
uint64_t keccak_gpu_state[25];
|
||||
#pragma unroll 25
|
||||
for (int i = 0; i<25; i++) {
|
||||
if (i<4)
|
||||
keccak_gpu_state[i] = outputHash[i*threads+thread];
|
||||
else
|
||||
keccak_gpu_state[i] = 0;
|
||||
}
|
||||
keccak_gpu_state[4] = 0x0000000000000001;
|
||||
keccak_gpu_state[16] = 0x8000000000000000;
|
||||
|
||||
keccak_blockv30(keccak_gpu_state, keccak_round_constants);
|
||||
#pragma unroll 4
|
||||
for (int i = 0; i<4; i++)
|
||||
outputHash[i*threads + thread] = keccak_gpu_state[i];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
keccak256_sm3_gpu_hash_32 <<<grid, block>>> (threads, startNounce, d_outputHash);
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_setBlock_80(void *pdata,const void *pTargetIn)
|
||||
{
|
||||
unsigned char PaddedMessage[80];
|
||||
memcpy(PaddedMessage, pdata, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(pTarget, pTargetIn, 8*sizeof(uint32_t), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_PaddedMessage80, PaddedMessage, 10*sizeof(uint64_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(keccak_round_constants, host_keccak_round_constants,
|
||||
sizeof(host_keccak_round_constants), 0, cudaMemcpyHostToDevice));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_KNonce[thr_id], 2*sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
__host__
|
||||
void keccak256_sm3_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_KNonce[thr_id]);
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
#include <memory.h>
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round512v35(uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7,
|
||||
const int ROT0, const int ROT1, const int ROT2, const int ROT3)
|
||||
{
|
||||
p0 += p1; p1 = ROL2(p1, ROT0) ^ p0;
|
||||
p2 += p3; p3 = ROL2(p3, ROT1) ^ p2;
|
||||
p4 += p5; p5 = ROL2(p5, ROT2) ^ p4;
|
||||
p6 += p7; p7 = ROL2(p7, ROT3) ^ p6;
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Round_8_512v35(const uint2 *const __restrict__ ks, const uint2 *const __restrict__ ts,
|
||||
uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7, int R)
|
||||
{
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[(R+0) % 9];
|
||||
p1 += ks[(R+1) % 9];
|
||||
p2 += ks[(R+2) % 9];
|
||||
p3 += ks[(R+3) % 9];
|
||||
p4 += ks[(R+4) % 9];
|
||||
p5 += ks[(R+5) % 9] + ts[(R+0) % 3];
|
||||
p6 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p7 += ks[(R+7) % 9] + make_uint2(R, 0);
|
||||
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[(R+1) % 9];
|
||||
p1 += ks[(R+2) % 9];
|
||||
p2 += ks[(R+3) % 9];
|
||||
p3 += ks[(R+4) % 9];
|
||||
p4 += ks[(R+5) % 9];
|
||||
p5 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p6 += ks[(R+7) % 9] + ts[(R+2) % 3];
|
||||
p7 += ks[(R+8) % 9] + make_uint2(R+1, 0);
|
||||
}
|
||||
|
||||
__forceinline__ __device__
|
||||
void Round_8_512v35_final(const uint2 *const __restrict__ ks, const uint2 *const __restrict__ ts,
|
||||
uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7)
|
||||
{
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[8];
|
||||
p1 += ks[0];
|
||||
p2 += ks[1];
|
||||
p3 += ks[2];
|
||||
p4 += ks[3];
|
||||
p5 += ks[4] + ts[2];
|
||||
p6 += ks[5] + ts[0];
|
||||
p7 += ks[6] + make_uint2(17, 0);
|
||||
|
||||
Round512v35(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[0];
|
||||
p1 += ks[1];
|
||||
p2 += ks[2];
|
||||
p3 += ks[3];
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(256,3)
|
||||
void skein256_gpu_hash_32(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint2 skein_ks_parity = { 0xA9FC1A22, 0x1BD11BDA };
|
||||
const uint2 t12[6] = {
|
||||
{ 0x20, 0 },
|
||||
{ 0, 0xf0000000 },
|
||||
{ 0x20, 0xf0000000 },
|
||||
{ 0x08, 0 },
|
||||
{ 0, 0xff000000 },
|
||||
{ 0x08, 0xff000000 }
|
||||
};
|
||||
|
||||
uint2 h[9] = {
|
||||
{ 0x2FDB3E13, 0xCCD044A1 },
|
||||
{ 0x1A79A9EB, 0xE8359030 },
|
||||
{ 0x4F816E6F, 0x55AEA061 },
|
||||
{ 0xAE9B94DB, 0x2A2767A4 },
|
||||
{ 0x74DD7683, 0xEC06025E },
|
||||
{ 0xC4746251, 0xE7A436CD },
|
||||
{ 0x393AD185, 0xC36FBAF9 },
|
||||
{ 0x33EDFC13, 0x3EEDBA18 },
|
||||
{ 0xC73A4E2A, 0xB69D3CFC }
|
||||
};
|
||||
uint2 dt0,dt1,dt2,dt3;
|
||||
uint2 p0, p1, p2, p3, p4, p5, p6, p7;
|
||||
|
||||
LOHI(dt0.x,dt0.y,outputHash[thread]);
|
||||
LOHI(dt1.x,dt1.y,outputHash[threads+thread]);
|
||||
LOHI(dt2.x,dt2.y,outputHash[2*threads+thread]);
|
||||
LOHI(dt3.x,dt3.y,outputHash[3*threads+thread]);
|
||||
|
||||
p0 = h[0] + dt0;
|
||||
p1 = h[1] + dt1;
|
||||
p2 = h[2] + dt2;
|
||||
p3 = h[3] + dt3;
|
||||
p4 = h[4];
|
||||
p5 = h[5] + t12[0];
|
||||
p6 = h[6] + t12[1];
|
||||
p7 = h[7];
|
||||
|
||||
// forced unroll required
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 1);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 3);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 5);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 7);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 9);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 11);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 13);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 15);
|
||||
Round_8_512v35(h, t12, p0, p1, p2, p3, p4, p5, p6, p7, 17);
|
||||
|
||||
p0 ^= dt0;
|
||||
p1 ^= dt1;
|
||||
p2 ^= dt2;
|
||||
p3 ^= dt3;
|
||||
|
||||
h[0] = p0;
|
||||
h[1] = p1;
|
||||
h[2] = p2;
|
||||
h[3] = p3;
|
||||
h[4] = p4;
|
||||
h[5] = p5;
|
||||
h[6] = p6;
|
||||
h[7] = p7;
|
||||
h[8] = skein_ks_parity ^ h[0] ^ h[1] ^ h[2] ^ h[3] ^ h[4] ^ h[5] ^ h[6] ^ h[7];
|
||||
|
||||
const uint2 *t = t12+3;
|
||||
p5 += t12[3]; //p5 already equal h[5]
|
||||
p6 += t12[4];
|
||||
|
||||
// forced unroll
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 1);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 3);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 5);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 7);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 9);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 11);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 13);
|
||||
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, 15);
|
||||
Round_8_512v35_final(h, t, p0, p1, p2, p3, p4, p5, p6, p7);
|
||||
|
||||
outputHash[thread] = devectorize(p0);
|
||||
outputHash[threads+thread] = devectorize(p1);
|
||||
outputHash[2*threads+thread] = devectorize(p2);
|
||||
outputHash[3*threads+thread] = devectorize(p3);
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round512v30(uint64_t &p0, uint64_t &p1, uint64_t &p2, uint64_t &p3,
|
||||
uint64_t &p4, uint64_t &p5, uint64_t &p6, uint64_t &p7,
|
||||
const int ROT0, const int ROT1, const int ROT2, const int ROT3)
|
||||
{
|
||||
p0 += p1; p1 = ROTL64(p1, ROT0) ^ p0;
|
||||
p2 += p3; p3 = ROTL64(p3, ROT1) ^ p2;
|
||||
p4 += p5; p5 = ROTL64(p5, ROT2) ^ p4;
|
||||
p6 += p7; p7 = ROTL64(p7, ROT3) ^ p6;
|
||||
}
|
||||
|
||||
static __forceinline__ __device__
|
||||
void Round_8_512v30(uint64_t *ks, uint64_t *ts,
|
||||
uint64_t &p0, uint64_t &p1, uint64_t &p2, uint64_t &p3,
|
||||
uint64_t &p4, uint64_t &p5, uint64_t &p6, uint64_t &p7, int R)
|
||||
{
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 46, 36, 19, 37);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 33, 27, 14, 42);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 17, 49, 36, 39);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 44, 9, 54, 56);
|
||||
|
||||
p0 += ks[(R+0) % 9];
|
||||
p1 += ks[(R+1) % 9];
|
||||
p2 += ks[(R+2) % 9];
|
||||
p3 += ks[(R+3) % 9];
|
||||
p4 += ks[(R+4) % 9];
|
||||
p5 += ks[(R+5) % 9] + ts[(R+0) % 3];
|
||||
p6 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p7 += ks[(R+7) % 9] + R;
|
||||
|
||||
Round512v30(p0, p1, p2, p3, p4, p5, p6, p7, 39, 30, 34, 24);
|
||||
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 13, 50, 10, 17);
|
||||
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 25, 29, 39, 43);
|
||||
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 8, 35, 56, 22);
|
||||
|
||||
p0 += ks[(R+1) % 9];
|
||||
p1 += ks[(R+2) % 9];
|
||||
p2 += ks[(R+3) % 9];
|
||||
p3 += ks[(R+4) % 9];
|
||||
p4 += ks[(R+5) % 9];
|
||||
p5 += ks[(R+6) % 9] + ts[(R+1) % 3];
|
||||
p6 += ks[(R+7) % 9] + ts[(R+2) % 3];
|
||||
p7 += ks[(R+8) % 9] + R+1;
|
||||
}
|
||||
|
||||
#define skein_ks_parity64 0x1BD11BDAA9FC1A22ull
|
||||
#include <stdio.h>
|
||||
__global__ __launch_bounds__(256, 3)
|
||||
void skein256_gpu_hash_32_v30(uint32_t threads, uint32_t startNounce, uint64_t *outputHash)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
uint64_t h[12] = { // SKEIN_IV512_256
|
||||
0xCCD044A12FDB3E13, 0xE83590301A79A9EB,
|
||||
0x55AEA0614F816E6F, 0x2A2767A4AE9B94DB,
|
||||
0xEC06025E74DD7683, 0xE7A436CDC4746251,
|
||||
0xC36FBAF9393AD185, 0x3EEDBA1833EDFC13,
|
||||
0xb69d3cfcc73a4e2a, // skein_ks_parity64 ^ h[0..7]
|
||||
0x20, 0xf000000000000000, 0xf000000000000020 // t0..2
|
||||
};
|
||||
uint64_t dt0 = outputHash[thread];
|
||||
uint64_t dt1 = outputHash[threads + thread];
|
||||
uint64_t dt2 = outputHash[threads*2 + thread];
|
||||
uint64_t dt3 = outputHash[threads*3 + thread];
|
||||
|
||||
uint64_t *t = &h[9];
|
||||
uint64_t p0 = h[0] + dt0;
|
||||
uint64_t p1 = h[1] + dt1;
|
||||
uint64_t p2 = h[2] + dt2;
|
||||
uint64_t p3 = h[3] + dt3;
|
||||
uint64_t p4 = h[4];
|
||||
uint64_t p5 = h[5] + t[0];
|
||||
uint64_t p6 = h[6] + t[1];
|
||||
uint64_t p7 = h[7];
|
||||
|
||||
#pragma unroll 9
|
||||
for (int i = 1; i<19; i += 2) {
|
||||
Round_8_512v30(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
|
||||
}
|
||||
|
||||
p0 ^= dt0;
|
||||
p1 ^= dt1;
|
||||
p2 ^= dt2;
|
||||
p3 ^= dt3;
|
||||
|
||||
h[0] = p0;
|
||||
h[1] = p1;
|
||||
h[2] = p2;
|
||||
h[3] = p3;
|
||||
h[4] = p4;
|
||||
h[5] = p5;
|
||||
h[6] = p6;
|
||||
h[7] = p7;
|
||||
h[8] = skein_ks_parity64;
|
||||
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i<8; i++) {
|
||||
h[8] ^= h[i];
|
||||
}
|
||||
|
||||
t[0] = 0x08;
|
||||
t[1] = 0xff00000000000000;
|
||||
t[2] = 0xff00000000000008;
|
||||
|
||||
p5 += t[0]; //p5 already equal h[5]
|
||||
p6 += t[1];
|
||||
|
||||
#pragma unroll 9
|
||||
for (int i = 1; i<19; i += 2) {
|
||||
Round_8_512v30(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
|
||||
}
|
||||
|
||||
outputHash[thread] = p0;
|
||||
outputHash[threads + thread] = p1;
|
||||
outputHash[threads*2 + thread] = p2;
|
||||
outputHash[threads*3 + thread] = p3;
|
||||
} //thread
|
||||
}
|
||||
|
||||
__host__
|
||||
void skein256_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cuda_get_arch(thr_id);
|
||||
}
|
||||
|
||||
__host__
|
||||
void skein256_cpu_hash_32(int thr_id, uint32_t threads, uint32_t startNounce, uint64_t *d_outputHash, int order)
|
||||
{
|
||||
const uint32_t threadsperblock = 256;
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
// only 1kH/s perf change between kernels on a 960...
|
||||
if (device_sm[dev_id] > 300 && cuda_arch[dev_id] > 300)
|
||||
skein256_gpu_hash_32<<<grid, block>>>(threads, startNounce, d_outputHash);
|
||||
else
|
||||
skein256_gpu_hash_32_v30<<<grid, block>>>(threads, startNounce, d_outputHash);
|
||||
|
||||
MyStreamSynchronize(NULL, order, thr_id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
* Blake-256 Decred 180-Bytes input Cuda Kernel
|
||||
*
|
||||
* Tanguy Pruvot, Alexis Provos - Feb/Sep 2016
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
#include <miner.h>
|
||||
|
||||
extern "C" {
|
||||
#include <sph/sph_blake.h>
|
||||
}
|
||||
|
||||
/* threads per block */
|
||||
#define TPB 640
|
||||
|
||||
/* max count of found nonces in one call (like sgminer) */
|
||||
#define MAX_RESULTS 4
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void decred_hash(void *output, const void *input)
|
||||
{
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(14);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 180);
|
||||
sph_blake256_close(&ctx, output);
|
||||
}
|
||||
|
||||
#include <cuda_helper.h>
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#define atomicInc(p, max) (*p)++
|
||||
#endif
|
||||
|
||||
__constant__ uint32_t _ALIGN(16) c_h[2];
|
||||
__constant__ uint32_t _ALIGN(16) c_data[32];
|
||||
__constant__ uint32_t _ALIGN(16) c_xors[215];
|
||||
|
||||
/* Buffers of candidate nonce(s) */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
|
||||
#define ROR8(a) __byte_perm(a, 0, 0x0321)
|
||||
#define ROL16(a) __byte_perm(a, 0, 0x1032)
|
||||
|
||||
/* macro bodies */
|
||||
#define pxorGS(a,b,c,d) { \
|
||||
v[a]+= c_xors[i++] + v[b]; \
|
||||
v[d] = ROL16(v[d] ^ v[a]); \
|
||||
v[c]+= v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a]+= c_xors[i++] + v[b]; \
|
||||
v[d] = ROR8(v[d] ^ v[a]); \
|
||||
v[c]+= v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
#define pxorGS2(a,b,c,d, a1,b1,c1,d1) {\
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxory1GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= (c_xors[i++]^nonce) + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxory0GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= (c_xors[i++]^nonce) + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxorx1GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= (c_xors[i++]^nonce) + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define pxorx0GS2(a,b,c,d, a1,b1,c1,d1) { \
|
||||
v[ a]+= (c_xors[i++]^nonce) + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROL16(v[ d] ^ v[ a]); v[d1] = ROL16(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[ a]+= c_xors[i++] + v[ b]; v[a1]+= c_xors[i++] + v[b1]; \
|
||||
v[ d] = ROR8(v[ d] ^ v[ a]); v[d1] = ROR8(v[d1] ^ v[a1]); \
|
||||
v[ c]+= v[ d]; v[c1]+= v[d1]; \
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void decred_gpu_hash_nonce(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce, const uint32_t highTarget)
|
||||
{
|
||||
const uint32_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
if (thread < threads)
|
||||
{
|
||||
uint32_t v[16];
|
||||
#pragma unroll
|
||||
for(int i=0; i<16; i+=4) {
|
||||
*(uint4*)&v[i] = *(uint4*)&c_data[i];
|
||||
}
|
||||
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
v[ 1]+= (nonce ^ 0x13198A2E);
|
||||
v[13] = ROR8(v[13] ^ v[1]);
|
||||
v[ 9]+= v[13];
|
||||
v[ 5] = ROTR32(v[5] ^ v[9], 7);
|
||||
|
||||
int i = 0;
|
||||
v[ 1]+= c_xors[i++];// + v[ 6];
|
||||
v[ 0]+= v[5];
|
||||
v[12] = ROL16(v[12] ^ v[ 1]); v[15] = ROL16(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12); v[ 5] = ROTR32(v[5] ^ v[10], 12);
|
||||
v[ 1]+= c_xors[i++] + v[ 6]; v[ 0]+= c_xors[i++] + v[ 5];
|
||||
v[12] = ROR8(v[12] ^ v[ 1]); v[15] = ROR8(v[15] ^ v[ 0]);
|
||||
v[11]+= v[12]; v[10]+= v[15];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7); v[ 5] = ROTR32(v[ 5] ^ v[10], 7);
|
||||
|
||||
pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxory1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorx1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorx1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorx1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxory1GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxory1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorx1GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxory0GS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorx0GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxory1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxory1GS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorGS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorx1GS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS2( 2, 7, 8, 13, 3, 4, 9, 14);
|
||||
pxorx1GS2( 0, 4, 8, 12, 1, 5, 9, 13); pxorGS2( 2, 6, 10, 14, 3, 7, 11, 15); pxorGS2( 0, 5, 10, 15, 1, 6, 11, 12); pxorGS( 2, 7, 8, 13);
|
||||
|
||||
if ((c_h[1]^v[15]) == v[7]) {
|
||||
v[ 3] += c_xors[i++] + v[4];
|
||||
v[14] = ROL16(v[14] ^ v[3]);
|
||||
v[ 9] += v[14];
|
||||
v[ 4] = ROTR32(v[4] ^ v[9], 12);
|
||||
v[ 3] += c_xors[i++] + v[4];
|
||||
v[14] = ROR8(v[14] ^ v[3]);
|
||||
if(cuda_swab32((c_h[0]^v[6]^v[14])) <= highTarget) {
|
||||
uint32_t pos = atomicInc(&resNonce[0], UINT32_MAX)+1;
|
||||
resNonce[pos] = nonce;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
void decred_cpu_setBlock_52(const uint32_t *input)
|
||||
{
|
||||
/*
|
||||
Precompute everything possible and pass it on constant memory
|
||||
*/
|
||||
const uint32_t z[16] = {
|
||||
0x243F6A88U, 0x85A308D3U, 0x13198A2EU, 0x03707344U,
|
||||
0xA4093822U, 0x299F31D0U, 0x082EFA98U, 0xEC4E6C89U,
|
||||
0x452821E6U, 0x38D01377U, 0xBE5466CFU, 0x34E90C6CU,
|
||||
0xC0AC29B7U, 0xC97C50DDU, 0x3F84D5B5U, 0xB5470917U
|
||||
};
|
||||
|
||||
int i=0;
|
||||
uint32_t _ALIGN(64) preXOR[215];
|
||||
uint32_t _ALIGN(64) data[16];
|
||||
uint32_t _ALIGN(64) m[16];
|
||||
uint32_t _ALIGN(64) h[ 2];
|
||||
|
||||
sph_blake256_context ctx;
|
||||
sph_blake256_set_rounds(14);
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 128);
|
||||
|
||||
data[ 0] = ctx.H[0];
|
||||
data[ 1] = ctx.H[1];
|
||||
data[ 2] = ctx.H[2];
|
||||
data[ 3] = ctx.H[3];
|
||||
data[ 4] = ctx.H[4];
|
||||
data[ 5] = ctx.H[5];
|
||||
data[ 8] = ctx.H[6];
|
||||
|
||||
data[12] = swab32(input[35]);
|
||||
data[13] = ctx.H[7];
|
||||
|
||||
// pre swab32
|
||||
m[ 0] = swab32(input[32]); m[ 1] = swab32(input[33]);
|
||||
m[ 2] = swab32(input[34]); m[ 3] = 0;
|
||||
m[ 4] = swab32(input[36]); m[ 5] = swab32(input[37]);
|
||||
m[ 6] = swab32(input[38]); m[ 7] = swab32(input[39]);
|
||||
m[ 8] = swab32(input[40]); m[ 9] = swab32(input[41]);
|
||||
m[10] = swab32(input[42]); m[11] = swab32(input[43]);
|
||||
m[12] = swab32(input[44]); m[13] = 0x80000001;
|
||||
m[14] = 0;
|
||||
m[15] = 0x000005a0;
|
||||
|
||||
h[ 0] = data[ 8];
|
||||
h[ 1] = data[13];
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_h,h, 8, 0, cudaMemcpyHostToDevice));
|
||||
|
||||
data[ 0]+= (m[ 0] ^ z[1]) + data[ 4];
|
||||
data[12] = SPH_ROTR32(z[4] ^ SPH_C32(0x5A0) ^ data[ 0], 16);
|
||||
|
||||
data[ 8] = z[0]+data[12];
|
||||
data[ 4] = SPH_ROTR32(data[ 4] ^ data[ 8], 12);
|
||||
data[ 0]+= (m[ 1] ^ z[0]) + data[ 4];
|
||||
data[12] = SPH_ROTR32(data[12] ^ data[ 0],8);
|
||||
data[ 8]+= data[12];
|
||||
data[ 4] = SPH_ROTR32(data[ 4] ^ data[ 8], 7);
|
||||
|
||||
data[ 1]+= (m[ 2] ^ z[3]) + data[ 5];
|
||||
data[13] = SPH_ROTR32((z[5] ^ SPH_C32(0x5A0)) ^ data[ 1], 16);
|
||||
data[ 9] = z[1]+data[13];
|
||||
data[ 5] = SPH_ROTR32(data[ 5] ^ data[ 9], 12);
|
||||
data[ 1]+= data[ 5]; //+nonce ^ ...
|
||||
|
||||
data[ 2]+= (m[ 4] ^ z[5]) + h[ 0];
|
||||
data[14] = SPH_ROTR32(z[6] ^ data[ 2],16);
|
||||
data[10] = z[2] + data[14];
|
||||
data[ 6] = SPH_ROTR32(h[ 0] ^ data[10], 12);
|
||||
data[ 2]+= (m[ 5] ^ z[4]) + data[ 6];
|
||||
data[14] = SPH_ROTR32(data[14] ^ data[ 2], 8);
|
||||
data[10]+= data[14];
|
||||
data[ 6] = SPH_ROTR32(data[ 6] ^ data[10], 7);
|
||||
|
||||
data[ 3]+= (m[ 6] ^ z[7]) + h[ 1];
|
||||
data[15] = SPH_ROTR32(z[7] ^ data[ 3],16);
|
||||
data[11] = z[3] + data[15];
|
||||
data[ 7] = SPH_ROTR32(h[ 1] ^ data[11], 12);
|
||||
data[ 3]+= (m[ 7] ^ z[6]) + data[ 7];
|
||||
data[15] = SPH_ROTR32(data[15] ^ data[ 3],8);
|
||||
data[11]+= data[15];
|
||||
data[ 7] = SPH_ROTR32(data[11] ^ data[ 7], 7);
|
||||
data[ 0]+= m[ 8] ^ z[9];
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_data, data, 64, 0, cudaMemcpyHostToDevice));
|
||||
|
||||
#define precalcXORGS(x,y) { \
|
||||
preXOR[i++]= (m[x] ^ z[y]); \
|
||||
preXOR[i++]= (m[y] ^ z[x]); \
|
||||
}
|
||||
#define precalcXORGS2(x,y,x1,y1){\
|
||||
preXOR[i++] = (m[ x] ^ z[ y]);\
|
||||
preXOR[i++] = (m[x1] ^ z[y1]);\
|
||||
preXOR[i++] = (m[ y] ^ z[ x]);\
|
||||
preXOR[i++] = (m[y1] ^ z[x1]);\
|
||||
}
|
||||
precalcXORGS(10,11);
|
||||
preXOR[ 0]+=data[ 6];
|
||||
preXOR[i++] = (m[9] ^ z[8]);
|
||||
precalcXORGS2(12,13,14,15);
|
||||
precalcXORGS2(14,10, 4, 8);
|
||||
precalcXORGS2( 9,15,13, 6);
|
||||
precalcXORGS2( 1,12, 0, 2);
|
||||
precalcXORGS2(11, 7, 5, 3);
|
||||
precalcXORGS2(11, 8,12, 0);
|
||||
precalcXORGS2( 5, 2,15,13);
|
||||
precalcXORGS2(10,14, 3, 6);
|
||||
precalcXORGS2( 7, 1, 9, 4);
|
||||
precalcXORGS2( 7, 9, 3, 1);
|
||||
precalcXORGS2(13,12,11,14);
|
||||
precalcXORGS2( 2, 6, 5,10);
|
||||
precalcXORGS2( 4, 0,15, 8);
|
||||
precalcXORGS2( 9, 0, 5, 7);
|
||||
precalcXORGS2( 2, 4,10,15);
|
||||
precalcXORGS2(14, 1,11,12);
|
||||
precalcXORGS2( 6, 8, 3,13);
|
||||
precalcXORGS2( 2,12, 6,10);
|
||||
precalcXORGS2( 0,11, 8, 3);
|
||||
precalcXORGS2( 4,13, 7, 5);
|
||||
precalcXORGS2(15,14, 1, 9);
|
||||
precalcXORGS2(12, 5, 1,15);
|
||||
precalcXORGS2(14,13, 4,10);
|
||||
precalcXORGS2( 0, 7, 6, 3);
|
||||
precalcXORGS2( 9, 2, 8,11);
|
||||
precalcXORGS2(13,11, 7,14);
|
||||
precalcXORGS2(12, 1, 3, 9);
|
||||
precalcXORGS2( 5, 0,15, 4);
|
||||
precalcXORGS2( 8, 6, 2,10);
|
||||
precalcXORGS2( 6,15,14, 9);
|
||||
precalcXORGS2(11, 3, 0, 8);
|
||||
precalcXORGS2(12, 2,13, 7);
|
||||
precalcXORGS2( 1, 4,10, 5);
|
||||
precalcXORGS2(10, 2, 8, 4);
|
||||
precalcXORGS2( 7, 6, 1, 5);
|
||||
precalcXORGS2(15,11, 9,14);
|
||||
precalcXORGS2( 3,12,13, 0);
|
||||
precalcXORGS2( 0, 1, 2, 3);
|
||||
precalcXORGS2( 4, 5, 6, 7);
|
||||
precalcXORGS2( 8, 9,10,11);
|
||||
precalcXORGS2(12,13,14,15);
|
||||
precalcXORGS2(14,10, 4, 8);
|
||||
precalcXORGS2( 9,15,13, 6);
|
||||
precalcXORGS2( 1,12, 0, 2);
|
||||
precalcXORGS2(11, 7, 5, 3);
|
||||
precalcXORGS2(11, 8,12, 0);
|
||||
precalcXORGS2( 5, 2,15,13);
|
||||
precalcXORGS2(10,14, 3, 6);
|
||||
precalcXORGS2( 7, 1, 9, 4);
|
||||
precalcXORGS2( 7, 9, 3, 1);
|
||||
precalcXORGS2(13,12,11,14);
|
||||
precalcXORGS2( 2, 6, 5,10);
|
||||
precalcXORGS( 4, 0);
|
||||
precalcXORGS(15, 8);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_xors, preXOR, 215*sizeof(uint32_t), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
|
||||
/* ############################################################################################################################### */
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
// nonce position is different in decred
|
||||
#define DCR_NONCE_OFT32 35
|
||||
|
||||
extern "C" int scanhash_decred(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[48];
|
||||
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
uint32_t *pnonce = &pdata[DCR_NONCE_OFT32];
|
||||
|
||||
const uint32_t first_nonce = *pnonce;
|
||||
const uint32_t targetHigh = opt_benchmark ? 0x1ULL : ptarget[6];
|
||||
|
||||
const int dev_id = device_map[thr_id];
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 29 : 25;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
const dim3 grid((throughput + TPB-1)/(TPB));
|
||||
const dim3 block(TPB);
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], MAX_RESULTS*sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], MAX_RESULTS*sizeof(uint32_t)), -1);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
memcpy(endiandata, pdata, 180);
|
||||
|
||||
decred_cpu_setBlock_52(endiandata);
|
||||
cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
do {
|
||||
uint32_t* resNonces = h_resNonce[thr_id];
|
||||
|
||||
if (resNonces[0]) cudaMemset(d_resNonce[thr_id], 0x00, sizeof(uint32_t));
|
||||
|
||||
// GPU HASH
|
||||
decred_gpu_hash_nonce <<<grid, block>>> (throughput, (*pnonce), d_resNonce[thr_id], targetHigh);
|
||||
|
||||
*hashes_done = (*pnonce) - first_nonce + throughput;
|
||||
|
||||
// first cell contains the valid nonces count
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
if (resNonces[0])
|
||||
{
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
|
||||
cudaMemcpy(resNonces, d_resNonce[thr_id], (resNonces[0]+1)*sizeof(uint32_t), cudaMemcpyDeviceToHost);
|
||||
|
||||
be32enc(&endiandata[DCR_NONCE_OFT32], resNonces[1]);
|
||||
decred_hash(vhash, endiandata);
|
||||
if (vhash[6] <= ptarget[6] && fulltest(vhash, ptarget))
|
||||
{
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[0] = swab32(resNonces[1]);
|
||||
*pnonce = work->nonces[0];
|
||||
|
||||
// search for another nonce
|
||||
for(uint32_t n=2; n <= resNonces[0]; n++)
|
||||
{
|
||||
be32enc(&endiandata[DCR_NONCE_OFT32], resNonces[n]);
|
||||
decred_hash(vhash, endiandata);
|
||||
if (vhash[6] <= ptarget[6] && fulltest(vhash, ptarget)) {
|
||||
work->nonces[1] = swab32(resNonces[n]);
|
||||
if (bn_hash_target_ratio(vhash, ptarget) > work->shareratio[0]) {
|
||||
// we really want the best first ? depends...
|
||||
work->shareratio[1] = work->shareratio[0];
|
||||
work->sharediff[1] = work->sharediff[0];
|
||||
xchg(work->nonces[1], work->nonces[0]);
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->valid_nonces++;
|
||||
} else if (work->valid_nonces == 1) {
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
}
|
||||
work->valid_nonces = 2; // MAX_NONCES submit limited to 2
|
||||
|
||||
gpulog(LOG_DEBUG, thr_id, "multiple nonces 1:%08x (%g) %u:%08x (%g)",
|
||||
work->nonces[0], work->sharediff[0], n, work->nonces[1], work->sharediff[1]);
|
||||
|
||||
} else if (vhash[6] > ptarget[6]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result %u for %08x does not validate on CPU!", n, resNonces[n]);
|
||||
}
|
||||
}
|
||||
return work->valid_nonces;
|
||||
|
||||
} else if (vhash[6] > ptarget[6]) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", resNonces[1]);
|
||||
}
|
||||
}
|
||||
*pnonce += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart && max_nonce > (uint64_t)throughput + (*pnonce));
|
||||
|
||||
*hashes_done = (*pnonce) - first_nonce;
|
||||
MyStreamSynchronize(NULL, 0, device_map[thr_id]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_decred(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Keccak 256
|
||||
*
|
||||
*/
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "sph/sph_shavite.h"
|
||||
#include "sph/sph_simd.h"
|
||||
#include "sph/sph_keccak.h"
|
||||
|
||||
#include "miner.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
// SM5+ cuda
|
||||
extern void keccak256_cpu_init(int thr_id);
|
||||
extern void keccak256_cpu_free(int thr_id);
|
||||
extern void keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, const uint2 highTarget);
|
||||
extern void keccak256_setBlock_80(uint64_t *endiandata);
|
||||
extern void keccak256_setOutput(int thr_id);
|
||||
|
||||
// compat
|
||||
extern void keccak256_sm3_init(int thr_id, uint32_t threads);
|
||||
extern void keccak256_sm3_free(int thr_id);
|
||||
extern void keccak256_sm3_setBlock_80(void *pdata, const void *ptarget);
|
||||
extern void keccak256_sm3_hash_80(int thr_id, uint32_t threads, uint32_t startNonce, uint32_t* resNonces, int order);
|
||||
|
||||
// CPU Hash
|
||||
extern "C" void keccak256_hash(void *state, const void *input)
|
||||
{
|
||||
uint32_t _ALIGN(64) hash[16];
|
||||
sph_keccak_context ctx_keccak;
|
||||
|
||||
sph_keccak256_init(&ctx_keccak);
|
||||
sph_keccak256 (&ctx_keccak, input, 80);
|
||||
sph_keccak256_close(&ctx_keccak, (void*) hash);
|
||||
|
||||
memcpy(state, hash, 32);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
static bool use_compat_kernels[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_keccak256(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
const int dev_id = device_map[thr_id];
|
||||
uint32_t throughput;
|
||||
uint32_t intensity = 23;
|
||||
if(!use_compat_kernels[thr_id]) {
|
||||
if (strstr(device_name[dev_id], "GTX 1070")) intensity = 25;
|
||||
if (strstr(device_name[dev_id], "GTX 1080")) intensity = 26;
|
||||
}
|
||||
throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x000f;
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
use_compat_kernels[thr_id] = (cuda_arch[dev_id] < 500);
|
||||
|
||||
if(!use_compat_kernels[thr_id]) {
|
||||
keccak256_cpu_init(thr_id);
|
||||
} else {
|
||||
// really useful ?
|
||||
keccak256_sm3_init(thr_id, throughput);
|
||||
}
|
||||
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 19; k++) {
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
}
|
||||
|
||||
const uint2 highTarget = make_uint2(ptarget[6], ptarget[7]);
|
||||
if(use_compat_kernels[thr_id])
|
||||
keccak256_sm3_setBlock_80((void*)endiandata, ptarget);
|
||||
else {
|
||||
keccak256_setBlock_80((uint64_t*)endiandata);
|
||||
keccak256_setOutput(thr_id);
|
||||
}
|
||||
|
||||
do {
|
||||
int order = 0;
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
if(use_compat_kernels[thr_id])
|
||||
keccak256_sm3_hash_80(thr_id, throughput, pdata[19], work->nonces, order++);
|
||||
else {
|
||||
keccak256_cpu_hash_80(thr_id, throughput, pdata[19], work->nonces, highTarget);
|
||||
}
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX && bench_algo < 0)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
keccak256_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
if (!use_compat_kernels[thr_id] && work->nonces[1] != UINT32_MAX) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
keccak256_hash(vhash, endiandata);
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces++;
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
}
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
}
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
//keccak256_setOutput(thr_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_keccak256(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
if(!use_compat_kernels[thr_id])
|
||||
keccak256_cpu_free(thr_id);
|
||||
else {
|
||||
keccak256_sm3_free(thr_id);
|
||||
}
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
@@ -0,0 +1,492 @@
|
||||
/**
|
||||
* Optimized Blake-256 8-rounds Cuda Kernel (Tested on SM >3.0)
|
||||
* Based upon Blake-256 implementation of Tanguy Pruvot - Nov. 2014
|
||||
*
|
||||
* Provos Alexis - Jan. 2016
|
||||
*
|
||||
* Fixed CUDA 7.5 flaw
|
||||
* minor code changes
|
||||
* code cleanup
|
||||
* increased nonces per thread
|
||||
* removed SSE2 midstate computation
|
||||
* Provos Alexis - Mar 2016
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __byte_perm(x, y, b) x
|
||||
#endif
|
||||
|
||||
/* threads per block and nonces per thread */
|
||||
#define TPB 768
|
||||
#define NPT 384
|
||||
#define NBN 2
|
||||
|
||||
__constant__ uint32_t _ALIGN(16) d_data[21];
|
||||
|
||||
/* 16 gpu threads max */
|
||||
static uint32_t *d_resNonce[MAX_GPUS];
|
||||
static uint32_t *h_resNonce[MAX_GPUS];
|
||||
static cudaStream_t streams[MAX_GPUS];
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void vanillahash(void *output, const void *input, int8_t blakerounds){
|
||||
uchar hash[64];
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(blakerounds);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 80);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
#define GS4(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1,a2,b2,c2,d2,x2,y2,a3,b3,c3,d3,x3,y3) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
v[a2]+= (m[x2] ^ z[y2]) + v[b2]; \
|
||||
v[a3]+= (m[x3] ^ z[y3]) + v[b3]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x1032); \
|
||||
v[d3] = __byte_perm(v[d3] ^ v[a3], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
v[c3]+= v[d3]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 12); \
|
||||
v[b3] = ROTR32(v[b3] ^ v[c3], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
v[a2]+= (m[y2] ^ z[x2]) + v[b2]; \
|
||||
v[a3]+= (m[y3] ^ z[x3]) + v[b3]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x0321); \
|
||||
v[d3] = __byte_perm(v[d3] ^ v[a3], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
v[c3]+= v[d3]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 7); \
|
||||
v[b3] = ROTR32(v[b3] ^ v[c3], 7); \
|
||||
}
|
||||
|
||||
#define GS3(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1,a2,b2,c2,d2,x2,y2) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
v[a2]+= (m[x2] ^ z[y2]) + v[b2]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
v[a2]+= (m[y2] ^ z[x2]) + v[b2]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
v[d2] = __byte_perm(v[d2] ^ v[a2], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
v[c2]+= v[d2]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
v[b2] = ROTR32(v[b2] ^ v[c2], 7); \
|
||||
}
|
||||
|
||||
#define GS2(a,b,c,d,x,y,a1,b1,c1,d1,x1,y1) { \
|
||||
v[ a]+= (m[ x] ^ z[ y]) + v[ b]; \
|
||||
v[a1]+= (m[x1] ^ z[y1]) + v[b1]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x1032); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x1032); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 12); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 12); \
|
||||
\
|
||||
v[ a]+= (m[ y] ^ z[ x]) + v[ b]; \
|
||||
v[a1]+= (m[y1] ^ z[x1]) + v[b1]; \
|
||||
\
|
||||
v[ d] = __byte_perm(v[ d] ^ v[ a], 0, 0x0321); \
|
||||
v[d1] = __byte_perm(v[d1] ^ v[a1], 0, 0x0321); \
|
||||
\
|
||||
v[ c]+= v[ d]; \
|
||||
v[c1]+= v[d1]; \
|
||||
\
|
||||
v[ b] = ROTR32(v[ b] ^ v[ c], 7); \
|
||||
v[b1] = ROTR32(v[b1] ^ v[c1], 7); \
|
||||
}
|
||||
|
||||
#define GS(a,b,c,d,x,y) { \
|
||||
v[a] += (m[x] ^ z[y]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x1032); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 12); \
|
||||
v[a] += (m[y] ^ z[x]) + v[b]; \
|
||||
v[d] = __byte_perm(v[d] ^ v[a],0, 0x0321); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(TPB,1)
|
||||
void vanilla_gpu_hash_16_8(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,const uint64_t highTarget){
|
||||
uint32_t _ALIGN(16) v[16];
|
||||
uint32_t _ALIGN(16) tmp[16];
|
||||
|
||||
const size_t thread = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
const uint64_t step = gridDim.x * blockDim.x;
|
||||
const uint64_t maxNonce = startNonce + threads;
|
||||
|
||||
const int8_t r[][16] = {
|
||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }
|
||||
};
|
||||
const uint32_t z[16] = {
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917
|
||||
};
|
||||
|
||||
//PREFETCH
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++){
|
||||
tmp[ i] = d_data[ i];
|
||||
}
|
||||
|
||||
uint32_t m[16] = {
|
||||
d_data[16], d_data[17], d_data[18], 0,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640
|
||||
};
|
||||
|
||||
const uint32_t h7 = d_data[19];
|
||||
const uint32_t h6 = d_data[20];
|
||||
//END OF PREFETCH
|
||||
uint64_t m3 = startNonce + thread;
|
||||
loopstart:
|
||||
if(m3>=maxNonce)return;
|
||||
m[3] = m3;
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0;i<16;i++)
|
||||
v[ i] = tmp[ i];
|
||||
|
||||
v[ 1]+= m[3] ^ z[2];
|
||||
v[13] = __byte_perm(v[13] ^ v[1],0, 0x0321);
|
||||
v[ 9]+= v[13];
|
||||
v[ 5] = ROTR32(v[5] ^ v[9], 7);
|
||||
v[ 0]+= v[5];
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x1032);
|
||||
|
||||
v[10]+= v[15];
|
||||
v[ 5] = ROTR32(v[5] ^ v[10], 12);
|
||||
v[ 0]+= z[8] + v[5];
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x0321);
|
||||
v[10]+= v[15];
|
||||
v[ 5] = ROTR32(v[5] ^ v[10], 7);
|
||||
|
||||
GS3( 1, 6,11,12,10,11, 2, 7, 8,13,12,13, 3, 4, 9,14,14,15);
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0;i<6;i++){
|
||||
GS4(0, 4, 8,12,r[i][ 0],r[i][ 1], 1, 5, 9,13,r[i][ 2],r[i][ 3], 2, 6,10,14,r[i][ 4],r[i][ 5], 3, 7,11,15,r[i][ 6],r[i][ 7]);
|
||||
GS4(0, 5,10,15,r[i][ 8],r[i][ 9], 1, 6,11,12,r[i][10],r[i][11], 2, 7, 8,13,r[i][12],r[i][13], 3, 4, 9,14,r[i][14],r[i][15]);
|
||||
}
|
||||
GS4(0, 4, 8,12,r[6][ 0],r[6][ 1], 1, 5, 9,13,r[6][ 2],r[6][ 3], 2, 6,10,14,r[6][ 4],r[6][ 5], 3, 7,11,15,r[6][ 6],r[6][ 7]);
|
||||
|
||||
v[ 0] += (m[ 5] ^ z[0]) + v[5];
|
||||
v[ 2] += (m[ 8] ^ z[6]) + v[7];
|
||||
v[13] = __byte_perm(v[13] ^ v[2],0, 0x1032);
|
||||
v[15] = __byte_perm(v[15] ^ v[0],0, 0x1032);
|
||||
|
||||
v[ 8] += v[13];
|
||||
v[10] += v[15];
|
||||
|
||||
v[ 5] = ROTR32(v[ 5] ^ v[10], 12);
|
||||
v[ 7] = ROTR32(v[ 7] ^ v[ 8], 12);
|
||||
|
||||
v[ 0] += (m[ 0] ^ z[5]) + v[5];
|
||||
v[ 2] += (m[ 6] ^ z[8]) + v[7];
|
||||
|
||||
v[15] = __byte_perm(v[15] ^ v[ 0],0, 0x0321);
|
||||
v[13] = __byte_perm(v[13] ^ v[ 2],0, 0x0321);
|
||||
|
||||
v[8] += v[13];
|
||||
v[7] = ROTR32(v[7] ^ v[8], 7);
|
||||
|
||||
// only compute h6 & 7
|
||||
if((v[15]^h7)==v[7]){
|
||||
v[ 1] += (m[15] ^ z[ 4]) + v[6];
|
||||
v[ 3] += (m[2] ^ z[10]) + v[4];
|
||||
v[12] = __byte_perm(v[12] ^ v[ 1],0, 0x1032);
|
||||
v[14] = __byte_perm(v[14] ^ v[3],0, 0x1032);
|
||||
v[11] += v[12];
|
||||
v[ 9] += v[14];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 12);
|
||||
|
||||
v[ 1] += (m[ 4] ^ z[15]) + v[ 6];
|
||||
v[ 3] += (m[10] ^ z[ 2]) + ROTR32(v[ 4] ^ v[ 9],12);
|
||||
v[12] = __byte_perm(v[12] ^ v[ 1],0, 0x0321);
|
||||
v[14] = __byte_perm(v[14] ^ v[ 3],0, 0x0321);
|
||||
|
||||
v[11] += v[12];
|
||||
v[ 6] = ROTR32(v[ 6] ^ v[11], 7);
|
||||
|
||||
if(cuda_swab32(h6^v[6]^v[14]) <= highTarget) {
|
||||
#if NBN == 2
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (m[3] < resNonce[0]){
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = m[3];
|
||||
}
|
||||
else
|
||||
resNonce[1] = m[3];
|
||||
#else
|
||||
resNonce[0] = m[3];
|
||||
#endif
|
||||
return; //<-- this may cause a problem on extranonce if the extranonce is on position current_nonce + X * step where X=[1,2,3..,N]
|
||||
}
|
||||
}
|
||||
m3+=step;
|
||||
goto loopstart;
|
||||
}
|
||||
|
||||
__host__
|
||||
void vanilla_cpu_setBlock_16(const int thr_id,const uint32_t* endiandata, uint32_t *penddata){
|
||||
|
||||
const uint32_t _ALIGN(64) z[16] = {
|
||||
SPH_C32(0x243F6A88), SPH_C32(0x85A308D3), SPH_C32(0x13198A2E), SPH_C32(0x03707344),
|
||||
SPH_C32(0xA4093822), SPH_C32(0x299F31D0), SPH_C32(0x082EFA98), SPH_C32(0xEC4E6C89),
|
||||
SPH_C32(0x452821E6), SPH_C32(0x38D01377), SPH_C32(0xBE5466CF), SPH_C32(0x34E90C6C),
|
||||
SPH_C32(0xC0AC29B7), SPH_C32(0xC97C50DD), SPH_C32(0x3F84D5B5), SPH_C32(0xB5470917)
|
||||
};
|
||||
uint32_t _ALIGN(64) h[22];
|
||||
|
||||
sph_blake256_context ctx;
|
||||
|
||||
sph_blake256_set_rounds(8);
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, endiandata, 64);
|
||||
|
||||
h[ 0] = ctx.H[0]; h[ 1] = ctx.H[1];
|
||||
h[ 2] = ctx.H[2]; h[21] = ctx.H[3];
|
||||
h[ 4] = ctx.H[4]; h[20] = ctx.H[5];
|
||||
h[19] = ctx.H[6]; h[16] = ctx.H[7];
|
||||
|
||||
uint32_t tmp = h[20];
|
||||
h[20] = h[19];
|
||||
h[19] = h[16];
|
||||
h[16] = penddata[ 0];
|
||||
h[17] = penddata[ 1];
|
||||
h[18] = penddata[ 2];
|
||||
h[12] = z[ 4] ^ 640;
|
||||
h[ 8] = z[ 0];
|
||||
|
||||
h[ 0] += (h[16] ^ z[ 1]) + h[ 4];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[0],16);
|
||||
h[ 8] += h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8], 12);
|
||||
h[ 0] += (h[17] ^ z[ 0]) + h[ 4];
|
||||
h[12] = SPH_ROTR32(h[12] ^ h[0],8);
|
||||
h[ 8] += h[12];
|
||||
h[ 4] = SPH_ROTR32(h[ 4] ^ h[ 8], 7);
|
||||
|
||||
h[1] += (h[18] ^ z[ 3]) + tmp;
|
||||
|
||||
h[13] = SPH_ROTR32(z[ 5] ^ 640 ^ h[1],16);
|
||||
h[ 5] = ROTR32(tmp ^ (z[ 1] + h[13]), 12);
|
||||
|
||||
h[ 1] += h[ 5];
|
||||
h[ 2] += (0x80000000UL ^ z[ 5]) + h[20];
|
||||
|
||||
h[14] = SPH_ROTR32(z[ 6] ^ h[2], 16);
|
||||
h[ 6] = z[ 2] + h[14];
|
||||
h[ 6] = SPH_ROTR32(h[20] ^ h[ 6], 12);
|
||||
|
||||
h[21] += z[ 7] + h[19];
|
||||
h[ 0] += z[ 9];
|
||||
|
||||
h[ 2] += z[ 4] + h[ 6];
|
||||
|
||||
h[ 9] = z[ 1] + h[13];
|
||||
h[10] = z[ 2] + h[14];
|
||||
|
||||
h[14] = SPH_ROTR32(h[14] ^ h[2],8); //0x0321
|
||||
h[10]+=h[14];
|
||||
|
||||
h[ 6] = SPH_ROTR32(h[ 6] ^ h[10],7);
|
||||
h[15] = SPH_ROTR32(z[ 7] ^ h[21],16);
|
||||
|
||||
h[11] = z[ 3] + h[15];
|
||||
h[ 7] = SPH_ROTR32(h[19] ^ h[11], 12);
|
||||
h[ 3] = h[21] + h[ 7] + z[ 6];
|
||||
|
||||
h[15] = SPH_ROTR32(h[15] ^ h[ 3],8);
|
||||
h[11]+= h[15];
|
||||
h[ 7] = ROTR32(h[ 7] ^ h[11],7);
|
||||
|
||||
cudaMemcpyToSymbolAsync(d_data, h, 21*sizeof(uint32_t), 0, cudaMemcpyHostToDevice, streams[thr_id]);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_vanilla(int thr_id, struct work* work, uint32_t max_nonce, unsigned long *hashes_done, const int8_t blakerounds)
|
||||
{
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
const uint32_t targetHigh = ptarget[6];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
int intensity = (device_sm[dev_id] > 500 && !is_windows()) ? 30 : 24;
|
||||
if (device_sm[dev_id] < 350) intensity = 22;
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << intensity);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (!init[thr_id]) {
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage (linux)
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
cudaDeviceSetCacheConfig(cudaFuncCachePreferL1);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
cuda_get_arch(thr_id);
|
||||
|
||||
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), -1);
|
||||
cudaStreamCreate(&streams[thr_id]);
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
|
||||
for (int k = 0; k < 16; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
cudaMemsetAsync(d_resNonce[thr_id], 0xff, sizeof(uint32_t),streams[thr_id]);
|
||||
|
||||
vanilla_cpu_setBlock_16(thr_id,endiandata,&pdata[16]);
|
||||
|
||||
const dim3 grid((throughput + (NPT*TPB)-1)/(NPT*TPB));
|
||||
const dim3 block(TPB);
|
||||
int rc = 0;
|
||||
|
||||
do {
|
||||
vanilla_gpu_hash_16_8<<<grid,block, 0, streams[thr_id]>>>(throughput, pdata[19], d_resNonce[thr_id], targetHigh);
|
||||
cudaMemcpyAsync(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost,streams[thr_id]);
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
cudaStreamSynchronize(streams[thr_id]);
|
||||
|
||||
if (h_resNonce[thr_id][0] != UINT32_MAX){
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t Htarg = (uint32_t)targetHigh;
|
||||
|
||||
for (int k=0; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
be32enc(&endiandata[19], h_resNonce[thr_id][0]);
|
||||
vanillahash(vhashcpu, endiandata, blakerounds);
|
||||
|
||||
if (vhashcpu[6] <= Htarg && fulltest(vhashcpu, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work->nonces[0] = h_resNonce[thr_id][0];
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
#if NBN > 1
|
||||
if (h_resNonce[thr_id][1] != UINT32_MAX) {
|
||||
work->nonces[1] = h_resNonce[thr_id][1];
|
||||
be32enc(&endiandata[19], h_resNonce[thr_id][1]);
|
||||
vanillahash(vhashcpu, endiandata, blakerounds);
|
||||
if (bn_hash_target_ratio(vhashcpu, ptarget) > work->shareratio[0]) {
|
||||
work_set_target_ratio(work, vhashcpu);
|
||||
xchg(work->nonces[0], work->nonces[1]);
|
||||
}
|
||||
work->valid_nonces = 2;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhashcpu[6] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", h_resNonce[thr_id][0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
MyStreamSynchronize(NULL, 0, dev_id);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_vanilla(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFreeHost(h_resNonce[thr_id]);
|
||||
cudaFree(d_resNonce[thr_id]);
|
||||
|
||||
init[thr_id] = false;
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
}
|
||||
@@ -1,11 +1,97 @@
|
||||
|
||||
You can use ./build.sh to configure and build with default options.
|
||||
|
||||
It is advised to run ./autogen.sh before ./configure (autoconf and automake
|
||||
need to be installed on your system for autogen.sh to work)
|
||||
|
||||
./configure has an option named --with-cuda that allows you to specify
|
||||
where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda,
|
||||
but some distros may have a different default location)
|
||||
|
||||
See README.txt
|
||||
|
||||
You can use ./build.sh to configure and build with default options.
|
||||
|
||||
It is advised to run ./autogen.sh before ./configure (autoconf and automake
|
||||
need to be installed on your system for autogen.sh to work)
|
||||
|
||||
./configure has an option named --with-cuda that allows you to specify
|
||||
where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda,
|
||||
but some distros may have a different default location)
|
||||
|
||||
|
||||
** How to compile on Ubuntu (16.04 LTS)
|
||||
|
||||
First, install Cuda toolkit and nVidia Driver, and type `nvidia-smi` to check if your card is detected.
|
||||
|
||||
Install dependencies
|
||||
```sudo apt-get install libcurl4-openssl-dev libssl-dev libjansson-dev automake autotools-dev build-essential```
|
||||
|
||||
Ubuntu is now shipped with gcc 6 or 7 so please install gcc/g++ 5 and make it the default (required by the cuda toolkit)
|
||||
```
|
||||
sudo apt-get install gcc-5 g++-5
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1
|
||||
```
|
||||
|
||||
Then use the helper ./build.sh in ccminer source folder, edit configure.sh and the Makefile.am if required.
|
||||
```
|
||||
./build.sh
|
||||
./ccminer --version
|
||||
```
|
||||
|
||||
|
||||
** How to compile on Fedora 25 **
|
||||
|
||||
Note: You may find an alternative method via rpms :
|
||||
see https://negativo17.org/nvidia-driver/ and https://negativo17.org/repos/multimedia/
|
||||
|
||||
|
||||
# Step 1: gcc and dependencies
|
||||
dnf install gcc gcc-c++ autoconf automake
|
||||
dnf install jansson-devel openssl-devel libcurl-devel zlib-devel
|
||||
|
||||
# Step 2: nvidia drivers (Download common linux drivers from nvidia site)
|
||||
dnf install kernel-devel
|
||||
dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
|
||||
dnf check-update
|
||||
dnf install xorg-x11-drv-nvidia-cuda kmod-nvidia
|
||||
ln -s libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so
|
||||
|
||||
# Step 3: CUDA SDK (Download from nvidia the generic ".run" archive)
|
||||
# --override is required to ignore "too recent" gcc 6.3
|
||||
# --silent is required to install only the toolkit (no kmod)
|
||||
./cuda_8.0.61_375.26_linux.run --toolkit --silent --override
|
||||
nvcc --version
|
||||
|
||||
# add the nvcc binary path to the system
|
||||
ln -s /usr/local/cuda-8.0 /usr/local/cuda # (if not already made)
|
||||
echo 'export PATH=$PATH:/usr/local/cuda/bin' > /etc/profile.d/cuda.sh
|
||||
|
||||
# add the cudart library path to the system
|
||||
echo /usr/local/cuda/lib64 > /etc/ld.so.conf.d/cuda.conf
|
||||
ldconfig
|
||||
|
||||
# Step 4: Fix the toolkit incompatibility with gcc 6
|
||||
|
||||
# You need to build yourself an older GCC/G++ version, i recommend the 5.4
|
||||
# see https://gcc.gnu.org/mirrors.html
|
||||
# Note: this manual method will override the default gcc, it could be better to use a custom toolchain prefix
|
||||
|
||||
wget ftp://ftp.lip6.fr/pub/gcc/releases/gcc-5.4.0/gcc-5.4.0.tar.bz2
|
||||
dnf install libmpc-devel mpfr-devel gmp-devel
|
||||
./configure --prefix=/usr/local --enable-languages=c,c++,lto --disable-multilib
|
||||
make -j 8 && make install
|
||||
(while this step, you have the time to cook something :p)
|
||||
|
||||
# or, for previous fedora versions, edit the file /usr/local/cuda/include/host_config.h
|
||||
# and comment/delete the line 121 : #error -- unsupported GNU version! gcc versions later than 5 are not supported!
|
||||
|
||||
./build.sh
|
||||
|
||||
./ccminer -n
|
||||
|
||||
|
||||
** How to compile on macOS **
|
||||
|
||||
# Step 1: download and install CUDA Toolkit 8 or more recent
|
||||
# https://developer.nvidia.com/cuda-toolkit-archive
|
||||
|
||||
# Step 2: install Homebrew
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
|
||||
# Step 3: dependencies
|
||||
brew install pkg-config autoconf automake curl openssl llvm
|
||||
|
||||
./build.sh
|
||||
|
||||
./ccminer -n
|
||||
|
||||
@@ -4,20 +4,15 @@
|
||||
#include "cuda_helper.h"
|
||||
#include <sm_30_intrinsics.h>
|
||||
|
||||
// aus cpu-miner.c
|
||||
extern int device_map[8];
|
||||
#ifdef __INTELLISENSE__
|
||||
#define __shfl_up(a,b)
|
||||
#endif
|
||||
|
||||
// diese Struktur wird in der Init Funktion angefordert
|
||||
static cudaDeviceProp props[8];
|
||||
static uint32_t *d_tempBranch1Nonces[MAX_GPUS];
|
||||
static uint32_t *d_numValid[MAX_GPUS];
|
||||
static uint32_t *h_numValid[MAX_GPUS];
|
||||
|
||||
static uint32_t *d_tempBranch1Nonces[8];
|
||||
static uint32_t *d_numValid[8];
|
||||
static uint32_t *h_numValid[8];
|
||||
|
||||
static uint32_t *d_partSum[2][8]; // für bis zu vier partielle Summen
|
||||
|
||||
// aus heavy.cu
|
||||
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);
|
||||
static uint32_t *d_partSum[2][MAX_GPUS]; // für bis zu vier partielle Summen
|
||||
|
||||
// True/False tester
|
||||
typedef uint32_t(*cuda_compactTestFunction_t)(uint32_t *inpHash);
|
||||
@@ -35,13 +30,13 @@ __device__ uint32_t JackpotFalseTest(uint32_t *inpHash)
|
||||
}
|
||||
|
||||
__device__ cuda_compactTestFunction_t d_JackpotTrueFunction = JackpotTrueTest, d_JackpotFalseFunction = JackpotFalseTest;
|
||||
cuda_compactTestFunction_t h_JackpotTrueFunction[8], h_JackpotFalseFunction[8];
|
||||
|
||||
// Setup-Funktionen
|
||||
__host__ void jackpot_compactTest_cpu_init(int thr_id, int threads)
|
||||
cuda_compactTestFunction_t h_JackpotTrueFunction[MAX_GPUS], h_JackpotFalseFunction[MAX_GPUS];
|
||||
|
||||
// Setup-Function
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads)
|
||||
{
|
||||
cudaGetDeviceProperties(&props[thr_id], device_map[thr_id]);
|
||||
|
||||
cudaMemcpyFromSymbol(&h_JackpotTrueFunction[thr_id], d_JackpotTrueFunction, sizeof(cuda_compactTestFunction_t));
|
||||
cudaMemcpyFromSymbol(&h_JackpotFalseFunction[thr_id], d_JackpotFalseFunction, sizeof(cuda_compactTestFunction_t));
|
||||
|
||||
@@ -57,6 +52,18 @@ __host__ void jackpot_compactTest_cpu_init(int thr_id, int threads)
|
||||
cudaMalloc(&d_partSum[1][thr_id], sizeof(uint32_t) * s1); // BLOCKSIZE (Threads/Block)
|
||||
}
|
||||
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_free(int thr_id)
|
||||
{
|
||||
cudaFree(d_tempBranch1Nonces[thr_id]);
|
||||
cudaFree(d_numValid[thr_id]);
|
||||
|
||||
cudaFree(d_partSum[0][thr_id]);
|
||||
cudaFree(d_partSum[1][thr_id]);
|
||||
|
||||
cudaFreeHost(h_numValid[thr_id]);
|
||||
}
|
||||
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 300
|
||||
/**
|
||||
* __shfl_up() calculates a source lane ID by subtracting delta from the caller's lane ID, and clamping to the range 0..width-1
|
||||
@@ -66,7 +73,9 @@ __host__ void jackpot_compactTest_cpu_init(int thr_id, int threads)
|
||||
#endif
|
||||
|
||||
// Die Summenfunktion (vom NVIDIA SDK)
|
||||
__global__ void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t *partial_sums=NULL, cuda_compactTestFunction_t testFunc=NULL, int threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL)
|
||||
__global__
|
||||
void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t *partial_sums=NULL, cuda_compactTestFunction_t testFunc=NULL,
|
||||
uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL)
|
||||
{
|
||||
extern __shared__ uint32_t sums[];
|
||||
int id = ((blockIdx.x * blockDim.x) + threadIdx.x);
|
||||
@@ -178,7 +187,8 @@ __global__ void jackpot_compactTest_gpu_SCAN(uint32_t *data, int width, uint32_t
|
||||
}
|
||||
|
||||
// Uniform add: add partial sums array
|
||||
__global__ void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_sums, int len)
|
||||
__global__
|
||||
void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_sums, int len)
|
||||
{
|
||||
__shared__ uint32_t buf;
|
||||
int id = ((blockIdx.x * blockDim.x) + threadIdx.x);
|
||||
@@ -195,7 +205,9 @@ __global__ void jackpot_compactTest_gpu_ADD(uint32_t *data, uint32_t *partial_su
|
||||
}
|
||||
|
||||
// Der Scatter
|
||||
__global__ void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, cuda_compactTestFunction_t testFunc, int threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL)
|
||||
__global__
|
||||
void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, cuda_compactTestFunction_t testFunc,
|
||||
uint32_t threads=0, uint32_t startNounce=0, uint32_t *inpHashes=NULL, uint32_t *d_validNonceTable=NULL)
|
||||
{
|
||||
int id = ((blockIdx.x * blockDim.x) + threadIdx.x);
|
||||
uint32_t actNounce = id;
|
||||
@@ -230,7 +242,8 @@ __global__ void jackpot_compactTest_gpu_SCATTER(uint32_t *sum, uint32_t *outp, c
|
||||
}
|
||||
}
|
||||
|
||||
__host__ static uint32_t jackpot_compactTest_roundUpExp(uint32_t val)
|
||||
__host__
|
||||
static uint32_t jackpot_compactTest_roundUpExp(uint32_t val)
|
||||
{
|
||||
if(val == 0)
|
||||
return 0;
|
||||
@@ -244,9 +257,9 @@ __host__ static uint32_t jackpot_compactTest_roundUpExp(uint32_t val)
|
||||
return mask;
|
||||
}
|
||||
|
||||
__host__ void jackpot_compactTest_cpu_singleCompaction(int thr_id, int threads, uint32_t *nrm,
|
||||
uint32_t *d_nonces1, cuda_compactTestFunction_t function,
|
||||
uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable)
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_singleCompaction(int thr_id, uint32_t threads, uint32_t *nrm, uint32_t *d_nonces1,
|
||||
cuda_compactTestFunction_t function, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable)
|
||||
{
|
||||
int orgThreads = threads;
|
||||
threads = (int)jackpot_compactTest_roundUpExp((uint32_t)threads);
|
||||
@@ -300,9 +313,9 @@ __host__ void jackpot_compactTest_cpu_singleCompaction(int thr_id, int threads,
|
||||
}
|
||||
|
||||
////// ACHTUNG: Diese funktion geht aktuell nur mit threads > 65536 (Am besten 256 * 1024 oder 256*2048)
|
||||
__host__ void jackpot_compactTest_cpu_dualCompaction(int thr_id, int threads, uint32_t *nrm,
|
||||
uint32_t *d_nonces1, uint32_t *d_nonces2,
|
||||
uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable)
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_dualCompaction(int thr_id, uint32_t threads, uint32_t *nrm, uint32_t *d_nonces1,
|
||||
uint32_t *d_nonces2, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable)
|
||||
{
|
||||
jackpot_compactTest_cpu_singleCompaction(thr_id, threads, &nrm[0], d_nonces1, h_JackpotTrueFunction[thr_id], startNounce, inpHashes, d_validNonceTable);
|
||||
jackpot_compactTest_cpu_singleCompaction(thr_id, threads, &nrm[1], d_nonces2, h_JackpotFalseFunction[thr_id], startNounce, inpHashes, d_validNonceTable);
|
||||
@@ -339,10 +352,9 @@ __host__ void jackpot_compactTest_cpu_dualCompaction(int thr_id, int threads, ui
|
||||
*/
|
||||
}
|
||||
|
||||
__host__ void jackpot_compactTest_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, size_t *nrm1,
|
||||
uint32_t *d_nonces2, size_t *nrm2,
|
||||
int order)
|
||||
__host__
|
||||
void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, uint32_t *nrm1, uint32_t *d_nonces2, uint32_t *nrm2, int order)
|
||||
{
|
||||
// Wenn validNonceTable genutzt wird, dann werden auch nur die Nonces betrachtet, die dort enthalten sind
|
||||
// "threads" ist in diesem Fall auf die Länge dieses Array's zu setzen!
|
||||
@@ -352,6 +364,6 @@ __host__ void jackpot_compactTest_cpu_hash_64(int thr_id, int threads, uint32_t
|
||||
startNounce, inpHashes, d_validNonceTable);
|
||||
|
||||
cudaStreamSynchronize(NULL); // Das original braucht zwar etwas CPU-Last, ist an dieser Stelle aber evtl besser
|
||||
*nrm1 = (size_t)h_numValid[thr_id][0];
|
||||
*nrm2 = (size_t)h_numValid[thr_id][1];
|
||||
*nrm1 = h_numValid[thr_id][0];
|
||||
*nrm2 = h_numValid[thr_id][1];
|
||||
}
|
||||
+578
-453
File diff suppressed because it is too large.
Load diff
+162
-104
@@ -9,122 +9,124 @@ extern "C"
|
||||
|
||||
#include "miner.h"
|
||||
#include "cuda_helper.h"
|
||||
#include "quark/cuda_quark.h"
|
||||
|
||||
extern int device_map[8];
|
||||
|
||||
static uint32_t *d_hash[8];
|
||||
|
||||
extern void jackpot_keccak512_cpu_init(int thr_id, int threads);
|
||||
extern void jackpot_keccak512_cpu_setBlock(void *pdata, size_t inlen);
|
||||
extern void jackpot_keccak512_cpu_hash(int thr_id, int threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_blake512_cpu_init(int thr_id, int threads);
|
||||
extern void quark_blake512_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_groestl512_cpu_init(int thr_id, int threads);
|
||||
extern void quark_groestl512_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_jh512_cpu_init(int thr_id, int threads);
|
||||
extern void quark_jh512_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void quark_skein512_cpu_init(int thr_id, int threads);
|
||||
extern void quark_skein512_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_hash, int order);
|
||||
|
||||
extern void jackpot_compactTest_cpu_init(int thr_id, int threads);
|
||||
extern void jackpot_compactTest_cpu_hash_64(int thr_id, int threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, size_t *nrm1,
|
||||
uint32_t *d_nonces2, size_t *nrm2,
|
||||
int order);
|
||||
static uint32_t *d_hash[MAX_GPUS] = { 0 };
|
||||
|
||||
// Speicher zur Generierung der Noncevektoren für die bedingten Hashes
|
||||
static uint32_t *d_jackpotNonces[8];
|
||||
static uint32_t *d_branch1Nonces[8];
|
||||
static uint32_t *d_branch2Nonces[8];
|
||||
static uint32_t *d_branch3Nonces[8];
|
||||
static uint32_t *d_jackpotNonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch1Nonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch2Nonces[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_branch3Nonces[MAX_GPUS] = { 0 };
|
||||
|
||||
// Original jackpothash Funktion aus einem miner Quelltext
|
||||
extern "C" unsigned int jackpothash(void *state, const void *input)
|
||||
extern void jackpot_keccak512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_keccak512_cpu_setBlock(void *pdata, size_t inlen);
|
||||
extern void jackpot_keccak512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
extern void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_compactTest_cpu_free(int thr_id);
|
||||
extern void jackpot_compactTest_cpu_hash_64(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *inpHashes, uint32_t *d_validNonceTable,
|
||||
uint32_t *d_nonces1, uint32_t *nrm1, uint32_t *d_nonces2, uint32_t *nrm2, int order);
|
||||
|
||||
extern uint32_t cuda_check_hash_branch(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_nonceVector, uint32_t *d_inputHash, int order);
|
||||
|
||||
// CPU HASH JHA v8
|
||||
extern "C" void jackpothash(void *state, const void *input)
|
||||
{
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
uint32_t hash[16];
|
||||
unsigned int rnd;
|
||||
|
||||
uint32_t hash[16];
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
|
||||
unsigned int round;
|
||||
for (round = 0; round < 3; round++) {
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(state, hash, 32);
|
||||
for (rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
|
||||
return round;
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(state, hash, 32);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern bool opt_benchmark;
|
||||
|
||||
extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
|
||||
const uint32_t *ptarget, uint32_t max_nonce,
|
||||
unsigned long *hashes_done)
|
||||
extern "C" int scanhash_jackpot(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[22];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 20);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
((uint32_t*)ptarget)[7] = 0x0000ff;
|
||||
ptarget[7] = 0x000f;
|
||||
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
|
||||
const int throughput = 256*4096*4; // 100;
|
||||
|
||||
static bool init[8] = {0,0,0,0,0,0,0,0};
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(device_map[thr_id]);
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
if (device_sm[dev_id] < 300 || cuda_arch[dev_id] < 300) {
|
||||
gpulog(LOG_ERR, thr_id, "Sorry, This algo is not supported by this GPU arch (SM 3.0 required)");
|
||||
proper_exit(EXIT_CODE_CUDA_ERROR);
|
||||
}
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput));
|
||||
|
||||
// Konstanten kopieren, Speicher belegen
|
||||
cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput);
|
||||
jackpot_keccak512_cpu_init(thr_id, throughput);
|
||||
jackpot_compactTest_cpu_init(thr_id, throughput);
|
||||
quark_blake512_cpu_init(thr_id, throughput);
|
||||
quark_groestl512_cpu_init(thr_id, throughput);
|
||||
quark_jh512_cpu_init(thr_id, throughput);
|
||||
quark_skein512_cpu_init(thr_id, throughput);
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
cudaMalloc(&d_jackpotNonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput*2);
|
||||
|
||||
cudaMalloc(&d_branch1Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch2Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
cudaMalloc(&d_branch3Nonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_jackpotNonces[thr_id], (size_t) sizeof(uint32_t)*throughput*2));
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
uint32_t endiandata[22];
|
||||
for (int k=0; k < 22; k++)
|
||||
be32enc(&endiandata[k], ((uint32_t*)pdata)[k]);
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
jackpot_keccak512_cpu_setBlock((void*)endiandata, 80);
|
||||
cuda_check_cpu_setTarget(ptarget);
|
||||
@@ -135,7 +137,7 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
|
||||
// erstes Keccak512 Hash mit CUDA
|
||||
jackpot_keccak512_cpu_hash(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
|
||||
|
||||
size_t nrm1, nrm2, nrm3;
|
||||
uint32_t nrm1, nrm2, nrm3;
|
||||
|
||||
// Runde 1 (ohne Gröstl)
|
||||
|
||||
@@ -206,32 +208,88 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
|
||||
quark_jh512_cpu_hash_64(thr_id, nrm2, pdata[19], d_branch2Nonces[thr_id], d_hash[thr_id], order++);
|
||||
}
|
||||
|
||||
// Scan nach Gewinner Hashes auf der GPU
|
||||
uint32_t foundNonce = cuda_check_cpu_hash_64(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++);
|
||||
if (foundNonce != 0xffffffff)
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
work->nonces[0] = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++);
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
unsigned int rounds;
|
||||
uint32_t vhash64[8];
|
||||
be32enc(&endiandata[19], foundNonce);
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
|
||||
// diese jackpothash Funktion gibt die Zahl der Runden zurück
|
||||
rounds = jackpothash(vhash64, endiandata);
|
||||
// jackpothash function gibt die Zahl der Runden zurück
|
||||
jackpothash(vhash, endiandata);
|
||||
|
||||
if ((vhash64[7]<=Htarg) && fulltest(vhash64, ptarget)) {
|
||||
|
||||
pdata[19] = foundNonce;
|
||||
*hashes_done = (foundNonce - first_nonce + 1)/2;
|
||||
//applog(LOG_INFO, "GPU #%d: result for nonce $%08X does validate on CPU (%d rounds)!", thr_id, foundNonce, rounds);
|
||||
return 1;
|
||||
} else {
|
||||
applog(LOG_INFO, "GPU #%d: result for nonce $%08X does not validate on CPU (%d rounds)!", thr_id, foundNonce, rounds);
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
#if 0
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
jackpothash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
#else
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
#endif
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart);
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
*hashes_done = (pdata[19] - first_nonce + 1)/2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_jackpot(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_branch1Nonces[thr_id]);
|
||||
cudaFree(d_branch2Nonces[thr_id]);
|
||||
cudaFree(d_branch3Nonces[thr_id]);
|
||||
cudaFree(d_jackpotNonces[thr_id]);
|
||||
|
||||
quark_blake512_cpu_free(thr_id);
|
||||
quark_groestl512_cpu_free(thr_id);
|
||||
jackpot_compactTest_cpu_free(thr_id);
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
|
||||
cuda_check_cpu_free(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
|
||||
init[thr_id] = false;
|
||||
}
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* JHA v8 algorithm - compatible implementation
|
||||
* @author tpruvot@github 05-2017
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_keccak.h"
|
||||
#include "sph/sph_blake.h"
|
||||
#include "sph/sph_groestl.h"
|
||||
#include "sph/sph_jh.h"
|
||||
#include "sph/sph_skein.h"
|
||||
}
|
||||
|
||||
#include "miner.h"
|
||||
#include "cuda_helper.h"
|
||||
#include "quark/cuda_quark.h"
|
||||
|
||||
static uint32_t *d_hash[MAX_GPUS] = { 0 };
|
||||
static uint32_t *d_hash_br2[MAX_GPUS];
|
||||
static uint32_t *d_tempBranch[MAX_GPUS];
|
||||
|
||||
extern void jackpot_keccak512_cpu_init(int thr_id, uint32_t threads);
|
||||
extern void jackpot_keccak512_cpu_setBlock(void *pdata, size_t inlen);
|
||||
extern void jackpot_keccak512_cpu_hash(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, int order);
|
||||
|
||||
// CPU HASH
|
||||
extern "C" void jha_hash(void *output, const void *input)
|
||||
{
|
||||
uint32_t hash[16];
|
||||
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_skein512_context ctx_skein;
|
||||
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512 (&ctx_keccak, input, 80);
|
||||
sph_keccak512_close(&ctx_keccak, hash);
|
||||
|
||||
for (int rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
if (hash[0] & 0x01) {
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512 (&ctx_groestl, (&hash), 64);
|
||||
sph_groestl512_close(&ctx_groestl, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512 (&ctx_skein, (&hash), 64);
|
||||
sph_skein512_close(&ctx_skein, (&hash));
|
||||
}
|
||||
|
||||
if (hash[0] & 0x01) {
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512 (&ctx_blake, (&hash), 64);
|
||||
sph_blake512_close(&ctx_blake, (&hash));
|
||||
}
|
||||
else {
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, (&hash), 64);
|
||||
sph_jh512_close(&ctx_jh, (&hash));
|
||||
}
|
||||
}
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(128, 8)
|
||||
void jha_filter_gpu(const uint32_t threads, const uint32_t* d_hash, uint32_t* d_branch2, uint32_t* d_NonceBranch)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t offset = thread * 16U; // 64U / sizeof(uint32_t);
|
||||
uint4 *psrc = (uint4*) (&d_hash[offset]);
|
||||
d_NonceBranch[thread] = ((uint8_t*)psrc)[0] & 0x01;
|
||||
if (d_NonceBranch[thread]) return;
|
||||
// uint4 = 4x uint32_t = 16 bytes
|
||||
uint4 *pdst = (uint4*) (&d_branch2[offset]);
|
||||
pdst[0] = psrc[0];
|
||||
pdst[1] = psrc[1];
|
||||
pdst[2] = psrc[2];
|
||||
pdst[3] = psrc[3];
|
||||
}
|
||||
}
|
||||
|
||||
__global__ __launch_bounds__(128, 8)
|
||||
void jha_merge_gpu(const uint32_t threads, uint32_t* d_hash, uint32_t* d_branch2, uint32_t* const d_NonceBranch)
|
||||
{
|
||||
const uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads && !d_NonceBranch[thread])
|
||||
{
|
||||
const uint32_t offset = thread * 16U;
|
||||
uint4 *pdst = (uint4*) (&d_hash[offset]);
|
||||
uint4 *psrc = (uint4*) (&d_branch2[offset]);
|
||||
pdst[0] = psrc[0];
|
||||
pdst[1] = psrc[1];
|
||||
pdst[2] = psrc[2];
|
||||
pdst[3] = psrc[3];
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t jha_filter_cpu(const int thr_id, const uint32_t threads, const uint32_t *inpHashes, uint32_t* d_branch2)
|
||||
{
|
||||
const uint32_t threadsperblock = 128;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
// extract algo permution hashes to a second branch buffer
|
||||
jha_filter_gpu <<<grid, block>>> (threads, inpHashes, d_branch2, d_tempBranch[thr_id]);
|
||||
return threads;
|
||||
}
|
||||
|
||||
__host__
|
||||
void jha_merge_cpu(const int thr_id, const uint32_t threads, uint32_t *outpHashes, uint32_t* d_branch2)
|
||||
{
|
||||
const uint32_t threadsperblock = 128;
|
||||
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
// put back second branch hashes to the common buffer d_hash
|
||||
jha_merge_gpu <<<grid, block>>> (threads, outpHashes, d_branch2, d_tempBranch[thr_id]);
|
||||
}
|
||||
|
||||
static bool init[MAX_GPUS] = { 0 };
|
||||
|
||||
extern "C" int scanhash_jha(int thr_id, struct work *work, uint32_t max_nonce, unsigned long *hashes_done)
|
||||
{
|
||||
uint32_t _ALIGN(64) endiandata[22];
|
||||
uint32_t *pdata = work->data;
|
||||
uint32_t *ptarget = work->target;
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
int dev_id = device_map[thr_id];
|
||||
|
||||
uint32_t throughput = cuda_default_throughput(thr_id, 1U << 20);
|
||||
if (init[thr_id]) throughput = min(throughput, max_nonce - first_nonce);
|
||||
|
||||
if (opt_benchmark)
|
||||
ptarget[7] = 0x000f;
|
||||
|
||||
if (!init[thr_id])
|
||||
{
|
||||
cudaSetDevice(dev_id);
|
||||
if (opt_cudaschedule == -1 && gpu_threads == 1) {
|
||||
cudaDeviceReset();
|
||||
// reduce cpu usage
|
||||
cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync);
|
||||
CUDA_LOG_ERROR();
|
||||
}
|
||||
cuda_get_arch(thr_id);
|
||||
gpulog(LOG_INFO, thr_id, "Intensity set to %g, %u cuda threads", throughput2intensity(throughput), throughput);
|
||||
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], (size_t) 64 * throughput));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_hash_br2[thr_id], (size_t) 64 * throughput));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_tempBranch[thr_id], sizeof(uint32_t) * throughput));
|
||||
|
||||
jackpot_keccak512_cpu_init(thr_id, throughput);
|
||||
quark_blake512_cpu_init(thr_id, throughput);
|
||||
quark_groestl512_cpu_init(thr_id, throughput);
|
||||
quark_jh512_cpu_init(thr_id, throughput);
|
||||
quark_skein512_cpu_init(thr_id, throughput);
|
||||
|
||||
cuda_check_cpu_init(thr_id, throughput);
|
||||
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
for (int k=0; k < 22; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
jackpot_keccak512_cpu_setBlock((void*)endiandata, 80);
|
||||
cuda_check_cpu_setTarget(ptarget);
|
||||
|
||||
do {
|
||||
int order = 0;
|
||||
|
||||
jackpot_keccak512_cpu_hash(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
|
||||
|
||||
for (int rnd = 0; rnd < 3; rnd++)
|
||||
{
|
||||
jha_filter_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
quark_groestl512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
|
||||
quark_skein512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++);
|
||||
jha_merge_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
|
||||
jha_filter_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
quark_blake512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash[thr_id], order++);
|
||||
quark_jh512_cpu_hash_64(thr_id, throughput, pdata[19], NULL, d_hash_br2[thr_id], order++);
|
||||
jha_merge_cpu(thr_id, throughput, d_hash[thr_id], d_hash_br2[thr_id]);
|
||||
}
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce + throughput;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
work->nonces[0] = cuda_check_hash(thr_id, throughput, pdata[19], d_hash[thr_id]);
|
||||
|
||||
if (work->nonces[0] != UINT32_MAX)
|
||||
{
|
||||
const uint32_t Htarg = ptarget[7];
|
||||
uint32_t _ALIGN(64) vhash[8];
|
||||
|
||||
be32enc(&endiandata[19], work->nonces[0]);
|
||||
jha_hash(vhash, endiandata);
|
||||
|
||||
if (vhash[7] <= ptarget[7] && fulltest(vhash, ptarget)) {
|
||||
work->valid_nonces = 1;
|
||||
work_set_target_ratio(work, vhash);
|
||||
work->nonces[1] = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
|
||||
if (work->nonces[1] != 0) {
|
||||
be32enc(&endiandata[19], work->nonces[1]);
|
||||
jha_hash(vhash, endiandata);
|
||||
bn_set_target_ratio(work, vhash, 1);
|
||||
work->valid_nonces++;
|
||||
pdata[19] = max(work->nonces[0], work->nonces[1]) + 1;
|
||||
} else {
|
||||
pdata[19] = work->nonces[0] + 1; // cursor
|
||||
}
|
||||
return work->valid_nonces;
|
||||
}
|
||||
else if (vhash[7] > Htarg) {
|
||||
gpu_increment_reject(thr_id);
|
||||
if (!opt_quiet)
|
||||
gpulog(LOG_WARNING, thr_id, "result for %08x does not validate on CPU!", work->nonces[0]);
|
||||
pdata[19] = work->nonces[0] + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) throughput + pdata[19] >= max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
*hashes_done = pdata[19] - first_nonce;
|
||||
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cleanup
|
||||
extern "C" void free_jha(int thr_id)
|
||||
{
|
||||
if (!init[thr_id])
|
||||
return;
|
||||
|
||||
cudaThreadSynchronize();
|
||||
|
||||
cudaFree(d_hash[thr_id]);
|
||||
cudaFree(d_hash_br2[thr_id]);
|
||||
cudaFree(d_tempBranch[thr_id]);
|
||||
|
||||
quark_blake512_cpu_free(thr_id);
|
||||
quark_groestl512_cpu_free(thr_id);
|
||||
|
||||
cuda_check_cpu_free(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
cudaDeviceSynchronize();
|
||||
init[thr_id] = false;
|
||||
}
|
||||
+137
-37
@@ -1,3 +1,5 @@
|
||||
# allow to use Host cuda functions in C/C++
|
||||
DEF_INCLUDES = @CUDA_INCLUDES@
|
||||
|
||||
if WANT_JANSSON
|
||||
JANSSON_INCLUDES= -I$(top_srcdir)/compat/jansson
|
||||
@@ -5,19 +7,23 @@ else
|
||||
JANSSON_INCLUDES=
|
||||
endif
|
||||
|
||||
EXTRA_DIST = autogen.sh README.txt LICENSE.txt \
|
||||
cudaminer.sln cudaminer.vcxproj cudaminer.vcxproj.filters \
|
||||
compat/gettimeofday.c compat/getopt/getopt_long.c cpuminer-config.h.in
|
||||
EXTRA_DIST = autogen.sh README.md README.txt LICENSE.txt \
|
||||
ccminer.sln ccminer.vcxproj ccminer.vcxproj.filters \
|
||||
compat/gettimeofday.c compat/getopt/getopt_long.c
|
||||
|
||||
SUBDIRS = compat
|
||||
SUBDIRS = compat
|
||||
|
||||
bin_PROGRAMS = ccminer
|
||||
bin_PROGRAMS = ccminer
|
||||
|
||||
ccminer_SOURCES = elist.h miner.h compat.h \
|
||||
ccminer_SOURCES = elist.h miner.h compat.h \
|
||||
compat/inttypes.h compat/stdbool.h compat/unistd.h \
|
||||
compat/sys/time.h compat/getopt/getopt.h \
|
||||
cpu-miner.c util.c crc32.c hefty1.c scrypt.c \
|
||||
hashlog.cpp \
|
||||
crc32.c hefty1.c \
|
||||
ccminer.cpp pools.cpp util.cpp bench.cpp bignum.cpp \
|
||||
api.cpp hashlog.cpp nvml.cpp stats.cpp sysinfos.cpp cuda.cpp \
|
||||
nvsettings.cpp \
|
||||
equi/equi-stratum.cpp equi/equi.cpp equi/blake2/blake2bx.cpp \
|
||||
equi/equihash.cpp equi/cuda_equi.cu \
|
||||
heavy/heavy.cu \
|
||||
heavy/cuda_blake512.cu heavy/cuda_blake512.h \
|
||||
heavy/cuda_combine.cu heavy/cuda_combine.h \
|
||||
@@ -25,54 +31,118 @@ ccminer_SOURCES = elist.h miner.h compat.h \
|
||||
heavy/cuda_hefty1.cu heavy/cuda_hefty1.h \
|
||||
heavy/cuda_keccak512.cu heavy/cuda_keccak512.h \
|
||||
heavy/cuda_sha256.cu heavy/cuda_sha256.h \
|
||||
keccak/cuda_keccak256.cu keccak/keccak256.cu \
|
||||
fuguecoin.cpp cuda_fugue256.cu sph/fugue.c sph/sph_fugue.h uint256.h \
|
||||
heavy/bastion.cu heavy/cuda_bastion.cu \
|
||||
fuguecoin.cpp Algo256/cuda_fugue256.cu sph/fugue.c uint256.h \
|
||||
groestlcoin.cpp cuda_groestlcoin.cu cuda_groestlcoin.h \
|
||||
myriadgroestl.cpp cuda_myriadgroestl.cu \
|
||||
JHA/jackpotcoin.cu JHA/cuda_jha_keccak512.cu \
|
||||
lyra2/Lyra2.c lyra2/Sponge.c \
|
||||
lyra2/lyra2RE.cu lyra2/cuda_lyra2.cu \
|
||||
lyra2/lyra2REv2.cu lyra2/cuda_lyra2v2.cu \
|
||||
lyra2/Lyra2Z.c lyra2/lyra2Z.cu lyra2/cuda_lyra2Z.cu \
|
||||
lyra2/allium.cu \
|
||||
Algo256/cuda_bmw256.cu Algo256/cuda_cubehash256.cu \
|
||||
Algo256/cuda_blake256.cu Algo256/cuda_groestl256.cu \
|
||||
Algo256/cuda_keccak256_sm3.cu Algo256/cuda_keccak256.cu Algo256/cuda_skein256.cu \
|
||||
Algo256/blake256.cu Algo256/decred.cu Algo256/vanilla.cu Algo256/keccak256.cu \
|
||||
Algo256/blake2s.cu sph/blake2s.c \
|
||||
Algo256/bmw.cu Algo256/cuda_bmw.cu \
|
||||
crypto/xmr-rpc.cpp crypto/wildkeccak-cpu.cpp crypto/wildkeccak.cu \
|
||||
crypto/cryptolight.cu crypto/cryptolight-core.cu crypto/cryptolight-cpu.cpp \
|
||||
crypto/cryptonight.cu crypto/cryptonight-core.cu crypto/cryptonight-extra.cu \
|
||||
crypto/cryptonight-cpu.cpp crypto/oaes_lib.cpp crypto/aesb.cpp crypto/cpu/c_keccak.c \
|
||||
JHA/jha.cu JHA/jackpotcoin.cu JHA/cuda_jha_keccak512.cu \
|
||||
JHA/cuda_jha_compactionTest.cu cuda_checkhash.cu \
|
||||
quark/cuda_jh512.cu quark/cuda_quark_blake512.cu quark/cuda_quark_groestl512.cu quark/cuda_skein512.cu \
|
||||
quark/cuda_bmw512.cu quark/cuda_quark_keccak512.cu \
|
||||
quark/quarkcoin.cu quark/animecoin.cu \
|
||||
quark/cuda_quark_compactionTest.cu \
|
||||
cuda_nist5.cu blake32.cu pentablake.cu \
|
||||
quark/nist5.cu \
|
||||
quark/quarkcoin.cu quark/cuda_quark_compactionTest.cu \
|
||||
neoscrypt/neoscrypt.cpp neoscrypt/neoscrypt-cpu.c neoscrypt/cuda_neoscrypt.cu \
|
||||
pentablake.cu skein.cu cuda_skeincoin.cu skein2.cpp zr5.cu \
|
||||
skunk/skunk.cu skunk/cuda_skunk.cu skunk/cuda_skunk_streebog.cu \
|
||||
sha256/sha256d.cu sha256/cuda_sha256d.cu sha256/sha256t.cu sha256/cuda_sha256t.cu \
|
||||
sia/sia.cu sia/sia-rpc.cpp sph/blake2b.c \
|
||||
sph/bmw.c sph/blake.c sph/groestl.c sph/jh.c sph/keccak.c sph/skein.c \
|
||||
sph/cubehash.c sph/echo.c sph/luffa.c sph/sha2.c sph/shavite.c sph/simd.c \
|
||||
sph/hamsi.c sph/hamsi_helper.c sph/sph_hamsi.h \
|
||||
sph/hamsi.c sph/hamsi_helper.c sph/streebog.c \
|
||||
sph/shabal.c sph/whirlpool.c sph/sha2big.c sph/haval.c \
|
||||
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/doom.cu \
|
||||
x11/x11.cu x11/fresh.cu x11/cuda_x11_luffa512.cu x11/cuda_x11_cubehash512.cu \
|
||||
sph/ripemd.c sph/sph_sha2.c \
|
||||
polytimos.cu \
|
||||
lbry/lbry.cu lbry/cuda_sha256_lbry.cu lbry/cuda_sha512_lbry.cu lbry/cuda_lbry_merged.cu \
|
||||
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/luffa.cu \
|
||||
tribus/tribus.cu tribus/cuda_echo512_final.cu \
|
||||
x11/x11.cu x12/x12.cu x11/fresh.cu x11/cuda_x11_luffa512.cu x11/cuda_x11_cubehash512.cu \
|
||||
x11/cuda_x11_shavite512.cu x11/cuda_x11_simd512.cu x11/cuda_x11_echo.cu \
|
||||
x11/cuda_x11_luffa512_Cubehash.cu x11/x11evo.cu x11/timetravel.cu x11/bitcore.cu \
|
||||
x13/x13.cu x13/cuda_x13_hamsi512.cu x13/cuda_x13_fugue512.cu \
|
||||
x13/hsr.cu x13/cuda_hsr_sm3.cu x13/sm3.c \
|
||||
x15/x14.cu x15/x15.cu x15/cuda_x14_shabal512.cu x15/cuda_x15_whirlpool.cu \
|
||||
x15/whirlpool.cu \
|
||||
x17/x17.cu x17/cuda_x17_haval512.cu x17/cuda_x17_sha512.cu \
|
||||
x11/s3.cu
|
||||
x15/whirlpool.cu x15/cuda_x15_whirlpool_sm3.cu \
|
||||
x16/x16r.cu x16/x16s.cu x16/cuda_x16_echo512.cu x16/cuda_x16_fugue512.cu \
|
||||
x16/cuda_x16_shabal512.cu x16/cuda_x16_simd512_80.cu \
|
||||
x16/cuda_x16_echo512_64.cu \
|
||||
x17/x17.cu x17/hmq17.cu x17/cuda_x17_haval256.cu x17/cuda_x17_sha512.cu \
|
||||
phi/phi.cu phi/phi2.cu phi/cuda_phi2.cu phi/cuda_phi2_cubehash512.cu x11/cuda_streebog_maxwell.cu \
|
||||
x11/c11.cu x11/s3.cu x11/sib.cu x11/veltor.cu x11/cuda_streebog.cu
|
||||
|
||||
# scrypt
|
||||
ccminer_SOURCES += scrypt.cpp scrypt-jane.cpp \
|
||||
scrypt/blake.cu scrypt/keccak.cu scrypt/sha256.cu \
|
||||
scrypt/salsa_kernel.cu scrypt/test_kernel.cu \
|
||||
scrypt/fermi_kernel.cu scrypt/kepler_kernel.cu \
|
||||
scrypt/nv_kernel.cu scrypt/nv_kernel2.cu scrypt/titan_kernel.cu
|
||||
|
||||
if HAVE_NVML
|
||||
nvml_defs = -DUSE_WRAPNVML
|
||||
nvml_libs = -ldl
|
||||
endif
|
||||
|
||||
if HAVE_WINDOWS
|
||||
ccminer_SOURCES += compat/winansi.c
|
||||
endif
|
||||
|
||||
ccminer_LDFLAGS = $(PTHREAD_FLAGS) @CUDA_LDFLAGS@
|
||||
ccminer_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ @CUDA_LIBS@ @OPENMP_CFLAGS@ @LIBS@
|
||||
ccminer_CPPFLAGS = @LIBCURL_CPPFLAGS@ @OPENMP_CFLAGS@ $(CPPFLAGS) $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) -DSCRYPT_KECCAK512 -DSCRYPT_CHACHA -DSCRYPT_CHOOSE_COMPILETIME
|
||||
ccminer_LDFLAGS = $(PTHREAD_FLAGS) @CUDA_LDFLAGS@
|
||||
ccminer_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ @CUDA_LIBS@ @OPENMP_CFLAGS@ @LIBS@ $(nvml_libs)
|
||||
ccminer_CPPFLAGS = @LIBCURL_CPPFLAGS@ @OPENMP_CFLAGS@ $(CPPFLAGS) $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) $(DEF_INCLUDES) $(nvml_defs)
|
||||
|
||||
nvcc_ARCH = -gencode=arch=compute_50,code=\"sm_50,compute_50\"
|
||||
if HAVE_OSX
|
||||
ccminer_CPPFLAGS += -I/usr/local/llvm/lib/clang/4.0.0/include
|
||||
ccminer_LDFLAGS += -L/usr/local/llvm/lib
|
||||
ccminer_LDADD += -lomp
|
||||
endif
|
||||
|
||||
#ccminer_CPPFLAGS += -DUSE_LIBSODIUM
|
||||
#ccminer_LDFLAGS += -Lequi/lib
|
||||
#ccminer_LDADD += -lsodium
|
||||
ccminer_LDADD += -lcuda
|
||||
|
||||
nvcc_ARCH :=
|
||||
#nvcc_ARCH += -gencode=arch=compute_61,code=\"sm_61,compute_61\"
|
||||
nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
|
||||
nvcc_ARCH += -gencode=arch=compute_50,code=\"sm_50,compute_50\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
|
||||
#nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\"
|
||||
|
||||
nvcc_FLAGS = $(nvcc_ARCH) -I . @CUDA_CFLAGS@
|
||||
nvcc_FLAGS = $(nvcc_ARCH) @CUDA_INCLUDES@ -I. @CUDA_CFLAGS@
|
||||
nvcc_FLAGS += $(JANSSON_INCLUDES) --ptxas-options="-v"
|
||||
|
||||
# we're now targeting all major compute architectures within one binary.
|
||||
.cu.o:
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=128 -o $@ -c $<
|
||||
|
||||
blake32.o: blake32.cu
|
||||
Algo256/blake256.o: Algo256/blake256.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
keccak/cuda_keccak256.o: keccak/cuda_keccak256.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=92 -o $@ -c $<
|
||||
Algo256/cuda_bmw.o: Algo256/cuda_bmw.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=76 -o $@ -c $<
|
||||
|
||||
crypto/cryptonight-core.o: crypto/cryptonight-core.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
crypto/cryptonight-extra.o: crypto/cryptonight-extra.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -o $@ -c $<
|
||||
|
||||
heavy/cuda_hefty1.o: heavy/cuda_hefty1.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
qubit/qubit_luffa512.o: qubit/qubit_luffa512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
@@ -81,24 +151,54 @@ qubit/qubit_luffa512.o: qubit/qubit_luffa512.cu
|
||||
x11/cuda_x11_luffa512.o: x11/cuda_x11_luffa512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
x11/cuda_x11_echo.o: x11/cuda_x11_echo.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
x11/cuda_x11_luffa512_Cubehash.o: x11/cuda_x11_luffa512_Cubehash.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=76 -o $@ -c $<
|
||||
|
||||
# Shavite compiles faster with 128 regs
|
||||
x11/cuda_x11_shavite512.o: x11/cuda_x11_shavite512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -I cudpp-2.1/include --maxrregcount=128 -o $@ -c $<
|
||||
x11/cuda_x11_simd512.o: x11/cuda_x11_simd512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -Xcompiler -Wno-unused-variable -o $@ -c $<
|
||||
|
||||
x13/cuda_x13_hamsi512.o: x13/cuda_x13_hamsi512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=72 -o $@ -c $<
|
||||
|
||||
x17/cuda_x17_sha512.o: x17/cuda_x17_sha512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
quark/cuda_quark_blake512.o: quark/cuda_quark_blake512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -I cudpp-2.1/include --maxrregcount=80 -o $@ -c $<
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
quark/cuda_jh512.o: quark/cuda_jh512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
quark/cuda_quark_keccak512.o: quark/cuda_quark_keccak512.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -I cudpp-2.1/include --maxrregcount=88 -o $@ -c $<
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=88 -o $@ -c $<
|
||||
|
||||
quark/cuda_quark_compactionTest.o: quark/cuda_quark_compactionTest.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -I cudpp-2.1/include --maxrregcount=80 -o $@ -c $<
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
JHA/cuda_jha_compactionTest.o: JHA/cuda_jha_compactionTest.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -I cudpp-2.1/include --maxrregcount=80 -o $@ -c $<
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=80 -o $@ -c $<
|
||||
|
||||
# This object does not use cuda device code but call the different kernels (autotune)
|
||||
scrypt/salsa_kernel.o: scrypt/salsa_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
# These kernels are for older devices (SM)
|
||||
|
||||
scrypt/test_kernel.o: scrypt/test_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/fermi_kernel.o: scrypt/fermi_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/kepler_kernel.o: scrypt/kepler_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/nv_kernel.o: scrypt/nv_kernel.cu
|
||||
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_30,code=\"sm_30,compute_30\" -o $@ -c $<
|
||||
|
||||
scrypt/titan_kernel.o: scrypt/titan_kernel.cu
|
||||
$(NVCC) $(nvcc_FLAGS) -gencode=arch=compute_35,code=\"sm_35,compute_35\" -o $@ -c $<
|
||||
|
||||
skein.o: skein.cu
|
||||
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
ccminer
|
||||
=======
|
||||
# ccminer
|
||||
|
||||
Based on Christian Buchner's & Christian H.'s CUDA project
|
||||
Based on Christian Buchner's & Christian H.'s CUDA project, no more active on github since 2014.
|
||||
|
||||
Fork by tpruvot@github with X14,X15,X17,WHIRL and Blake256 support (NEOS + BlakeCoin), and some others, check the [README.txt](README.txt)
|
||||
Check the [README.txt](README.txt) for the additions
|
||||
|
||||
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
|
||||
[](https://tip4commit.com/github/tpruvot/ccminer)
|
||||
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo (tpruvot)
|
||||
|
||||
A part of the recent algos were originally wrote by [djm34](https://github.com/djm34).
|
||||
A part of the recent algos were originally written by [djm34](https://github.com/djm34) and [alexis78](https://github.com/alexis78)
|
||||
|
||||
This variant was tested and built on Linux (ubuntu server 14.04) and VStudio 2013 on Windows 7.
|
||||
This variant was tested and built on Linux (ubuntu server 14.04, 16.04, Fedora 22 to 25)
|
||||
It is also built for Windows 7 to 10 with VStudio 2013, to stay compatible with Windows 7 and Vista.
|
||||
|
||||
Note that the x86 releases are generally faster than x64 ones on Windows.
|
||||
Note that the x86 releases are generally faster than x64 ones on Windows, but that tend to change with the recent drivers.
|
||||
|
||||
The recommended CUDA Toolkit version was the [6.5.19](http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.19_windows_general_64.exe), but some light algos could be faster with the version 7.5 and 8.0 (like lbry, decred and skein).
|
||||
|
||||
About source code dependencies
|
||||
------------------------------
|
||||
@@ -20,9 +21,7 @@ About source code dependencies
|
||||
This project requires some libraries to be built :
|
||||
|
||||
- OpenSSL (prebuilt for win)
|
||||
|
||||
- Curl (prebuilt for win)
|
||||
|
||||
- pthreads (prebuilt for win)
|
||||
|
||||
The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64 platforms (windows).
|
||||
@@ -30,5 +29,8 @@ The tree now contains recent prebuilt openssl and curl .lib for both x86 and x64
|
||||
To rebuild them, you need to clone this repository and its submodules :
|
||||
git clone https://github.com/peters/curl-for-windows.git compat/curl-for-windows
|
||||
|
||||
There is also a [Tutorial for windows](http://cudamining.co.uk/url/tutorials/id/3) on [CudaMining](http://cudamining.co.uk) website.
|
||||
|
||||
Compile on Linux
|
||||
----------------
|
||||
|
||||
Please see [INSTALL](https://github.com/tpruvot/ccminer/blob/linux/INSTALL) file or [project Wiki](https://github.com/tpruvot/ccminer/wiki/Compatibility)
|
||||
+383
-37
@@ -1,16 +1,14 @@
|
||||
|
||||
ccMiner release 1.4.7-tpruvot (Nov 2014) - "Blake update"
|
||||
ccminer 2.2.6 "phi2 and allium"
|
||||
---------------------------------------------------------------
|
||||
|
||||
***************************************************************
|
||||
If you find this tool useful and like to support its continued
|
||||
If you find this tool useful and like to support its continuous
|
||||
development, then consider a donation.
|
||||
|
||||
tpruvot@github:
|
||||
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
|
||||
DRK : XeVrkPrWB7pDbdFLfKhF1Z3xpqhsx6wkH3
|
||||
NEOS : NaEcVrdzoCWHUYXb7X8QoafoKS9UV69Yk4
|
||||
XST : S9TqZucWgT6ajZLDBxQnHUtmkotCEHn9z9
|
||||
BTC : 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
|
||||
DCR : DsUCcACGcyP8McNMRXQwbtpDxaVUYLDQDeU
|
||||
|
||||
DJM34:
|
||||
BTC donation address: 1NENYmxwZGHsKFmyjTc5WferTn5VTFb7Ze
|
||||
@@ -25,19 +23,38 @@ cbuchner v1.2:
|
||||
|
||||
This is a CUDA accelerated mining application which handle :
|
||||
|
||||
Decred (Blake256 14-rounds - 180 bytes)
|
||||
HeavyCoin & MjollnirCoin
|
||||
FugueCoin
|
||||
GroestlCoin & Myriad-Groestl
|
||||
JackpotCoin
|
||||
Lbry Credits
|
||||
JackpotCoin (JHA)
|
||||
QuarkCoin family & AnimeCoin
|
||||
TalkCoin
|
||||
DarkCoin and other X11 coins
|
||||
NEOS blake (256 14-rounds)
|
||||
Chaincoin and Flaxscript (C11)
|
||||
Saffroncoin blake (256 14-rounds)
|
||||
BlakeCoin (256 8-rounds)
|
||||
Qubit (Digibyte, ...)
|
||||
Luffa (Joincoin)
|
||||
Keccak (Maxcoin)
|
||||
Deep, Doom and Qubit
|
||||
Pentablake (Blake 512 x5)
|
||||
S3 (OneCoin)
|
||||
1Coin Triple S
|
||||
Neoscrypt (FeatherCoin)
|
||||
Revolver (X11evo)
|
||||
Scrypt and Scrypt:N
|
||||
Scrypt-Jane (Chacha)
|
||||
Sibcoin (sib)
|
||||
Skein (Skein + SHA)
|
||||
Signatum (Skein cubehash fugue Streebog)
|
||||
Tribus (JH, keccak, simd)
|
||||
Woodcoin (Double Skein)
|
||||
Vanilla (Blake256 8-rounds - double sha256)
|
||||
Vertcoin Lyra2RE
|
||||
Ziftrcoin (ZR5)
|
||||
Boolberry (Wild Keccak)
|
||||
Monero (Cryptonight)
|
||||
Aeon (Cryptonight-lite)
|
||||
|
||||
where some of these coins have a VERY NOTABLE nVidia advantage
|
||||
over competing AMD (OpenCL Only) implementations.
|
||||
@@ -52,43 +69,82 @@ that the most of our comments are in german.
|
||||
|
||||
>>> Command Line Interface <<<
|
||||
|
||||
This code is based on the pooler cpuminer 2.3.2 release and inherits
|
||||
This code is based on the pooler cpuminer and inherits
|
||||
its command line interface and options.
|
||||
|
||||
-a, --algo=ALGO specify the algorithm to use
|
||||
anime use to mine Animecoin
|
||||
blake use to mine NEOS (Blake 256)
|
||||
allium use to mine Garlic
|
||||
bastion use to mine Joincoin
|
||||
bitcore use to mine Bitcore's Timetravel10
|
||||
blake use to mine Saffroncoin (Blake256)
|
||||
blakecoin use to mine Old Blake 256
|
||||
blake2s use to mine Nevacoin (Blake2-S 256)
|
||||
bmw use to mine Midnight
|
||||
cryptolight use to mine AEON cryptonight (MEM/2)
|
||||
cryptonight use to mine XMR cryptonight, Bytecoin, Dash, DigitalNote, etc
|
||||
c11/flax use to mine Chaincoin and Flax
|
||||
decred use to mine Decred 180 bytes Blake256-14
|
||||
deep use to mine Deepcoin
|
||||
dmd-gr use to mine Diamond-Groestl
|
||||
equihash use to mine ZEC, HUSH and KMD
|
||||
fresh use to mine Freshcoin
|
||||
fugue256 use to mine Fuguecoin
|
||||
groestl use to mine Groestlcoin
|
||||
heavy use to mine Heavycoin
|
||||
jackpot use to mine Jackpotcoin
|
||||
hsr use to mine Hshare
|
||||
jackpot use to mine Sweepcoin
|
||||
keccak use to mine Maxcoin
|
||||
luffa use to mine Doomcoin
|
||||
mjollnir use to mine Mjollnircoin
|
||||
keccakc use to mine CreativeCoin
|
||||
lbry use to mine LBRY Credits
|
||||
luffa use to mine Joincoin
|
||||
lyra2 use to mine CryptoCoin
|
||||
lyra2v2 use to mine Vertcoin
|
||||
lyra2z use to mine Zerocoin (XZC)
|
||||
myr-gr use to mine Myriad-Groest
|
||||
neoscrypt use to mine FeatherCoin, Trezarcoin, Orbitcoin, etc
|
||||
nist5 use to mine TalkCoin
|
||||
penta use to mine Joincoin / Pentablake
|
||||
phi2 use to mine LUXCoin
|
||||
polytimos use to mine Polytimos
|
||||
quark use to mine Quarkcoin
|
||||
qubit use to mine Qubit Algo
|
||||
s3 use to mine 1coin
|
||||
whirl use to mine Whirlcoin
|
||||
qubit use to mine Qubit
|
||||
scrypt use to mine Scrypt coins (Litecoin, Dogecoin, etc)
|
||||
scrypt:N use to mine Scrypt-N (:10 for 2048 iterations)
|
||||
scrypt-jane use to mine Chacha coins like Cache and Ultracoin
|
||||
s3 use to mine 1coin (ONE)
|
||||
sha256t use to mine OneCoin (OC)
|
||||
sia use to mine SIA
|
||||
sib use to mine Sibcoin
|
||||
skein use to mine Skeincoin
|
||||
skein2 use to mine Woodcoin
|
||||
skunk use to mine Signatum
|
||||
timetravel use to mine MachineCoin
|
||||
tribus use to mine Denarius
|
||||
x11evo use to mine Revolver
|
||||
x11 use to mine DarkCoin
|
||||
x14 use to mine X14Coin
|
||||
x12 use to mine GalaxyCash
|
||||
x13 use to mine X13
|
||||
x14 use to mine X14
|
||||
x15 use to mine Halcyon
|
||||
x16r use to mine Raven
|
||||
x16s use to mine Pigeon and Eden
|
||||
x17 use to mine X17
|
||||
vanilla use to mine Vanilla (Blake256)
|
||||
veltor use to mine VeltorCoin
|
||||
whirlpool use to mine Joincoin
|
||||
wildkeccak use to mine Boolberry (Stratum only)
|
||||
zr5 use to mine ZiftrCoin
|
||||
|
||||
-d, --devices gives a comma separated list of CUDA device IDs
|
||||
to operate on. Device IDs start counting from 0!
|
||||
Alternatively give string names of your card like
|
||||
gtx780ti or gt640#2 (matching 2nd gt640 in the PC).
|
||||
|
||||
-f, --diff Divide difficulty by this factor (std is 1) \n\
|
||||
-v, --vote Heavycoin block vote (default: 512)
|
||||
-o, --url=URL URL of mining server (default: " DEF_RPC_URL ")
|
||||
-i, --intensity=N[,N] GPU threads per call 8-25 (2^N + F, default: 0=auto)
|
||||
Decimals and multiple values are allowed for fine tuning
|
||||
--cuda-schedule Set device threads scheduling mode (default: auto)
|
||||
-f, --diff-factor Divide difficulty by this factor (default 1.0)
|
||||
-m, --diff-multiplier Multiply difficulty by this value (default 1.0)
|
||||
-o, --url=URL URL of mining server
|
||||
-O, --userpass=U:P username:password pair for mining server
|
||||
-u, --user=USERNAME username for mining server
|
||||
-p, --pass=PASSWORD password for mining server
|
||||
@@ -98,44 +154,99 @@ its command line interface and options.
|
||||
-r, --retries=N number of times to retry if a network call fails
|
||||
(default: retry indefinitely)
|
||||
-R, --retry-pause=N time to pause between retries, in seconds (default: 15)
|
||||
-T, --timeout=N network timeout, in seconds (default: 270)
|
||||
--shares-limit maximum shares to mine before exiting the program.
|
||||
--time-limit maximum time [s] to mine before exiting the program.
|
||||
-T, --timeout=N network timeout, in seconds (default: 300)
|
||||
-s, --scantime=N upper bound on time spent scanning current work when
|
||||
long polling is unavailable, in seconds (default: 5)
|
||||
--submit-stale ignore stale job checks, may create more rejected shares
|
||||
-n, --ndevs list cuda devices
|
||||
-N, --statsavg number of samples used to display hashrate (default: 30)
|
||||
--no-gbt disable getblocktemplate support (height check in solo)
|
||||
--no-longpoll disable X-Long-Polling support
|
||||
--no-stratum disable X-Stratum support
|
||||
-q, --quiet disable per-thread hashmeter output
|
||||
--no-color disable colored output
|
||||
-D, --debug enable debug output
|
||||
-P, --protocol-dump verbose dump of protocol-level activities
|
||||
-b, --api-bind=port IP:port for the miner API (default: 127.0.0.1:4068), 0 disabled
|
||||
--api-remote Allow remote control, like pool switching, imply --api-allow=0/0
|
||||
--api-allow=... IP/mask of the allowed api client(s), 0/0 for all
|
||||
--max-temp=N Only mine if gpu temp is less than specified value
|
||||
--max-rate=N[KMG] Only mine if net hashrate is less than specified value
|
||||
--max-diff=N Only mine if net difficulty is less than specified value
|
||||
--max-log-rate Interval to reduce per gpu hashrate logs (default: 3)
|
||||
--pstate=0 will force the Geforce 9xx to run in P0 P-State
|
||||
--plimit=150W set the gpu power limit, allow multiple values for N cards
|
||||
on windows this parameter use percentages (like OC tools)
|
||||
--tlimit=85 Set the gpu thermal limit (windows only)
|
||||
--keep-clocks prevent reset clocks and/or power limit on exit
|
||||
--hide-diff Hide submitted shares diff and net difficulty
|
||||
-B, --background run the miner in the background
|
||||
--benchmark run in offline benchmark mode
|
||||
--cputest debug hashes from cpu algorithms
|
||||
--cpu-affinity set process affinity to specific cpu core(s) mask
|
||||
--cpu-priority set process priority (default: 0 idle, 2 normal to 5 highest)
|
||||
-c, --config=FILE load a JSON-format configuration file
|
||||
--no-color disable colored console output
|
||||
can be from an url with the http:// prefix
|
||||
-V, --version display version information and exit
|
||||
-h, --help display this help text and exit
|
||||
|
||||
|
||||
Scrypt specific options:
|
||||
-l, --launch-config gives the launch configuration for each kernel
|
||||
in a comma separated list, one per device.
|
||||
--interactive comma separated list of flags (0/1) specifying
|
||||
which of the CUDA device you need to run at inter-
|
||||
active frame rates (because it drives a display).
|
||||
-L, --lookup-gap Divides the per-hash memory requirement by this factor
|
||||
by storing only every N'th value in the scratchpad.
|
||||
Default is 1.
|
||||
--texture-cache comma separated list of flags (0/1/2) specifying
|
||||
which of the CUDA devices shall use the texture
|
||||
cache for mining. Kepler devices may profit.
|
||||
--no-autotune disable auto-tuning of kernel launch parameters
|
||||
|
||||
CryptoNight specific options:
|
||||
-l, --launch-config gives the launch configuration for each kernel
|
||||
in a comma separated list, one per device.
|
||||
--bfactor=[0-12] Run Cryptonight core kernel in smaller pieces,
|
||||
From 0 (ui freeze) to 12 (smooth), win default is 11
|
||||
This is a per-device setting like the launch config.
|
||||
|
||||
Wildkeccak specific:
|
||||
-l, --launch-config gives the launch configuration for each kernel
|
||||
in a comma separated list, one per device.
|
||||
-k, --scratchpad url Url used to download the scratchpad cache.
|
||||
|
||||
|
||||
>>> Examples <<<
|
||||
|
||||
|
||||
Example for Heavycoin Mining on heavycoinpool.com with a single gpu in your system
|
||||
ccminer.exe -t 1 -a heavy -o stratum+tcp://stratum01.heavycoinpool.com:5333 -u <<username.worker>> -p <<workerpassword>> -v 8
|
||||
ccminer -t 1 -a heavy -o stratum+tcp://stratum01.heavycoinpool.com:5333 -u <<username.worker>> -p <<workerpassword>> -v 8
|
||||
|
||||
|
||||
Example for Heavycoin Mining on hvc.1gh.com with a dual gpu in your system
|
||||
ccminer.exe -t 2 -a heavy -o stratum+tcp://hvcpool.1gh.com:5333 -u <<WALLET>> -p x -v 8
|
||||
ccminer -t 2 -a heavy -o stratum+tcp://hvcpool.1gh.com:5333/ -u <<WALLET>> -p x -v 8
|
||||
|
||||
|
||||
Example for Fuguecoin solo-mining with 4 gpu's in your system and a Fuguecoin-wallet running on localhost
|
||||
ccminer.exe -q -s 1 -t 4 -a fugue256 -o http://localhost:9089 -u <<myusername>> -p <<mypassword>>
|
||||
ccminer -q -s 1 -t 4 -a fugue256 -o http://localhost:9089/ -u <<myusername>> -p <<mypassword>>
|
||||
|
||||
|
||||
Example for Fuguecoin pool mining on dwarfpool.com with all your GPUs
|
||||
ccminer.exe -q -a fugue256 -o stratum+tcp://erebor.dwarfpool.com:3340 -u YOURWALLETADDRESS.1 -p YOUREMAILADDRESS
|
||||
ccminer -q -a fugue256 -o stratum+tcp://erebor.dwarfpool.com:3340/ -u YOURWALLETADDRESS.1 -p YOUREMAILADDRESS
|
||||
|
||||
|
||||
Example for Groestlcoin solo mining
|
||||
ccminer.exe -q -s 1 -a groestl -o http://127.0.0.1:1441 -u USERNAME -p PASSWORD
|
||||
ccminer -q -s 1 -a groestl -o http://127.0.0.1:1441/ -u USERNAME -p PASSWORD
|
||||
|
||||
Example for Boolberry
|
||||
ccminer -a wildkeccak -o stratum+tcp://bbr.suprnova.cc:7777 -u tpruvot.donate -p x -k http://bbr.suprnova.cc/scratchpad.bin -l 64x360
|
||||
|
||||
Example for Scrypt-N (2048) on Nicehash
|
||||
ccminer -a scrypt:10 -o stratum+tcp://stratum.nicehash.com:3335 -u 3EujYFcoBzWvpUEvbe3obEG95mBuU88QBD -p x
|
||||
|
||||
For solo-mining you typically use -o http://127.0.0.1:xxxx where xxxx represents
|
||||
the rpcport number specified in your wallet's .conf file and you have to pass the same username
|
||||
@@ -143,18 +254,253 @@ and password with -O (or -u -p) as specified in the wallet config.
|
||||
|
||||
The wallet must also be started with the -server option and/or with the server=1 flag in the .conf file
|
||||
|
||||
>>> Configuration files <<<
|
||||
|
||||
With the -c parameter you can use a json config file to set your prefered settings.
|
||||
An example is present in source tree, and is also the default one when no command line parameters are given.
|
||||
This allow you to run the miner without batch/script.
|
||||
|
||||
|
||||
>>> API and Monitoring <<<
|
||||
|
||||
With the -b parameter you can open your ccminer to your network, use -b 0.0.0.0:4068 if required.
|
||||
On windows, setting 0.0.0.0 will ask firewall permissions on the first launch. Its normal.
|
||||
|
||||
Default API feature is only enabled for localhost queries by default, on port 4068.
|
||||
|
||||
You can test this api on linux with "telnet <miner-ip> 4068" and type "help" to list the commands.
|
||||
Default api format is delimited text. If required a php json wrapper is present in api/ folder.
|
||||
|
||||
I plan to add a json format later, if requests are formatted in json too..
|
||||
|
||||
|
||||
>>> Additional Notes <<<
|
||||
|
||||
This code should be running on nVidia GPUs ranging from compute capability
|
||||
3.0 up to compute capability 3.5. Support for Compute 2.0 has been dropped
|
||||
3.0 up to compute capability 5.2. Support for Compute 2.0 has been dropped
|
||||
so we can more efficiently implement new algorithms using the latest hardware
|
||||
features.
|
||||
|
||||
>>> RELEASE HISTORY <<<
|
||||
June 10th 2018 v2.2.6
|
||||
New phi2 algo for LUX
|
||||
New allium algo for Garlic
|
||||
|
||||
Nov 2014 v1.4.7
|
||||
Apr. 02nd 2018 v2.2.5
|
||||
New x16r algo for Raven
|
||||
New x16s algo for Pigeon and Eden
|
||||
New x12 algo for Galaxycash
|
||||
Equihash (SIMT) sync issues for the Volta generation
|
||||
|
||||
Jan. 04th 2018 v2.2.4
|
||||
Improve lyra2v2
|
||||
Higher keccak default intensity
|
||||
Drop SM 2.x support by default, for CUDA 9 and more recent
|
||||
|
||||
Dec. 04th 2017 v2.2.3
|
||||
Polytimos Algo
|
||||
Handle keccakc variant (with refreshed sha256d merkle)
|
||||
Optimised keccak for SM5+, based on alexis improvements
|
||||
|
||||
Oct. 09th 2017 v2.2.2
|
||||
Import and clean the hsr algo (x13 + custom hash)
|
||||
Import and optimise phi algo from LuxCoin repository
|
||||
Improve sib algo too for maxwell and pascal cards
|
||||
Small fix to handle more than 9 cards on linux (-d 10+)
|
||||
Attempt to free equihash memory "properly"
|
||||
--submit-stale parameter for supernova pool (which change diff too fast)
|
||||
|
||||
Sep. 01st 2017 v2.2.1
|
||||
Improve tribus algo on recent cards (up to +10%)
|
||||
|
||||
Aug. 13th 2017 v2.2
|
||||
New skunk algo, using the heavy streebog algorithm
|
||||
Enhance tribus algo (+10%)
|
||||
equihash protocol enhancement on yiimp.ccminer.org and zpool.ca
|
||||
|
||||
June 16th 2017 v2.1-tribus
|
||||
Interface equihash algo with djeZo solver (from nheqminer 0.5c)
|
||||
New api parameters (and multicast announces for local networks)
|
||||
New tribus algo
|
||||
|
||||
May. 14th 2017 v2.0
|
||||
Handle cryptonight, wildkeccak and cryptonight-lite
|
||||
Add a serie of new algos: timetravel, bastion, hmq1725, sha256t
|
||||
Import lyra2z from djm34 work...
|
||||
Rework the common skein512 (used in most algos except skein ;)
|
||||
Upgrade whirlpool algo with alexis version (2x faster)
|
||||
Store the share diff of second nonce(s) in most algos
|
||||
Hardware monitoring thread to get more accurate power readings
|
||||
Small changes for the quiet mode & max-log-rate to reduce logs
|
||||
Add bitcore and a compatible jha algo
|
||||
|
||||
Dec. 21th 2016 v1.8.4
|
||||
Improve streebog based algos, veltor and sib (from alexis work)
|
||||
Blake2s greetly improved (3x), thanks to alexis too...
|
||||
|
||||
Sep. 28th 2016 v1.8.3
|
||||
show intensity on startup for each cards
|
||||
show-diff is now used by default, use --hide-diff if not wanted
|
||||
|
||||
Sep. 22th 2016 v1.8.2
|
||||
lbry improvements by Alexis Provos
|
||||
Prevent Windows hibernate while mining
|
||||
veltor algo (basic implementation)
|
||||
|
||||
Aug. 10th 2016 v1.8.1
|
||||
SIA Blake2-B Algo (getwork over stratum for Suprnova)
|
||||
SIA Nanopool RPC (getwork over http)
|
||||
Update also the older lyra2 with Nanashi version
|
||||
|
||||
July 20th 2016 v1.8.0
|
||||
Pascal support with cuda 8
|
||||
lbry new multi sha / ripemd algo (LBC)
|
||||
x11evo algo (XRE)
|
||||
Lyra2v2, Neoscrypt and Decred improvements
|
||||
Enhance windows NVAPI clock and power limits
|
||||
Led support for mining/shares activity on windows
|
||||
|
||||
May 18th 2016 v1.7.6
|
||||
Decred vote support
|
||||
X17 cleanup and improvement
|
||||
Add mining.ping stratum method and handle unknown methods
|
||||
Implement a pool stats/benchmark mode (-p stats on yiimp)
|
||||
Add --shares-limit parameter, can be used for benchmarks
|
||||
|
||||
Mar. 13th 2016 v1.7.5
|
||||
Blake2S Algo (NEVA/OXEN)
|
||||
|
||||
Feb. 28th 2016 v1.7.4 (1.7.3 was a preview, not official)
|
||||
Decred simplified stratum (getwork over stratum)
|
||||
Vanilla kernel by MrMad
|
||||
Drop/Disable WhirlpoolX
|
||||
|
||||
Feb. 11th 2016 v1.7.2
|
||||
Decred Algo (longpoll only)
|
||||
Blake256 improvements/cleanup
|
||||
|
||||
Jan. 26th 2016 v1.7.1
|
||||
Implement sib algo (X11 + Russian Streebog-512/GOST)
|
||||
Whirlpool speed x2 with the midstate precompute
|
||||
Small bug fixes about device ids mapping (and vendor names)
|
||||
Add Vanilla algo (Blake256 8-rounds - double sha256)
|
||||
|
||||
Nov. 06th 2015 v1.7
|
||||
Improve old devices compatibility (x11, lyra2v2, quark, qubit...)
|
||||
Add windows support for SM 2.1 and drop SM 3.5 (x86)
|
||||
Improve lyra2 (v1/v2) cuda implementations
|
||||
Improve most common algos on SM5+ with sp blake kernel
|
||||
Restore whirlpool algo (and whirlcoin variant)
|
||||
Prepare algo/pool switch ability, trivial method
|
||||
Add --benchmark alone to run a benchmark for all algos
|
||||
Add --cuda-schedule parameter
|
||||
Add --show-diff parameter, which display shares diff,
|
||||
and is able to detect real solved blocks on pools.
|
||||
|
||||
Aug. 28th 2015 v1.6.6
|
||||
Allow to load remote config with curl (-c http://...)
|
||||
Add Lyra2REv2 algo (Vertcoin/Zoom)
|
||||
Restore WhirlpoolX algo (VNL)
|
||||
Drop Animecoin support
|
||||
Add bmw (Midnight) algo
|
||||
|
||||
July 06th 2015 v1.6.5-C11
|
||||
Nvml api power limits
|
||||
Add chaincoin c11 algo (used by Flaxscript too)
|
||||
Remove pluck algo
|
||||
|
||||
June 23th 2015 v1.6.5
|
||||
Handle Ziftrcoin PoK solo mining
|
||||
Basic compatibility with CUDA 7.0 (generally slower hashrate)
|
||||
Show gpus vendor names on linux (windows test branch is pciutils)
|
||||
Remove -v and -m short params specific to heavycoin
|
||||
Add --diff-multiplier (-m) and rename --diff to --diff-factor (-f)
|
||||
First steps to handle nvml application clocks and P0 on the GTX9xx
|
||||
Various improvements on multipool and cmdline parameters
|
||||
Optimize a bit qubit, deep, luffa, x11 and quark algos
|
||||
|
||||
May 26th 2015 v1.6.4
|
||||
Implement multi-pool support (failover and time rotate)
|
||||
try "ccminer -c pools.conf" to test the sample config
|
||||
Update the API to allow remote pool switching and pool stats
|
||||
Auto bind the api port to the first available when using default
|
||||
Try to compute network difficulty on pools too (for most algos)
|
||||
Drop Whirlpool and whirpoolx algos, no more used...
|
||||
|
||||
May 15th 2015 v1.6.3
|
||||
Import and adapt Neoscrypt from djm34 work (SM 5+ only)
|
||||
Conditional mining options based on gpu temp, network diff and rate
|
||||
background option implementation for windows too
|
||||
"Multithreaded" devices (-d 0,0) intensity and stats changes
|
||||
SM5+ Optimisation of skein based on sp/klaus method (+20%)
|
||||
|
||||
Apr. 21th 2015 v1.6.2
|
||||
Import Scrypt, Scrypt:N and Scrypt-jane from Cudaminer
|
||||
Add the --time-limit command line parameter
|
||||
|
||||
Apr. 14th 2015 v1.6.1
|
||||
Add the Double Skein Algo for Woodcoin
|
||||
Skein/Skein2 SM 3.0 devices support
|
||||
|
||||
Mar. 27th 2015 v1.6.0
|
||||
Add the ZR5 Algo for Ziftcoin
|
||||
Implement Skeincoin algo (skein + sha)
|
||||
Import pluck (djm34) and whirlpoolx (alexis78) algos
|
||||
Hashrate units based on hashing rate values (Hs/kHs/MHs/GHs)
|
||||
Default config file (also help to debug without command line)
|
||||
Various small fixes
|
||||
|
||||
Feb. 11th 2015 v1.5.3
|
||||
Fix anime algo
|
||||
Allow a default config file in user or ccminer folder
|
||||
SM 2.1 windows binary (lyra2 and blake/blakecoin for the moment)
|
||||
|
||||
Jan. 24th 2015 v1.5.2
|
||||
Allow per device intensity, example: -i 20,19.5
|
||||
Add process CPU priority and affinity mask parameters
|
||||
Intelligent duplicate shares check feature (enabled if needed)
|
||||
api: Fan RPM (windows), Cuda threads count, linux kernel ver.
|
||||
More X11 optimisations from sp and KlausT
|
||||
SM 3.0 enhancements
|
||||
|
||||
Dec. 16th 2014 v1.5.1
|
||||
Add lyra2RE algo for Vertcoin based on djm34/vtc code
|
||||
Multiple shares support (2 for the moment)
|
||||
X11 optimisations (From klaust and sp-hash)
|
||||
HTML5 WebSocket api compatibility (see api/websocket.htm)
|
||||
Solo mode height checks with getblocktemplate rpc calls
|
||||
|
||||
Nov. 27th 2014 v1.5.0
|
||||
Upgrade compat jansson to 2.6 (for windows)
|
||||
Add pool mining.set_extranonce support
|
||||
Allow intermediate intensity with decimals
|
||||
Update prebuilt x86 openssl lib to 1.0.1i
|
||||
Fix heavy algo on linux (broken since 1.4)
|
||||
Some internal changes to use the C++ compiler
|
||||
New API 1.2 with some new commands (read only)
|
||||
Add some of sp x11/x15 optimisations (and tsiv x13)
|
||||
|
||||
Nov. 15th 2014 v1.4.9
|
||||
Support of nvml and nvapi(windows) to monitor gpus
|
||||
Fix (again) displayed hashrate for multi gpus systems
|
||||
Average is now made by card (30 scans of the card)
|
||||
Final API v1.1 (new fields + histo command)
|
||||
Add support of telnet queries "telnet 127.0.0.1 4068"
|
||||
add histo api command to get performance debug details
|
||||
Add a rig sample php ui using json wrapper (php)
|
||||
Restore quark/jackpot previous speed (differently)
|
||||
|
||||
Nov. 12th 2014 v1.4.8
|
||||
Add a basic API and a sample php json wrapper
|
||||
Add statsavg (def 20) and api-bind parameters
|
||||
|
||||
Nov. 11th 2014 v1.4.7
|
||||
Average hashrate (based on the 20 last scans)
|
||||
Rewrite blake algo
|
||||
Add the -i (gpu threads/intensity parameter)
|
||||
Add some X11 optimisations based on sp_ commits
|
||||
Fix quark reported hashrate and benchmark mode for some algos
|
||||
Enhance json config file param (int/float/false) (-c config.json)
|
||||
Update windows prebuilt curl to 7.38.0
|
||||
|
||||
Oct. 26th 2014 v1.4.6
|
||||
@@ -250,12 +596,12 @@ features.
|
||||
|
||||
Notable contributors to this application are:
|
||||
|
||||
Christian Buchner, Christian H. (Germany): CUDA implementation
|
||||
Christian Buchner, Christian H. (Germany): Initial CUDA implementation
|
||||
|
||||
djm34, tsiv : Recent CUDA algos
|
||||
djm34, tsiv, sp and klausT for cuda algos implementation and optimisation
|
||||
|
||||
Tanguy Pruvot : 750Ti tuning, blake, colors, general code cleanup/opts
|
||||
linux Config/Makefile and vstudio stuff...
|
||||
Tanguy Pruvot : 750Ti tuning, blake, colors, zr5, skein, general code cleanup
|
||||
API monitoring, linux Config/Makefile and vstudio libs...
|
||||
|
||||
and also many thanks to anyone else who contributed to the original
|
||||
cpuminer application (Jeff Garzik, pooler), it's original HVC-fork
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
#ifndef ALGOS_H
|
||||
#define ALGOS_H
|
||||
|
||||
#include <string.h>
|
||||
#include "compat.h"
|
||||
|
||||
enum sha_algos {
|
||||
ALGO_BLAKECOIN = 0,
|
||||
ALGO_BLAKE,
|
||||
ALGO_BLAKE2S,
|
||||
ALGO_ALLIUM,
|
||||
ALGO_BMW,
|
||||
ALGO_BASTION,
|
||||
ALGO_C11,
|
||||
ALGO_CRYPTOLIGHT,
|
||||
ALGO_CRYPTONIGHT,
|
||||
ALGO_DEEP,
|
||||
ALGO_DECRED,
|
||||
ALGO_DMD_GR,
|
||||
ALGO_EQUIHASH,
|
||||
ALGO_FRESH,
|
||||
ALGO_FUGUE256, /* Fugue256 */
|
||||
ALGO_GROESTL,
|
||||
ALGO_HEAVY, /* Heavycoin hash */
|
||||
ALGO_HMQ1725,
|
||||
ALGO_HSR,
|
||||
ALGO_KECCAK,
|
||||
ALGO_KECCAKC, /* refreshed Keccak with pool factor 256 */
|
||||
ALGO_JACKPOT,
|
||||
ALGO_JHA,
|
||||
ALGO_LBRY,
|
||||
ALGO_LUFFA,
|
||||
ALGO_LYRA2,
|
||||
ALGO_LYRA2v2,
|
||||
ALGO_LYRA2Z,
|
||||
ALGO_MJOLLNIR, /* Hefty hash */
|
||||
ALGO_MYR_GR,
|
||||
ALGO_NEOSCRYPT,
|
||||
ALGO_NIST5,
|
||||
ALGO_PENTABLAKE,
|
||||
ALGO_PHI,
|
||||
ALGO_PHI2,
|
||||
ALGO_POLYTIMOS,
|
||||
ALGO_QUARK,
|
||||
ALGO_QUBIT,
|
||||
ALGO_SCRYPT,
|
||||
ALGO_SCRYPT_JANE,
|
||||
ALGO_SHA256D,
|
||||
ALGO_SHA256T,
|
||||
ALGO_SIA,
|
||||
ALGO_SIB,
|
||||
ALGO_SKEIN,
|
||||
ALGO_SKEIN2,
|
||||
ALGO_SKUNK,
|
||||
ALGO_S3,
|
||||
ALGO_TIMETRAVEL,
|
||||
ALGO_TRIBUS,
|
||||
ALGO_BITCORE,
|
||||
ALGO_X11EVO,
|
||||
ALGO_X11,
|
||||
ALGO_X12,
|
||||
ALGO_X13,
|
||||
ALGO_X14,
|
||||
ALGO_X15,
|
||||
ALGO_X16R,
|
||||
ALGO_X16S,
|
||||
ALGO_X17,
|
||||
ALGO_VANILLA,
|
||||
ALGO_VELTOR,
|
||||
ALGO_WHIRLCOIN,
|
||||
ALGO_WHIRLPOOL,
|
||||
ALGO_WHIRLPOOLX,
|
||||
ALGO_WILDKECCAK,
|
||||
ALGO_ZR5,
|
||||
ALGO_MONERO,
|
||||
ALGO_GRAFT,
|
||||
ALGO_STELLITE,
|
||||
ALGO_AUTO,
|
||||
ALGO_COUNT
|
||||
};
|
||||
|
||||
extern volatile enum sha_algos opt_algo;
|
||||
|
||||
static const char *algo_names[] = {
|
||||
"blakecoin",
|
||||
"blake",
|
||||
"blake2s",
|
||||
"allium",
|
||||
"bmw",
|
||||
"bastion",
|
||||
"c11",
|
||||
"cryptolight",
|
||||
"cryptonight",
|
||||
"deep",
|
||||
"decred",
|
||||
"dmd-gr",
|
||||
"equihash",
|
||||
"fresh",
|
||||
"fugue256",
|
||||
"groestl",
|
||||
"heavy",
|
||||
"hmq1725",
|
||||
"hsr",
|
||||
"keccak",
|
||||
"keccakc",
|
||||
"jackpot",
|
||||
"jha",
|
||||
"lbry",
|
||||
"luffa",
|
||||
"lyra2",
|
||||
"lyra2v2",
|
||||
"lyra2z",
|
||||
"mjollnir",
|
||||
"myr-gr",
|
||||
"neoscrypt",
|
||||
"nist5",
|
||||
"penta",
|
||||
"phi",
|
||||
"phi2",
|
||||
"polytimos",
|
||||
"quark",
|
||||
"qubit",
|
||||
"scrypt",
|
||||
"scrypt-jane",
|
||||
"sha256d",
|
||||
"sha256t",
|
||||
"sia",
|
||||
"sib",
|
||||
"skein",
|
||||
"skein2",
|
||||
"skunk",
|
||||
"s3",
|
||||
"timetravel",
|
||||
"tribus",
|
||||
"bitcore",
|
||||
"x11evo",
|
||||
"x11",
|
||||
"x12",
|
||||
"x13",
|
||||
"x14",
|
||||
"x15",
|
||||
"x16r",
|
||||
"x16s",
|
||||
"x17",
|
||||
"vanilla",
|
||||
"veltor",
|
||||
"whirlcoin",
|
||||
"whirlpool",
|
||||
"whirlpoolx",
|
||||
"wildkeccak",
|
||||
"zr5",
|
||||
"monero",
|
||||
"graft",
|
||||
"stellite",
|
||||
"auto", /* reserved for multi algo */
|
||||
""
|
||||
};
|
||||
|
||||
// string to int/enum
|
||||
static inline int algo_to_int(char* arg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ALGO_COUNT; i++) {
|
||||
if (algo_names[i] && !strcasecmp(arg, algo_names[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == ALGO_COUNT) {
|
||||
// some aliases...
|
||||
if (!strcasecmp("all", arg))
|
||||
i = ALGO_AUTO;
|
||||
else if (!strcasecmp("cryptonight-light", arg))
|
||||
i = ALGO_CRYPTOLIGHT;
|
||||
else if (!strcasecmp("cryptonight-lite", arg))
|
||||
i = ALGO_CRYPTOLIGHT;
|
||||
else if (!strcasecmp("flax", arg))
|
||||
i = ALGO_C11;
|
||||
else if (!strcasecmp("diamond", arg))
|
||||
i = ALGO_DMD_GR;
|
||||
else if (!strcasecmp("equi", arg))
|
||||
i = ALGO_EQUIHASH;
|
||||
else if (!strcasecmp("doom", arg))
|
||||
i = ALGO_LUFFA;
|
||||
else if (!strcasecmp("hmq17", arg))
|
||||
i = ALGO_HMQ1725;
|
||||
else if (!strcasecmp("hshare", arg))
|
||||
i = ALGO_HSR;
|
||||
else if (!strcasecmp("lyra2re", arg))
|
||||
i = ALGO_LYRA2;
|
||||
else if (!strcasecmp("lyra2rev2", arg))
|
||||
i = ALGO_LYRA2v2;
|
||||
else if (!strcasecmp("phi1612", arg))
|
||||
i = ALGO_PHI;
|
||||
else if (!strcasecmp("bitcoin", arg))
|
||||
i = ALGO_SHA256D;
|
||||
else if (!strcasecmp("sha256", arg))
|
||||
i = ALGO_SHA256D;
|
||||
else if (!strcasecmp("thorsriddle", arg))
|
||||
i = ALGO_VELTOR;
|
||||
else if (!strcasecmp("timetravel10", arg))
|
||||
i = ALGO_BITCORE;
|
||||
else if (!strcasecmp("whirl", arg))
|
||||
i = ALGO_WHIRLPOOL;
|
||||
else if (!strcasecmp("ziftr", arg))
|
||||
i = ALGO_ZR5;
|
||||
else
|
||||
i = -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline int get_cryptonight_algo(int fork)
|
||||
{
|
||||
int algo = ALGO_COUNT;
|
||||
|
||||
switch (fork) {
|
||||
case 8:
|
||||
algo = ALGO_GRAFT;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
algo = ALGO_MONERO;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
algo = ALGO_STELLITE;
|
||||
break;
|
||||
|
||||
default:
|
||||
algo = ALGO_CRYPTONIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
return algo;
|
||||
}
|
||||
|
||||
#endif
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
/* ccminer API sample UI (API 1.9) */
|
||||
|
||||
$host = 'http://localhost/api/'; // 'http://'.$_SERVER['SERVER_NAME'].'/api/';
|
||||
$configs = array(
|
||||
'LOCAL'=>'local-sample.php',
|
||||
//'EPSYTOUR'=>'epsytour.php', /* copy local.php file and edit target IP:PORT */
|
||||
);
|
||||
|
||||
// 3 seconds max.
|
||||
set_time_limit(3);
|
||||
error_reporting(0);
|
||||
|
||||
function getdataFromPeers()
|
||||
{
|
||||
global $host, $configs;
|
||||
$data = array();
|
||||
foreach ($configs as $name => $conf) {
|
||||
|
||||
$json = file_get_contents($host.$conf);
|
||||
|
||||
$data[$name] = json_decode($json, TRUE);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function ignoreField($key)
|
||||
{
|
||||
$ignored = array(
|
||||
'API','VER','GPU','BUS','POOLS',
|
||||
'CARD','GPUS','CPU','TS','URL',
|
||||
);
|
||||
return in_array($key, $ignored);
|
||||
}
|
||||
|
||||
function translateField($key)
|
||||
{
|
||||
$intl = array();
|
||||
$intl['NAME'] = 'Software';
|
||||
$intl['VER'] = 'Version';
|
||||
|
||||
$intl['ALGO'] = 'Algorithm';
|
||||
$intl['GPUS'] = 'GPUs';
|
||||
$intl['CPUS'] = 'Threads';
|
||||
$intl['KHS'] = 'Hash rate';
|
||||
$intl['ACC'] = 'Accepted shares';
|
||||
$intl['ACCMN'] = 'Accepted / mn';
|
||||
$intl['REJ'] = 'Rejected';
|
||||
$intl['SOLV'] = 'Solved';
|
||||
$intl['BEST'] = 'Best share';
|
||||
$intl['STALE'] = 'Stale shares';
|
||||
$intl['LAST'] = 'Last share';
|
||||
$intl['DIFF'] = 'Difficulty';
|
||||
$intl['NETKHS'] = 'Net Rate';
|
||||
$intl['UPTIME'] = 'Miner up time';
|
||||
$intl['TS'] = 'Last update';
|
||||
$intl['THR'] = 'Throughput';
|
||||
$intl['WAIT'] = 'Wait time';
|
||||
|
||||
$intl['H'] = 'Bloc height';
|
||||
$intl['I'] = 'Intensity';
|
||||
$intl['HWF'] = 'Failures';
|
||||
$intl['POOL'] = 'Pool';
|
||||
$intl['POOLS'] = 'Pools';
|
||||
|
||||
$intl['TEMP'] = 'T°c';
|
||||
$intl['FAN'] = 'Fan %';
|
||||
$intl['CPUFREQ'] = 'CPU Freq.';
|
||||
$intl['FREQ'] = 'Base Freq.';
|
||||
$intl['MEMFREQ'] = 'Mem. Freq.';
|
||||
$intl['GPUF'] = 'Curr Freq.';
|
||||
$intl['MEMF'] = 'Mem. Freq.';
|
||||
$intl['KHW'] = 'Efficiency';
|
||||
$intl['POWER'] = 'Power';
|
||||
$intl['PLIM'] = 'P.Limit';
|
||||
$intl['PST'] = 'P-State';
|
||||
|
||||
// pool infos
|
||||
$intl['POOL'] = 'Pool';
|
||||
$intl['PING'] = 'Ping (ms)';
|
||||
$intl['DISCO'] = 'Disconnects';
|
||||
$intl['USER'] = 'User';
|
||||
|
||||
if (isset($intl[$key]))
|
||||
return $intl[$key];
|
||||
else
|
||||
return $key;
|
||||
}
|
||||
|
||||
function translateValue($key,$val,$data=array())
|
||||
{
|
||||
switch ($key) {
|
||||
case 'UPTIME':
|
||||
case 'WAIT':
|
||||
$min = floor(intval($val) / 60);
|
||||
$sec = intval($val) % 60;
|
||||
$val = "${min}mn${sec}s";
|
||||
if ($min > 180) {
|
||||
$hrs = floor($min / 60);
|
||||
$min = $min % 60;
|
||||
$val = "${hrs}h${min}mn";
|
||||
}
|
||||
break;
|
||||
case 'NAME':
|
||||
$val = $data['NAME'].' '.$data['VER'];
|
||||
break;
|
||||
case 'CPUFREQ':
|
||||
case 'FREQ':
|
||||
case 'MEMFREQ':
|
||||
case 'GPUF':
|
||||
case 'MEMF':
|
||||
$val = sprintf("%d MHz", $val);
|
||||
break;
|
||||
case 'POWER':
|
||||
$val = sprintf("%d W", round(floatval($val)/1000.0));
|
||||
break;
|
||||
case 'TS':
|
||||
$val = strftime("%H:%M:%S", (int) $val);
|
||||
break;
|
||||
case 'KHS':
|
||||
case 'NETKHS':
|
||||
$val = '<span class="bold">'.$val.'</span> kH/s';
|
||||
break;
|
||||
case 'KHW':
|
||||
$val = $val.' kH/W';
|
||||
break;
|
||||
case 'NAME':
|
||||
case 'POOL';
|
||||
case 'USER':
|
||||
// long fields
|
||||
$val = '<span class="elipsis">'.$val.'</span>';
|
||||
break;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
function filterPoolInfos($stats)
|
||||
{
|
||||
$keys = array('USER','H','PING','DISCO');
|
||||
$data = array();
|
||||
$pool = array_pop($stats);
|
||||
// simplify URL to host only
|
||||
$data['POOL'] = $pool['URL'];
|
||||
if (strstr($pool['URL'],'://')) {
|
||||
$parts = explode(':', $pool['URL']);
|
||||
$data['POOL'] = substr($parts[1],2);
|
||||
}
|
||||
foreach ($pool as $key=>$val) {
|
||||
if (in_array($key, $keys))
|
||||
$data[$key] = $val;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function displayData($data)
|
||||
{
|
||||
$htm = '';
|
||||
$totals = array();
|
||||
foreach ($data as $name => $stats) {
|
||||
if (!isset($stats['summary']))
|
||||
continue;
|
||||
$htm .= '<table id="tb_'.$name.'" class="stats">'."\n";
|
||||
$htm .= '<tr><th class="machine" colspan="2">'.$name."</th></tr>\n";
|
||||
if (!empty($stats)) {
|
||||
$summary = (array) $stats['summary'];
|
||||
foreach ($summary as $key=>$val) {
|
||||
if (!empty($val) && !ignoreField($key))
|
||||
$htm .= '<tr><td class="key">'.translateField($key).'</td>'.
|
||||
'<td class="val">'.translateValue($key, $val, $summary)."</td></tr>\n";
|
||||
}
|
||||
if (isset($summary['KHS']))
|
||||
@ $totals[$summary['ALGO']] += floatval($summary['KHS']);
|
||||
|
||||
if (isset($stats['pool']) && !empty($stats['pool']) ) {
|
||||
$pool = filterPoolInfos($stats['pool']);
|
||||
$htm .= '<tr><th class="gpu" colspan="2">POOL</th></tr>'."\n";
|
||||
foreach ($pool as $key=>$val) {
|
||||
if (!empty($val) && !ignoreField($key))
|
||||
$htm .= '<tr><td class="key">'.translateField($key).'</td>'.
|
||||
'<td class="val">'.translateValue($key, $val)."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($stats['threads'] as $g=>$gpu) {
|
||||
$card = isset($gpu['CARD']) ? $gpu['CARD'] : '';
|
||||
$htm .= '<tr><th class="gpu" colspan="2">'.$g." $card</th></tr>\n";
|
||||
foreach ($gpu as $key=>$val) {
|
||||
if (!empty($val) && !ignoreField($key))
|
||||
$htm .= '<tr><td class="key">'.translateField($key).'</td>'.
|
||||
'<td class="val">'.translateValue($key, $val)."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$htm .= "</table>\n";
|
||||
}
|
||||
// totals
|
||||
if (!empty($totals)) {
|
||||
$htm .= '<div class="totals"><h2>Total Hash rate</h2>'."\n";
|
||||
foreach ($totals as $algo => $hashrate) {
|
||||
$htm .= '<li><span class="algo">'.$algo.":</span>$hashrate kH/s</li>\n";
|
||||
}
|
||||
$htm .= '</div>';
|
||||
}
|
||||
return $htm;
|
||||
}
|
||||
|
||||
$data = getdataFromPeers();
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>ccminer rig api sample</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="refresh" content="10">
|
||||
<style type="text/css">
|
||||
body {
|
||||
color:#cccccc; background:#1d1d1d; margin:30px 30px 0px 30px; padding:0px;
|
||||
font-size:.8em; font-family:Arial,Helvetica,sans-serif;
|
||||
}
|
||||
a { color:#aaaaaa; text-decoration: none; }
|
||||
a:focus { outline-style:none; }
|
||||
.clear { clear: both; }
|
||||
|
||||
div#page, div#header, div#footer {
|
||||
margin: auto;
|
||||
width: 950px;
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
div#page {
|
||||
padding-top: 8px;
|
||||
background: #252525;
|
||||
min-height: 820px;
|
||||
}
|
||||
div#header {
|
||||
background: rgba(65, 65, 65, 0.85);
|
||||
height: 50px;
|
||||
margin-bottom: 24px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
div#footer {
|
||||
background: rgba(25, 25, 25, 0.85);
|
||||
height: 0px;
|
||||
margin-bottom: 40px;
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
text-shadow: rgba(0, 0, 0, 0.8) 0px 1px 0px;
|
||||
}
|
||||
#header h1 { padding: 12px; font-size: 20px; }
|
||||
#footer p { margin: 12px 24px; }
|
||||
|
||||
table.stats { width: 280px; margin: 4px 16px; display: inline-block; vertical-align: top; }
|
||||
th.machine { color: darkcyan; padding: 16px 0px 0px 0px; text-align: left; border-bottom: 1px solid gray; }
|
||||
th.gpu { color: white; padding: 3px 3px; font: bolder; text-align: left; background: rgba(65, 65, 65, 0.85); }
|
||||
td.key { width: 99px; max-width: 180px; }
|
||||
td.val { width: 40px; max-width: 100px; color: white; }
|
||||
|
||||
div.totals { margin: 16px; padding-bottom: 16px; }
|
||||
div.totals h2 { color: darkcyan; font-size: 16px; margin-bottom: 4px; }
|
||||
div.totals li { list-style-type: none; font-size: 16px; margin-left: 4px; margin-bottom: 8px; }
|
||||
li span.algo { display: inline-block; width: 100px; max-width: 180px; }
|
||||
|
||||
span.bold { color: #bb99aa; }
|
||||
span.elipsis { display: inline-block; max-width: 130px; overflow: hidden; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<h1>ccminer monitoring API RIG sample</h1>
|
||||
</div>
|
||||
|
||||
<div id="page">
|
||||
<?=displayData($data)?>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<p>© 2014-2015 <a href="http://github.com/tpruvot/ccminer">tpruvot@github</a></p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Sample Request API to ccminer
|
||||
*/
|
||||
defined('API_HOST') || define('API_HOST', '127.0.0.1');
|
||||
defined('API_PORT') || define('API_PORT', 4068);
|
||||
|
||||
// 2 seconds max.
|
||||
set_time_limit(2);
|
||||
|
||||
function getsock($port)
|
||||
{
|
||||
$socket = null;
|
||||
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
if ($socket === false || $socket === null) {
|
||||
$error = socket_strerror(socket_last_error());
|
||||
$msg = "socket create($port) failed";
|
||||
echo "ERR: $msg '$error'\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
socket_set_nonblock($socket);
|
||||
|
||||
$res = socket_connect($socket, API_HOST, $port);
|
||||
$timeout = 50;
|
||||
while ($res === false && $timeout > 0) {
|
||||
$err = socket_last_error($socket);
|
||||
echo ".";
|
||||
if ($timeout > 1 && ($err == 115 || $err == 114)) {
|
||||
$timeout--;
|
||||
usleep(50);
|
||||
$res = socket_connect($socket, API_HOST, $port);
|
||||
continue;
|
||||
}
|
||||
$error = socket_strerror($err);
|
||||
$msg = "socket connect($port) failed";
|
||||
echo "ERR: $msg '$error'\n";
|
||||
socket_close($socket);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
socket_set_block($socket);
|
||||
|
||||
return $socket;
|
||||
}
|
||||
|
||||
function readsockline($socket)
|
||||
{
|
||||
$line = '';
|
||||
while (true) {
|
||||
$byte = socket_read($socket, 1);
|
||||
if ($byte === false || $byte === '')
|
||||
break;
|
||||
if ($byte === "\0")
|
||||
break;
|
||||
$line .= $byte;
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
|
||||
function request($cmd)
|
||||
{
|
||||
$socket = getsock(API_PORT);
|
||||
if ($socket == null)
|
||||
return NULL;
|
||||
|
||||
socket_write($socket, $cmd, strlen($cmd));
|
||||
$line = readsockline($socket);
|
||||
socket_close($socket);
|
||||
|
||||
if (strlen($line) == 0) {
|
||||
echo "WARN: '$cmd' returned nothing\n";
|
||||
return $line;
|
||||
}
|
||||
|
||||
echo "$cmd returned '$line'\n";
|
||||
|
||||
$data = array();
|
||||
|
||||
$objs = explode('|', $line);
|
||||
foreach ($objs as $obj)
|
||||
{
|
||||
if (strlen($obj) > 0)
|
||||
{
|
||||
$items = explode(';', $obj);
|
||||
$item = $items[0];
|
||||
$id = explode('=', $items[0], 2);
|
||||
if (count($id) == 1)
|
||||
$name = $id[0];
|
||||
else
|
||||
$name = $id[0].$id[1];
|
||||
|
||||
if (strlen($name) == 0)
|
||||
$name = 'null';
|
||||
|
||||
if (isset($data[$name])) {
|
||||
$num = 1;
|
||||
while (isset($data[$name.$num]))
|
||||
$num++;
|
||||
$name .= $num;
|
||||
}
|
||||
|
||||
$counter = 0;
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$id = explode('=', $item, 2);
|
||||
if (count($id) == 2)
|
||||
$data[$name][$id[0]] = $id[1];
|
||||
else
|
||||
$data[$name][$counter] = $id[0];
|
||||
|
||||
$counter++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($cmd == 'summary')
|
||||
return array_pop($data);
|
||||
else
|
||||
return $data;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
$summary = request('summary');
|
||||
$threads = request('threads');
|
||||
$pool = request('pool');
|
||||
|
||||
ob_end_clean(); /* swap to debug */
|
||||
//echo ob_get_clean()."\n";
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode(compact('summary', 'threads', 'pool'))."\n";
|
||||
?>
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# sample script to query ccminer API
|
||||
|
||||
my $command = "summary|";
|
||||
|
||||
use Socket;
|
||||
use IO::Socket::INET;
|
||||
|
||||
my $sock = new IO::Socket::INET (
|
||||
PeerAddr => '127.0.0.1',
|
||||
PeerPort => 4068,
|
||||
Proto => 'tcp',
|
||||
ReuseAddr => 1,
|
||||
Timeout => 10,
|
||||
);
|
||||
|
||||
if ($sock) {
|
||||
|
||||
print $sock $command;
|
||||
my $res = "";
|
||||
|
||||
while(<$sock>) {
|
||||
$res .= $_;
|
||||
}
|
||||
|
||||
close($sock);
|
||||
print("$res\n");
|
||||
|
||||
} else {
|
||||
|
||||
print("ccminer socket failed\n");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="http://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="http://code.highcharts.com/modules/exporting.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var hashrates = [];
|
||||
|
||||
function drawChart(ip) {
|
||||
|
||||
$('#container').highcharts({
|
||||
chart: {
|
||||
type: 'spline'
|
||||
},
|
||||
title: {
|
||||
text: 'ccMiner WebSocket Sample - ' + ip,
|
||||
x: -20 //center
|
||||
},
|
||||
subtitle: {
|
||||
text: 'By <a href="http://github.com/tpruvot/ccminer">tpruvot@github</a> 2014',
|
||||
x: -20
|
||||
},
|
||||
xAxis: {
|
||||
type: 'datetime',
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
text: 'Hash Rate (KH/s)'
|
||||
},
|
||||
plotLines: [{
|
||||
value: 0,
|
||||
width: 1,
|
||||
color: '#808080'
|
||||
}],
|
||||
min: 0
|
||||
},
|
||||
tooltip: {
|
||||
valueSuffix: ' KH'
|
||||
},
|
||||
legend: {
|
||||
layout: 'vertical',
|
||||
align: 'right',
|
||||
verticalAlign: 'middle',
|
||||
borderWidth: 0
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'GPU0',
|
||||
data: hashrates[0]
|
||||
},
|
||||
{
|
||||
name: 'GPU1',
|
||||
data: hashrates[1]
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function getData(ip, port) {
|
||||
if ("WebSocket" in window) {
|
||||
var ws = new WebSocket('ws://'+ip+':'+port+'/histo','text');
|
||||
var rates = [];
|
||||
for (var gpu=0; gpu<8; gpu++) {
|
||||
hashrates[gpu] = [];
|
||||
rates[gpu] = [];
|
||||
}
|
||||
ws.onmessage = function (evt) {
|
||||
var now = new Date();
|
||||
var ts = Math.round(now/1000);
|
||||
var data = evt.data.split('|');
|
||||
for (n in data) {
|
||||
var map = data[n].split(';');
|
||||
var gpu = 0;
|
||||
var uid = 0;
|
||||
var plot = {};
|
||||
for (k in map) {
|
||||
var kv = map[k].split('=');
|
||||
if (kv.length == 1)
|
||||
continue;
|
||||
if (kv[0] === 'GPU')
|
||||
gpu = parseInt(kv[1], 10);
|
||||
else if (kv[0] === 'ID')
|
||||
uid = parseInt(kv[1], 10);
|
||||
else if (kv[0] === 'TS')
|
||||
plot.timestamp = parseInt(kv[1], 10);
|
||||
else if (kv[0] === 'KHS')
|
||||
plot.hashrate = parseInt(kv[1], 10) / 1000.0;
|
||||
console.log('Data received: #GPU'+gpu+': '+kv[0]+' = '+kv[1]);
|
||||
}
|
||||
if (uid == 0)
|
||||
continue;
|
||||
rates[gpu][uid] = [+new Date(plot.timestamp*1000), plot.hashrate];
|
||||
}
|
||||
|
||||
// sort values with id
|
||||
for (gpu in rates) {
|
||||
for (uid in rates[gpu])
|
||||
hashrates[gpu].push(rates[gpu][uid]);
|
||||
}
|
||||
|
||||
drawChart(ip);
|
||||
};
|
||||
ws.onerror = function (evt) {
|
||||
var w = evt.target;
|
||||
console.log('Error! readyState=' + w.readyState); //log errors
|
||||
$('#container').html('Error! Unable to get WebSocket data from '+ip); //log errors
|
||||
return false;
|
||||
};
|
||||
ws.onclose = function() {
|
||||
// websocket is closed.
|
||||
};
|
||||
} else {
|
||||
// The browser doesn't support WebSocket
|
||||
alert("WebSocket NOT supported by your Browser!");
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
//getData('192.168.0.110', 4068);
|
||||
getData('localhost', 4068);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,243 @@
|
||||
/**
|
||||
* Made to benchmark and test algo switch
|
||||
*
|
||||
* 2015 - tpruvot@github
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "miner.h"
|
||||
#include "algos.h"
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "compat/pthreads/pthread_barrier.hpp"
|
||||
#endif
|
||||
|
||||
int bench_algo = -1;
|
||||
|
||||
static double algo_hashrates[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static uint32_t algo_throughput[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static int algo_mem_used[MAX_GPUS][ALGO_COUNT] = { 0 };
|
||||
static int device_mem_free[MAX_GPUS] = { 0 };
|
||||
|
||||
static pthread_barrier_t miner_barr;
|
||||
static pthread_barrier_t algo_barr;
|
||||
static pthread_mutex_t bench_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
extern double thr_hashrates[MAX_GPUS];
|
||||
|
||||
void bench_init(int threads)
|
||||
{
|
||||
bench_algo = opt_algo = (enum sha_algos) 0; /* first */
|
||||
applog(LOG_BLUE, "Starting benchmark mode with %s", algo_names[opt_algo]);
|
||||
pthread_barrier_init(&miner_barr, NULL, threads);
|
||||
pthread_barrier_init(&algo_barr, NULL, threads);
|
||||
// required for usage of first algo.
|
||||
for (int n=0; n < opt_n_threads; n++) {
|
||||
device_mem_free[n] = cuda_available_memory(n);
|
||||
}
|
||||
}
|
||||
|
||||
void bench_free()
|
||||
{
|
||||
pthread_barrier_destroy(&miner_barr);
|
||||
pthread_barrier_destroy(&algo_barr);
|
||||
}
|
||||
|
||||
// required to switch algos
|
||||
void algo_free_all(int thr_id)
|
||||
{
|
||||
// only initialized algos will be freed
|
||||
free_allium(thr_id);
|
||||
free_bastion(thr_id);
|
||||
free_bitcore(thr_id);
|
||||
free_blake256(thr_id);
|
||||
free_blake2s(thr_id);
|
||||
free_bmw(thr_id);
|
||||
free_c11(thr_id);
|
||||
free_cryptolight(thr_id);
|
||||
free_cryptonight(thr_id);
|
||||
free_decred(thr_id);
|
||||
free_deep(thr_id);
|
||||
free_equihash(thr_id);
|
||||
free_keccak256(thr_id);
|
||||
free_fresh(thr_id);
|
||||
free_fugue256(thr_id);
|
||||
free_groestlcoin(thr_id);
|
||||
#ifdef WITH_HEAVY_ALGO
|
||||
free_heavy(thr_id);
|
||||
#endif
|
||||
free_hmq17(thr_id);
|
||||
free_hsr(thr_id);
|
||||
free_jackpot(thr_id);
|
||||
free_jha(thr_id);
|
||||
free_lbry(thr_id);
|
||||
free_luffa(thr_id);
|
||||
free_lyra2(thr_id);
|
||||
free_lyra2v2(thr_id);
|
||||
free_lyra2Z(thr_id);
|
||||
free_myriad(thr_id);
|
||||
free_neoscrypt(thr_id);
|
||||
free_nist5(thr_id);
|
||||
free_pentablake(thr_id);
|
||||
free_phi(thr_id);
|
||||
free_polytimos(thr_id);
|
||||
free_quark(thr_id);
|
||||
free_qubit(thr_id);
|
||||
free_skeincoin(thr_id);
|
||||
free_skein2(thr_id);
|
||||
free_skunk(thr_id);
|
||||
free_sha256d(thr_id);
|
||||
free_sha256t(thr_id);
|
||||
free_sia(thr_id);
|
||||
free_sib(thr_id);
|
||||
free_s3(thr_id);
|
||||
free_vanilla(thr_id);
|
||||
free_veltor(thr_id);
|
||||
free_whirl(thr_id);
|
||||
//free_whirlx(thr_id);
|
||||
free_wildkeccak(thr_id);
|
||||
free_x11evo(thr_id);
|
||||
free_x11(thr_id);
|
||||
free_x12(thr_id);
|
||||
free_x13(thr_id);
|
||||
free_x14(thr_id);
|
||||
free_x15(thr_id);
|
||||
free_x16r(thr_id);
|
||||
free_x16s(thr_id);
|
||||
free_x17(thr_id);
|
||||
free_zr5(thr_id);
|
||||
free_scrypt(thr_id);
|
||||
free_scrypt_jane(thr_id);
|
||||
free_timetravel(thr_id);
|
||||
free_tribus(thr_id);
|
||||
free_bitcore(thr_id);
|
||||
}
|
||||
|
||||
// benchmark all algos (called once per mining thread)
|
||||
bool bench_algo_switch_next(int thr_id)
|
||||
{
|
||||
int algo = (int) opt_algo;
|
||||
int prev_algo = algo;
|
||||
int dev_id = device_map[thr_id % MAX_GPUS];
|
||||
int mfree, mused;
|
||||
// doesnt seems enough to prevent device slow down
|
||||
// after some algo switchs
|
||||
bool need_reset = (gpu_threads == 1);
|
||||
|
||||
algo++;
|
||||
|
||||
// skip some duplicated algos
|
||||
if (algo == ALGO_C11) algo++; // same as x11
|
||||
if (algo == ALGO_DMD_GR) algo++; // same as groestl
|
||||
if (algo == ALGO_HEAVY) algo++; // dead
|
||||
if (algo == ALGO_MJOLLNIR) algo++; // same as heavy
|
||||
if (algo == ALGO_KECCAKC) algo++; // same as keccak
|
||||
if (algo == ALGO_WHIRLCOIN) algo++; // same as whirlpool
|
||||
if (algo == ALGO_WHIRLPOOLX) algo++; // disabled
|
||||
// todo: algo switch from RPC 2.0
|
||||
if (algo == ALGO_CRYPTOLIGHT) algo++;
|
||||
if (algo == ALGO_CRYPTONIGHT) algo++;
|
||||
if (algo == ALGO_WILDKECCAK) algo++;
|
||||
if (algo == ALGO_QUARK) algo++; // to fix
|
||||
if (algo == ALGO_LBRY && CUDART_VERSION < 7000) algo++;
|
||||
|
||||
if (device_sm[dev_id] && device_sm[dev_id] < 300) {
|
||||
// incompatible SM 2.1 kernels...
|
||||
if (algo == ALGO_GROESTL) algo++;
|
||||
if (algo == ALGO_MYR_GR) algo++;
|
||||
if (algo == ALGO_NEOSCRYPT) algo++;
|
||||
if (algo == ALGO_WHIRLPOOLX) algo++;
|
||||
}
|
||||
// and unwanted ones...
|
||||
if (algo == ALGO_SCRYPT) algo++;
|
||||
if (algo == ALGO_SCRYPT_JANE) algo++;
|
||||
|
||||
// free current algo memory and track mem usage
|
||||
mused = cuda_available_memory(thr_id);
|
||||
algo_free_all(thr_id);
|
||||
CUDA_LOG_ERROR();
|
||||
|
||||
// device can take some time to free
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
if (device_mem_free[thr_id] > mfree) {
|
||||
sleep(1);
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
|
||||
// we need to wait completion on all cards before the switch
|
||||
if (opt_n_threads > 1) {
|
||||
pthread_barrier_wait(&miner_barr);
|
||||
}
|
||||
|
||||
char rate[32] = { 0 };
|
||||
double hashrate = stats_get_speed(thr_id, thr_hashrates[thr_id]);
|
||||
format_hashrate(hashrate, rate);
|
||||
gpulog(LOG_NOTICE, thr_id, "%s hashrate = %s", algo_names[prev_algo], rate);
|
||||
|
||||
// ensure memory leak is still real after the barrier
|
||||
if (device_mem_free[thr_id] > mfree) {
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
|
||||
// check if there is memory leak
|
||||
if (device_mem_free[thr_id] - mfree > 1) {
|
||||
gpulog(LOG_WARNING, thr_id, "possible %d MB memory leak in %s! %d MB free",
|
||||
(device_mem_free[thr_id] - mfree), algo_names[prev_algo], mfree);
|
||||
cuda_reset_device(thr_id, NULL); // force to free the leak
|
||||
need_reset = false;
|
||||
mfree = cuda_available_memory(thr_id);
|
||||
}
|
||||
// store used memory per algo
|
||||
algo_mem_used[thr_id][opt_algo] = device_mem_free[thr_id] - mused;
|
||||
device_mem_free[thr_id] = mfree;
|
||||
|
||||
// store to dump a table per gpu later
|
||||
algo_hashrates[thr_id][prev_algo] = hashrate;
|
||||
|
||||
// wait the other threads to display logs correctly
|
||||
if (opt_n_threads > 1) {
|
||||
pthread_barrier_wait(&algo_barr);
|
||||
}
|
||||
|
||||
if (algo == ALGO_AUTO)
|
||||
return false; // all algos done
|
||||
|
||||
// mutex primary used for the stats purge
|
||||
pthread_mutex_lock(&bench_lock);
|
||||
stats_purge_all();
|
||||
|
||||
opt_algo = (enum sha_algos) algo;
|
||||
global_hashrate = 0;
|
||||
thr_hashrates[thr_id] = 0; // reset for minmax64
|
||||
pthread_mutex_unlock(&bench_lock);
|
||||
|
||||
if (need_reset)
|
||||
cuda_reset_device(thr_id, NULL);
|
||||
|
||||
if (thr_id == 0)
|
||||
applog(LOG_BLUE, "Benchmark algo %s...", algo_names[algo]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void bench_set_throughput(int thr_id, uint32_t throughput)
|
||||
{
|
||||
algo_throughput[thr_id][opt_algo] = throughput;
|
||||
}
|
||||
|
||||
void bench_display_results()
|
||||
{
|
||||
for (int n=0; n < opt_n_threads; n++)
|
||||
{
|
||||
int dev_id = device_map[n];
|
||||
applog(LOG_BLUE, "Benchmark results for GPU #%d - %s:", dev_id, device_name[dev_id]);
|
||||
for (int i=0; i < ALGO_COUNT-1; i++) {
|
||||
double rate = algo_hashrates[n][i];
|
||||
if (rate == 0.0) continue;
|
||||
applog(LOG_INFO, "%12s : %12.1f kH/s, %5d MB, %8u thr.", algo_names[i],
|
||||
rate / 1024., algo_mem_used[n][i], algo_throughput[n][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Wrapper to OpenSSL BIGNUM used by net diff (nBits)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#include <openssl/opensslv.h>
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
#include "compat/bignum_ssl10.hpp"
|
||||
#else
|
||||
#include "bignum.hpp"
|
||||
#endif
|
||||
|
||||
#include "miner.h" // hex2bin
|
||||
|
||||
extern "C" double bn_convert_nbits(const uint32_t nBits)
|
||||
{
|
||||
uint256 bn = CBigNum().SetCompact(nBits).getuint256();
|
||||
return bn.getdouble();
|
||||
}
|
||||
|
||||
// copy the big number to 32-bytes uchar
|
||||
extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target)
|
||||
{
|
||||
char buff[65];
|
||||
uint256 bn = CBigNum().SetCompact(nBits).getuint256();
|
||||
|
||||
snprintf(buff, 65, "%s\n", bn.ToString().c_str()); buff[64] = '\0';
|
||||
hex2bin(target, buff, 32);
|
||||
}
|
||||
|
||||
// unused, but should allow more than 256bits targets
|
||||
#if 0
|
||||
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
||||
{
|
||||
double dhash;
|
||||
|
||||
if (!opt_showdiff)
|
||||
return 0.0;
|
||||
|
||||
CBigNum h(0), t(0);
|
||||
std::vector<unsigned char> vch(32);
|
||||
|
||||
memcpy(&vch[0], (void*) target, 32);
|
||||
t.setvch(vch);
|
||||
memcpy(&vch[0], (void*) hash, 32);
|
||||
h.setvch(vch);
|
||||
|
||||
dhash = h.getuint256().getdouble();
|
||||
if (dhash > 0.)
|
||||
return t.getuint256().getdouble() / dhash;
|
||||
else
|
||||
return dhash;
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute the diff ratio between a found hash and the target
|
||||
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
||||
{
|
||||
uint256 h, t;
|
||||
double dhash;
|
||||
|
||||
if (!opt_showdiff)
|
||||
return 0.0;
|
||||
|
||||
memcpy(&t, (void*) target, 32);
|
||||
memcpy(&h, (void*) hash, 32);
|
||||
|
||||
dhash = h.getdouble();
|
||||
if (dhash > 0.)
|
||||
return t.getdouble() / dhash;
|
||||
else
|
||||
return dhash;
|
||||
}
|
||||
|
||||
// store ratio in work struct
|
||||
extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work, int nonce)
|
||||
{
|
||||
// only if the option is enabled (to reduce cpu usage)
|
||||
if (!opt_showdiff) return;
|
||||
if (nonce < 0 || nonce >= MAX_NONCES) return;
|
||||
|
||||
work->shareratio[nonce] = bn_hash_target_ratio(hash, target);
|
||||
work->sharediff[nonce] = work->targetdiff * work->shareratio[nonce];
|
||||
}
|
||||
|
||||
// new method to save all nonce(s) share diff/ration
|
||||
extern "C" void bn_set_target_ratio(struct work* work, uint32_t* hash, int nonce)
|
||||
{
|
||||
bn_store_hash_target_ratio(hash, work->target, work, nonce);
|
||||
}
|
||||
|
||||
// compat (only store single nonce share diff per work)
|
||||
extern "C" void work_set_target_ratio(struct work* work, uint32_t* hash)
|
||||
{
|
||||
bn_store_hash_target_ratio(hash, work->target, work, work->submit_nonce_id);
|
||||
}
|
||||
|
||||
+584
@@ -0,0 +1,584 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_BIGNUM_H
|
||||
#define BITCOIN_BIGNUM_H
|
||||
|
||||
#ifndef PROTOCOL_VERSION
|
||||
#define PROTOCOL_VERSION 70001
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include "serialize.hpp"
|
||||
|
||||
/** Errors thrown by the bignum class */
|
||||
class bignum_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
|
||||
};
|
||||
|
||||
|
||||
/** RAII encapsulated BN_CTX (OpenSSL bignum context) */
|
||||
class CAutoBN_CTX
|
||||
{
|
||||
protected:
|
||||
BN_CTX* pctx;
|
||||
BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
|
||||
|
||||
public:
|
||||
CAutoBN_CTX()
|
||||
{
|
||||
pctx = BN_CTX_new();
|
||||
if (pctx == NULL)
|
||||
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
|
||||
}
|
||||
|
||||
~CAutoBN_CTX()
|
||||
{
|
||||
if (pctx != NULL)
|
||||
BN_CTX_free(pctx);
|
||||
}
|
||||
|
||||
operator BN_CTX*() { return pctx; }
|
||||
BN_CTX& operator*() { return *pctx; }
|
||||
BN_CTX** operator&() { return &pctx; }
|
||||
bool operator!() { return (pctx == NULL); }
|
||||
};
|
||||
|
||||
|
||||
/** C++ wrapper for BIGNUM (OpenSSL bignum) */
|
||||
class CBigNum
|
||||
{
|
||||
private:
|
||||
BIGNUM *self = NULL;
|
||||
|
||||
void init()
|
||||
{
|
||||
if (self)
|
||||
BN_clear_free(self);
|
||||
self = BN_new();
|
||||
if (!self)
|
||||
throw bignum_error("CBigNum::init(): BN_new() returned NULL");
|
||||
}
|
||||
|
||||
public:
|
||||
BIGNUM *get() { return self; }
|
||||
const BIGNUM *getc() const { return self; }
|
||||
|
||||
CBigNum()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
CBigNum(const CBigNum& b)
|
||||
{
|
||||
init();
|
||||
if (!BN_copy(self, b.getc()))
|
||||
{
|
||||
BN_clear_free(self);
|
||||
throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& operator=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy(self, b.getc()))
|
||||
throw bignum_error("CBigNum::operator= : BN_copy failed");
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CBigNum()
|
||||
{
|
||||
BN_clear_free(self);
|
||||
}
|
||||
|
||||
//CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
|
||||
CBigNum(signed char n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(short n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int64 n) { init(); setint64(n); }
|
||||
CBigNum(unsigned char n) { init(); setulong(n); }
|
||||
CBigNum(unsigned short n) { init(); setulong(n); }
|
||||
CBigNum(unsigned int n) { init(); setulong(n); }
|
||||
CBigNum(unsigned long n) { init(); setulong(n); }
|
||||
CBigNum(uint64 n) { init(); setuint64(n); }
|
||||
explicit CBigNum(uint256 n) { init(); setuint256(n); }
|
||||
|
||||
explicit CBigNum(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
init();
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
void setulong(unsigned long n)
|
||||
{
|
||||
if (!BN_set_word(self, n))
|
||||
throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long getulong() const
|
||||
{
|
||||
return BN_get_word(self);
|
||||
}
|
||||
|
||||
unsigned int getuint() const
|
||||
{
|
||||
return BN_get_word(self);
|
||||
}
|
||||
|
||||
int getint() const
|
||||
{
|
||||
unsigned long n = BN_get_word(self);
|
||||
if (!BN_is_negative(self))
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
||||
else
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
|
||||
}
|
||||
|
||||
void setint64(int64 sn)
|
||||
{
|
||||
unsigned char pch[sizeof(sn) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fNegative;
|
||||
uint64 n;
|
||||
|
||||
if (sn < (int64)0)
|
||||
{
|
||||
// Since the minimum signed integer cannot be represented as positive so long as its type is signed, and it's not well-defined what happens if you make it unsigned before negating it, we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
|
||||
n = -(sn + 1);
|
||||
++n;
|
||||
fNegative = true;
|
||||
} else {
|
||||
n = sn;
|
||||
fNegative = false;
|
||||
}
|
||||
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = (fNegative ? 0x80 : 0);
|
||||
else if (fNegative)
|
||||
c |= 0x80;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
uint64 getuint64()
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint64 n = 0;
|
||||
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
void setuint64(uint64 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
void setuint256(uint256 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
unsigned char* pbegin = (unsigned char*)&n;
|
||||
unsigned char* psrc = pbegin + sizeof(n);
|
||||
while (psrc != pbegin)
|
||||
{
|
||||
unsigned char c = *(--psrc);
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = p - (pch + 4);
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize >> 0) & 0xff;
|
||||
BN_mpi2bn(pch, p - pch, self);
|
||||
}
|
||||
|
||||
uint256 getuint256()
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint256 n = 0;
|
||||
for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void setvch(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||
unsigned int nSize = vch.size();
|
||||
// BIGNUM's byte stream format expects 4 bytes of
|
||||
// big endian size data info at the front
|
||||
vch2[0] = (nSize >> 24) & 0xff;
|
||||
vch2[1] = (nSize >> 16) & 0xff;
|
||||
vch2[2] = (nSize >> 8) & 0xff;
|
||||
vch2[3] = (nSize >> 0) & 0xff;
|
||||
// swap data to big endian
|
||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||
BN_mpi2bn(&vch2[0], vch2.size(), self);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getvch() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
if (nSize <= 4)
|
||||
return std::vector<unsigned char>();
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
vch.erase(vch.begin(), vch.begin() + 4);
|
||||
reverse(vch.begin(), vch.end());
|
||||
return vch;
|
||||
}
|
||||
|
||||
CBigNum& SetCompact(unsigned int nCompact)
|
||||
{
|
||||
unsigned int nSize = nCompact >> 24;
|
||||
std::vector<unsigned char> vch(4 + nSize);
|
||||
vch[3] = nSize;
|
||||
if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff;
|
||||
if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff;
|
||||
if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff;
|
||||
BN_mpi2bn(&vch[0], vch.size(), self);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int GetCompact() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(self, NULL);
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
nSize -= 4;
|
||||
BN_bn2mpi(self, &vch[0]);
|
||||
unsigned int nCompact = nSize << 24;
|
||||
if (nSize >= 1) nCompact |= (vch[4] << 16);
|
||||
if (nSize >= 2) nCompact |= (vch[5] << 8);
|
||||
if (nSize >= 3) nCompact |= (vch[6] << 0);
|
||||
return nCompact;
|
||||
}
|
||||
|
||||
void SetHex(const std::string& str)
|
||||
{
|
||||
// skip 0x
|
||||
const char* psz = str.c_str();
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
bool fNegative = false;
|
||||
if (*psz == '-')
|
||||
{
|
||||
fNegative = true;
|
||||
psz++;
|
||||
}
|
||||
if (psz[0] == '0' && tolower(psz[1]) == 'x')
|
||||
psz += 2;
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
|
||||
// hex string to bignum
|
||||
static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
|
||||
*this = 0;
|
||||
while (isxdigit(*psz))
|
||||
{
|
||||
*this <<= 4;
|
||||
int n = phexdigit[(unsigned char)*psz++];
|
||||
*this += n;
|
||||
}
|
||||
if (fNegative)
|
||||
*this = 0 - *this;
|
||||
}
|
||||
|
||||
std::string ToString(int nBase=10) const
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum bnBase = nBase;
|
||||
CBigNum bn0 = 0;
|
||||
std::string str;
|
||||
CBigNum bn = *this;
|
||||
BN_set_negative(bn.get(), false);
|
||||
CBigNum dv;
|
||||
CBigNum rem;
|
||||
if (BN_cmp(bn.getc(), bn0.getc()) == 0)
|
||||
return "0";
|
||||
while (BN_cmp(bn.getc(), bn0.getc()) > 0)
|
||||
{
|
||||
if (!BN_div(dv.get(), rem.get(), bn.getc(), bnBase.getc(), pctx))
|
||||
throw bignum_error("CBigNum::ToString() : BN_div failed");
|
||||
bn = dv;
|
||||
unsigned int c = rem.getulong();
|
||||
str += "0123456789abcdef"[c];
|
||||
}
|
||||
if (BN_is_negative(self))
|
||||
str += "-";
|
||||
reverse(str.begin(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string GetHex() const
|
||||
{
|
||||
return ToString(16);
|
||||
}
|
||||
|
||||
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
return ::GetSerializeSize(getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
::Serialize(s, getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
std::vector<unsigned char> vch;
|
||||
::Unserialize(s, vch, nType, nVersion);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return BN_is_zero(self);
|
||||
}
|
||||
|
||||
CBigNum& operator+=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_add(self, self, b.getc()))
|
||||
throw bignum_error("CBigNum::operator+= : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator-=(const CBigNum& b)
|
||||
{
|
||||
*this = *this - b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator*=(const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
if (!BN_mul(self, self, b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator*= : BN_mul failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator/=(const CBigNum& b)
|
||||
{
|
||||
*this = *this / b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator%=(const CBigNum& b)
|
||||
{
|
||||
*this = *this % b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator<<=(unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift(self, self, shift))
|
||||
throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator>>=(unsigned int shift)
|
||||
{
|
||||
// Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
|
||||
// if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
|
||||
CBigNum a = 1;
|
||||
a <<= shift;
|
||||
if (BN_cmp(a.getc(), self) > 0)
|
||||
{
|
||||
*this = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (!BN_rshift(self, self, shift))
|
||||
throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CBigNum& operator++()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add(self, self, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator++ : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator++(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
++(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CBigNum& operator--()
|
||||
{
|
||||
// prefix operator
|
||||
CBigNum r;
|
||||
if (!BN_sub(r.get(), self, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator-- : BN_sub failed");
|
||||
*this = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator--(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
--(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_add(r.get(), a.getc(), b.getc()))
|
||||
throw bignum_error("CBigNum::operator+ : BN_add failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_sub(r.get(), a.getc(), b.getc()))
|
||||
throw bignum_error("CBigNum::operator- : BN_sub failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a)
|
||||
{
|
||||
CBigNum r(a);
|
||||
BN_set_negative(r.get(), !BN_is_negative(r.getc()));
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mul(r.get(), a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator* : BN_mul failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_div(r.get(), NULL, a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator/ : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mod(r.get(), a.getc(), b.getc(), pctx))
|
||||
throw bignum_error("CBigNum::operator% : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_lshift(r.get(), a.getc(), shift))
|
||||
throw bignum_error("CBigNum:operator<< : BN_lshift failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r = a;
|
||||
r >>= shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) == 0); }
|
||||
inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) != 0); }
|
||||
inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) <= 0); }
|
||||
inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) >= 0); }
|
||||
inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) < 0); }
|
||||
inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.getc(), b.getc()) > 0); }
|
||||
|
||||
#endif
|
||||
@@ -1,441 +0,0 @@
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 300
|
||||
/**
|
||||
* __shfl() returns the value of var held by the thread whose ID is given by srcLane.
|
||||
* If srcLane is outside the range 0..width-1, the thread's own value of var is returned.
|
||||
*/
|
||||
#undef __shfl
|
||||
#define __shfl(var, srcLane, width) (uint32_t)(var)
|
||||
#endif
|
||||
|
||||
#ifdef __CUDA_ARCH__
|
||||
|
||||
__device__ __forceinline__
|
||||
void to_bitslice_quad(uint32_t *input, uint32_t *output)
|
||||
{
|
||||
uint32_t other[8];
|
||||
const int n = threadIdx.x % 4;
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 8; i++) {
|
||||
input[i] = __shfl((int)input[i], n ^ (3*(n >=1 && n <=2)), 4);
|
||||
other[i] = __shfl((int)input[i], (threadIdx.x + 1) % 4, 4);
|
||||
input[i] = __shfl((int)input[i], threadIdx.x & 2, 4);
|
||||
other[i] = __shfl((int)other[i], threadIdx.x & 2, 4);
|
||||
if (threadIdx.x & 1) {
|
||||
input[i] = __byte_perm(input[i], 0, 0x1032);
|
||||
other[i] = __byte_perm(other[i], 0, 0x1032);
|
||||
}
|
||||
output[i] = 0;
|
||||
}
|
||||
|
||||
output[ 0] |= (input[ 0] & 0x00000001);
|
||||
output[ 0] |= ((other[ 0] & 0x00000001) << 1);
|
||||
output[ 0] |= ((input[ 1] & 0x00000001) << 2);
|
||||
output[ 0] |= ((other[ 1] & 0x00000001) << 3);
|
||||
output[ 0] |= ((input[ 2] & 0x00000001) << 4);
|
||||
output[ 0] |= ((other[ 2] & 0x00000001) << 5);
|
||||
output[ 0] |= ((input[ 3] & 0x00000001) << 6);
|
||||
output[ 0] |= ((other[ 3] & 0x00000001) << 7);
|
||||
output[ 0] |= ((input[ 4] & 0x00000001) << 8);
|
||||
output[ 0] |= ((other[ 4] & 0x00000001) << 9);
|
||||
output[ 0] |= ((input[ 5] & 0x00000001) <<10);
|
||||
output[ 0] |= ((other[ 5] & 0x00000001) <<11);
|
||||
output[ 0] |= ((input[ 6] & 0x00000001) <<12);
|
||||
output[ 0] |= ((other[ 6] & 0x00000001) <<13);
|
||||
output[ 0] |= ((input[ 7] & 0x00000001) <<14);
|
||||
output[ 0] |= ((other[ 7] & 0x00000001) <<15);
|
||||
output[ 0] |= ((input[ 0] & 0x00000100) << 8);
|
||||
output[ 0] |= ((other[ 0] & 0x00000100) << 9);
|
||||
output[ 0] |= ((input[ 1] & 0x00000100) <<10);
|
||||
output[ 0] |= ((other[ 1] & 0x00000100) <<11);
|
||||
output[ 0] |= ((input[ 2] & 0x00000100) <<12);
|
||||
output[ 0] |= ((other[ 2] & 0x00000100) <<13);
|
||||
output[ 0] |= ((input[ 3] & 0x00000100) <<14);
|
||||
output[ 0] |= ((other[ 3] & 0x00000100) <<15);
|
||||
output[ 0] |= ((input[ 4] & 0x00000100) <<16);
|
||||
output[ 0] |= ((other[ 4] & 0x00000100) <<17);
|
||||
output[ 0] |= ((input[ 5] & 0x00000100) <<18);
|
||||
output[ 0] |= ((other[ 5] & 0x00000100) <<19);
|
||||
output[ 0] |= ((input[ 6] & 0x00000100) <<20);
|
||||
output[ 0] |= ((other[ 6] & 0x00000100) <<21);
|
||||
output[ 0] |= ((input[ 7] & 0x00000100) <<22);
|
||||
output[ 0] |= ((other[ 7] & 0x00000100) <<23);
|
||||
|
||||
output[ 1] |= ((input[ 0] & 0x00000002) >> 1);
|
||||
output[ 1] |= (other[ 0] & 0x00000002);
|
||||
output[ 1] |= ((input[ 1] & 0x00000002) << 1);
|
||||
output[ 1] |= ((other[ 1] & 0x00000002) << 2);
|
||||
output[ 1] |= ((input[ 2] & 0x00000002) << 3);
|
||||
output[ 1] |= ((other[ 2] & 0x00000002) << 4);
|
||||
output[ 1] |= ((input[ 3] & 0x00000002) << 5);
|
||||
output[ 1] |= ((other[ 3] & 0x00000002) << 6);
|
||||
output[ 1] |= ((input[ 4] & 0x00000002) << 7);
|
||||
output[ 1] |= ((other[ 4] & 0x00000002) << 8);
|
||||
output[ 1] |= ((input[ 5] & 0x00000002) << 9);
|
||||
output[ 1] |= ((other[ 5] & 0x00000002) <<10);
|
||||
output[ 1] |= ((input[ 6] & 0x00000002) <<11);
|
||||
output[ 1] |= ((other[ 6] & 0x00000002) <<12);
|
||||
output[ 1] |= ((input[ 7] & 0x00000002) <<13);
|
||||
output[ 1] |= ((other[ 7] & 0x00000002) <<14);
|
||||
output[ 1] |= ((input[ 0] & 0x00000200) << 7);
|
||||
output[ 1] |= ((other[ 0] & 0x00000200) << 8);
|
||||
output[ 1] |= ((input[ 1] & 0x00000200) << 9);
|
||||
output[ 1] |= ((other[ 1] & 0x00000200) <<10);
|
||||
output[ 1] |= ((input[ 2] & 0x00000200) <<11);
|
||||
output[ 1] |= ((other[ 2] & 0x00000200) <<12);
|
||||
output[ 1] |= ((input[ 3] & 0x00000200) <<13);
|
||||
output[ 1] |= ((other[ 3] & 0x00000200) <<14);
|
||||
output[ 1] |= ((input[ 4] & 0x00000200) <<15);
|
||||
output[ 1] |= ((other[ 4] & 0x00000200) <<16);
|
||||
output[ 1] |= ((input[ 5] & 0x00000200) <<17);
|
||||
output[ 1] |= ((other[ 5] & 0x00000200) <<18);
|
||||
output[ 1] |= ((input[ 6] & 0x00000200) <<19);
|
||||
output[ 1] |= ((other[ 6] & 0x00000200) <<20);
|
||||
output[ 1] |= ((input[ 7] & 0x00000200) <<21);
|
||||
output[ 1] |= ((other[ 7] & 0x00000200) <<22);
|
||||
|
||||
output[ 2] |= ((input[ 0] & 0x00000004) >> 2);
|
||||
output[ 2] |= ((other[ 0] & 0x00000004) >> 1);
|
||||
output[ 2] |= (input[ 1] & 0x00000004);
|
||||
output[ 2] |= ((other[ 1] & 0x00000004) << 1);
|
||||
output[ 2] |= ((input[ 2] & 0x00000004) << 2);
|
||||
output[ 2] |= ((other[ 2] & 0x00000004) << 3);
|
||||
output[ 2] |= ((input[ 3] & 0x00000004) << 4);
|
||||
output[ 2] |= ((other[ 3] & 0x00000004) << 5);
|
||||
output[ 2] |= ((input[ 4] & 0x00000004) << 6);
|
||||
output[ 2] |= ((other[ 4] & 0x00000004) << 7);
|
||||
output[ 2] |= ((input[ 5] & 0x00000004) << 8);
|
||||
output[ 2] |= ((other[ 5] & 0x00000004) << 9);
|
||||
output[ 2] |= ((input[ 6] & 0x00000004) <<10);
|
||||
output[ 2] |= ((other[ 6] & 0x00000004) <<11);
|
||||
output[ 2] |= ((input[ 7] & 0x00000004) <<12);
|
||||
output[ 2] |= ((other[ 7] & 0x00000004) <<13);
|
||||
output[ 2] |= ((input[ 0] & 0x00000400) << 6);
|
||||
output[ 2] |= ((other[ 0] & 0x00000400) << 7);
|
||||
output[ 2] |= ((input[ 1] & 0x00000400) << 8);
|
||||
output[ 2] |= ((other[ 1] & 0x00000400) << 9);
|
||||
output[ 2] |= ((input[ 2] & 0x00000400) <<10);
|
||||
output[ 2] |= ((other[ 2] & 0x00000400) <<11);
|
||||
output[ 2] |= ((input[ 3] & 0x00000400) <<12);
|
||||
output[ 2] |= ((other[ 3] & 0x00000400) <<13);
|
||||
output[ 2] |= ((input[ 4] & 0x00000400) <<14);
|
||||
output[ 2] |= ((other[ 4] & 0x00000400) <<15);
|
||||
output[ 2] |= ((input[ 5] & 0x00000400) <<16);
|
||||
output[ 2] |= ((other[ 5] & 0x00000400) <<17);
|
||||
output[ 2] |= ((input[ 6] & 0x00000400) <<18);
|
||||
output[ 2] |= ((other[ 6] & 0x00000400) <<19);
|
||||
output[ 2] |= ((input[ 7] & 0x00000400) <<20);
|
||||
output[ 2] |= ((other[ 7] & 0x00000400) <<21);
|
||||
output[ 3] |= ((input[ 0] & 0x00000008) >> 3);
|
||||
output[ 3] |= ((other[ 0] & 0x00000008) >> 2);
|
||||
output[ 3] |= ((input[ 1] & 0x00000008) >> 1);
|
||||
output[ 3] |= (other[ 1] & 0x00000008);
|
||||
output[ 3] |= ((input[ 2] & 0x00000008) << 1);
|
||||
output[ 3] |= ((other[ 2] & 0x00000008) << 2);
|
||||
output[ 3] |= ((input[ 3] & 0x00000008) << 3);
|
||||
output[ 3] |= ((other[ 3] & 0x00000008) << 4);
|
||||
output[ 3] |= ((input[ 4] & 0x00000008) << 5);
|
||||
output[ 3] |= ((other[ 4] & 0x00000008) << 6);
|
||||
output[ 3] |= ((input[ 5] & 0x00000008) << 7);
|
||||
output[ 3] |= ((other[ 5] & 0x00000008) << 8);
|
||||
output[ 3] |= ((input[ 6] & 0x00000008) << 9);
|
||||
output[ 3] |= ((other[ 6] & 0x00000008) <<10);
|
||||
output[ 3] |= ((input[ 7] & 0x00000008) <<11);
|
||||
output[ 3] |= ((other[ 7] & 0x00000008) <<12);
|
||||
output[ 3] |= ((input[ 0] & 0x00000800) << 5);
|
||||
output[ 3] |= ((other[ 0] & 0x00000800) << 6);
|
||||
output[ 3] |= ((input[ 1] & 0x00000800) << 7);
|
||||
output[ 3] |= ((other[ 1] & 0x00000800) << 8);
|
||||
output[ 3] |= ((input[ 2] & 0x00000800) << 9);
|
||||
output[ 3] |= ((other[ 2] & 0x00000800) <<10);
|
||||
output[ 3] |= ((input[ 3] & 0x00000800) <<11);
|
||||
output[ 3] |= ((other[ 3] & 0x00000800) <<12);
|
||||
output[ 3] |= ((input[ 4] & 0x00000800) <<13);
|
||||
output[ 3] |= ((other[ 4] & 0x00000800) <<14);
|
||||
output[ 3] |= ((input[ 5] & 0x00000800) <<15);
|
||||
output[ 3] |= ((other[ 5] & 0x00000800) <<16);
|
||||
output[ 3] |= ((input[ 6] & 0x00000800) <<17);
|
||||
output[ 3] |= ((other[ 6] & 0x00000800) <<18);
|
||||
output[ 3] |= ((input[ 7] & 0x00000800) <<19);
|
||||
output[ 3] |= ((other[ 7] & 0x00000800) <<20);
|
||||
output[ 4] |= ((input[ 0] & 0x00000010) >> 4);
|
||||
output[ 4] |= ((other[ 0] & 0x00000010) >> 3);
|
||||
output[ 4] |= ((input[ 1] & 0x00000010) >> 2);
|
||||
output[ 4] |= ((other[ 1] & 0x00000010) >> 1);
|
||||
output[ 4] |= (input[ 2] & 0x00000010);
|
||||
output[ 4] |= ((other[ 2] & 0x00000010) << 1);
|
||||
output[ 4] |= ((input[ 3] & 0x00000010) << 2);
|
||||
output[ 4] |= ((other[ 3] & 0x00000010) << 3);
|
||||
output[ 4] |= ((input[ 4] & 0x00000010) << 4);
|
||||
output[ 4] |= ((other[ 4] & 0x00000010) << 5);
|
||||
output[ 4] |= ((input[ 5] & 0x00000010) << 6);
|
||||
output[ 4] |= ((other[ 5] & 0x00000010) << 7);
|
||||
output[ 4] |= ((input[ 6] & 0x00000010) << 8);
|
||||
output[ 4] |= ((other[ 6] & 0x00000010) << 9);
|
||||
output[ 4] |= ((input[ 7] & 0x00000010) <<10);
|
||||
output[ 4] |= ((other[ 7] & 0x00000010) <<11);
|
||||
output[ 4] |= ((input[ 0] & 0x00001000) << 4);
|
||||
output[ 4] |= ((other[ 0] & 0x00001000) << 5);
|
||||
output[ 4] |= ((input[ 1] & 0x00001000) << 6);
|
||||
output[ 4] |= ((other[ 1] & 0x00001000) << 7);
|
||||
output[ 4] |= ((input[ 2] & 0x00001000) << 8);
|
||||
output[ 4] |= ((other[ 2] & 0x00001000) << 9);
|
||||
output[ 4] |= ((input[ 3] & 0x00001000) <<10);
|
||||
output[ 4] |= ((other[ 3] & 0x00001000) <<11);
|
||||
output[ 4] |= ((input[ 4] & 0x00001000) <<12);
|
||||
output[ 4] |= ((other[ 4] & 0x00001000) <<13);
|
||||
output[ 4] |= ((input[ 5] & 0x00001000) <<14);
|
||||
output[ 4] |= ((other[ 5] & 0x00001000) <<15);
|
||||
output[ 4] |= ((input[ 6] & 0x00001000) <<16);
|
||||
output[ 4] |= ((other[ 6] & 0x00001000) <<17);
|
||||
output[ 4] |= ((input[ 7] & 0x00001000) <<18);
|
||||
output[ 4] |= ((other[ 7] & 0x00001000) <<19);
|
||||
output[ 5] |= ((input[ 0] & 0x00000020) >> 5);
|
||||
output[ 5] |= ((other[ 0] & 0x00000020) >> 4);
|
||||
output[ 5] |= ((input[ 1] & 0x00000020) >> 3);
|
||||
output[ 5] |= ((other[ 1] & 0x00000020) >> 2);
|
||||
output[ 5] |= ((input[ 2] & 0x00000020) >> 1);
|
||||
output[ 5] |= (other[ 2] & 0x00000020);
|
||||
output[ 5] |= ((input[ 3] & 0x00000020) << 1);
|
||||
output[ 5] |= ((other[ 3] & 0x00000020) << 2);
|
||||
output[ 5] |= ((input[ 4] & 0x00000020) << 3);
|
||||
output[ 5] |= ((other[ 4] & 0x00000020) << 4);
|
||||
output[ 5] |= ((input[ 5] & 0x00000020) << 5);
|
||||
output[ 5] |= ((other[ 5] & 0x00000020) << 6);
|
||||
output[ 5] |= ((input[ 6] & 0x00000020) << 7);
|
||||
output[ 5] |= ((other[ 6] & 0x00000020) << 8);
|
||||
output[ 5] |= ((input[ 7] & 0x00000020) << 9);
|
||||
output[ 5] |= ((other[ 7] & 0x00000020) <<10);
|
||||
output[ 5] |= ((input[ 0] & 0x00002000) << 3);
|
||||
output[ 5] |= ((other[ 0] & 0x00002000) << 4);
|
||||
output[ 5] |= ((input[ 1] & 0x00002000) << 5);
|
||||
output[ 5] |= ((other[ 1] & 0x00002000) << 6);
|
||||
output[ 5] |= ((input[ 2] & 0x00002000) << 7);
|
||||
output[ 5] |= ((other[ 2] & 0x00002000) << 8);
|
||||
output[ 5] |= ((input[ 3] & 0x00002000) << 9);
|
||||
output[ 5] |= ((other[ 3] & 0x00002000) <<10);
|
||||
output[ 5] |= ((input[ 4] & 0x00002000) <<11);
|
||||
output[ 5] |= ((other[ 4] & 0x00002000) <<12);
|
||||
output[ 5] |= ((input[ 5] & 0x00002000) <<13);
|
||||
output[ 5] |= ((other[ 5] & 0x00002000) <<14);
|
||||
output[ 5] |= ((input[ 6] & 0x00002000) <<15);
|
||||
output[ 5] |= ((other[ 6] & 0x00002000) <<16);
|
||||
output[ 5] |= ((input[ 7] & 0x00002000) <<17);
|
||||
output[ 5] |= ((other[ 7] & 0x00002000) <<18);
|
||||
output[ 6] |= ((input[ 0] & 0x00000040) >> 6);
|
||||
output[ 6] |= ((other[ 0] & 0x00000040) >> 5);
|
||||
output[ 6] |= ((input[ 1] & 0x00000040) >> 4);
|
||||
output[ 6] |= ((other[ 1] & 0x00000040) >> 3);
|
||||
output[ 6] |= ((input[ 2] & 0x00000040) >> 2);
|
||||
output[ 6] |= ((other[ 2] & 0x00000040) >> 1);
|
||||
output[ 6] |= (input[ 3] & 0x00000040);
|
||||
output[ 6] |= ((other[ 3] & 0x00000040) << 1);
|
||||
output[ 6] |= ((input[ 4] & 0x00000040) << 2);
|
||||
output[ 6] |= ((other[ 4] & 0x00000040) << 3);
|
||||
output[ 6] |= ((input[ 5] & 0x00000040) << 4);
|
||||
output[ 6] |= ((other[ 5] & 0x00000040) << 5);
|
||||
output[ 6] |= ((input[ 6] & 0x00000040) << 6);
|
||||
output[ 6] |= ((other[ 6] & 0x00000040) << 7);
|
||||
output[ 6] |= ((input[ 7] & 0x00000040) << 8);
|
||||
output[ 6] |= ((other[ 7] & 0x00000040) << 9);
|
||||
output[ 6] |= ((input[ 0] & 0x00004000) << 2);
|
||||
output[ 6] |= ((other[ 0] & 0x00004000) << 3);
|
||||
output[ 6] |= ((input[ 1] & 0x00004000) << 4);
|
||||
output[ 6] |= ((other[ 1] & 0x00004000) << 5);
|
||||
output[ 6] |= ((input[ 2] & 0x00004000) << 6);
|
||||
output[ 6] |= ((other[ 2] & 0x00004000) << 7);
|
||||
output[ 6] |= ((input[ 3] & 0x00004000) << 8);
|
||||
output[ 6] |= ((other[ 3] & 0x00004000) << 9);
|
||||
output[ 6] |= ((input[ 4] & 0x00004000) <<10);
|
||||
output[ 6] |= ((other[ 4] & 0x00004000) <<11);
|
||||
output[ 6] |= ((input[ 5] & 0x00004000) <<12);
|
||||
output[ 6] |= ((other[ 5] & 0x00004000) <<13);
|
||||
output[ 6] |= ((input[ 6] & 0x00004000) <<14);
|
||||
output[ 6] |= ((other[ 6] & 0x00004000) <<15);
|
||||
output[ 6] |= ((input[ 7] & 0x00004000) <<16);
|
||||
output[ 6] |= ((other[ 7] & 0x00004000) <<17);
|
||||
output[ 7] |= ((input[ 0] & 0x00000080) >> 7);
|
||||
output[ 7] |= ((other[ 0] & 0x00000080) >> 6);
|
||||
output[ 7] |= ((input[ 1] & 0x00000080) >> 5);
|
||||
output[ 7] |= ((other[ 1] & 0x00000080) >> 4);
|
||||
output[ 7] |= ((input[ 2] & 0x00000080) >> 3);
|
||||
output[ 7] |= ((other[ 2] & 0x00000080) >> 2);
|
||||
output[ 7] |= ((input[ 3] & 0x00000080) >> 1);
|
||||
output[ 7] |= (other[ 3] & 0x00000080);
|
||||
output[ 7] |= ((input[ 4] & 0x00000080) << 1);
|
||||
output[ 7] |= ((other[ 4] & 0x00000080) << 2);
|
||||
output[ 7] |= ((input[ 5] & 0x00000080) << 3);
|
||||
output[ 7] |= ((other[ 5] & 0x00000080) << 4);
|
||||
output[ 7] |= ((input[ 6] & 0x00000080) << 5);
|
||||
output[ 7] |= ((other[ 6] & 0x00000080) << 6);
|
||||
output[ 7] |= ((input[ 7] & 0x00000080) << 7);
|
||||
output[ 7] |= ((other[ 7] & 0x00000080) << 8);
|
||||
output[ 7] |= ((input[ 0] & 0x00008000) << 1);
|
||||
output[ 7] |= ((other[ 0] & 0x00008000) << 2);
|
||||
output[ 7] |= ((input[ 1] & 0x00008000) << 3);
|
||||
output[ 7] |= ((other[ 1] & 0x00008000) << 4);
|
||||
output[ 7] |= ((input[ 2] & 0x00008000) << 5);
|
||||
output[ 7] |= ((other[ 2] & 0x00008000) << 6);
|
||||
output[ 7] |= ((input[ 3] & 0x00008000) << 7);
|
||||
output[ 7] |= ((other[ 3] & 0x00008000) << 8);
|
||||
output[ 7] |= ((input[ 4] & 0x00008000) << 9);
|
||||
output[ 7] |= ((other[ 4] & 0x00008000) <<10);
|
||||
output[ 7] |= ((input[ 5] & 0x00008000) <<11);
|
||||
output[ 7] |= ((other[ 5] & 0x00008000) <<12);
|
||||
output[ 7] |= ((input[ 6] & 0x00008000) <<13);
|
||||
output[ 7] |= ((other[ 6] & 0x00008000) <<14);
|
||||
output[ 7] |= ((input[ 7] & 0x00008000) <<15);
|
||||
output[ 7] |= ((other[ 7] & 0x00008000) <<16);
|
||||
}
|
||||
|
||||
__device__ __forceinline__
|
||||
void from_bitslice_quad(uint32_t *input, uint32_t *output)
|
||||
{
|
||||
#pragma unroll 8
|
||||
for (int i=0; i < 16; i+=2) output[i] = 0;
|
||||
|
||||
output[ 0] |= ((input[ 0] & 0x00000100) >> 8);
|
||||
output[ 0] |= ((input[ 1] & 0x00000100) >> 7);
|
||||
output[ 0] |= ((input[ 2] & 0x00000100) >> 6);
|
||||
output[ 0] |= ((input[ 3] & 0x00000100) >> 5);
|
||||
output[ 0] |= ((input[ 4] & 0x00000100) >> 4);
|
||||
output[ 0] |= ((input[ 5] & 0x00000100) >> 3);
|
||||
output[ 0] |= ((input[ 6] & 0x00000100) >> 2);
|
||||
output[ 0] |= ((input[ 7] & 0x00000100) >> 1);
|
||||
output[ 0] |= ((input[ 0] & 0x01000000) >>16);
|
||||
output[ 0] |= ((input[ 1] & 0x01000000) >>15);
|
||||
output[ 0] |= ((input[ 2] & 0x01000000) >>14);
|
||||
output[ 0] |= ((input[ 3] & 0x01000000) >>13);
|
||||
output[ 0] |= ((input[ 4] & 0x01000000) >>12);
|
||||
output[ 0] |= ((input[ 5] & 0x01000000) >>11);
|
||||
output[ 0] |= ((input[ 6] & 0x01000000) >>10);
|
||||
output[ 0] |= ((input[ 7] & 0x01000000) >> 9);
|
||||
output[ 2] |= ((input[ 0] & 0x00000200) >> 9);
|
||||
output[ 2] |= ((input[ 1] & 0x00000200) >> 8);
|
||||
output[ 2] |= ((input[ 2] & 0x00000200) >> 7);
|
||||
output[ 2] |= ((input[ 3] & 0x00000200) >> 6);
|
||||
output[ 2] |= ((input[ 4] & 0x00000200) >> 5);
|
||||
output[ 2] |= ((input[ 5] & 0x00000200) >> 4);
|
||||
output[ 2] |= ((input[ 6] & 0x00000200) >> 3);
|
||||
output[ 2] |= ((input[ 7] & 0x00000200) >> 2);
|
||||
output[ 2] |= ((input[ 0] & 0x02000000) >>17);
|
||||
output[ 2] |= ((input[ 1] & 0x02000000) >>16);
|
||||
output[ 2] |= ((input[ 2] & 0x02000000) >>15);
|
||||
output[ 2] |= ((input[ 3] & 0x02000000) >>14);
|
||||
output[ 2] |= ((input[ 4] & 0x02000000) >>13);
|
||||
output[ 2] |= ((input[ 5] & 0x02000000) >>12);
|
||||
output[ 2] |= ((input[ 6] & 0x02000000) >>11);
|
||||
output[ 2] |= ((input[ 7] & 0x02000000) >>10);
|
||||
output[ 4] |= ((input[ 0] & 0x00000400) >>10);
|
||||
output[ 4] |= ((input[ 1] & 0x00000400) >> 9);
|
||||
output[ 4] |= ((input[ 2] & 0x00000400) >> 8);
|
||||
output[ 4] |= ((input[ 3] & 0x00000400) >> 7);
|
||||
output[ 4] |= ((input[ 4] & 0x00000400) >> 6);
|
||||
output[ 4] |= ((input[ 5] & 0x00000400) >> 5);
|
||||
output[ 4] |= ((input[ 6] & 0x00000400) >> 4);
|
||||
output[ 4] |= ((input[ 7] & 0x00000400) >> 3);
|
||||
output[ 4] |= ((input[ 0] & 0x04000000) >>18);
|
||||
output[ 4] |= ((input[ 1] & 0x04000000) >>17);
|
||||
output[ 4] |= ((input[ 2] & 0x04000000) >>16);
|
||||
output[ 4] |= ((input[ 3] & 0x04000000) >>15);
|
||||
output[ 4] |= ((input[ 4] & 0x04000000) >>14);
|
||||
output[ 4] |= ((input[ 5] & 0x04000000) >>13);
|
||||
output[ 4] |= ((input[ 6] & 0x04000000) >>12);
|
||||
output[ 4] |= ((input[ 7] & 0x04000000) >>11);
|
||||
output[ 6] |= ((input[ 0] & 0x00000800) >>11);
|
||||
output[ 6] |= ((input[ 1] & 0x00000800) >>10);
|
||||
output[ 6] |= ((input[ 2] & 0x00000800) >> 9);
|
||||
output[ 6] |= ((input[ 3] & 0x00000800) >> 8);
|
||||
output[ 6] |= ((input[ 4] & 0x00000800) >> 7);
|
||||
output[ 6] |= ((input[ 5] & 0x00000800) >> 6);
|
||||
output[ 6] |= ((input[ 6] & 0x00000800) >> 5);
|
||||
output[ 6] |= ((input[ 7] & 0x00000800) >> 4);
|
||||
output[ 6] |= ((input[ 0] & 0x08000000) >>19);
|
||||
output[ 6] |= ((input[ 1] & 0x08000000) >>18);
|
||||
output[ 6] |= ((input[ 2] & 0x08000000) >>17);
|
||||
output[ 6] |= ((input[ 3] & 0x08000000) >>16);
|
||||
output[ 6] |= ((input[ 4] & 0x08000000) >>15);
|
||||
output[ 6] |= ((input[ 5] & 0x08000000) >>14);
|
||||
output[ 6] |= ((input[ 6] & 0x08000000) >>13);
|
||||
output[ 6] |= ((input[ 7] & 0x08000000) >>12);
|
||||
output[ 8] |= ((input[ 0] & 0x00001000) >>12);
|
||||
output[ 8] |= ((input[ 1] & 0x00001000) >>11);
|
||||
output[ 8] |= ((input[ 2] & 0x00001000) >>10);
|
||||
output[ 8] |= ((input[ 3] & 0x00001000) >> 9);
|
||||
output[ 8] |= ((input[ 4] & 0x00001000) >> 8);
|
||||
output[ 8] |= ((input[ 5] & 0x00001000) >> 7);
|
||||
output[ 8] |= ((input[ 6] & 0x00001000) >> 6);
|
||||
output[ 8] |= ((input[ 7] & 0x00001000) >> 5);
|
||||
output[ 8] |= ((input[ 0] & 0x10000000) >>20);
|
||||
output[ 8] |= ((input[ 1] & 0x10000000) >>19);
|
||||
output[ 8] |= ((input[ 2] & 0x10000000) >>18);
|
||||
output[ 8] |= ((input[ 3] & 0x10000000) >>17);
|
||||
output[ 8] |= ((input[ 4] & 0x10000000) >>16);
|
||||
output[ 8] |= ((input[ 5] & 0x10000000) >>15);
|
||||
output[ 8] |= ((input[ 6] & 0x10000000) >>14);
|
||||
output[ 8] |= ((input[ 7] & 0x10000000) >>13);
|
||||
output[10] |= ((input[ 0] & 0x00002000) >>13);
|
||||
output[10] |= ((input[ 1] & 0x00002000) >>12);
|
||||
output[10] |= ((input[ 2] & 0x00002000) >>11);
|
||||
output[10] |= ((input[ 3] & 0x00002000) >>10);
|
||||
output[10] |= ((input[ 4] & 0x00002000) >> 9);
|
||||
output[10] |= ((input[ 5] & 0x00002000) >> 8);
|
||||
output[10] |= ((input[ 6] & 0x00002000) >> 7);
|
||||
output[10] |= ((input[ 7] & 0x00002000) >> 6);
|
||||
output[10] |= ((input[ 0] & 0x20000000) >>21);
|
||||
output[10] |= ((input[ 1] & 0x20000000) >>20);
|
||||
output[10] |= ((input[ 2] & 0x20000000) >>19);
|
||||
output[10] |= ((input[ 3] & 0x20000000) >>18);
|
||||
output[10] |= ((input[ 4] & 0x20000000) >>17);
|
||||
output[10] |= ((input[ 5] & 0x20000000) >>16);
|
||||
output[10] |= ((input[ 6] & 0x20000000) >>15);
|
||||
output[10] |= ((input[ 7] & 0x20000000) >>14);
|
||||
output[12] |= ((input[ 0] & 0x00004000) >>14);
|
||||
output[12] |= ((input[ 1] & 0x00004000) >>13);
|
||||
output[12] |= ((input[ 2] & 0x00004000) >>12);
|
||||
output[12] |= ((input[ 3] & 0x00004000) >>11);
|
||||
output[12] |= ((input[ 4] & 0x00004000) >>10);
|
||||
output[12] |= ((input[ 5] & 0x00004000) >> 9);
|
||||
output[12] |= ((input[ 6] & 0x00004000) >> 8);
|
||||
output[12] |= ((input[ 7] & 0x00004000) >> 7);
|
||||
output[12] |= ((input[ 0] & 0x40000000) >>22);
|
||||
output[12] |= ((input[ 1] & 0x40000000) >>21);
|
||||
output[12] |= ((input[ 2] & 0x40000000) >>20);
|
||||
output[12] |= ((input[ 3] & 0x40000000) >>19);
|
||||
output[12] |= ((input[ 4] & 0x40000000) >>18);
|
||||
output[12] |= ((input[ 5] & 0x40000000) >>17);
|
||||
output[12] |= ((input[ 6] & 0x40000000) >>16);
|
||||
output[12] |= ((input[ 7] & 0x40000000) >>15);
|
||||
output[14] |= ((input[ 0] & 0x00008000) >>15);
|
||||
output[14] |= ((input[ 1] & 0x00008000) >>14);
|
||||
output[14] |= ((input[ 2] & 0x00008000) >>13);
|
||||
output[14] |= ((input[ 3] & 0x00008000) >>12);
|
||||
output[14] |= ((input[ 4] & 0x00008000) >>11);
|
||||
output[14] |= ((input[ 5] & 0x00008000) >>10);
|
||||
output[14] |= ((input[ 6] & 0x00008000) >> 9);
|
||||
output[14] |= ((input[ 7] & 0x00008000) >> 8);
|
||||
output[14] |= ((input[ 0] & 0x80000000) >>23);
|
||||
output[14] |= ((input[ 1] & 0x80000000) >>22);
|
||||
output[14] |= ((input[ 2] & 0x80000000) >>21);
|
||||
output[14] |= ((input[ 3] & 0x80000000) >>20);
|
||||
output[14] |= ((input[ 4] & 0x80000000) >>19);
|
||||
output[14] |= ((input[ 5] & 0x80000000) >>18);
|
||||
output[14] |= ((input[ 6] & 0x80000000) >>17);
|
||||
output[14] |= ((input[ 7] & 0x80000000) >>16);
|
||||
|
||||
#pragma unroll 8
|
||||
for (int i = 0; i < 16; i+=2) {
|
||||
if (threadIdx.x & 1) output[i] = __byte_perm(output[i], 0, 0x1032);
|
||||
output[i] = __byte_perm(output[i], __shfl((int)output[i], (threadIdx.x+1)%4, 4), 0x7610);
|
||||
output[i+1] = __shfl((int)output[i], (threadIdx.x+2)%4, 4);
|
||||
if (threadIdx.x % 4) output[i] = output[i+1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* host "fake" functions */
|
||||
#define from_bitslice_quad(st, out)
|
||||
#define to_bitslice_quad(in, msg) in[0] = (uint32_t) in[0];
|
||||
|
||||
#endif /* device only code */
|
||||
-512
@@ -1,512 +0,0 @@
|
||||
/**
|
||||
* Blake-256 Cuda Kernel (Tested on SM 5.0)
|
||||
*
|
||||
* Tanguy Pruvot - Nov. 2014
|
||||
*/
|
||||
|
||||
#define PRECALC64 1
|
||||
|
||||
#include "miner.h"
|
||||
|
||||
extern "C" {
|
||||
#include "sph/sph_blake.h"
|
||||
#include <stdint.h>
|
||||
#include <memory.h>
|
||||
}
|
||||
|
||||
/* threads per block and throughput (intensity) */
|
||||
#define TPB 128
|
||||
#define INTENSITY (1 << 20) // = 1048576 nonces per call
|
||||
|
||||
/* added in sph_blake.c */
|
||||
extern "C" int blake256_rounds = 14;
|
||||
|
||||
/* hash by cpu with blake 256 */
|
||||
extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14)
|
||||
{
|
||||
uchar hash[64];
|
||||
sph_blake256_context ctx;
|
||||
|
||||
blake256_rounds = rounds;
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 80);
|
||||
sph_blake256_close(&ctx, hash);
|
||||
|
||||
memcpy(output, hash, 32);
|
||||
}
|
||||
|
||||
#include "cuda_helper.h"
|
||||
|
||||
#define MAXU 0xffffffffU
|
||||
|
||||
// in cpu-miner.c
|
||||
extern bool opt_n_threads;
|
||||
extern int device_map[8];
|
||||
|
||||
#if PRECALC64
|
||||
__constant__ uint32_t _ALIGN(32) d_data[12];
|
||||
#else
|
||||
__constant__ static uint32_t _ALIGN(32) c_data[20];
|
||||
/* midstate hash cache, this algo is run on 2 parts */
|
||||
__device__ static uint32_t cache[8];
|
||||
__device__ static uint32_t prevsum = 0;
|
||||
/* crc32.c */
|
||||
extern "C" uint32_t crc32_u32t(const uint32_t *buf, size_t size);
|
||||
#endif
|
||||
|
||||
/* 8 adapters max (-t threads) */
|
||||
static uint32_t *d_resNonce[8];
|
||||
static uint32_t *h_resNonce[8];
|
||||
|
||||
/* max count of found nonces in one call */
|
||||
#define NBN 2
|
||||
static uint32_t extra_results[NBN] = { MAXU };
|
||||
|
||||
/* prefer uint32_t to prevent size conversions = speed +5/10 % */
|
||||
__constant__
|
||||
static uint32_t _ALIGN(32) c_sigma[16][16] = {
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
|
||||
{12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
|
||||
{13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
|
||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
|
||||
{10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
|
||||
{14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
|
||||
{11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
|
||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
|
||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
|
||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }
|
||||
};
|
||||
|
||||
#if !PRECALC64
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_IV256[8] = {
|
||||
SPH_C32(0x6A09E667), SPH_C32(0xBB67AE85),
|
||||
SPH_C32(0x3C6EF372), SPH_C32(0xA54FF53A),
|
||||
SPH_C32(0x510E527F), SPH_C32(0x9B05688C),
|
||||
SPH_C32(0x1F83D9AB), SPH_C32(0x5BE0CD19)
|
||||
};
|
||||
#endif
|
||||
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_u256[16] = {
|
||||
SPH_C32(0x243F6A88), SPH_C32(0x85A308D3),
|
||||
SPH_C32(0x13198A2E), SPH_C32(0x03707344),
|
||||
SPH_C32(0xA4093822), SPH_C32(0x299F31D0),
|
||||
SPH_C32(0x082EFA98), SPH_C32(0xEC4E6C89),
|
||||
SPH_C32(0x452821E6), SPH_C32(0x38D01377),
|
||||
SPH_C32(0xBE5466CF), SPH_C32(0x34E90C6C),
|
||||
SPH_C32(0xC0AC29B7), SPH_C32(0xC97C50DD),
|
||||
SPH_C32(0x3F84D5B5), SPH_C32(0xB5470917)
|
||||
};
|
||||
|
||||
#define GS(a,b,c,d,x) { \
|
||||
const uint32_t idx1 = c_sigma[r][x]; \
|
||||
const uint32_t idx2 = c_sigma[r][x+1]; \
|
||||
v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
|
||||
v[d] = SPH_ROTL32(v[d] ^ v[a], 16); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 12); \
|
||||
\
|
||||
v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \
|
||||
v[d] = SPH_ROTR32(v[d] ^ v[a], 8); \
|
||||
v[c] += v[d]; \
|
||||
v[b] = SPH_ROTR32(v[b] ^ v[c], 7); \
|
||||
}
|
||||
|
||||
/* Second part (64-80) msg never change, store it */
|
||||
__device__ __constant__
|
||||
static const uint32_t __align__(32) c_Padding[16] = {
|
||||
0, 0, 0, 0,
|
||||
0x80000000UL, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 1, 0, 640,
|
||||
};
|
||||
|
||||
__device__ static
|
||||
void blake256_compress(uint32_t *h, const uint32_t *block, const uint32_t T0, const int rounds)
|
||||
{
|
||||
uint32_t /*_ALIGN(8)*/ m[16];
|
||||
uint32_t v[16];
|
||||
|
||||
m[0] = block[0];
|
||||
m[1] = block[1];
|
||||
m[2] = block[2];
|
||||
m[3] = block[3];
|
||||
|
||||
for (uint32_t i = 4; i < 16; i++) {
|
||||
#if PRECALC64
|
||||
m[i] = c_Padding[i];
|
||||
#else
|
||||
m[i] = (T0 == 0x200) ? block[i] : c_Padding[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
//#pragma unroll 8
|
||||
for(uint32_t i = 0; i < 8; i++)
|
||||
v[i] = h[i];
|
||||
|
||||
v[ 8] = c_u256[0];
|
||||
v[ 9] = c_u256[1];
|
||||
v[10] = c_u256[2];
|
||||
v[11] = c_u256[3];
|
||||
|
||||
v[12] = c_u256[4] ^ T0;
|
||||
v[13] = c_u256[5] ^ T0;
|
||||
v[14] = c_u256[6];
|
||||
v[15] = c_u256[7];
|
||||
|
||||
for (int r = 0; r < rounds; r++) {
|
||||
/* column step */
|
||||
GS(0, 4, 0x8, 0xC, 0x0);
|
||||
GS(1, 5, 0x9, 0xD, 0x2);
|
||||
GS(2, 6, 0xA, 0xE, 0x4);
|
||||
GS(3, 7, 0xB, 0xF, 0x6);
|
||||
/* diagonal step */
|
||||
GS(0, 5, 0xA, 0xF, 0x8);
|
||||
GS(1, 6, 0xB, 0xC, 0xA);
|
||||
GS(2, 7, 0x8, 0xD, 0xC);
|
||||
GS(3, 4, 0x9, 0xE, 0xE);
|
||||
}
|
||||
#if PRECALC64
|
||||
// only compute h6 & 7
|
||||
h[6U] ^= v[6U] ^ v[14U];
|
||||
h[7U] ^= v[7U] ^ v[15U];
|
||||
#else
|
||||
//#pragma unroll 16
|
||||
for (uint32_t i = 0; i < 16; i++) {
|
||||
uint32_t j = i % 8U;
|
||||
h[j] ^= v[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !PRECALC64 /* original method */
|
||||
__global__
|
||||
void blake256_gpu_hash_80(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,
|
||||
const uint64_t highTarget, const int crcsum, const int rounds)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t h[8];
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
h[i] = c_IV256[i];
|
||||
}
|
||||
|
||||
if (crcsum != prevsum) {
|
||||
prevsum = crcsum;
|
||||
blake256_compress(h, c_data, 512, rounds);
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
cache[i] = h[i];
|
||||
}
|
||||
} else {
|
||||
#pragma unroll
|
||||
for(int i=0; i<8; i++) {
|
||||
h[i] = cache[i];
|
||||
}
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t ending[4];
|
||||
ending[0] = c_data[16];
|
||||
ending[1] = c_data[17];
|
||||
ending[2] = c_data[18];
|
||||
ending[3] = nonce; /* our tested value */
|
||||
|
||||
blake256_compress(h, ending, 640, rounds);
|
||||
|
||||
// not sure why, h[7] is ok
|
||||
h[6] = cuda_swab32(h[6]);
|
||||
|
||||
// compare count of leading zeros h[6] + h[7]
|
||||
uint64_t high64 = ((uint64_t*)h)[3];
|
||||
if (high64 <= highTarget)
|
||||
#if NBN == 2
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (resNonce[0] > nonce) {
|
||||
// printf("%llx %llx \n", high64, highTarget);
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = nonce;
|
||||
}
|
||||
else
|
||||
resNonce[1] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
uint32_t blake256_cpu_hash_80(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint64_t highTarget,
|
||||
const uint32_t crcsum, const int8_t rounds)
|
||||
{
|
||||
const int threadsperblock = TPB;
|
||||
uint32_t result = MAXU;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
size_t shared_size = 0;
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonce[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
blake256_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNonce, d_resNonce[thr_id], highTarget, crcsum, (int) rounds);
|
||||
cudaDeviceSynchronize();
|
||||
if (cudaSuccess == cudaMemcpy(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
//cudaThreadSynchronize(); /* seems no more required */
|
||||
result = h_resNonce[thr_id][0];
|
||||
for (int n=0; n < (NBN-1); n++)
|
||||
extra_results[n] = h_resNonce[thr_id][n+1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_80(uint32_t *pdata, const uint32_t *ptarget)
|
||||
{
|
||||
uint32_t data[20];
|
||||
memcpy(data, pdata, 80);
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(c_data, data, sizeof(data), 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
#else
|
||||
|
||||
/* ############################################################################################################################### */
|
||||
/* Precalculated 1st 64-bytes block (midstate) method */
|
||||
|
||||
__global__
|
||||
void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uint32_t *resNonce,
|
||||
const uint64_t highTarget, const int rounds, const bool trace)
|
||||
{
|
||||
uint32_t thread = (blockDim.x * blockIdx.x + threadIdx.x);
|
||||
if (thread < threads)
|
||||
{
|
||||
const uint32_t nonce = startNonce + thread;
|
||||
uint32_t _ALIGN(16) h[8];
|
||||
|
||||
#pragma unroll
|
||||
for(int i=0; i < 8; i++) {
|
||||
h[i] = d_data[i];
|
||||
}
|
||||
|
||||
// ------ Close: Bytes 64 to 80 ------
|
||||
|
||||
uint32_t _ALIGN(16) ending[4];
|
||||
ending[0] = d_data[8];
|
||||
ending[1] = d_data[9];
|
||||
ending[2] = d_data[10];
|
||||
ending[3] = nonce; /* our tested value */
|
||||
|
||||
blake256_compress(h, ending, 640, rounds);
|
||||
|
||||
//if (h[7] == 0 && high64 <= highTarget) {
|
||||
if (h[7] == 0) {
|
||||
#if NBN == 2
|
||||
/* keep the smallest nonce, + extra one if found */
|
||||
if (resNonce[0] > nonce) {
|
||||
// printf("%llx %llx \n", high64, highTarget);
|
||||
resNonce[1] = resNonce[0];
|
||||
resNonce[0] = nonce;
|
||||
}
|
||||
else
|
||||
resNonce[1] = nonce;
|
||||
#else
|
||||
resNonce[0] = nonce;
|
||||
#endif
|
||||
if (trace) {
|
||||
#ifdef _DEBUG
|
||||
uint64_t high64 = ((uint64_t*)h)[3];
|
||||
printf("gpu: %16llx\n", high64);
|
||||
printf("gpu: %08x.%08x\n", h[7], h[6]);
|
||||
printf("tgt: %16llx\n", highTarget);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
__host__
|
||||
static uint32_t blake256_cpu_hash_16(const int thr_id, const uint32_t threads, const uint32_t startNonce, const uint64_t highTarget,
|
||||
const int8_t rounds)
|
||||
{
|
||||
const int threadsperblock = TPB;
|
||||
uint32_t result = MAXU;
|
||||
|
||||
dim3 grid((threads + threadsperblock-1)/threadsperblock);
|
||||
dim3 block(threadsperblock);
|
||||
|
||||
/* Check error on Ctrl+C or kill to prevent segfaults on exit */
|
||||
if (cudaMemset(d_resNonce[thr_id], 0xff, NBN*sizeof(uint32_t)) != cudaSuccess)
|
||||
return result;
|
||||
|
||||
blake256_gpu_hash_16 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget, (int) rounds, opt_tracegpu);
|
||||
cudaDeviceSynchronize();
|
||||
if (cudaSuccess == cudaMemcpy(h_resNonce[thr_id], d_resNonce[thr_id], NBN*sizeof(uint32_t), cudaMemcpyDeviceToHost)) {
|
||||
//cudaThreadSynchronize(); /* seems no more required */
|
||||
result = h_resNonce[thr_id][0];
|
||||
for (int n=0; n < (NBN-1); n++)
|
||||
extra_results[n] = h_resNonce[thr_id][n+1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__host__
|
||||
static void blake256mid(uint32_t *output, const uint32_t *input, int8_t rounds = 14)
|
||||
{
|
||||
sph_blake256_context ctx;
|
||||
|
||||
/* in sph_blake.c */
|
||||
blake256_rounds = rounds;
|
||||
|
||||
sph_blake256_init(&ctx);
|
||||
sph_blake256(&ctx, input, 64);
|
||||
|
||||
memcpy(output, (void*)ctx.H, 32);
|
||||
}
|
||||
|
||||
__host__
|
||||
void blake256_cpu_setBlock_16(uint32_t *penddata, const uint32_t *midstate, const uint32_t *ptarget)
|
||||
{
|
||||
uint32_t _ALIGN(64) data[11];
|
||||
memcpy(data, midstate, 32);
|
||||
data[8] = penddata[0];
|
||||
data[9] = penddata[1];
|
||||
data[10]= penddata[2];
|
||||
CUDA_SAFE_CALL(cudaMemcpyToSymbol(d_data, data, 32 + 12, 0, cudaMemcpyHostToDevice));
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, int8_t blakerounds=14)
|
||||
{
|
||||
const uint32_t first_nonce = pdata[19];
|
||||
static bool init[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
uint64_t targetHigh = ((uint64_t*)ptarget)[3]; // 0x00000000.0fffffff
|
||||
uint32_t _ALIGN(64) endiandata[20];
|
||||
#if PRECALC64
|
||||
uint32_t _ALIGN(64) midstate[8];
|
||||
#else
|
||||
uint32_t crcsum;
|
||||
#endif
|
||||
/* todo: -i param */
|
||||
uint32_t throughput = min(INTENSITY, max_nonce - first_nonce);
|
||||
|
||||
int rc = 0;
|
||||
|
||||
#if NBN > 1
|
||||
if (extra_results[0] != MAXU) {
|
||||
// possible extra result found in previous call
|
||||
if (first_nonce <= extra_results[0] && max_nonce >= extra_results[0]) {
|
||||
pdata[19] = extra_results[0];
|
||||
*hashes_done = pdata[19] - first_nonce + 1;
|
||||
extra_results[0] = MAXU;
|
||||
rc = 1;
|
||||
goto exit_scan;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opt_benchmark)
|
||||
targetHigh = 0x1ULL << 32;
|
||||
|
||||
if (opt_tracegpu) {
|
||||
/* test call from util.c */
|
||||
throughput = 1;
|
||||
for (int k = 0; k < 20; k++)
|
||||
pdata[k] = swab32(pdata[k]);
|
||||
}
|
||||
|
||||
if (!init[thr_id]) {
|
||||
if (opt_n_threads > 1) {
|
||||
CUDA_SAFE_CALL(cudaSetDevice(device_map[thr_id]));
|
||||
}
|
||||
CUDA_SAFE_CALL(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)));
|
||||
CUDA_SAFE_CALL(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)));
|
||||
init[thr_id] = true;
|
||||
}
|
||||
|
||||
#if PRECALC64
|
||||
for (int k = 0; k < 16; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
blake256mid(midstate, endiandata, blakerounds);
|
||||
blake256_cpu_setBlock_16(&pdata[16], midstate, ptarget);
|
||||
#else
|
||||
blake256_cpu_setBlock_80(pdata, ptarget);
|
||||
crcsum = crc32_u32t(pdata, 64);
|
||||
#endif /* PRECALC64 */
|
||||
|
||||
do {
|
||||
uint32_t foundNonce =
|
||||
#if PRECALC64
|
||||
// GPU HASH (second block only, first is midstate)
|
||||
blake256_cpu_hash_16(thr_id, throughput, pdata[19], targetHigh, blakerounds);
|
||||
#else
|
||||
// GPU FULL HASH
|
||||
blake256_cpu_hash_80(thr_id, throughput, pdata[19], targetHigh, crcsum, blakerounds);
|
||||
#endif
|
||||
if (foundNonce != MAXU)
|
||||
{
|
||||
uint32_t vhashcpu[8];
|
||||
uint32_t Htarg = (uint32_t)targetHigh;
|
||||
|
||||
for (int k=0; k < 19; k++)
|
||||
be32enc(&endiandata[k], pdata[k]);
|
||||
|
||||
be32enc(&endiandata[19], foundNonce);
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
|
||||
//applog(LOG_BLUE, "%08x %16llx", vhashcpu[6], targetHigh);
|
||||
if (vhashcpu[6] <= Htarg /*&& fulltest(vhashcpu, ptarget)*/)
|
||||
{
|
||||
pdata[19] = foundNonce;
|
||||
rc = 1;
|
||||
|
||||
if (extra_results[0] != MAXU) {
|
||||
// Rare but possible if the throughput is big
|
||||
be32enc(&endiandata[19], extra_results[0]);
|
||||
|
||||
blake256hash(vhashcpu, endiandata, blakerounds);
|
||||
if (vhashcpu[6] <= Htarg /* && fulltest(vhashcpu, ptarget) */) {
|
||||
applog(LOG_NOTICE, "GPU found more than one result " CL_GRN "yippee!");
|
||||
rc = 2;
|
||||
} else {
|
||||
extra_results[0] = MAXU;
|
||||
}
|
||||
}
|
||||
|
||||
//applog_hash((uint8_t*)ptarget);
|
||||
//applog_compare_hash((uint8_t*)vhashcpu,(uint8_t*)ptarget);
|
||||
goto exit_scan;
|
||||
}
|
||||
else if (opt_debug) {
|
||||
applog_hash((uint8_t*)ptarget);
|
||||
applog_compare_hash((uint8_t*)vhashcpu,(uint8_t*)ptarget);
|
||||
applog(LOG_DEBUG, "GPU #%d: result for nonce %08x does not validate on CPU!", thr_id, foundNonce);
|
||||
}
|
||||
}
|
||||
|
||||
if ((uint64_t) pdata[19] + throughput > (uint64_t) max_nonce) {
|
||||
pdata[19] = max_nonce;
|
||||
break;
|
||||
}
|
||||
|
||||
pdata[19] += throughput;
|
||||
|
||||
} while (!work_restart[thr_id].restart);
|
||||
|
||||
exit_scan:
|
||||
*hashes_done = pdata[19] - first_nonce + 1; // (+1 to prevent locks)
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
REM COMMAND LINE MS BUILD
|
||||
REM Note: /m:2 = 2 threads, but for host code only...
|
||||
|
||||
msbuild ccminer.vcxproj /m /p:Configuration=Release
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"_comment1" : "Possible keys are the long options (ccminer --help)",
|
||||
"_comment2" : "todo: support /* comments */",
|
||||
|
||||
"algo" : "lbry",
|
||||
"intensity": 22,
|
||||
|
||||
"api-bind": "127.0.0.1:4068",
|
||||
"statsavg": 20,
|
||||
|
||||
"max-log-rate": 60,
|
||||
"quiet" : false,
|
||||
"debug" : false,
|
||||
"protocol" : false,
|
||||
"cpu-priority" : 3,
|
||||
|
||||
"url" : "stratum+tcp://yiimp.ccminer.org:3334",
|
||||
"user" : "bK2wcSFJv2nnNjFvTN5Q7VX8X8unJktJsa",
|
||||
"pass" : "donate"
|
||||
}
|
||||
+4343
File diff suppressed because it is too large.
Load diff
+320
-288
@@ -23,38 +23,23 @@
|
||||
<RootNamespace>ccminer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CLRSupport>false</CLRSupport>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 6.5.props" />
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.0.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -68,44 +53,35 @@
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;pthreadVC2.lib;libcurl.x86.lib;openssl.x86.lib;zlib.x86.lib;ws2_32.lib;Wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;pthreadVC2.lib;libcurl.x86.lib;openssl.x86.lib;zlib.x86.lib;ws2_32.lib;Wldap32.lib;nvapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib;msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x86;compat\curl-for-windows\out\x86\Release\lib;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x86;compat\curl-for-windows\out\x86\Release\lib;compat\nvapi\x86;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
|
||||
<LinkStatus>true</LinkStatus>
|
||||
</Link>
|
||||
<CudaCompile>
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<GenerateLineInfo>true</GenerateLineInfo>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>false</Keep>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
|
||||
</CudaCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -114,27 +90,31 @@
|
||||
<Optimization>Disabled</Optimization>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<StructMemberAlignment>8Bytes</StructMemberAlignment>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;pthreadVC2.lib;libcurl.x64.lib;openssl.x64.lib;zlib.x64.lib;ws2_32.lib;Wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;pthreadVC2.lib;libcurl.x64.lib;openssl.x64.lib;zlib.x64.lib;ws2_32.lib;Wldap32.lib;nvapi64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x64;compat\curl-for-windows\out\x64\Release\lib;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x64;compat\curl-for-windows\out\x64\Release\lib;compat\nvapi\amd64;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions>
|
||||
<LinkStatus>true</LinkStatus>
|
||||
</Link>
|
||||
<CudaCompile>
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<GenerateLineInfo>true</GenerateLineInfo>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<CodeGeneration>compute_52,sm_52</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
|
||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaLink>
|
||||
<PerformDeviceLink>false</PerformDeviceLink>
|
||||
@@ -150,37 +130,38 @@
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<ExceptionHandling>SyncCThrow</ExceptionHandling>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.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;pthreadVC2.lib;libcurl.x86.lib;openssl.x86.lib;zlib.x86.lib;ws2_32.lib;Wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.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;pthreadVC2.lib;libcurl.x86.lib;openssl.x86.lib;zlib.x86.lib;ws2_32.lib;Wldap32.lib;nvapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x86;compat\curl-for-windows\out\x86\Release\lib;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x86;compat\curl-for-windows\out\x86\Release\lib;compat\nvapi\x86;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<LinkStatus>false</LinkStatus>
|
||||
<LargeAddressAware>true</LargeAddressAware>
|
||||
</Link>
|
||||
<CudaCompile>
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>false</Keep>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<Defines>
|
||||
</Defines>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52;compute_30,sm_30</CodeGeneration>
|
||||
<AdditionalOptions>--ptxas-options="-O2" --Wno-deprecated-gpu-targets %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>O2</Optimization>
|
||||
</CudaCompile>
|
||||
<CudaLink>
|
||||
<GPUDebugInfo>false</GPUDebugInfo>
|
||||
</CudaLink>
|
||||
<CudaLink>
|
||||
<Optimization>O2</Optimization>
|
||||
<Optimization>O3</Optimization>
|
||||
</CudaLink>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -189,34 +170,42 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;CURL_STATICLIB;USE_WRAPNVML;SCRYPT_KECCAK512;SCRYPT_CHACHA;SCRYPT_CHOOSE_COMPILETIME;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;compat;compat\curl-for-windows\curl\include;compat\jansson;compat\getopt;compat\pthreads;compat\curl-for-windows\openssl\openssl\include;compat\curl-for-windows\zlib;%(AdditionalIncludeDirectories);$(CudaToolkitIncludeDir)</AdditionalIncludeDirectories>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>cudart_static.lib;cuda.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;pthreadVC2.lib;libcurl.x64.lib;openssl.x64.lib;zlib.x64.lib;ws2_32.lib;Wldap32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;pthreadVC2.lib;libcurl.x64.lib;openssl.x64.lib;zlib.x64.lib;ws2_32.lib;Wldap32.lib;cudart_static.lib;cuda.lib;nvapi64.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x64;compat\curl-for-windows\out\x64\Release\lib;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories>compat\pthreads\x64;compat\curl-for-windows\out\x64\Release\lib;compat\nvapi\amd64;%(AdditionalLibraryDirectories);$(CudaToolkitLibDir)</AdditionalLibraryDirectories>
|
||||
<AdditionalOptions>/NODEFAULTLIB:LIBCMT %(AdditionalOptions)</AdditionalOptions>
|
||||
<LinkStatus>false</LinkStatus>
|
||||
<LargeAddressAware>true</LargeAddressAware>
|
||||
</Link>
|
||||
<CudaCompile>
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<PtxAsOptionV>true</PtxAsOptionV>
|
||||
<Keep>true</Keep>
|
||||
<CodeGeneration>compute_50,sm_50</CodeGeneration>
|
||||
<Include>
|
||||
</Include>
|
||||
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_35,sm_35;compute_30,sm_30</CodeGeneration>
|
||||
<Include>$(NVTOOLSEXT_PATH)\include</Include>
|
||||
<Optimization>O3</Optimization>
|
||||
<TargetMachinePlatform>64</TargetMachinePlatform>
|
||||
<AdditionalOptions>--Wno-deprecated-gpu-targets %(AdditionalOptions)</AdditionalOptions>
|
||||
</CudaCompile>
|
||||
<CudaLink>
|
||||
<Optimization>O3</Optimization>
|
||||
<PerformDeviceLink>false</PerformDeviceLink>
|
||||
</CudaLink>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -224,78 +213,168 @@
|
||||
<ClCompile Include="compat\getopt\getopt_long.c" />
|
||||
<ClCompile Include="compat\gettimeofday.c" />
|
||||
<ClCompile Include="compat\jansson\dump.c" />
|
||||
<ClCompile Include="compat\jansson\error.c" />
|
||||
<ClCompile Include="compat\jansson\hashtable.c" />
|
||||
<ClCompile Include="compat\jansson\load.c" />
|
||||
<ClCompile Include="compat\jansson\memory.c" />
|
||||
<ClCompile Include="compat\jansson\pack_unpack.c" />
|
||||
<ClCompile Include="compat\jansson\strbuffer.c" />
|
||||
<ClCompile Include="compat\jansson\strconv.c" />
|
||||
<ClCompile Include="compat\jansson\utf.c" />
|
||||
<ClCompile Include="compat\jansson\value.c" />
|
||||
<ClInclude Include="compat\pthreads\pthread.h" />
|
||||
<ClCompile Include="compat\winansi.c" />
|
||||
<ClCompile Include="cpu-miner.c">
|
||||
<AdditionalOptions>/Tp %(AdditionalOptions)</AdditionalOptions>
|
||||
<ClCompile Include="ccminer.cpp">
|
||||
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
|
||||
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crc32.c" />
|
||||
<ClCompile Include="crypto\mman.c" />
|
||||
<ClCompile Include="crypto\wildkeccak-cpu.cpp" />
|
||||
<ClCompile Include="crypto\xmr-rpc.cpp" />
|
||||
<ClCompile Include="crypto\aesb.cpp" />
|
||||
<ClCompile Include="crypto\oaes_lib.cpp" />
|
||||
<ClCompile Include="crypto\cryptolight-cpu.cpp" />
|
||||
<ClCompile Include="crypto\cryptonight-cpu.cpp" />
|
||||
<ClCompile Include="crypto\cpu\c_keccak.c" />
|
||||
<ClCompile Include="equi\blake2\blake2bx.cpp">
|
||||
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">StreamingSIMDExtensions</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi-stratum.cpp" />
|
||||
<ClCompile Include="equi\equi.cpp" />
|
||||
<ClCompile Include="equi\equihash.cpp" />
|
||||
<ClCompile Include="nvapi.cpp" />
|
||||
<ClCompile Include="nvsettings.cpp" />
|
||||
<ClCompile Include="pools.cpp" />
|
||||
<ClCompile Include="util.cpp" />
|
||||
<ClCompile Include="bench.cpp" />
|
||||
<ClCompile Include="bignum.cpp" />
|
||||
<ClInclude Include="bignum.hpp" />
|
||||
<ClCompile Include="fuguecoin.cpp" />
|
||||
<ClCompile Include="groestlcoin.cpp" />
|
||||
<ClCompile Include="hashlog.cpp" />
|
||||
<ClCompile Include="stats.cpp" />
|
||||
<ClCompile Include="nvml.cpp" />
|
||||
<ClCompile Include="api.cpp" />
|
||||
<ClCompile Include="sysinfos.cpp" />
|
||||
<ClCompile Include="crc32.c" />
|
||||
<ClCompile Include="hefty1.c" />
|
||||
<ClCompile Include="myriadgroestl.cpp" />
|
||||
<ClCompile Include="scrypt.c">
|
||||
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
|
||||
<AdditionalOptions>/Tp %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lyra2\Lyra2.c" />
|
||||
<ClCompile Include="lyra2\Sponge.c" />
|
||||
<ClCompile Include="lyra2\Lyra2Z.c" />
|
||||
<ClInclude Include="equi\eqcuda.hpp" />
|
||||
<ClInclude Include="equi\equihash.h" />
|
||||
<ClInclude Include="neoscrypt\neoscrypt.h" />
|
||||
<ClCompile Include="neoscrypt\neoscrypt.cpp" />
|
||||
<ClCompile Include="neoscrypt\neoscrypt-cpu.c" />
|
||||
<ClInclude Include="neoscrypt\cuda_vectors.h" />
|
||||
<ClInclude Include="x11\cuda_x11_simd512_sm2.cuh" />
|
||||
<ClInclude Include="x16\cuda_x16.h" />
|
||||
<CudaCompile Include="Algo256\bmw.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_bmw.cu">
|
||||
<MaxRegCount>76</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight.cu" />
|
||||
<CudaCompile Include="crypto\cryptolight-core.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight.cu" />
|
||||
<CudaCompile Include="crypto\cryptonight-core.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-extra.cu">
|
||||
<MaxRegCount>255</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="crypto\cn_aes.cuh" />
|
||||
<ClInclude Include="crypto\cn_blake.cuh" />
|
||||
<ClInclude Include="crypto\cn_groestl.cuh" />
|
||||
<ClInclude Include="crypto\cn_jh.cuh" />
|
||||
<ClInclude Include="crypto\cn_keccak.cuh" />
|
||||
<ClInclude Include="crypto\cn_skein.cuh" />
|
||||
<CudaCompile Include="crypto\wildkeccak.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="equi\cuda_equi.cu">
|
||||
<CodeGeneration>compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
|
||||
<AdditionalOptions> -Xptxas -dlcm=ca -Xptxas -dscm=cs %(AdditionalOptions)</AdditionalOptions>
|
||||
<MaxRegCount>0</MaxRegCount>
|
||||
<CodeGeneration Condition="'$(Configuration)|$(Platform)'=='Release|x64'">compute_61,sm_61;compute_52,sm_52;compute_50,sm_50;compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
|
||||
<MaxRegCount>160</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClCompile Include="scrypt-jane.cpp" />
|
||||
<ClCompile Include="scrypt.cpp" />
|
||||
<ClCompile Include="sia\sia-rpc.cpp" />
|
||||
<ClCompile Include="skein2.cpp" />
|
||||
<ClCompile Include="sph\aes_helper.c" />
|
||||
<ClCompile Include="sph\blake.c" />
|
||||
<ClCompile Include="sph\blake2b.c" />
|
||||
<ClCompile Include="sph\blake2s.c" />
|
||||
<ClCompile Include="sph\bmw.c" />
|
||||
<ClCompile Include="sph\cubehash.c" />
|
||||
<ClCompile Include="sph\echo.c" />
|
||||
<ClCompile Include="sph\fugue.c" />
|
||||
<ClCompile Include="sph\groestl.c" />
|
||||
<ClCompile Include="sph\haval.c" />
|
||||
<ClCompile Include="sph\haval_helper.c">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\jh.c" />
|
||||
<ClCompile Include="sph\keccak.c" />
|
||||
<ClCompile Include="sph\luffa.c" />
|
||||
<ClCompile Include="sph\md_helper.c">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\ripemd.c" />
|
||||
<ClCompile Include="sph\sph_sha2.c" />
|
||||
<ClCompile Include="sph\sha2.c" />
|
||||
<ClCompile Include="sph\sha2big.c" />
|
||||
<ClCompile Include="sph\shabal.c" />
|
||||
<ClCompile Include="sph\shavite.c" />
|
||||
<ClCompile Include="sph\simd.c" />
|
||||
<ClCompile Include="sph\skein.c" />
|
||||
<ClCompile Include="sph\streebog.c" />
|
||||
<ClCompile Include="sph\hamsi.c" />
|
||||
<ClCompile Include="sph\hamsi_helper.c" />
|
||||
<ClCompile Include="sph\whirlpool.c" />
|
||||
<ClCompile Include="util.c">
|
||||
<AdditionalOptions>/Tp %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
|
||||
</ClCompile>
|
||||
<ClCompile Include="x13\sm3.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="compat.h" />
|
||||
<ClInclude Include="compat\getopt\getopt.h" />
|
||||
<ClInclude Include="compat\inttypes.h" />
|
||||
<ClInclude Include="compat\jansson\jansson_config.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_ccminer.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_common.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_d3dext.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_salend.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_salstart.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_sli.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_stereo.h" />
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_surround.h" />
|
||||
<ClInclude Include="compat\stdbool.h" />
|
||||
<ClInclude Include="compat\sys\time.h" />
|
||||
<ClInclude Include="compat\unistd.h" />
|
||||
<ClInclude Include="compat\winansi.h" />
|
||||
<ClInclude Include="cpuminer-config.h" />
|
||||
<ClInclude Include="compat\ccminer-config.h" />
|
||||
<ClInclude Include="crypto\cryptolight.h" />
|
||||
<ClInclude Include="crypto\cryptonight.h" />
|
||||
<ClInclude Include="crypto\mman.h" />
|
||||
<ClInclude Include="crypto\wildkeccak.h" />
|
||||
<ClInclude Include="crypto\xmr-rpc.h" />
|
||||
<ClInclude Include="cuda_groestlcoin.h" />
|
||||
<ClInclude Include="cuda_helper.h" />
|
||||
<ClInclude Include="cuda_vector_uint2x4.h" />
|
||||
<ClInclude Include="elist.h" />
|
||||
<ClInclude Include="heavy\cuda_blake512.h" />
|
||||
<ClInclude Include="heavy\cuda_combine.h" />
|
||||
<ClInclude Include="heavy\cuda_groestl512.h" />
|
||||
<ClInclude Include="heavy\cuda_hefty1.h" />
|
||||
<ClInclude Include="heavy\cuda_keccak512.h" />
|
||||
<ClInclude Include="heavy\cuda_sha256.h" />
|
||||
<ClInclude Include="heavy\heavy.h" />
|
||||
<ClInclude Include="hefty1.h" />
|
||||
<ClInclude Include="algos.h" />
|
||||
<ClInclude Include="miner.h" />
|
||||
<ClInclude Include="nvml.h" />
|
||||
<ClInclude Include="quark\cuda_bmw512_sm3.cuh" />
|
||||
<ClInclude Include="quark\cuda_quark_groestl512_sm2.cuh" />
|
||||
<ClInclude Include="quark\cuda_quark_blake512_sp.cuh" />
|
||||
<ClInclude Include="res\resource.h" />
|
||||
<ClInclude Include="sia\sia-rpc.h" />
|
||||
<ClInclude Include="scrypt\salsa_kernel.h" />
|
||||
<ClInclude Include="sph\blake2b.h" />
|
||||
<ClInclude Include="sph\blake2s.h" />
|
||||
<ClInclude Include="sph\sph_blake.h" />
|
||||
<ClInclude Include="sph\sph_bmw.h" />
|
||||
<ClInclude Include="sph\sph_cubehash.h" />
|
||||
@@ -311,286 +390,239 @@
|
||||
<ClInclude Include="sph\sph_shavite.h" />
|
||||
<ClInclude Include="sph\sph_simd.h" />
|
||||
<ClInclude Include="sph\sph_skein.h" />
|
||||
<ClInclude Include="sph\sph_streebog.h" />
|
||||
<ClInclude Include="sph\sph_hamsi.h" />
|
||||
<ClInclude Include="sph\sph_types.h" />
|
||||
<ClInclude Include="sph\sph_whirlpool.h" />
|
||||
<ClInclude Include="uint256.h" />
|
||||
<ClInclude Include="lyra2\Lyra2.h" />
|
||||
<ClInclude Include="lyra2\Sponge.h" />
|
||||
<ClInclude Include="lyra2\Lyra2Z.h" />
|
||||
<ClInclude Include="quark\groestl_transf_quad.h" />
|
||||
<ClInclude Include="quark\groestl_functions_quad.h" />
|
||||
<ClInclude Include="quark\cuda_quark.h" />
|
||||
<ClInclude Include="x11\cuda_x11.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CudaCompile Include="bitslice_transformations_quad.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
<CudaCompile Include="cuda.cpp" />
|
||||
<CudaCompile Include="cuda_groestlcoin.cu" />
|
||||
<CudaCompile Include="cuda_myriadgroestl.cu" />
|
||||
<CudaCompile Include="scrypt\blake.cu" />
|
||||
<CudaCompile Include="scrypt\keccak.cu" />
|
||||
<CudaCompile Include="scrypt\sha256.cu" />
|
||||
<CudaCompile Include="scrypt\salsa_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_fugue256.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="scrypt\fermi_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_groestlcoin.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="scrypt\kepler_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_myriadgroestl.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="scrypt\nv_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_nist5.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="scrypt\nv_kernel2.cu">
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="groestl_functions_quad.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
<CudaCompile Include="scrypt\test_kernel.cu">
|
||||
<CodeGeneration>compute_30,sm_30</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\titan_kernel.cu">
|
||||
<CodeGeneration>compute_35,sm_35;compute_50,sm_50</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256d.cu" />
|
||||
<CudaCompile Include="sha256\sha256d.cu" />
|
||||
<CudaCompile Include="sha256\cuda_sha256t.cu" />
|
||||
<CudaCompile Include="sha256\sha256t.cu" />
|
||||
<CudaCompile Include="zr5.cu" />
|
||||
<CudaCompile Include="heavy\cuda_blake512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_combine.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_groestl512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_hefty1.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_keccak512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_sha256.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\heavy.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\bastion.cu" />
|
||||
<CudaCompile Include="heavy\cuda_bastion.cu" />
|
||||
<CudaCompile Include="JHA\jha.cu" />
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu" />
|
||||
<CudaCompile Include="JHA\cuda_jha_compactionTest.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes -O2" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<AdditionalOptions>-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\cuda_jha_keccak512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="blake32.cu">
|
||||
<CudaCompile Include="Algo256\blake256.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-O2 -dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<FastMath>true</FastMath>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="keccak\cuda_keccak256.cu">
|
||||
<MaxRegCount Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">92</MaxRegCount>
|
||||
<CudaCompile Include="Algo256\blake2s.cu" />
|
||||
<CudaCompile Include="Algo256\decred.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="keccak\keccak256.cu" />
|
||||
<CudaCompile Include="Algo256\vanilla.cu" />
|
||||
<CudaCompile Include="Algo256\keccak256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_blake256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_bmw256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_cubehash256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_fugue256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_groestl256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_keccak256.cu" />
|
||||
<CudaCompile Include="Algo256\cuda_keccak256_sm3.cu">
|
||||
<MaxRegCount>92</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_skein256.cu" />
|
||||
<CudaCompile Include="lbry\cuda_sha256_lbry.cu" />
|
||||
<CudaCompile Include="lbry\cuda_sha512_lbry.cu" />
|
||||
<CudaCompile Include="lbry\cuda_lbry_merged.cu" />
|
||||
<CudaCompile Include="lbry\lbry.cu" />
|
||||
<CudaCompile Include="pentablake.cu">
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-O2 -dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options="-dlcm=cg" %(AdditionalOptions)</AdditionalOptions>
|
||||
<FastMath>true</FastMath>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\animecoin.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_bmw512.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_jh512.cu">
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_quark_blake512.cu">
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_checkhash.cu">
|
||||
<CInterleavedPTX>false</CInterleavedPTX>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_quark_compactionTest.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes -O2" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">-Xptxas "-abi=yes" %(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_quark_groestl512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_quark_keccak512.cu">
|
||||
<MaxRegCount>88</MaxRegCount>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_skein512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\quarkcoin.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\deep.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\doom.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_aes.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_cubehash512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_echo.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_shavite512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_simd512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="quark\quarkcoin.cu" />
|
||||
<CudaCompile Include="quark\nist5.cu" />
|
||||
<CudaCompile Include="qubit\deep.cu" />
|
||||
<CudaCompile Include="qubit\luffa.cu" />
|
||||
<CudaCompile Include="qubit\qubit.cu" />
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu" />
|
||||
<CudaCompile Include="lyra2\allium.cu" />
|
||||
<CudaCompile Include="lyra2\lyra2RE.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2.cu" />
|
||||
<CudaCompile Include="lyra2\lyra2REv2.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v2.cu" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm2.cuh" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm5.cuh" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2v2_sm3.cuh" />
|
||||
<CudaCompile Include="lyra2\lyra2Z.cu" />
|
||||
<CudaCompile Include="lyra2\cuda_lyra2Z.cu" />
|
||||
<ClInclude Include="lyra2\cuda_lyra2Z_sm5.cuh" />
|
||||
<CudaCompile Include="polytimos.cu" />
|
||||
<CudaCompile Include="sia\sia.cu" />
|
||||
<CudaCompile Include="skein.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\fresh.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="cuda_skeincoin.cu">
|
||||
<MaxRegCount>48</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\phi.cu" />
|
||||
<CudaCompile Include="phi\phi2.cu" />
|
||||
<CudaCompile Include="phi\cuda_phi2.cu" />
|
||||
<CudaCompile Include="phi\cuda_phi2_cubehash512.cu" />
|
||||
<CudaCompile Include="skunk\skunk.cu" />
|
||||
<CudaCompile Include="skunk\cuda_skunk.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk_streebog.cu" />
|
||||
<ClInclude Include="tribus\cuda_echo512_aes.cuh" />
|
||||
<CudaCompile Include="tribus\cuda_echo512_final.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\tribus.cu" />
|
||||
<ClInclude Include="x11\cuda_x11_aes.cuh" />
|
||||
<CudaCompile Include="x11\cuda_x11_cubehash512.cu" />
|
||||
<CudaCompile Include="x11\cuda_x11_echo.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512.cu" />
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512_Cubehash.cu">
|
||||
<MaxRegCount>76</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_shavite512.cu">
|
||||
<MaxRegCount>128</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_func.cuh" />
|
||||
<CudaCompile Include="x11\cuda_x11_simd512.cu">
|
||||
<MaxRegCount>64</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog.cu" />
|
||||
<CudaCompile Include="x11\cuda_streebog_maxwell.cu" />
|
||||
<CudaCompile Include="x11\c11.cu" />
|
||||
<CudaCompile Include="x11\fresh.cu" />
|
||||
<CudaCompile Include="x11\sib.cu" />
|
||||
<CudaCompile Include="x11\s3.cu" />
|
||||
<CudaCompile Include="x11\simd_functions.cu">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\x11.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\timetravel.cu" />
|
||||
<CudaCompile Include="x11\bitcore.cu" />
|
||||
<CudaCompile Include="x11\veltor.cu" />
|
||||
<CudaCompile Include="x11\x11.cu" />
|
||||
<CudaCompile Include="x11\x11evo.cu" />
|
||||
<CudaCompile Include="x12\x12.cu" />
|
||||
<CudaCompile Include="x13\cuda_x13_hamsi512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
<MaxRegCount>72</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_x13_fugue512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\x13.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="x13\x13.cu" />
|
||||
<CudaCompile Include="x13\cuda_hsr_sm3.cu" />
|
||||
<CudaCompile Include="x13\hsr.cu" />
|
||||
<CudaCompile Include="x15\x14.cu" />
|
||||
<CudaCompile Include="x15\cuda_x14_shabal512.cu" />
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu" />
|
||||
<CudaCompile Include="x17\hmq17.cu" />
|
||||
<CudaCompile Include="x15\x15.cu" />
|
||||
<CudaCompile Include="x15\whirlpool.cu" />
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool_sm3.cu" />
|
||||
<CudaCompile Include="x16\x16r.cu" />
|
||||
<CudaCompile Include="x16\x16s.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_echo512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_fugue512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_shabal512.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_simd512_80.cu" />
|
||||
<CudaCompile Include="x16\cuda_x16_echo512_64.cu">
|
||||
<CodeGeneration>compute_50,sm_50;compute_52,sm_52</CodeGeneration>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x14_shabal512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_haval512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<CudaCompile Include="x17\x17.cu" />
|
||||
<CudaCompile Include="x17\cuda_x17_haval256.cu">
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_sha512.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
<MaxRegCount>80</MaxRegCount>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\whirlpool.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\x14.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\x15.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\x17.cu">
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Release'">--ptxas-options=-O2 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalOptions Condition="'$(Configuration)'=='Debug'">%(AdditionalOptions)</AdditionalOptions>
|
||||
<TargetMachinePlatform Condition="'$(Platform)'=='x64'">64</TargetMachinePlatform>
|
||||
</CudaCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\ccminer.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="res\ccminer.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="README.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 6.5.targets" />
|
||||
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 9.0.targets" />
|
||||
</ImportGroup>
|
||||
<!-- Copy the required dlls -->
|
||||
<Target Name="AfterBuild">
|
||||
@@ -599,4 +631,4 @@
|
||||
<Target Name="AfterClean">
|
||||
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
+640
-76
@@ -43,12 +43,12 @@
|
||||
<Filter Include="Source Files\CUDA\heavy">
|
||||
<UniqueIdentifier>{c3222908-22ba-4586-a637-6363f455b06d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\CUDA\heavy">
|
||||
<UniqueIdentifier>{3281db48-f394-49ea-a1ef-6ebd09828d50}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\qubit">
|
||||
<UniqueIdentifier>{f3ed23a2-8ce7-41a5-b051-6da56047dc35}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\skunk">
|
||||
<UniqueIdentifier>{23ed23a2-8e7a-65a2-b051-8aa63047d352}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x11">
|
||||
<UniqueIdentifier>{dd751f2d-bfd6-42c1-8f9b-cbe94e539353}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -58,15 +58,69 @@
|
||||
<Filter Include="Source Files\CUDA\x15">
|
||||
<UniqueIdentifier>{a2403c22-6777-46ab-a55a-3fcc7386c974}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x16">
|
||||
<UniqueIdentifier>{55dfae6a-66ba-43e2-8ceb-98ee70cbdf16}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x17">
|
||||
<UniqueIdentifier>{85dfae6a-66ca-4332-8cec-98ee70cbdf2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\jansson">
|
||||
<UniqueIdentifier>{17b56151-79ec-4a32-bac3-9d94ae7f68fe}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\keccak">
|
||||
<Filter Include="Header Files\compat\nvapi">
|
||||
<UniqueIdentifier>{ef6f9983-bda5-4fb2-adfa-ac4f29b74f25}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\Algo256">
|
||||
<UniqueIdentifier>{9762c92c-9677-4044-8292-ff6ba4bfdd89}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\lyra2">
|
||||
<UniqueIdentifier>{2ff6e4ce-7c92-4cb2-a3ad-c331e94fd81d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Ressources">
|
||||
<UniqueIdentifier>{f5117ccb-a70d-411a-b7ea-d6faed230bc7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\scrypt">
|
||||
<UniqueIdentifier>{c26f5b02-37b5-4420-a4e8-ee1ad517dc95}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\neoscrypt">
|
||||
<UniqueIdentifier>{2037fd0d-e7a2-4da8-956c-150aec726a99}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\lyra2">
|
||||
<UniqueIdentifier>{1613763f-895c-4321-b58b-6f5849868956}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\lbry">
|
||||
<UniqueIdentifier>{3079ea1f-f768-455a-acd6-f517fac535b4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\sha256">
|
||||
<UniqueIdentifier>{86a896c0-1688-4854-98e3-285d166069a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\sia">
|
||||
<UniqueIdentifier>{86a896c0-1688-4854-98e0-285d166069a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto">
|
||||
<UniqueIdentifier>{fea0fce3-c0fe-42f7-aa37-0cbba10b008a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto\xmr">
|
||||
<UniqueIdentifier>{af52b078-ed91-4c6e-b07a-e9243acc85d2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\crypto\bbr">
|
||||
<UniqueIdentifier>{af387eac-e9e6-4e91-a5e8-637b1e7a8d93}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\xmr">
|
||||
<UniqueIdentifier>{0f9aec5e-5409-488f-992a-2c108590d1ac}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\equi">
|
||||
<UniqueIdentifier>{031afae7-2a78-4e32-9738-4b589b6f7ff3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\tribus">
|
||||
<UniqueIdentifier>{1e548d79-c217-4203-989a-a592fe2b2de3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\phi">
|
||||
<UniqueIdentifier>{311e8d79-1612-4f0f-8591-23a592f2b2d3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CUDA\x12">
|
||||
<UniqueIdentifier>{xde48d89-fx12-1323-129a-b592fe2b2de3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="compat\jansson\dump.c">
|
||||
@@ -93,33 +147,30 @@
|
||||
<ClCompile Include="compat\gettimeofday.c">
|
||||
<Filter>Source Files\gettimeofday</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="util.c">
|
||||
<ClCompile Include="util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cpu-miner.c">
|
||||
<ClCompile Include="ccminer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crc32.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hefty1.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scrypt.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fuguecoin.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="groestlcoin.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\aes_helper.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\blake.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\blake2b.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\blake2s.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\bmw.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
@@ -144,9 +195,6 @@
|
||||
<ClCompile Include="sph\luffa.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\md_helper.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sha2.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
@@ -159,9 +207,6 @@
|
||||
<ClCompile Include="sph\skein.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="myriadgroestl.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\hamsi.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
@@ -177,23 +222,149 @@
|
||||
<ClCompile Include="sph\haval.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\haval_helper.c">
|
||||
<ClCompile Include="sph\ripemd.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sph_sha2.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\sha2big.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sph\streebog.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="x13\sm3.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\winansi.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hashlog.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stats.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="api.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvml.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sysinfos.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\jansson\memory.c">
|
||||
<Filter>Source Files\jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\jansson\pack_unpack.c">
|
||||
<Filter>Source Files\jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\jansson\strconv.c">
|
||||
<Filter>Source Files\jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat\jansson\error.c">
|
||||
<Filter>Source Files\jansson</Filter>
|
||||
</ClCompile>
|
||||
<ClInclude Include="compat\pthreads\pthread.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClCompile Include="lyra2\Lyra2.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lyra2\Sponge.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lyra2\Lyra2Z.c">
|
||||
<Filter>Source Files\sph</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scrypt.cpp">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="scrypt-jane.cpp">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="neoscrypt\neoscrypt.cpp">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="neoscrypt\neoscrypt-cpu.c">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="skein2.cpp">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="fuguecoin.cpp">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="groestlcoin.cpp">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="myriadgroestl.cpp">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="hefty1.c">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bench.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="bignum.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvapi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="nvsettings.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sia\sia-rpc.cpp">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\xmr-rpc.cpp">
|
||||
<Filter>Source Files\crypto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\aesb.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cpu\c_keccak.c">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\oaes_lib.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cryptolight-cpu.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\cryptonight-cpu.cpp">
|
||||
<Filter>Source Files\crypto\xmr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\mman.c">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="crypto\wildkeccak-cpu.cpp">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equihash.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\equi-stratum.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="equi\blake2\blake2bx.cpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="compat.h">
|
||||
<ClInclude Include="algos.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elist.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@@ -215,11 +386,8 @@
|
||||
<ClInclude Include="compat\stdbool.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cpuminer-config.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="hefty1.h">
|
||||
<Filter>Header Files</Filter>
|
||||
<ClInclude Include="compat\ccminer-config.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="uint256.h">
|
||||
<Filter>Header Files</Filter>
|
||||
@@ -227,6 +395,18 @@
|
||||
<ClInclude Include="cuda_groestlcoin.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x11\cuda_x11.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\blake2b.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\blake2s.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_blake.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
@@ -266,33 +446,24 @@
|
||||
<ClInclude Include="sph\sph_types.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_blake512.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_combine.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_groestl512.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_hefty1.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_keccak512.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="heavy\cuda_sha256.h">
|
||||
<Filter>Header Files\CUDA\heavy</Filter>
|
||||
<ClInclude Include="heavy\heavy.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cuda_helper.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cuda_vector_uint2x4.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_hamsi.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_shabal.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_streebog.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sph\sph_whirlpool.h">
|
||||
<Filter>Header Files\sph</Filter>
|
||||
</ClInclude>
|
||||
@@ -305,23 +476,155 @@
|
||||
<ClInclude Include="compat\winansi.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="nvml.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_ccminer.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_sli.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_stereo.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_surround.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_common.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_d3dext.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_salend.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\nvapi\nvapi_lite_salstart.h">
|
||||
<Filter>Header Files\compat\nvapi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="compat\jansson\jansson_config.h">
|
||||
<Filter>Header Files\compat</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\Lyra2.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\Lyra2Z.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\Sponge.h">
|
||||
<Filter>Header Files\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\groestl_transf_quad.h">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\groestl_functions_quad.h">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="res\resource.h">
|
||||
<Filter>Ressources</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="scrypt\salsa_kernel.h">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="neoscrypt\neoscrypt.h">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="neoscrypt\cuda_vectors.h">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="hefty1.h">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bignum.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2v2_sm3.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2_sm5.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lyra2\cuda_lyra2Z_sm5.cuh">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark_blake512_sp.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_bmw512_sm3.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="quark\cuda_quark_groestl512_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_sm2.cuh">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sia\sia-rpc.h">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\xmr-rpc.h">
|
||||
<Filter>Source Files\crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\mman.h">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\wildkeccak.h">
|
||||
<Filter>Source Files\crypto\bbr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_aes.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_blake.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_groestl.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_jh.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_keccak.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cn_skein.cuh">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cryptolight.h">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto\cryptonight.h">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="equi\eqcuda.hpp">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="equi\equihash.h">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="x16\cuda_x16.h">
|
||||
<Filter>Header Files\CUDA</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CudaCompile Include="cuda_fugue256.cu">
|
||||
<CudaCompile Include="cuda.cpp">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_groestlcoin.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="groestl_functions_quad.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="bitslice_transformations_quad.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\cuda_jha_keccak512.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\jha.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="JHA\jackpotcoin.cu">
|
||||
<Filter>Source Files\CUDA\JHA</Filter>
|
||||
</CudaCompile>
|
||||
@@ -364,8 +667,11 @@
|
||||
<CudaCompile Include="heavy\heavy.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\animecoin.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
<CudaCompile Include="heavy\bastion.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="heavy\cuda_bastion.cu">
|
||||
<Filter>Source Files\CUDA\heavy</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\cuda_bmw512.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
@@ -376,13 +682,16 @@
|
||||
<CudaCompile Include="quark\cuda_quark_keccak512.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\nist5.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="quark\quarkcoin.cu">
|
||||
<Filter>Source Files\CUDA\quark</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\deep.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\doom.cu">
|
||||
<CudaCompile Include="qubit\luffa.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="qubit\qubit.cu">
|
||||
@@ -391,12 +700,9 @@
|
||||
<CudaCompile Include="qubit\qubit_luffa512.cu">
|
||||
<Filter>Source Files\CUDA\qubit</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_nist5.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_aes.cu">
|
||||
<ClInclude Include="x11\cuda_x11_aes.cuh">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="x11\cuda_x11_cubehash512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
@@ -406,19 +712,28 @@
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_luffa512_Cubehash.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_shavite512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_x11_simd512.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="x11\cuda_x11_simd512_func.cuh">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="x11\c11.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\fresh.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\x11.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\simd_functions.cu">
|
||||
<CudaCompile Include="x11\x11evo.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_x13_fugue512.cu">
|
||||
@@ -430,6 +745,12 @@
|
||||
<CudaCompile Include="x13\x13.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\cuda_hsr_sm3.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x13\hsr.cu">
|
||||
<Filter>Source Files\CUDA\x13</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_checkhash.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
@@ -439,38 +760,281 @@
|
||||
<CudaCompile Include="x15\cuda_x14_shabal512.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\whirlpool.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\x15.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_haval512.cu">
|
||||
<CudaCompile Include="x15\whirlpool.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_haval256.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\cuda_x17_sha512.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x17\x17.cu">
|
||||
<CudaCompile Include="x17\hmq17.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="blake32.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
<CudaCompile Include="x17\x17.cu">
|
||||
<Filter>Source Files\CUDA\x17</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="pentablake.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="keccak\cuda_keccak256.cu">
|
||||
<Filter>Source Files\CUDA\keccak</Filter>
|
||||
<CudaCompile Include="polytimos.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="keccak\keccak256.cu">
|
||||
<Filter>Source Files\CUDA\keccak</Filter>
|
||||
<CudaCompile Include="phi\phi.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\phi2.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\cuda_phi2.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="phi\cuda_phi2_cubehash512.cu">
|
||||
<Filter>Source Files\CUDA\phi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\skunk.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skunk\cuda_skunk_streebog.cu">
|
||||
<Filter>Source Files\CUDA\skunk</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\tribus.cu">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="tribus\cuda_echo512_final.cu">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</CudaCompile>
|
||||
<ClInclude Include="tribus\cuda_echo512_aes.cuh">
|
||||
<Filter>Source Files\CUDA\tribus</Filter>
|
||||
</ClInclude>
|
||||
<CudaCompile Include="x11\sib.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\cuda_streebog_maxwell.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\s3.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x12\x12.cu">
|
||||
<Filter>Source Files\CUDA\x12</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\timetravel.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\bitcore.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x11\veltor.cu">
|
||||
<Filter>Source Files\CUDA\x11</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\decred.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\vanilla.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\keccak256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_blake256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_bmw256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_cubehash256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_fugue256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_groestl256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_keccak256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_keccak256_sm3.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_skein256.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="zr5.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="skein.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="cuda_skeincoin.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\blake.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\fermi_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\keccak.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\kepler_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\nv_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\nv_kernel2.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\salsa_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\sha256.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\test_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="scrypt\titan_kernel.cu">
|
||||
<Filter>Source Files\CUDA\scrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu">
|
||||
<Filter>Source Files\neoscrypt</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\bmw.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\cuda_bmw.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\allium.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2v2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2RE.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2REv2.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\cuda_lyra2Z.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lyra2\lyra2Z.cu">
|
||||
<Filter>Source Files\CUDA\lyra2</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="Algo256\blake2s.cu">
|
||||
<Filter>Source Files\CUDA\Algo256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_sha256_lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_sha512_lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\cuda_lbry_merged.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="lbry\lbry.cu">
|
||||
<Filter>Source Files\CUDA\lbry</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256d.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\sha256d.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\cuda_sha256t.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sha256\sha256t.cu">
|
||||
<Filter>Source Files\CUDA\sha256</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="sia\sia.cu">
|
||||
<Filter>Source Files\sia</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptolight-core.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-core.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\cryptonight-extra.cu">
|
||||
<Filter>Source Files\CUDA\xmr</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="crypto\wildkeccak.cu">
|
||||
<Filter>Source Files\CUDA</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="equi\cuda_equi.cu">
|
||||
<Filter>Source Files\equi</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x15\cuda_x15_whirlpool_sm3.cu">
|
||||
<Filter>Source Files\CUDA\x15</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_echo512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_echo512_64.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_fugue512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_shabal512.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\cuda_x16_simd512_80.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\x16r.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
<CudaCompile Include="x16\x16s.cu">
|
||||
<Filter>Source Files\CUDA\x16</Filter>
|
||||
</CudaCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
<ItemGroup>
|
||||
<Image Include="res\ccminer.ico">
|
||||
<Filter>Ressources</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="res\ccminer.rc">
|
||||
<Filter>Ressources</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="README.txt">
|
||||
<Filter>Ressources</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -4,6 +4,9 @@
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
|
||||
#define localtime_r(src, dst) localtime_s(dst, src)
|
||||
|
||||
static __inline void sleep(int secs)
|
||||
{
|
||||
@@ -11,14 +14,81 @@ static __inline void sleep(int secs)
|
||||
}
|
||||
|
||||
enum {
|
||||
PRIO_PROCESS = 0,
|
||||
PRIO_PROCESS = 0,
|
||||
};
|
||||
|
||||
extern int opt_priority;
|
||||
|
||||
static __inline int setpriority(int which, int who, int prio)
|
||||
{
|
||||
return -!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE /*THREAD_PRIORITY_TIME_CRITICAL*/);
|
||||
switch (opt_priority) {
|
||||
case 5:
|
||||
prio = THREAD_PRIORITY_TIME_CRITICAL;
|
||||
break;
|
||||
case 4:
|
||||
prio = THREAD_PRIORITY_HIGHEST;
|
||||
break;
|
||||
case 3:
|
||||
prio = THREAD_PRIORITY_ABOVE_NORMAL;
|
||||
break;
|
||||
case 2:
|
||||
prio = THREAD_PRIORITY_NORMAL;
|
||||
break;
|
||||
case 1:
|
||||
prio = THREAD_PRIORITY_BELOW_NORMAL;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
prio = THREAD_PRIORITY_IDLE;
|
||||
}
|
||||
return -!SetThreadPriority(GetCurrentThread(), prio);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf(...) _snprintf(__VA_ARGS__)
|
||||
#define strdup(...) _strdup(__VA_ARGS__)
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
typedef int ssize_t;
|
||||
|
||||
__inline int msver(void) {
|
||||
switch (_MSC_VER) {
|
||||
case 1500: return 2008;
|
||||
case 1600: return 2010;
|
||||
case 1700: return 2012;
|
||||
case 1800: return 2013;
|
||||
case 1900: return 2015;
|
||||
default: return (_MSC_VER/100);
|
||||
}
|
||||
}
|
||||
|
||||
#include <stdlib.h>
|
||||
static __inline char * dirname(char *file) {
|
||||
char buffer[_MAX_PATH] = { 0 };
|
||||
char drive[_MAX_DRIVE];
|
||||
char dir[_MAX_DIR];
|
||||
char fname[_MAX_FNAME];
|
||||
char ext[_MAX_EXT];
|
||||
_splitpath_s(file, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT);
|
||||
sprintf(buffer, "%s%s", drive, dir);
|
||||
return strdup(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define __func__ __FUNCTION__
|
||||
# define __thread __declspec(thread)
|
||||
# define _ALIGN(x) __declspec(align(x))
|
||||
#else
|
||||
# define _ALIGN(x) __attribute__ ((aligned(x)))
|
||||
/* dirname() for linux/mingw */
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
|
||||
#endif /* __COMPAT_H__ */
|
||||
@@ -0,0 +1,602 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2012 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_BIGNUM_H
|
||||
#define BITCOIN_BIGNUM_H
|
||||
|
||||
#ifndef PROTOCOL_VERSION
|
||||
#define PROTOCOL_VERSION 70001
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#include "serialize.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/** Errors thrown by the bignum class */
|
||||
class bignum_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit bignum_error(const std::string& str) : std::runtime_error(str) {}
|
||||
};
|
||||
|
||||
|
||||
/** RAII encapsulated BN_CTX (OpenSSL bignum context) */
|
||||
class CAutoBN_CTX
|
||||
{
|
||||
protected:
|
||||
BN_CTX* pctx;
|
||||
BN_CTX* operator=(BN_CTX* pnew) { return pctx = pnew; }
|
||||
|
||||
public:
|
||||
CAutoBN_CTX()
|
||||
{
|
||||
pctx = BN_CTX_new();
|
||||
if (pctx == NULL)
|
||||
throw bignum_error("CAutoBN_CTX : BN_CTX_new() returned NULL");
|
||||
}
|
||||
|
||||
~CAutoBN_CTX()
|
||||
{
|
||||
if (pctx != NULL)
|
||||
BN_CTX_free(pctx);
|
||||
}
|
||||
|
||||
operator BN_CTX*() { return pctx; }
|
||||
BN_CTX& operator*() { return *pctx; }
|
||||
BN_CTX** operator&() { return &pctx; }
|
||||
bool operator!() { return (pctx == NULL); }
|
||||
};
|
||||
|
||||
|
||||
/** C++ wrapper for BIGNUM (OpenSSL bignum) */
|
||||
class CBigNum : public BIGNUM
|
||||
{
|
||||
public:
|
||||
CBigNum()
|
||||
{
|
||||
BN_init(this);
|
||||
}
|
||||
|
||||
CBigNum(const CBigNum& b)
|
||||
{
|
||||
BN_init(this);
|
||||
if (!BN_copy(this, &b))
|
||||
{
|
||||
BN_clear_free(this);
|
||||
throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed");
|
||||
}
|
||||
}
|
||||
|
||||
CBigNum& operator=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_copy(this, &b))
|
||||
throw bignum_error("CBigNum::operator= : BN_copy failed");
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CBigNum()
|
||||
{
|
||||
BN_clear_free(this);
|
||||
}
|
||||
|
||||
//CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'.
|
||||
CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); }
|
||||
CBigNum(int64 n) { BN_init(this); setint64(n); }
|
||||
CBigNum(unsigned char n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned short n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned int n) { BN_init(this); setulong(n); }
|
||||
CBigNum(unsigned long n) { BN_init(this); setulong(n); }
|
||||
CBigNum(uint64 n) { BN_init(this); setuint64(n); }
|
||||
explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }
|
||||
|
||||
explicit CBigNum(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
BN_init(this);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
void setulong(unsigned long n)
|
||||
{
|
||||
if (!BN_set_word(this, n))
|
||||
throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed");
|
||||
}
|
||||
|
||||
unsigned long getulong() const
|
||||
{
|
||||
return (unsigned long) BN_get_word(this);
|
||||
}
|
||||
|
||||
unsigned int getuint() const
|
||||
{
|
||||
return (unsigned int) BN_get_word(this);
|
||||
}
|
||||
|
||||
int getint() const
|
||||
{
|
||||
unsigned long n = (unsigned long) BN_get_word(this);
|
||||
if (!BN_is_negative(this))
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : n);
|
||||
else
|
||||
return (n > (unsigned long)std::numeric_limits<int>::max() ? std::numeric_limits<int>::min() : -(int)n);
|
||||
}
|
||||
|
||||
void setint64(int64 sn)
|
||||
{
|
||||
unsigned char pch[sizeof(sn) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fNegative;
|
||||
uint64 n;
|
||||
|
||||
if (sn < 0LL)
|
||||
{
|
||||
// Since the minimum signed integer cannot be represented as positive so long as its type is signed,
|
||||
// and it's not well-defined what happens if you make it unsigned before negating it,
|
||||
// we instead increment the negative integer by 1, convert it, then increment the (now positive) unsigned integer by 1 to compensate
|
||||
n = -(sn + 1);
|
||||
++n;
|
||||
fNegative = true;
|
||||
} else {
|
||||
n = sn;
|
||||
fNegative = false;
|
||||
}
|
||||
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = (fNegative ? 0x80 : 0);
|
||||
else if (fNegative)
|
||||
c |= 0x80;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
void setuint64(uint64 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
unsigned char c = (n >> 56) & 0xff;
|
||||
n <<= 8;
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
void setuint256(uint256 n)
|
||||
{
|
||||
unsigned char pch[sizeof(n) + 6];
|
||||
unsigned char* p = pch + 4;
|
||||
bool fLeadingZeroes = true;
|
||||
unsigned char* pbegin = (unsigned char*)&n;
|
||||
unsigned char* psrc = pbegin + sizeof(n);
|
||||
while (psrc != pbegin)
|
||||
{
|
||||
unsigned char c = *(--psrc);
|
||||
if (fLeadingZeroes)
|
||||
{
|
||||
if (c == 0)
|
||||
continue;
|
||||
if (c & 0x80)
|
||||
*p++ = 0;
|
||||
fLeadingZeroes = false;
|
||||
}
|
||||
*p++ = c;
|
||||
}
|
||||
unsigned int nSize = (unsigned int) (p - (pch + 4));
|
||||
pch[0] = (nSize >> 24) & 0xff;
|
||||
pch[1] = (nSize >> 16) & 0xff;
|
||||
pch[2] = (nSize >> 8) & 0xff;
|
||||
pch[3] = (nSize >> 0) & 0xff;
|
||||
BN_mpi2bn(pch, (int) (p - pch), this);
|
||||
}
|
||||
|
||||
uint256 getuint256() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(this, NULL);
|
||||
if (nSize < 4)
|
||||
return 0;
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(this, &vch[0]);
|
||||
if (vch.size() > 4)
|
||||
vch[4] &= 0x7f;
|
||||
uint256 n = 0;
|
||||
for (unsigned int i = 0, j = (unsigned int) vch.size()-1; i < sizeof(n) && j >= 4; i++, j--)
|
||||
((unsigned char*)&n)[i] = vch[j];
|
||||
return n;
|
||||
}
|
||||
|
||||
void setvch(const std::vector<unsigned char>& vch)
|
||||
{
|
||||
std::vector<unsigned char> vch2(vch.size() + 4);
|
||||
unsigned int nSize = (unsigned int) vch.size();
|
||||
// BIGNUM's byte stream format expects 4 bytes of
|
||||
// big endian size data info at the front
|
||||
vch2[0] = (nSize >> 24) & 0xff;
|
||||
vch2[1] = (nSize >> 16) & 0xff;
|
||||
vch2[2] = (nSize >> 8) & 0xff;
|
||||
vch2[3] = (nSize >> 0) & 0xff;
|
||||
// swap data to big endian
|
||||
reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4);
|
||||
BN_mpi2bn(&vch2[0], (int) vch2.size(), this);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getvch() const
|
||||
{
|
||||
unsigned int nSize = BN_bn2mpi(this, NULL);
|
||||
if (nSize <= 4)
|
||||
return std::vector<unsigned char>();
|
||||
std::vector<unsigned char> vch(nSize);
|
||||
BN_bn2mpi(this, &vch[0]);
|
||||
vch.erase(vch.begin(), vch.begin() + 4);
|
||||
reverse(vch.begin(), vch.end());
|
||||
return vch;
|
||||
}
|
||||
|
||||
// The "compact" format is a representation of a whole
|
||||
// number N using an unsigned 32bit number similar to a
|
||||
// floating point format.
|
||||
// The most significant 8 bits are the unsigned exponent of base 256.
|
||||
// This exponent can be thought of as "number of bytes of N".
|
||||
// The lower 23 bits are the mantissa.
|
||||
// Bit number 24 (0x800000) represents the sign of N.
|
||||
// N = (-1^sign) * mantissa * 256^(exponent-3)
|
||||
//
|
||||
// Satoshi's original implementation used BN_bn2mpi() and BN_mpi2bn().
|
||||
// MPI uses the most significant bit of the first byte as sign.
|
||||
// Thus 0x1234560000 is compact (0x05123456)
|
||||
// and 0xc0de000000 is compact (0x0600c0de)
|
||||
// (0x05c0de00) would be -0x40de000000
|
||||
//
|
||||
// Bitcoin only uses this "compact" format for encoding difficulty
|
||||
// targets, which are unsigned 256bit quantities. Thus, all the
|
||||
// complexities of the sign bit and using base 256 are probably an
|
||||
// implementation accident.
|
||||
//
|
||||
// This implementation directly uses shifts instead of going
|
||||
// through an intermediate MPI representation.
|
||||
CBigNum& SetCompact(unsigned int nCompact)
|
||||
{
|
||||
unsigned int nSize = nCompact >> 24;
|
||||
bool fNegative =(nCompact & 0x00800000) != 0;
|
||||
unsigned int nWord = nCompact & 0x007fffff;
|
||||
if (nSize <= 3)
|
||||
{
|
||||
nWord >>= 8*(3-nSize);
|
||||
BN_set_word(this, nWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
BN_set_word(this, nWord);
|
||||
BN_lshift(this, this, 8*(nSize-3));
|
||||
}
|
||||
BN_set_negative(this, fNegative);
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int GetCompact() const
|
||||
{
|
||||
unsigned int nSize = BN_num_bytes(this);
|
||||
unsigned int nCompact = 0;
|
||||
if (nSize <= 3)
|
||||
nCompact = (unsigned int) BN_get_word(this) << 8*(3-nSize);
|
||||
else
|
||||
{
|
||||
CBigNum bn;
|
||||
BN_rshift(&bn, this, 8*(nSize-3));
|
||||
nCompact = (unsigned int) BN_get_word(&bn);
|
||||
}
|
||||
// The 0x00800000 bit denotes the sign.
|
||||
// Thus, if it is already set, divide the mantissa by 256 and increase the exponent.
|
||||
if (nCompact & 0x00800000)
|
||||
{
|
||||
nCompact >>= 8;
|
||||
nSize++;
|
||||
}
|
||||
nCompact |= nSize << 24;
|
||||
nCompact |= (BN_is_negative(this) ? 0x00800000 : 0);
|
||||
return nCompact;
|
||||
}
|
||||
|
||||
void SetHex(const std::string& str)
|
||||
{
|
||||
// skip 0x
|
||||
const char* psz = str.c_str();
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
bool fNegative = false;
|
||||
if (*psz == '-')
|
||||
{
|
||||
fNegative = true;
|
||||
psz++;
|
||||
}
|
||||
if (psz[0] == '0' && tolower(psz[1]) == 'x')
|
||||
psz += 2;
|
||||
while (isspace(*psz))
|
||||
psz++;
|
||||
|
||||
// hex string to bignum
|
||||
static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
|
||||
*this = 0;
|
||||
while (isxdigit(*psz))
|
||||
{
|
||||
*this <<= 4;
|
||||
int n = phexdigit[(unsigned char)*psz++];
|
||||
*this += n;
|
||||
}
|
||||
if (fNegative)
|
||||
*this = 0 - *this;
|
||||
}
|
||||
|
||||
std::string ToString(int nBase=10) const
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum bnBase = nBase;
|
||||
CBigNum bn0 = 0;
|
||||
std::string str;
|
||||
CBigNum bn = *this;
|
||||
BN_set_negative(&bn, false);
|
||||
CBigNum dv;
|
||||
CBigNum rem;
|
||||
if (BN_cmp(&bn, &bn0) == 0)
|
||||
return "0";
|
||||
while (BN_cmp(&bn, &bn0) > 0)
|
||||
{
|
||||
if (!BN_div(&dv, &rem, &bn, &bnBase, pctx))
|
||||
throw bignum_error("CBigNum::ToString() : BN_div failed");
|
||||
bn = dv;
|
||||
unsigned int c = rem.getulong();
|
||||
str += "0123456789abcdef"[c];
|
||||
}
|
||||
if (BN_is_negative(this))
|
||||
str += "-";
|
||||
reverse(str.begin(), str.end());
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string GetHex() const
|
||||
{
|
||||
return ToString(16);
|
||||
}
|
||||
|
||||
unsigned int GetSerializeSize(int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
return ::GetSerializeSize(getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION) const
|
||||
{
|
||||
::Serialize(s, getvch(), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Unserialize(Stream& s, int nType=0, int nVersion=PROTOCOL_VERSION)
|
||||
{
|
||||
std::vector<unsigned char> vch;
|
||||
::Unserialize(s, vch, nType, nVersion);
|
||||
setvch(vch);
|
||||
}
|
||||
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return BN_is_zero(this);
|
||||
}
|
||||
|
||||
CBigNum& operator+=(const CBigNum& b)
|
||||
{
|
||||
if (!BN_add(this, this, &b))
|
||||
throw bignum_error("CBigNum::operator+= : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator-=(const CBigNum& b)
|
||||
{
|
||||
*this = *this - b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator*=(const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
if (!BN_mul(this, this, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator*= : BN_mul failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator/=(const CBigNum& b)
|
||||
{
|
||||
*this = *this / b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator%=(const CBigNum& b)
|
||||
{
|
||||
*this = *this % b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator<<=(unsigned int shift)
|
||||
{
|
||||
if (!BN_lshift(this, this, shift))
|
||||
throw bignum_error("CBigNum:operator<<= : BN_lshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
CBigNum& operator>>=(unsigned int shift)
|
||||
{
|
||||
// Note: BN_rshift segfaults on 64-bit if 2^shift is greater than the number
|
||||
// if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL
|
||||
CBigNum a = 1;
|
||||
a <<= shift;
|
||||
if (BN_cmp(&a, this) > 0)
|
||||
{
|
||||
*this = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (!BN_rshift(this, this, shift))
|
||||
throw bignum_error("CBigNum:operator>>= : BN_rshift failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CBigNum& operator++()
|
||||
{
|
||||
// prefix operator
|
||||
if (!BN_add(this, this, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator++ : BN_add failed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator++(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
++(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
CBigNum& operator--()
|
||||
{
|
||||
// prefix operator
|
||||
CBigNum r;
|
||||
if (!BN_sub(&r, this, BN_value_one()))
|
||||
throw bignum_error("CBigNum::operator-- : BN_sub failed");
|
||||
*this = r;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CBigNum operator--(int)
|
||||
{
|
||||
// postfix operator
|
||||
const CBigNum ret = *this;
|
||||
--(*this);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b);
|
||||
friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline const CBigNum operator+(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_add(&r, &a, &b))
|
||||
throw bignum_error("CBigNum::operator+ : BN_add failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_sub(&r, &a, &b))
|
||||
throw bignum_error("CBigNum::operator- : BN_sub failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator-(const CBigNum& a)
|
||||
{
|
||||
CBigNum r(a);
|
||||
BN_set_negative(&r, !BN_is_negative(&r));
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator*(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mul(&r, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator* : BN_mul failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator/(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_div(&r, NULL, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator/ : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator%(const CBigNum& a, const CBigNum& b)
|
||||
{
|
||||
CAutoBN_CTX pctx;
|
||||
CBigNum r;
|
||||
if (!BN_mod(&r, &a, &b, pctx))
|
||||
throw bignum_error("CBigNum::operator% : BN_div failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator<<(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r;
|
||||
if (!BN_lshift(&r, &a, shift))
|
||||
throw bignum_error("CBigNum:operator<< : BN_lshift failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
inline const CBigNum operator>>(const CBigNum& a, unsigned int shift)
|
||||
{
|
||||
CBigNum r = a;
|
||||
r >>= shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); }
|
||||
inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); }
|
||||
inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); }
|
||||
inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); }
|
||||
inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); }
|
||||
inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); }
|
||||
|
||||
#endif
|
||||
@@ -1,197 +1,188 @@
|
||||
/* cpuminer-config.h. Generated from cpuminer-config.h.in by configure. */
|
||||
/* cpuminer-config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have a functional curl library. */
|
||||
#define HAVE_LIBCURL 1
|
||||
|
||||
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||
#define HAVE_LIBSSL 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#define HAVE_SYSLOG_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Defined if libcurl supports AsynchDNS */
|
||||
#define LIBCURL_FEATURE_ASYNCHDNS 1
|
||||
|
||||
/* Defined if libcurl supports IDN */
|
||||
#define LIBCURL_FEATURE_IDN 1
|
||||
|
||||
/* Defined if libcurl supports IPv6 */
|
||||
#define LIBCURL_FEATURE_IPV6 1
|
||||
|
||||
/* Defined if libcurl supports KRB4 */
|
||||
/* #undef LIBCURL_FEATURE_KRB4 */
|
||||
|
||||
/* Defined if libcurl supports libz */
|
||||
#define LIBCURL_FEATURE_LIBZ 1
|
||||
|
||||
/* Defined if libcurl supports NTLM */
|
||||
#define LIBCURL_FEATURE_NTLM 1
|
||||
|
||||
/* Defined if libcurl supports SSL */
|
||||
#define LIBCURL_FEATURE_SSL 1
|
||||
|
||||
/* Defined if libcurl supports SSPI */
|
||||
/* #undef LIBCURL_FEATURE_SSPI */
|
||||
|
||||
/* Defined if libcurl supports DICT */
|
||||
#define LIBCURL_PROTOCOL_DICT 1
|
||||
|
||||
/* Defined if libcurl supports FILE */
|
||||
#define LIBCURL_PROTOCOL_FILE 1
|
||||
|
||||
/* Defined if libcurl supports FTP */
|
||||
#define LIBCURL_PROTOCOL_FTP 1
|
||||
|
||||
/* Defined if libcurl supports FTPS */
|
||||
#define LIBCURL_PROTOCOL_FTPS 1
|
||||
|
||||
/* Defined if libcurl supports HTTP */
|
||||
#define LIBCURL_PROTOCOL_HTTP 1
|
||||
|
||||
/* Defined if libcurl supports HTTPS */
|
||||
#define LIBCURL_PROTOCOL_HTTPS 1
|
||||
|
||||
/* Defined if libcurl supports IMAP */
|
||||
#define LIBCURL_PROTOCOL_IMAP 1
|
||||
|
||||
/* Defined if libcurl supports LDAP */
|
||||
#define LIBCURL_PROTOCOL_LDAP 1
|
||||
|
||||
/* Defined if libcurl supports POP3 */
|
||||
#define LIBCURL_PROTOCOL_POP3 1
|
||||
|
||||
/* Defined if libcurl supports RTSP */
|
||||
#define LIBCURL_PROTOCOL_RTSP 1
|
||||
|
||||
/* Defined if libcurl supports SMTP */
|
||||
#define LIBCURL_PROTOCOL_SMTP 1
|
||||
|
||||
/* Defined if libcurl supports TELNET */
|
||||
#define LIBCURL_PROTOCOL_TELNET 1
|
||||
|
||||
/* Defined if libcurl supports TFTP */
|
||||
#define LIBCURL_PROTOCOL_TFTP 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "ccminer"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "ccminer"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "ccminer 1.4.7"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "ccminer"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.4.7"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if AVX assembly is available. */
|
||||
#define USE_AVX 1
|
||||
|
||||
/* Define to 1 if AVX2 assembly is available. */
|
||||
#define USE_AVX2 1
|
||||
|
||||
/* Define to 1 if XOP assembly is available. */
|
||||
#define USE_XOP 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.4.7"
|
||||
|
||||
/* Define curl_free() as free() if our version of curl lacks curl_free. */
|
||||
/* #undef curl_free */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
/* CONFIG ONLY FOR MS VC++ BUILD */
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
/* #undef CRAY_STACKSEG_END */
|
||||
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
/* #undef C_ALLOCA */
|
||||
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#define HAVE_ALLOCA 1
|
||||
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#define HAVE_ALLOCA_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `be32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32dec', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32DEC 0
|
||||
|
||||
/* Define to 1 if you have the declaration of `le32enc', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_LE32ENC 0
|
||||
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `crypto' library (-lcrypto). */
|
||||
#define HAVE_LIBCRYPTO 1
|
||||
|
||||
/* Define to 1 if you have a functional curl library. */
|
||||
#define HAVE_LIBCURL 1
|
||||
|
||||
/* Define to 1 if you have the `ssl' library (-lssl). */
|
||||
#define HAVE_LIBSSL 1
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#define HAVE_LIBZ 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
/* #undef HAVE_SYSLOG_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Defined if libcurl supports AsynchDNS */
|
||||
/* #undef LIBCURL_FEATURE_ASYNCHDNS */
|
||||
|
||||
/* Defined if libcurl supports IDN */
|
||||
#define LIBCURL_FEATURE_IDN 1
|
||||
|
||||
/* Defined if libcurl supports IPv6 */
|
||||
#define LIBCURL_FEATURE_IPV6 1
|
||||
|
||||
/* Defined if libcurl supports KRB4 */
|
||||
/* #undef LIBCURL_FEATURE_KRB4 */
|
||||
|
||||
/* Defined if libcurl supports libz */
|
||||
#define LIBCURL_FEATURE_LIBZ 1
|
||||
|
||||
/* Defined if libcurl supports NTLM */
|
||||
#define LIBCURL_FEATURE_NTLM 1
|
||||
|
||||
/* Defined if libcurl supports SSL */
|
||||
#define LIBCURL_FEATURE_SSL 1
|
||||
|
||||
/* Defined if libcurl supports SSPI */
|
||||
/* #undef LIBCURL_FEATURE_SSPI */
|
||||
|
||||
/* Defined if libcurl supports DICT */
|
||||
/* #undef LIBCURL_PROTOCOL_DICT */
|
||||
|
||||
/* Defined if libcurl supports FILE */
|
||||
#define LIBCURL_PROTOCOL_FILE 1
|
||||
|
||||
/* Defined if libcurl supports FTP */
|
||||
#define LIBCURL_PROTOCOL_FTP 1
|
||||
|
||||
/* Defined if libcurl supports FTPS */
|
||||
#define LIBCURL_PROTOCOL_FTPS 1
|
||||
|
||||
/* Defined if libcurl supports HTTP */
|
||||
#define LIBCURL_PROTOCOL_HTTP 1
|
||||
|
||||
/* Defined if libcurl supports HTTPS */
|
||||
#define LIBCURL_PROTOCOL_HTTPS 1
|
||||
|
||||
/* Defined if libcurl supports IMAP */
|
||||
/* #undef LIBCURL_PROTOCOL_IMAP */
|
||||
|
||||
/* Defined if libcurl supports LDAP */
|
||||
/* #undef LIBCURL_PROTOCOL_LDAP */
|
||||
|
||||
/* Defined if libcurl supports POP3 */
|
||||
/* #undef LIBCURL_PROTOCOL_POP3 */
|
||||
|
||||
/* Defined if libcurl supports RTSP */
|
||||
/* #undef LIBCURL_PROTOCOL_RTSP */
|
||||
|
||||
/* Defined if libcurl supports SMTP */
|
||||
/* #undef LIBCURL_PROTOCOL_SMTP */
|
||||
|
||||
/* Defined if libcurl supports TELNET */
|
||||
/* #undef LIBCURL_PROTOCOL_TELNET */
|
||||
|
||||
/* Defined if libcurl supports TFTP */
|
||||
/* #undef LIBCURL_PROTOCOL_TFTP */
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "ccminer"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "ccminer"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "http://github.com/tpruvot/ccminer"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.2.6"
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
/* #undef STACK_DIRECTION */
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define curl_free() as free() if our version of curl lacks curl_free. */
|
||||
/* #undef curl_free */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
//#define size_t unsigned int
|
||||
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
@@ -0,0 +1,902 @@
|
||||
/* crypto/bn/bn.h */
|
||||
/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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 product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the Eric Young open source
|
||||
* license provided above.
|
||||
*
|
||||
* The binary polynomial arithmetic software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_H
|
||||
#define HEADER_BN_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h> /* FILE */
|
||||
#endif
|
||||
#include <openssl/ossl_typ.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These preprocessor symbols control various aspects of the bignum headers and
|
||||
* library code. They're not defined by any "normal" configuration, as they are
|
||||
* intended for development and testing purposes. NB: defining all three can be
|
||||
* useful for debugging application code as well as openssl itself.
|
||||
*
|
||||
* BN_DEBUG - turn on various debugging alterations to the bignum code
|
||||
* BN_DEBUG_RAND - uses random poisoning of unused words to trip up
|
||||
* mismanagement of bignum internals. You must also define BN_DEBUG.
|
||||
*/
|
||||
/* #define BN_DEBUG */
|
||||
/* #define BN_DEBUG_RAND */
|
||||
|
||||
#ifndef OPENSSL_SMALL_FOOTPRINT
|
||||
#define BN_MUL_COMBA
|
||||
#define BN_SQR_COMBA
|
||||
#define BN_RECURSION
|
||||
#endif
|
||||
|
||||
/* This next option uses the C libraries (2 word)/(1 word) function.
|
||||
* If it is not defined, I use my C version (which is slower).
|
||||
* The reason for this flag is that when the particular C compiler
|
||||
* library routine is used, and the library is linked with a different
|
||||
* compiler, the library is missing. This mostly happens when the
|
||||
* library is built with gcc and then linked using normal cc. This would
|
||||
* be a common occurrence because gcc normally produces code that is
|
||||
* 2 times faster than system compilers for the big number stuff.
|
||||
* For machines with only one compiler (or shared libraries), this should
|
||||
* be on. Again this in only really a problem on machines
|
||||
* using "long long's", are 32bit, and are not using my assembler code. */
|
||||
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
|
||||
defined(OPENSSL_SYS_WIN32) || defined(linux)
|
||||
# ifndef BN_DIV2W
|
||||
# define BN_DIV2W
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* assuming long is 64bit - this is the DEC Alpha
|
||||
* unsigned long long is only 64 bits :-(, don't define
|
||||
* BN_LLONG for the DEC Alpha */
|
||||
#ifdef SIXTY_FOUR_BIT_LONG
|
||||
#define BN_ULLONG unsigned long long
|
||||
#define BN_ULONG unsigned long
|
||||
#define BN_LONG long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK (0xffffffffffffffffffffffffffffffffLL)
|
||||
#define BN_MASK2 (0xffffffffffffffffL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000L)
|
||||
#define BN_MASK2h1 (0xffffffff80000000L)
|
||||
#define BN_TBIT (0x8000000000000000L)
|
||||
#define BN_DEC_CONV (10000000000000000000UL)
|
||||
#define BN_DEC_FMT1 "%lu"
|
||||
#define BN_DEC_FMT2 "%019lu"
|
||||
#define BN_DEC_NUM 19
|
||||
#define BN_HEX_FMT1 "%lX"
|
||||
#define BN_HEX_FMT2 "%016lX"
|
||||
#endif
|
||||
|
||||
/* This is where the long long data type is 64 bits, but long is 32.
|
||||
* For machines where there are 64bit registers, this is the mode to use.
|
||||
* IRIX, on R4000 and above should use this mode, along with the relevant
|
||||
* assembler code :-). Do NOT define BN_LLONG.
|
||||
*/
|
||||
#ifdef SIXTY_FOUR_BIT
|
||||
#undef BN_LLONG
|
||||
#undef BN_ULLONG
|
||||
#define BN_ULONG unsigned long long
|
||||
#define BN_LONG long long
|
||||
#define BN_BITS 128
|
||||
#define BN_BYTES 8
|
||||
#define BN_BITS2 64
|
||||
#define BN_BITS4 32
|
||||
#define BN_MASK2 (0xffffffffffffffffLL)
|
||||
#define BN_MASK2l (0xffffffffL)
|
||||
#define BN_MASK2h (0xffffffff00000000LL)
|
||||
#define BN_MASK2h1 (0xffffffff80000000LL)
|
||||
#define BN_TBIT (0x8000000000000000LL)
|
||||
#define BN_DEC_CONV (10000000000000000000ULL)
|
||||
#define BN_DEC_FMT1 "%llu"
|
||||
#define BN_DEC_FMT2 "%019llu"
|
||||
#define BN_DEC_NUM 19
|
||||
#define BN_HEX_FMT1 "%llX"
|
||||
#define BN_HEX_FMT2 "%016llX"
|
||||
#endif
|
||||
|
||||
#ifdef THIRTY_TWO_BIT
|
||||
#ifdef BN_LLONG
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define BN_ULLONG unsigned __int64
|
||||
# define BN_MASK (0xffffffffffffffffI64)
|
||||
# else
|
||||
# define BN_ULLONG unsigned long long
|
||||
# define BN_MASK (0xffffffffffffffffLL)
|
||||
# endif
|
||||
#endif
|
||||
#define BN_ULONG unsigned int
|
||||
#define BN_LONG int
|
||||
#define BN_BITS 64
|
||||
#define BN_BYTES 4
|
||||
#define BN_BITS2 32
|
||||
#define BN_BITS4 16
|
||||
#define BN_MASK2 (0xffffffffL)
|
||||
#define BN_MASK2l (0xffff)
|
||||
#define BN_MASK2h1 (0xffff8000L)
|
||||
#define BN_MASK2h (0xffff0000L)
|
||||
#define BN_TBIT (0x80000000L)
|
||||
#define BN_DEC_CONV (1000000000L)
|
||||
#define BN_DEC_FMT1 "%u"
|
||||
#define BN_DEC_FMT2 "%09u"
|
||||
#define BN_DEC_NUM 9
|
||||
#define BN_HEX_FMT1 "%X"
|
||||
#define BN_HEX_FMT2 "%08X"
|
||||
#endif
|
||||
|
||||
/* 2011-02-22 SMS.
|
||||
* In various places, a size_t variable or a type cast to size_t was
|
||||
* used to perform integer-only operations on pointers. This failed on
|
||||
* VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t is
|
||||
* still only 32 bits. What's needed in these cases is an integer type
|
||||
* with the same size as a pointer, which size_t is not certain to be.
|
||||
* The only fix here is VMS-specific.
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VMS)
|
||||
# if __INITIAL_POINTER_SIZE == 64
|
||||
# define PTR_SIZE_INT long long
|
||||
# else /* __INITIAL_POINTER_SIZE == 64 */
|
||||
# define PTR_SIZE_INT int
|
||||
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
||||
#else /* defined(OPENSSL_SYS_VMS) */
|
||||
# define PTR_SIZE_INT size_t
|
||||
#endif /* defined(OPENSSL_SYS_VMS) [else] */
|
||||
|
||||
#define BN_DEFAULT_BITS 1280
|
||||
|
||||
#define BN_FLG_MALLOCED 0x01
|
||||
#define BN_FLG_STATIC_DATA 0x02
|
||||
#define BN_FLG_CONSTTIME 0x04 /* avoid leaking exponent information through timing,
|
||||
* BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,
|
||||
* BN_div() will call BN_div_no_branch,
|
||||
* BN_mod_inverse() will call BN_mod_inverse_no_branch.
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */
|
||||
/* avoid leaking exponent information through timings
|
||||
* (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
#define BN_FLG_FREE 0x8000 /* used for debuging */
|
||||
#endif
|
||||
#define BN_set_flags(b,n) ((b)->flags|=(n))
|
||||
#define BN_get_flags(b,n) ((b)->flags&(n))
|
||||
|
||||
/* get a clone of a BIGNUM with changed flags, for *temporary* use only
|
||||
* (the two BIGNUMs cannot not be used in parallel!) */
|
||||
#define BN_with_flags(dest,b,n) ((dest)->d=(b)->d, \
|
||||
(dest)->top=(b)->top, \
|
||||
(dest)->dmax=(b)->dmax, \
|
||||
(dest)->neg=(b)->neg, \
|
||||
(dest)->flags=(((dest)->flags & BN_FLG_MALLOCED) \
|
||||
| ((b)->flags & ~BN_FLG_MALLOCED) \
|
||||
| BN_FLG_STATIC_DATA \
|
||||
| (n)))
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct bignum_st BIGNUM;
|
||||
/* Used for temp variables (declaration hidden in bn_lcl.h) */
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
#endif
|
||||
|
||||
struct bignum_st
|
||||
{
|
||||
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
|
||||
int top; /* Index of last used d +1. */
|
||||
/* The next are internal book keeping for bn_expand. */
|
||||
int dmax; /* Size of the d array. */
|
||||
int neg; /* one if the number is negative */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for montgomery multiplication */
|
||||
struct bn_mont_ctx_st
|
||||
{
|
||||
int ri; /* number of bits in R */
|
||||
BIGNUM RR; /* used to convert to montgomery form */
|
||||
BIGNUM N; /* The modulus */
|
||||
BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1
|
||||
* (Ni is only stored for bignum algorithm) */
|
||||
BN_ULONG n0[2];/* least significant word(s) of Ni;
|
||||
(type changed with 0.9.9, was "BN_ULONG n0;" before) */
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for reciprocal division/mod functions
|
||||
* It cannot be shared between threads
|
||||
*/
|
||||
struct bn_recp_ctx_st
|
||||
{
|
||||
BIGNUM N; /* the divisor */
|
||||
BIGNUM Nr; /* the reciprocal */
|
||||
int num_bits;
|
||||
int shift;
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Used for slow "generation" functions. */
|
||||
struct bn_gencb_st
|
||||
{
|
||||
unsigned int ver; /* To handle binary (in)compatibility */
|
||||
void *arg; /* callback-specific data */
|
||||
union
|
||||
{
|
||||
/* if(ver==1) - handles old style callbacks */
|
||||
void (*cb_1)(int, int, void *);
|
||||
/* if(ver==2) - new callback style */
|
||||
int (*cb_2)(int, int, BN_GENCB *);
|
||||
} cb;
|
||||
};
|
||||
/* Wrapper function to make using BN_GENCB easier, */
|
||||
int BN_GENCB_call(BN_GENCB *cb, int a, int b);
|
||||
/* Macro to populate a BN_GENCB structure with an "old"-style callback */
|
||||
#define BN_GENCB_set_old(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 1; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_1 = (callback); }
|
||||
/* Macro to populate a BN_GENCB structure with a "new"-style callback */
|
||||
#define BN_GENCB_set(gencb, callback, cb_arg) { \
|
||||
BN_GENCB *tmp_gencb = (gencb); \
|
||||
tmp_gencb->ver = 2; \
|
||||
tmp_gencb->arg = (cb_arg); \
|
||||
tmp_gencb->cb.cb_2 = (callback); }
|
||||
|
||||
#define BN_prime_checks 0 /* default: select number of iterations
|
||||
based on the size of the number */
|
||||
|
||||
/* number of Miller-Rabin iterations for an error rate of less than 2^-80
|
||||
* for random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook
|
||||
* of Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error estimates
|
||||
* for the strong probable prime test. -- Math. Comp. 61 (1993) 177-194) */
|
||||
#define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
/* Note that BN_abs_is_word didn't work reliably for w == 0 until 0.9.8 */
|
||||
#define BN_abs_is_word(a,w) ((((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) || \
|
||||
(((w) == 0) && ((a)->top == 0)))
|
||||
#define BN_is_zero(a) ((a)->top == 0)
|
||||
#define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg)
|
||||
#define BN_is_word(a,w) (BN_abs_is_word((a),(w)) && (!(w) || !(a)->neg))
|
||||
#define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1))
|
||||
|
||||
#define BN_one(a) (BN_set_word((a),1))
|
||||
#define BN_zero_ex(a) \
|
||||
do { \
|
||||
BIGNUM *_tmp_bn = (a); \
|
||||
_tmp_bn->top = 0; \
|
||||
_tmp_bn->neg = 0; \
|
||||
} while(0)
|
||||
#ifdef OPENSSL_NO_DEPRECATED
|
||||
#define BN_zero(a) BN_zero_ex(a)
|
||||
#else
|
||||
#define BN_zero(a) (BN_set_word((a),0))
|
||||
#endif
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
char * BN_options(void);
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_CTX_init(BN_CTX *c);
|
||||
#endif
|
||||
void BN_CTX_free(BN_CTX *c);
|
||||
void BN_CTX_start(BN_CTX *ctx);
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx);
|
||||
void BN_CTX_end(BN_CTX *ctx);
|
||||
int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
|
||||
int BN_num_bits(const BIGNUM *a);
|
||||
int BN_num_bits_word(BN_ULONG);
|
||||
BIGNUM *BN_new(void);
|
||||
void BN_init(BIGNUM *);
|
||||
void BN_clear_free(BIGNUM *a);
|
||||
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
|
||||
void BN_swap(BIGNUM *a, BIGNUM *b);
|
||||
BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
|
||||
BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
|
||||
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
|
||||
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
|
||||
int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx);
|
||||
/** BN_set_negative sets sign of a BIGNUM
|
||||
* \param b pointer to the BIGNUM object
|
||||
* \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise
|
||||
*/
|
||||
void BN_set_negative(BIGNUM *b, int n);
|
||||
/** BN_is_negative returns 1 if the BIGNUM is negative
|
||||
* \param a pointer to the BIGNUM object
|
||||
* \return 1 if a < 0 and 0 otherwise
|
||||
*/
|
||||
#define BN_is_negative(a) ((a)->neg != 0)
|
||||
|
||||
int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
|
||||
BN_CTX *ctx);
|
||||
#define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))
|
||||
int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);
|
||||
int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m);
|
||||
int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);
|
||||
int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);
|
||||
|
||||
BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_mul_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_add_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_sub_word(BIGNUM *a, BN_ULONG w);
|
||||
int BN_set_word(BIGNUM *a, BN_ULONG w);
|
||||
BN_ULONG BN_get_word(const BIGNUM *a);
|
||||
|
||||
int BN_cmp(const BIGNUM *a, const BIGNUM *b);
|
||||
void BN_free(BIGNUM *a);
|
||||
int BN_is_bit_set(const BIGNUM *a, int n);
|
||||
int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_lshift1(BIGNUM *r, const BIGNUM *a);
|
||||
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx);
|
||||
|
||||
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
|
||||
int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,
|
||||
const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m,
|
||||
BN_CTX *ctx,BN_MONT_CTX *m_ctx);
|
||||
int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m,BN_CTX *ctx);
|
||||
|
||||
int BN_mask_bits(BIGNUM *a,int n);
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
int BN_print_fp(FILE *fp, const BIGNUM *a);
|
||||
#endif
|
||||
#ifdef HEADER_BIO_H
|
||||
int BN_print(BIO *fp, const BIGNUM *a);
|
||||
#else
|
||||
int BN_print(void *fp, const BIGNUM *a);
|
||||
#endif
|
||||
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
|
||||
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
|
||||
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
|
||||
void BN_clear(BIGNUM *a);
|
||||
BIGNUM *BN_dup(const BIGNUM *a);
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
|
||||
int BN_set_bit(BIGNUM *a, int n);
|
||||
int BN_clear_bit(BIGNUM *a, int n);
|
||||
char * BN_bn2hex(const BIGNUM *a);
|
||||
char * BN_bn2dec(const BIGNUM *a);
|
||||
int BN_hex2bn(BIGNUM **a, const char *str);
|
||||
int BN_dec2bn(BIGNUM **a, const char *str);
|
||||
int BN_asc2bn(BIGNUM **a, const char *str);
|
||||
int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx);
|
||||
int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */
|
||||
BIGNUM *BN_mod_inverse(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
BIGNUM *BN_mod_sqrt(BIGNUM *ret,
|
||||
const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx);
|
||||
|
||||
void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);
|
||||
|
||||
/* Deprecated versions */
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,
|
||||
const BIGNUM *add, const BIGNUM *rem,
|
||||
void (*callback)(int,int,void *),void *cb_arg);
|
||||
int BN_is_prime(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),
|
||||
BN_CTX *ctx,void *cb_arg);
|
||||
int BN_is_prime_fasttest(const BIGNUM *p,int nchecks,
|
||||
void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg,
|
||||
int do_trial_division);
|
||||
#endif /* !defined(OPENSSL_NO_DEPRECATED) */
|
||||
|
||||
/* Newer versions */
|
||||
int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add,
|
||||
const BIGNUM *rem, BN_GENCB *cb);
|
||||
int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx,
|
||||
int do_trial_division, BN_GENCB *cb);
|
||||
|
||||
int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);
|
||||
|
||||
int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2,
|
||||
const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb);
|
||||
int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
|
||||
BIGNUM *Xp1, BIGNUM *Xp2,
|
||||
const BIGNUM *Xp,
|
||||
const BIGNUM *e, BN_CTX *ctx,
|
||||
BN_GENCB *cb);
|
||||
|
||||
BN_MONT_CTX *BN_MONT_CTX_new(void );
|
||||
void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
|
||||
int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
|
||||
(r),(a),&((mont)->RR),(mont),(ctx))
|
||||
int BN_from_montgomery(BIGNUM *r,const BIGNUM *a,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
void BN_MONT_CTX_free(BN_MONT_CTX *mont);
|
||||
int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *mod,BN_CTX *ctx);
|
||||
BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from);
|
||||
BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,
|
||||
const BIGNUM *mod, BN_CTX *ctx);
|
||||
|
||||
/* BN_BLINDING flags */
|
||||
#define BN_BLINDING_NO_UPDATE 0x00000001
|
||||
#define BN_BLINDING_NO_RECREATE 0x00000002
|
||||
|
||||
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);
|
||||
void BN_BLINDING_free(BN_BLINDING *b);
|
||||
int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
|
||||
int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
|
||||
int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
|
||||
#endif
|
||||
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
|
||||
unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
|
||||
void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
|
||||
BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
|
||||
const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
|
||||
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx),
|
||||
BN_MONT_CTX *m_ctx);
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void BN_set_params(int mul,int high,int low,int mont);
|
||||
int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */
|
||||
#endif
|
||||
|
||||
void BN_RECP_CTX_init(BN_RECP_CTX *recp);
|
||||
BN_RECP_CTX *BN_RECP_CTX_new(void);
|
||||
void BN_RECP_CTX_free(BN_RECP_CTX *recp);
|
||||
int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx);
|
||||
int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
|
||||
BN_RECP_CTX *recp,BN_CTX *ctx);
|
||||
int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx);
|
||||
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
|
||||
BN_RECP_CTX *recp, BN_CTX *ctx);
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
|
||||
/* Functions for arithmetic over binary polynomials represented by BIGNUMs.
|
||||
*
|
||||
* The BIGNUM::neg property of BIGNUMs representing binary polynomials is
|
||||
* ignored.
|
||||
*
|
||||
* Note that input arguments are not const so that their bit arrays can
|
||||
* be expanded to the appropriate size if needed.
|
||||
*/
|
||||
|
||||
int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); /*r = a + b*/
|
||||
#define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)
|
||||
int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); /*r=a mod p*/
|
||||
int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const BIGNUM *p, BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
#define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))
|
||||
/* Some functions allow for representation of the irreducible polynomials
|
||||
* as an unsigned int[], say p. The irreducible f(t) is then of the form:
|
||||
* t^p[0] + t^p[1] + ... + t^p[k]
|
||||
* where m = p[0] > p[1] > ... > p[k] = 0.
|
||||
*/
|
||||
int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);
|
||||
/* r = a mod p */
|
||||
int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a * b) mod p */
|
||||
int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],
|
||||
BN_CTX *ctx); /* r = (a * a) mod p */
|
||||
int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],
|
||||
BN_CTX *ctx); /* r = (1 / b) mod p */
|
||||
int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a / b) mod p */
|
||||
int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */
|
||||
int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */
|
||||
int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,
|
||||
const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);
|
||||
int BN_GF2m_arr2poly(const int p[], BIGNUM *a);
|
||||
|
||||
#endif
|
||||
|
||||
/* faster mod functions for the 'NIST primes'
|
||||
* 0 <= a < p^2 */
|
||||
int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
const BIGNUM *BN_get0_nist_prime_192(void);
|
||||
const BIGNUM *BN_get0_nist_prime_224(void);
|
||||
const BIGNUM *BN_get0_nist_prime_256(void);
|
||||
const BIGNUM *BN_get0_nist_prime_384(void);
|
||||
const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
/* library internal functions */
|
||||
|
||||
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
|
||||
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
|
||||
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
|
||||
BIGNUM *bn_expand2(BIGNUM *a, int words);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
|
||||
#endif
|
||||
|
||||
/* Bignum consistency macros
|
||||
* There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
|
||||
* bignum data after direct manipulations on the data. There is also an
|
||||
* "internal" macro, bn_check_top(), for verifying that there are no leading
|
||||
* zeroes. Unfortunately, some auditing is required due to the fact that
|
||||
* bn_fix_top() has become an overabused duct-tape because bignum data is
|
||||
* occasionally passed around in an inconsistent state. So the following
|
||||
* changes have been made to sort this out;
|
||||
* - bn_fix_top()s implementation has been moved to bn_correct_top()
|
||||
* - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
|
||||
* bn_check_top() is as before.
|
||||
* - if BN_DEBUG *is* defined;
|
||||
* - bn_check_top() tries to pollute unused words even if the bignum 'top' is
|
||||
* consistent. (ed: only if BN_DEBUG_RAND is defined)
|
||||
* - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
|
||||
* The idea is to have debug builds flag up inconsistent bignums when they
|
||||
* occur. If that occurs in a bn_fix_top(), we examine the code in question; if
|
||||
* the use of bn_fix_top() was appropriate (ie. it follows directly after code
|
||||
* that manipulates the bignum) it is converted to bn_correct_top(), and if it
|
||||
* was not appropriate, we convert it permanently to bn_check_top() and track
|
||||
* down the cause of the bug. Eventually, no internal code should be using the
|
||||
* bn_fix_top() macro. External applications and libraries should try this with
|
||||
* their own code too, both in terms of building against the openssl headers
|
||||
* with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
|
||||
* defined. This not only improves external code, it provides more test
|
||||
* coverage for openssl's own code.
|
||||
*/
|
||||
|
||||
#ifdef BN_DEBUG
|
||||
|
||||
/* We only need assert() when debugging */
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef BN_DEBUG_RAND
|
||||
/* To avoid "make update" cvs wars due to BN_DEBUG, use some tricks */
|
||||
#ifndef RAND_pseudo_bytes
|
||||
int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
#define BN_DEBUG_TRIX
|
||||
#endif
|
||||
#define bn_pollute(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum1 = (a); \
|
||||
if(_bnum1->top < _bnum1->dmax) { \
|
||||
unsigned char _tmp_char; \
|
||||
/* We cast away const without the compiler knowing, any \
|
||||
* *genuinely* constant variables that aren't mutable \
|
||||
* wouldn't be constructed with top!=dmax. */ \
|
||||
BN_ULONG *_not_const; \
|
||||
memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \
|
||||
RAND_pseudo_bytes(&_tmp_char, 1); \
|
||||
memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \
|
||||
(_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \
|
||||
} \
|
||||
} while(0)
|
||||
#ifdef BN_DEBUG_TRIX
|
||||
#undef RAND_pseudo_bytes
|
||||
#endif
|
||||
#else
|
||||
#define bn_pollute(a)
|
||||
#endif
|
||||
#define bn_check_top(a) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (a); \
|
||||
if (_bnum2 != NULL) { \
|
||||
assert((_bnum2->top == 0) || \
|
||||
(_bnum2->d[_bnum2->top - 1] != 0)); \
|
||||
bn_pollute(_bnum2); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define bn_fix_top(a) bn_check_top(a)
|
||||
|
||||
#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
|
||||
#define bn_wcheck_size(bn, words) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (bn); \
|
||||
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
|
||||
} while(0)
|
||||
|
||||
#else /* !BN_DEBUG */
|
||||
|
||||
#define bn_pollute(a)
|
||||
#define bn_check_top(a)
|
||||
#define bn_fix_top(a) bn_correct_top(a)
|
||||
#define bn_check_size(bn, bits)
|
||||
#define bn_wcheck_size(bn, words)
|
||||
|
||||
#endif
|
||||
|
||||
#define bn_correct_top(a) \
|
||||
{ \
|
||||
BN_ULONG *ftl; \
|
||||
int tmp_top = (a)->top; \
|
||||
if (tmp_top > 0) \
|
||||
{ \
|
||||
for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \
|
||||
if (*(ftl--)) break; \
|
||||
(a)->top = tmp_top; \
|
||||
} \
|
||||
bn_pollute(a); \
|
||||
}
|
||||
|
||||
BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
|
||||
void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
|
||||
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
|
||||
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
|
||||
|
||||
/* Primes from RFC 2409 */
|
||||
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
|
||||
BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn);
|
||||
|
||||
/* Primes from RFC 3526 */
|
||||
BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_2048(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_3072(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
|
||||
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
|
||||
|
||||
int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_BN_strings(void);
|
||||
|
||||
/* Error codes for the BN functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define BN_F_BNRAND 127
|
||||
#define BN_F_BN_BLINDING_CONVERT_EX 100
|
||||
#define BN_F_BN_BLINDING_CREATE_PARAM 128
|
||||
#define BN_F_BN_BLINDING_INVERT_EX 101
|
||||
#define BN_F_BN_BLINDING_NEW 102
|
||||
#define BN_F_BN_BLINDING_UPDATE 103
|
||||
#define BN_F_BN_BN2DEC 104
|
||||
#define BN_F_BN_BN2HEX 105
|
||||
#define BN_F_BN_CTX_GET 116
|
||||
#define BN_F_BN_CTX_NEW 106
|
||||
#define BN_F_BN_CTX_START 129
|
||||
#define BN_F_BN_DIV 107
|
||||
#define BN_F_BN_DIV_NO_BRANCH 138
|
||||
#define BN_F_BN_DIV_RECP 130
|
||||
#define BN_F_BN_EXP 123
|
||||
#define BN_F_BN_EXPAND2 108
|
||||
#define BN_F_BN_EXPAND_INTERNAL 120
|
||||
#define BN_F_BN_GF2M_MOD 131
|
||||
#define BN_F_BN_GF2M_MOD_EXP 132
|
||||
#define BN_F_BN_GF2M_MOD_MUL 133
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134
|
||||
#define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
#define BN_F_BN_GF2M_MOD_SQR 136
|
||||
#define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
#define BN_F_BN_MOD_EXP2_MONT 118
|
||||
#define BN_F_BN_MOD_EXP_MONT 109
|
||||
#define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124
|
||||
#define BN_F_BN_MOD_EXP_MONT_WORD 117
|
||||
#define BN_F_BN_MOD_EXP_RECP 125
|
||||
#define BN_F_BN_MOD_EXP_SIMPLE 126
|
||||
#define BN_F_BN_MOD_INVERSE 110
|
||||
#define BN_F_BN_MOD_INVERSE_NO_BRANCH 139
|
||||
#define BN_F_BN_MOD_LSHIFT_QUICK 119
|
||||
#define BN_F_BN_MOD_MUL_RECIPROCAL 111
|
||||
#define BN_F_BN_MOD_SQRT 121
|
||||
#define BN_F_BN_MPI2BN 112
|
||||
#define BN_F_BN_NEW 113
|
||||
#define BN_F_BN_RAND 114
|
||||
#define BN_F_BN_RAND_RANGE 122
|
||||
#define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
#define BN_R_ARG2_LT_ARG3 100
|
||||
#define BN_R_BAD_RECIPROCAL 101
|
||||
#define BN_R_BIGNUM_TOO_LONG 114
|
||||
#define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
||||
#define BN_R_DIV_BY_ZERO 103
|
||||
#define BN_R_ENCODING_ERROR 104
|
||||
#define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
||||
#define BN_R_INPUT_NOT_REDUCED 110
|
||||
#define BN_R_INVALID_LENGTH 106
|
||||
#define BN_R_INVALID_RANGE 115
|
||||
#define BN_R_NOT_A_SQUARE 111
|
||||
#define BN_R_NOT_INITIALIZED 107
|
||||
#define BN_R_NO_INVERSE 108
|
||||
#define BN_R_NO_SOLUTION 116
|
||||
#define BN_R_P_IS_NOT_PRIME 112
|
||||
#define BN_R_TOO_MANY_ITERATIONS 113
|
||||
#define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,611 @@
|
||||
/* crypto/crypto.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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 product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
* ECDH support in OpenSSL originally developed by
|
||||
* SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
|
||||
*/
|
||||
|
||||
#ifndef HEADER_CRYPTO_H
|
||||
#define HEADER_CRYPTO_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <openssl/stack.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/ossl_typ.h>
|
||||
|
||||
#ifdef CHARSET_EBCDIC
|
||||
#include <openssl/ebcdic.h>
|
||||
#endif
|
||||
|
||||
/* Resolve problems on some operating systems with symbol names that clash
|
||||
one way or another */
|
||||
#include <openssl/symhacks.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Backward compatibility to SSLeay */
|
||||
/* This is more to be used to check the correct DLL is being used
|
||||
* in the MS world. */
|
||||
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
||||
#define SSLEAY_VERSION 0
|
||||
/* #define SSLEAY_OPTIONS 1 no longer supported */
|
||||
#define SSLEAY_CFLAGS 2
|
||||
#define SSLEAY_BUILT_ON 3
|
||||
#define SSLEAY_PLATFORM 4
|
||||
#define SSLEAY_DIR 5
|
||||
|
||||
/* Already declared in ossl_typ.h */
|
||||
#if 0
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Called when a new object is created */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when an object is free()ed */
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
/* Called when we need to dup an object */
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
#endif
|
||||
|
||||
/* A generic structure to pass assorted data in a expandable way */
|
||||
typedef struct openssl_item_st
|
||||
{
|
||||
int code;
|
||||
void *value; /* Not used for flag attributes */
|
||||
size_t value_size; /* Max size of value for output, length for input */
|
||||
size_t *value_length; /* Returned length of value for output */
|
||||
} OPENSSL_ITEM;
|
||||
|
||||
|
||||
/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
|
||||
* names in cryptlib.c
|
||||
*/
|
||||
|
||||
#define CRYPTO_LOCK_ERR 1
|
||||
#define CRYPTO_LOCK_EX_DATA 2
|
||||
#define CRYPTO_LOCK_X509 3
|
||||
#define CRYPTO_LOCK_X509_INFO 4
|
||||
#define CRYPTO_LOCK_X509_PKEY 5
|
||||
#define CRYPTO_LOCK_X509_CRL 6
|
||||
#define CRYPTO_LOCK_X509_REQ 7
|
||||
#define CRYPTO_LOCK_DSA 8
|
||||
#define CRYPTO_LOCK_RSA 9
|
||||
#define CRYPTO_LOCK_EVP_PKEY 10
|
||||
#define CRYPTO_LOCK_X509_STORE 11
|
||||
#define CRYPTO_LOCK_SSL_CTX 12
|
||||
#define CRYPTO_LOCK_SSL_CERT 13
|
||||
#define CRYPTO_LOCK_SSL_SESSION 14
|
||||
#define CRYPTO_LOCK_SSL_SESS_CERT 15
|
||||
#define CRYPTO_LOCK_SSL 16
|
||||
#define CRYPTO_LOCK_SSL_METHOD 17
|
||||
#define CRYPTO_LOCK_RAND 18
|
||||
#define CRYPTO_LOCK_RAND2 19
|
||||
#define CRYPTO_LOCK_MALLOC 20
|
||||
#define CRYPTO_LOCK_BIO 21
|
||||
#define CRYPTO_LOCK_GETHOSTBYNAME 22
|
||||
#define CRYPTO_LOCK_GETSERVBYNAME 23
|
||||
#define CRYPTO_LOCK_READDIR 24
|
||||
#define CRYPTO_LOCK_RSA_BLINDING 25
|
||||
#define CRYPTO_LOCK_DH 26
|
||||
#define CRYPTO_LOCK_MALLOC2 27
|
||||
#define CRYPTO_LOCK_DSO 28
|
||||
#define CRYPTO_LOCK_DYNLOCK 29
|
||||
#define CRYPTO_LOCK_ENGINE 30
|
||||
#define CRYPTO_LOCK_UI 31
|
||||
#define CRYPTO_LOCK_ECDSA 32
|
||||
#define CRYPTO_LOCK_EC 33
|
||||
#define CRYPTO_LOCK_ECDH 34
|
||||
#define CRYPTO_LOCK_BN 35
|
||||
#define CRYPTO_LOCK_EC_PRE_COMP 36
|
||||
#define CRYPTO_LOCK_STORE 37
|
||||
#define CRYPTO_LOCK_COMP 38
|
||||
#define CRYPTO_LOCK_FIPS 39
|
||||
#define CRYPTO_LOCK_FIPS2 40
|
||||
#define CRYPTO_NUM_LOCKS 41
|
||||
|
||||
#define CRYPTO_LOCK 1
|
||||
#define CRYPTO_UNLOCK 2
|
||||
#define CRYPTO_READ 4
|
||||
#define CRYPTO_WRITE 8
|
||||
|
||||
#ifndef OPENSSL_NO_LOCKING
|
||||
#ifndef CRYPTO_w_lock
|
||||
#define CRYPTO_w_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_w_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_lock(type) \
|
||||
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_r_unlock(type) \
|
||||
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
|
||||
#define CRYPTO_add(addr,amount,type) \
|
||||
CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
|
||||
#endif
|
||||
#else
|
||||
#define CRYPTO_w_lock(a)
|
||||
#define CRYPTO_w_unlock(a)
|
||||
#define CRYPTO_r_lock(a)
|
||||
#define CRYPTO_r_unlock(a)
|
||||
#define CRYPTO_add(a,b,c) ((*(a))+=(b))
|
||||
#endif
|
||||
|
||||
/* Some applications as well as some parts of OpenSSL need to allocate
|
||||
and deallocate locks in a dynamic fashion. The following typedef
|
||||
makes this possible in a type-safe manner. */
|
||||
/* struct CRYPTO_dynlock_value has to be defined by the application. */
|
||||
typedef struct
|
||||
{
|
||||
int references;
|
||||
struct CRYPTO_dynlock_value *data;
|
||||
} CRYPTO_dynlock;
|
||||
|
||||
|
||||
/* The following can be used to detect memory leaks in the SSLeay library.
|
||||
* It used, it turns on malloc checking */
|
||||
|
||||
#define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */
|
||||
#define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
|
||||
#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
|
||||
|
||||
/* The following are bit values to turn on or off options connected to the
|
||||
* malloc checking functionality */
|
||||
|
||||
/* Adds time to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
|
||||
/* Adds thread number to the memory checking information */
|
||||
#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
|
||||
|
||||
#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
|
||||
|
||||
|
||||
/* predec of the BIO type */
|
||||
typedef struct bio_st BIO_dummy;
|
||||
|
||||
struct crypto_ex_data_st
|
||||
{
|
||||
STACK_OF(void) *sk;
|
||||
int dummy; /* gcc is screwing up this data structure :-( */
|
||||
};
|
||||
DECLARE_STACK_OF(void)
|
||||
|
||||
/* This stuff is basically class callback functions
|
||||
* The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
|
||||
|
||||
typedef struct crypto_ex_data_func_st
|
||||
{
|
||||
long argl; /* Arbitary long */
|
||||
void *argp; /* Arbitary void * */
|
||||
CRYPTO_EX_new *new_func;
|
||||
CRYPTO_EX_free *free_func;
|
||||
CRYPTO_EX_dup *dup_func;
|
||||
} CRYPTO_EX_DATA_FUNCS;
|
||||
|
||||
DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
|
||||
|
||||
/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
|
||||
* entry.
|
||||
*/
|
||||
|
||||
#define CRYPTO_EX_INDEX_BIO 0
|
||||
#define CRYPTO_EX_INDEX_SSL 1
|
||||
#define CRYPTO_EX_INDEX_SSL_CTX 2
|
||||
#define CRYPTO_EX_INDEX_SSL_SESSION 3
|
||||
#define CRYPTO_EX_INDEX_X509_STORE 4
|
||||
#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
|
||||
#define CRYPTO_EX_INDEX_RSA 6
|
||||
#define CRYPTO_EX_INDEX_DSA 7
|
||||
#define CRYPTO_EX_INDEX_DH 8
|
||||
#define CRYPTO_EX_INDEX_ENGINE 9
|
||||
#define CRYPTO_EX_INDEX_X509 10
|
||||
#define CRYPTO_EX_INDEX_UI 11
|
||||
#define CRYPTO_EX_INDEX_ECDSA 12
|
||||
#define CRYPTO_EX_INDEX_ECDH 13
|
||||
#define CRYPTO_EX_INDEX_COMP 14
|
||||
#define CRYPTO_EX_INDEX_STORE 15
|
||||
|
||||
/* Dynamically assigned indexes start from this value (don't use directly, use
|
||||
* via CRYPTO_ex_data_new_class). */
|
||||
#define CRYPTO_EX_INDEX_USER 100
|
||||
|
||||
|
||||
/* This is the default callbacks, but we can have others as well:
|
||||
* this is needed in Win32 where the application malloc and the
|
||||
* library malloc may not be the same.
|
||||
*/
|
||||
#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
|
||||
malloc, realloc, free)
|
||||
|
||||
#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
|
||||
# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
|
||||
# define CRYPTO_MDEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Set standard debugging functions (not done by default
|
||||
* unless CRYPTO_MDEBUG is defined) */
|
||||
#define CRYPTO_malloc_debug_init() do {\
|
||||
CRYPTO_set_mem_debug_functions(\
|
||||
CRYPTO_dbg_malloc,\
|
||||
CRYPTO_dbg_realloc,\
|
||||
CRYPTO_dbg_free,\
|
||||
CRYPTO_dbg_set_options,\
|
||||
CRYPTO_dbg_get_options);\
|
||||
} while(0)
|
||||
|
||||
int CRYPTO_mem_ctrl(int mode);
|
||||
int CRYPTO_is_mem_check_on(void);
|
||||
|
||||
/* for applications */
|
||||
#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
|
||||
#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
|
||||
|
||||
/* for library-internal use */
|
||||
#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
|
||||
#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
|
||||
#define is_MemCheck_on() CRYPTO_is_mem_check_on()
|
||||
|
||||
#define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc(addr,num) \
|
||||
CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_realloc_clean(addr,old_num,num) \
|
||||
CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
|
||||
#define OPENSSL_remalloc(addr,num) \
|
||||
CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_freeFunc CRYPTO_free
|
||||
#define OPENSSL_free(addr) CRYPTO_free(addr)
|
||||
|
||||
#define OPENSSL_malloc_locked(num) \
|
||||
CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
|
||||
#define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
|
||||
|
||||
|
||||
const char *SSLeay_version(int type);
|
||||
unsigned long SSLeay(void);
|
||||
|
||||
int OPENSSL_issetugid(void);
|
||||
|
||||
/* An opaque type representing an implementation of "ex_data" support */
|
||||
typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
|
||||
/* Return an opaque pointer to the current "ex_data" implementation */
|
||||
const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
|
||||
/* Sets the "ex_data" implementation to be used (if it's not too late) */
|
||||
int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
|
||||
/* Get a new "ex_data" class, and return the corresponding "class_index" */
|
||||
int CRYPTO_ex_data_new_class(void);
|
||||
/* Within a given class, get/register a new index */
|
||||
int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
|
||||
CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
|
||||
CRYPTO_EX_free *free_func);
|
||||
/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
|
||||
* class (invokes whatever per-class callbacks are applicable) */
|
||||
int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
CRYPTO_EX_DATA *from);
|
||||
void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
|
||||
/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
|
||||
* (relative to the class type involved) */
|
||||
int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
|
||||
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
|
||||
/* This function cleans up all "ex_data" state. It mustn't be called under
|
||||
* potential race-conditions. */
|
||||
void CRYPTO_cleanup_all_ex_data(void);
|
||||
|
||||
int CRYPTO_get_new_lockid(char *name);
|
||||
|
||||
int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
|
||||
void CRYPTO_lock(int mode, int type,const char *file,int line);
|
||||
void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
|
||||
const char *file,int line));
|
||||
void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
|
||||
int line);
|
||||
void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
|
||||
const char *file, int line));
|
||||
int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
|
||||
const char *file,int line);
|
||||
|
||||
/* Don't use this structure directly. */
|
||||
typedef struct crypto_threadid_st
|
||||
{
|
||||
void *ptr;
|
||||
unsigned long val;
|
||||
} CRYPTO_THREADID;
|
||||
/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
|
||||
void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
|
||||
void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
|
||||
int CRYPTO_THREADID_set_callback(void (*threadid_func)(CRYPTO_THREADID *));
|
||||
void (*CRYPTO_THREADID_get_callback(void))(CRYPTO_THREADID *);
|
||||
void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
|
||||
int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b);
|
||||
void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src);
|
||||
unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id);
|
||||
#ifndef OPENSSL_NO_DEPRECATED
|
||||
void CRYPTO_set_id_callback(unsigned long (*func)(void));
|
||||
unsigned long (*CRYPTO_get_id_callback(void))(void);
|
||||
unsigned long CRYPTO_thread_id(void);
|
||||
#endif
|
||||
|
||||
const char *CRYPTO_get_lock_name(int type);
|
||||
int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
|
||||
int line);
|
||||
|
||||
int CRYPTO_get_new_dynlockid(void);
|
||||
void CRYPTO_destroy_dynlockid(int i);
|
||||
struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
|
||||
void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
|
||||
void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
|
||||
struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
|
||||
|
||||
/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
|
||||
* call the latter last if you need different functions */
|
||||
int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void *(*r)(void *,size_t,const char *,int),
|
||||
void (*f)(void *));
|
||||
int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
|
||||
void (*free_func)(void *));
|
||||
int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
|
||||
void (*r)(void *,void *,int,const char *,int,int),
|
||||
void (*f)(void *,int),
|
||||
void (*so)(long),
|
||||
long (*go)(void));
|
||||
void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
|
||||
void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void *(**r)(void *, size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
|
||||
void (**f)(void *));
|
||||
void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
|
||||
void (**r)(void *,void *,int,const char *,int,int),
|
||||
void (**f)(void *,int),
|
||||
void (**so)(long),
|
||||
long (**go)(void));
|
||||
|
||||
void *CRYPTO_malloc_locked(int num, const char *file, int line);
|
||||
void CRYPTO_free_locked(void *ptr);
|
||||
void *CRYPTO_malloc(int num, const char *file, int line);
|
||||
char *CRYPTO_strdup(const char *str, const char *file, int line);
|
||||
void CRYPTO_free(void *ptr);
|
||||
void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
|
||||
void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
|
||||
int line);
|
||||
void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
|
||||
|
||||
void OPENSSL_cleanse(void *ptr, size_t len);
|
||||
|
||||
void CRYPTO_set_mem_debug_options(long bits);
|
||||
long CRYPTO_get_mem_debug_options(void);
|
||||
|
||||
#define CRYPTO_push_info(info) \
|
||||
CRYPTO_push_info_(info, __FILE__, __LINE__);
|
||||
int CRYPTO_push_info_(const char *info, const char *file, int line);
|
||||
int CRYPTO_pop_info(void);
|
||||
int CRYPTO_remove_all_info(void);
|
||||
|
||||
|
||||
/* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
|
||||
* used as default in CRYPTO_MDEBUG compilations): */
|
||||
/* The last argument has the following significance:
|
||||
*
|
||||
* 0: called before the actual memory allocation has taken place
|
||||
* 1: called after the actual memory allocation has taken place
|
||||
*/
|
||||
void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
|
||||
void CRYPTO_dbg_free(void *addr,int before_p);
|
||||
/* Tell the debugging code about options. By default, the following values
|
||||
* apply:
|
||||
*
|
||||
* 0: Clear all options.
|
||||
* V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option.
|
||||
* V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option.
|
||||
* V_CRYPTO_MDEBUG_ALL (3): 1 + 2
|
||||
*/
|
||||
void CRYPTO_dbg_set_options(long bits);
|
||||
long CRYPTO_dbg_get_options(void);
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_FP_API
|
||||
void CRYPTO_mem_leaks_fp(FILE *);
|
||||
#endif
|
||||
void CRYPTO_mem_leaks(struct bio_st *bio);
|
||||
/* unsigned long order, char *file, int line, int num_bytes, char *addr */
|
||||
typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
|
||||
void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
|
||||
|
||||
/* die if we have to */
|
||||
void OpenSSLDie(const char *file,int line,const char *assertion);
|
||||
#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
|
||||
|
||||
unsigned long *OPENSSL_ia32cap_loc(void);
|
||||
#define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
|
||||
int OPENSSL_isservice(void);
|
||||
|
||||
int FIPS_mode(void);
|
||||
int FIPS_mode_set(int r);
|
||||
|
||||
void OPENSSL_init(void);
|
||||
|
||||
#define fips_md_init(alg) fips_md_init_ctx(alg, alg)
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c) \
|
||||
{ \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to digest " #alg " forbidden in FIPS mode!"); \
|
||||
return private_##alg##_Init(c); \
|
||||
} \
|
||||
int private_##alg##_Init(cx##_CTX *c)
|
||||
|
||||
#define fips_cipher_abort(alg) \
|
||||
if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \
|
||||
"Low level API call to cipher " #alg " forbidden in FIPS mode!")
|
||||
|
||||
#else
|
||||
#define fips_md_init_ctx(alg, cx) \
|
||||
int alg##_Init(cx##_CTX *c)
|
||||
#define fips_cipher_abort(alg) while(0)
|
||||
#endif
|
||||
|
||||
/* CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It
|
||||
* takes an amount of time dependent on |len|, but independent of the contents
|
||||
* of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a
|
||||
* defined order as the return value when a != b is undefined, other than to be
|
||||
* non-zero. */
|
||||
int CRYPTO_memcmp(const void *a, const void *b, size_t len);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
void ERR_load_CRYPTO_strings(void);
|
||||
|
||||
/* Error codes for the CRYPTO functions. */
|
||||
|
||||
/* Function codes. */
|
||||
#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
|
||||
#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
|
||||
#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
|
||||
#define CRYPTO_F_DEF_ADD_INDEX 104
|
||||
#define CRYPTO_F_DEF_GET_CLASS 105
|
||||
#define CRYPTO_F_FIPS_MODE_SET 109
|
||||
#define CRYPTO_F_INT_DUP_EX_DATA 106
|
||||
#define CRYPTO_F_INT_FREE_EX_DATA 107
|
||||
#define CRYPTO_F_INT_NEW_EX_DATA 108
|
||||
|
||||
/* Reason codes. */
|
||||
#define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101
|
||||
#define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
#ifndef HEADER_OPENSSLV_H
|
||||
#define HEADER_OPENSSLV_H
|
||||
|
||||
/* Numeric release version identifier:
|
||||
* MNNFFPPS: major minor fix patch status
|
||||
* The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
* 1 to 14, and f for release. The patch level is exactly that.
|
||||
* For example:
|
||||
* 0.9.3-dev 0x00903000
|
||||
* 0.9.3-beta1 0x00903001
|
||||
* 0.9.3-beta2-dev 0x00903002
|
||||
* 0.9.3-beta2 0x00903002 (same as ...beta2-dev)
|
||||
* 0.9.3 0x0090300f
|
||||
* 0.9.3a 0x0090301f
|
||||
* 0.9.4 0x0090400f
|
||||
* 1.2.3z 0x102031af
|
||||
*
|
||||
* For continuity reasons (because 0.9.5 is already out, and is coded
|
||||
* 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level
|
||||
* part is slightly different, by setting the highest bit. This means
|
||||
* that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start
|
||||
* with 0x0090600S...
|
||||
*
|
||||
* (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000109fL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i-fips 6 Aug 2014"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.1i 6 Aug 2014"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
||||
/* The macros below are to be used for shared library (.so, .dll, ...)
|
||||
* versioning. That kind of versioning works a bit differently between
|
||||
* operating systems. The most usual scheme is to set a major and a minor
|
||||
* number, and have the runtime loader check that the major number is equal
|
||||
* to what it was at application link time, while the minor number has to
|
||||
* be greater or equal to what it was at application link time. With this
|
||||
* scheme, the version number is usually part of the file name, like this:
|
||||
*
|
||||
* libcrypto.so.0.9
|
||||
*
|
||||
* Some unixen also make a softlink with the major verson number only:
|
||||
*
|
||||
* libcrypto.so.0
|
||||
*
|
||||
* On Tru64 and IRIX 6.x it works a little bit differently. There, the
|
||||
* shared library version is stored in the file, and is actually a series
|
||||
* of versions, separated by colons. The rightmost version present in the
|
||||
* library when linking an application is stored in the application to be
|
||||
* matched at run time. When the application is run, a check is done to
|
||||
* see if the library version stored in the application matches any of the
|
||||
* versions in the version string of the library itself.
|
||||
* This version string can be constructed in any way, depending on what
|
||||
* kind of matching is desired. However, to implement the same scheme as
|
||||
* the one used in the other unixen, all compatible versions, from lowest
|
||||
* to highest, should be part of the string. Consecutive builds would
|
||||
* give the following versions strings:
|
||||
*
|
||||
* 3.0
|
||||
* 3.0:3.1
|
||||
* 3.0:3.1:3.2
|
||||
* 4.0
|
||||
* 4.0:4.1
|
||||
*
|
||||
* Notice how version 4 is completely incompatible with version, and
|
||||
* therefore give the breach you can see.
|
||||
*
|
||||
* There may be other schemes as well that I haven't yet discovered.
|
||||
*
|
||||
* So, here's the way it works here: first of all, the library version
|
||||
* number doesn't need at all to match the overall OpenSSL version.
|
||||
* However, it's nice and more understandable if it actually does.
|
||||
* The current library version is stored in the macro SHLIB_VERSION_NUMBER,
|
||||
* which is just a piece of text in the format "M.m.e" (Major, minor, edit).
|
||||
* For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,
|
||||
* we need to keep a history of version numbers, which is done in the
|
||||
* macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and
|
||||
* should only keep the versions that are binary compatible with the current.
|
||||
*/
|
||||
#define SHLIB_VERSION_HISTORY ""
|
||||
#define SHLIB_VERSION_NUMBER "1.0.0"
|
||||
|
||||
|
||||
#endif /* HEADER_OPENSSLV_H */
|
||||
@@ -0,0 +1,202 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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 product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_OPENSSL_TYPES_H
|
||||
#define HEADER_OPENSSL_TYPES_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef NO_ASN1_TYPEDEFS
|
||||
#define ASN1_INTEGER ASN1_STRING
|
||||
#define ASN1_ENUMERATED ASN1_STRING
|
||||
#define ASN1_BIT_STRING ASN1_STRING
|
||||
#define ASN1_OCTET_STRING ASN1_STRING
|
||||
#define ASN1_PRINTABLESTRING ASN1_STRING
|
||||
#define ASN1_T61STRING ASN1_STRING
|
||||
#define ASN1_IA5STRING ASN1_STRING
|
||||
#define ASN1_UTCTIME ASN1_STRING
|
||||
#define ASN1_GENERALIZEDTIME ASN1_STRING
|
||||
#define ASN1_TIME ASN1_STRING
|
||||
#define ASN1_GENERALSTRING ASN1_STRING
|
||||
#define ASN1_UNIVERSALSTRING ASN1_STRING
|
||||
#define ASN1_BMPSTRING ASN1_STRING
|
||||
#define ASN1_VISIBLESTRING ASN1_STRING
|
||||
#define ASN1_UTF8STRING ASN1_STRING
|
||||
#define ASN1_BOOLEAN int
|
||||
#define ASN1_NULL int
|
||||
#else
|
||||
typedef struct asn1_string_st ASN1_INTEGER;
|
||||
typedef struct asn1_string_st ASN1_ENUMERATED;
|
||||
typedef struct asn1_string_st ASN1_BIT_STRING;
|
||||
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
||||
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
||||
typedef struct asn1_string_st ASN1_T61STRING;
|
||||
typedef struct asn1_string_st ASN1_IA5STRING;
|
||||
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
||||
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
||||
typedef struct asn1_string_st ASN1_BMPSTRING;
|
||||
typedef struct asn1_string_st ASN1_UTCTIME;
|
||||
typedef struct asn1_string_st ASN1_TIME;
|
||||
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
||||
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
||||
typedef struct asn1_string_st ASN1_UTF8STRING;
|
||||
typedef struct asn1_string_st ASN1_STRING;
|
||||
typedef int ASN1_BOOLEAN;
|
||||
typedef int ASN1_NULL;
|
||||
#endif
|
||||
|
||||
typedef struct ASN1_ITEM_st ASN1_ITEM;
|
||||
typedef struct asn1_pctx_st ASN1_PCTX;
|
||||
|
||||
#ifdef OPENSSL_SYS_WIN32
|
||||
#undef X509_NAME
|
||||
#undef X509_EXTENSIONS
|
||||
#undef X509_CERT_PAIR
|
||||
#undef PKCS7_ISSUER_AND_SERIAL
|
||||
#undef OCSP_REQUEST
|
||||
#undef OCSP_RESPONSE
|
||||
#endif
|
||||
|
||||
#ifdef BIGNUM
|
||||
#undef BIGNUM
|
||||
#endif
|
||||
typedef struct bignum_st BIGNUM;
|
||||
typedef struct bignum_ctx BN_CTX;
|
||||
typedef struct bn_blinding_st BN_BLINDING;
|
||||
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
||||
typedef struct bn_recp_ctx_st BN_RECP_CTX;
|
||||
typedef struct bn_gencb_st BN_GENCB;
|
||||
|
||||
typedef struct buf_mem_st BUF_MEM;
|
||||
|
||||
typedef struct evp_cipher_st EVP_CIPHER;
|
||||
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
||||
typedef struct env_md_st EVP_MD;
|
||||
typedef struct env_md_ctx_st EVP_MD_CTX;
|
||||
typedef struct evp_pkey_st EVP_PKEY;
|
||||
|
||||
typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
|
||||
|
||||
typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
|
||||
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
|
||||
|
||||
typedef struct dh_st DH;
|
||||
typedef struct dh_method DH_METHOD;
|
||||
|
||||
typedef struct dsa_st DSA;
|
||||
typedef struct dsa_method DSA_METHOD;
|
||||
|
||||
typedef struct rsa_st RSA;
|
||||
typedef struct rsa_meth_st RSA_METHOD;
|
||||
|
||||
typedef struct rand_meth_st RAND_METHOD;
|
||||
|
||||
typedef struct ecdh_method ECDH_METHOD;
|
||||
typedef struct ecdsa_method ECDSA_METHOD;
|
||||
|
||||
typedef struct x509_st X509;
|
||||
typedef struct X509_algor_st X509_ALGOR;
|
||||
typedef struct X509_crl_st X509_CRL;
|
||||
typedef struct x509_crl_method_st X509_CRL_METHOD;
|
||||
typedef struct x509_revoked_st X509_REVOKED;
|
||||
typedef struct X509_name_st X509_NAME;
|
||||
typedef struct X509_pubkey_st X509_PUBKEY;
|
||||
typedef struct x509_store_st X509_STORE;
|
||||
typedef struct x509_store_ctx_st X509_STORE_CTX;
|
||||
|
||||
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
|
||||
|
||||
typedef struct v3_ext_ctx X509V3_CTX;
|
||||
typedef struct conf_st CONF;
|
||||
|
||||
typedef struct store_st STORE;
|
||||
typedef struct store_method_st STORE_METHOD;
|
||||
|
||||
typedef struct ui_st UI;
|
||||
typedef struct ui_method_st UI_METHOD;
|
||||
|
||||
typedef struct st_ERR_FNS ERR_FNS;
|
||||
|
||||
typedef struct engine_st ENGINE;
|
||||
typedef struct ssl_st SSL;
|
||||
typedef struct ssl_ctx_st SSL_CTX;
|
||||
|
||||
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
|
||||
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
|
||||
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
|
||||
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
|
||||
|
||||
typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
|
||||
typedef struct DIST_POINT_st DIST_POINT;
|
||||
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
|
||||
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
|
||||
|
||||
/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */
|
||||
#define DECLARE_PKCS12_STACK_OF(type) /* Nothing */
|
||||
#define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */
|
||||
|
||||
typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
|
||||
/* Callback types for crypto.h */
|
||||
typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
|
||||
int idx, long argl, void *argp);
|
||||
typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
|
||||
int idx, long argl, void *argp);
|
||||
|
||||
typedef struct ocsp_req_ctx_st OCSP_REQ_CTX;
|
||||
typedef struct ocsp_response_st OCSP_RESPONSE;
|
||||
typedef struct ocsp_responder_id_st OCSP_RESPID;
|
||||
|
||||
#endif /* def HEADER_OPENSSL_TYPES_H */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,108 @@
|
||||
/* crypto/stack/stack.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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 AUTHOR 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.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#ifndef HEADER_STACK_H
|
||||
#define HEADER_STACK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stack_st
|
||||
{
|
||||
int num;
|
||||
char **data;
|
||||
int sorted;
|
||||
|
||||
int num_alloc;
|
||||
int (*comp)(const void *, const void *);
|
||||
} _STACK; /* Use STACK_OF(...) instead */
|
||||
|
||||
#define M_sk_num(sk) ((sk) ? (sk)->num:-1)
|
||||
#define M_sk_value(sk,n) ((sk) ? (sk)->data[n] : NULL)
|
||||
|
||||
int sk_num(const _STACK *);
|
||||
void *sk_value(const _STACK *, int);
|
||||
|
||||
void *sk_set(_STACK *, int, void *);
|
||||
|
||||
_STACK *sk_new(int (*cmp)(const void *, const void *));
|
||||
_STACK *sk_new_null(void);
|
||||
void sk_free(_STACK *);
|
||||
void sk_pop_free(_STACK *st, void (*func)(void *));
|
||||
int sk_insert(_STACK *sk, void *data, int where);
|
||||
void *sk_delete(_STACK *st, int loc);
|
||||
void *sk_delete_ptr(_STACK *st, void *p);
|
||||
int sk_find(_STACK *st, void *data);
|
||||
int sk_find_ex(_STACK *st, void *data);
|
||||
int sk_push(_STACK *st, void *data);
|
||||
int sk_unshift(_STACK *st, void *data);
|
||||
void *sk_shift(_STACK *st);
|
||||
void *sk_pop(_STACK *st);
|
||||
void sk_zero(_STACK *st);
|
||||
int (*sk_set_cmp_func(_STACK *sk, int (*c)(const void *, const void *)))
|
||||
(const void *, const void *);
|
||||
_STACK *sk_dup(_STACK *st);
|
||||
void sk_sort(_STACK *st);
|
||||
int sk_is_sorted(const _STACK *st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,481 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. 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.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED 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 OpenSSL PROJECT OR
|
||||
* ITS 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 product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HEADER_SYMHACKS_H
|
||||
#define HEADER_SYMHACKS_H
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
/* Hacks to solve the problem with linkers incapable of handling very long
|
||||
symbol names. In the case of VMS, the limit is 31 characters on VMS for
|
||||
VAX. */
|
||||
/* Note that this affects util/libeay.num and util/ssleay.num... you may
|
||||
change those manually, but that's not recommended, as those files are
|
||||
controlled centrally and updated on Unix, and the central definition
|
||||
may disagree with yours, which in turn may come with shareable library
|
||||
incompatibilities. */
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
|
||||
/* Hack a long name in crypto/ex_data.c */
|
||||
#undef CRYPTO_get_ex_data_implementation
|
||||
#define CRYPTO_get_ex_data_implementation CRYPTO_get_ex_data_impl
|
||||
#undef CRYPTO_set_ex_data_implementation
|
||||
#define CRYPTO_set_ex_data_implementation CRYPTO_set_ex_data_impl
|
||||
|
||||
/* Hack a long name in crypto/asn1/a_mbstr.c */
|
||||
#undef ASN1_STRING_set_default_mask_asc
|
||||
#define ASN1_STRING_set_default_mask_asc ASN1_STRING_set_def_mask_asc
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO) */
|
||||
#undef i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO
|
||||
#define i2d_ASN1_SET_OF_PKCS7_SIGNER_INFO i2d_ASN1_SET_OF_PKCS7_SIGINF
|
||||
#undef d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO
|
||||
#define d2i_ASN1_SET_OF_PKCS7_SIGNER_INFO d2i_ASN1_SET_OF_PKCS7_SIGINF
|
||||
#endif
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO) */
|
||||
#undef i2d_ASN1_SET_OF_PKCS7_RECIP_INFO
|
||||
#define i2d_ASN1_SET_OF_PKCS7_RECIP_INFO i2d_ASN1_SET_OF_PKCS7_RECINF
|
||||
#undef d2i_ASN1_SET_OF_PKCS7_RECIP_INFO
|
||||
#define d2i_ASN1_SET_OF_PKCS7_RECIP_INFO d2i_ASN1_SET_OF_PKCS7_RECINF
|
||||
#endif
|
||||
|
||||
#if 0 /* No longer needed, since safestack macro magic does the job */
|
||||
/* Hack the names created with DECLARE_ASN1_SET_OF(ACCESS_DESCRIPTION) */
|
||||
#undef i2d_ASN1_SET_OF_ACCESS_DESCRIPTION
|
||||
#define i2d_ASN1_SET_OF_ACCESS_DESCRIPTION i2d_ASN1_SET_OF_ACC_DESC
|
||||
#undef d2i_ASN1_SET_OF_ACCESS_DESCRIPTION
|
||||
#define d2i_ASN1_SET_OF_ACCESS_DESCRIPTION d2i_ASN1_SET_OF_ACC_DESC
|
||||
#endif
|
||||
|
||||
/* Hack the names created with DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE) */
|
||||
#undef PEM_read_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_read_NETSCAPE_CERT_SEQUENCE PEM_read_NS_CERT_SEQ
|
||||
#undef PEM_write_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_NETSCAPE_CERT_SEQUENCE PEM_write_NS_CERT_SEQ
|
||||
#undef PEM_read_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_read_bio_NETSCAPE_CERT_SEQUENCE PEM_read_bio_NS_CERT_SEQ
|
||||
#undef PEM_write_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_bio_NETSCAPE_CERT_SEQUENCE PEM_write_bio_NS_CERT_SEQ
|
||||
#undef PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE
|
||||
#define PEM_write_cb_bio_NETSCAPE_CERT_SEQUENCE PEM_write_cb_bio_NS_CERT_SEQ
|
||||
|
||||
/* Hack the names created with DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO) */
|
||||
#undef PEM_read_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_read_PKCS8_PRIV_KEY_INFO PEM_read_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_PKCS8_PRIV_KEY_INFO PEM_write_P8_PRIV_KEY_INFO
|
||||
#undef PEM_read_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_read_bio_PKCS8_PRIV_KEY_INFO PEM_read_bio_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_bio_PKCS8_PRIV_KEY_INFO PEM_write_bio_P8_PRIV_KEY_INFO
|
||||
#undef PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO
|
||||
#define PEM_write_cb_bio_PKCS8_PRIV_KEY_INFO PEM_wrt_cb_bio_P8_PRIV_KEY_INFO
|
||||
|
||||
/* Hack other PEM names */
|
||||
#undef PEM_write_bio_PKCS8PrivateKey_nid
|
||||
#define PEM_write_bio_PKCS8PrivateKey_nid PEM_write_bio_PKCS8PrivKey_nid
|
||||
|
||||
/* Hack some long X509 names */
|
||||
#undef X509_REVOKED_get_ext_by_critical
|
||||
#define X509_REVOKED_get_ext_by_critical X509_REVOKED_get_ext_by_critic
|
||||
#undef X509_policy_tree_get0_user_policies
|
||||
#define X509_policy_tree_get0_user_policies X509_pcy_tree_get0_usr_policies
|
||||
#undef X509_policy_node_get0_qualifiers
|
||||
#define X509_policy_node_get0_qualifiers X509_pcy_node_get0_qualifiers
|
||||
#undef X509_STORE_CTX_get_explicit_policy
|
||||
#define X509_STORE_CTX_get_explicit_policy X509_STORE_CTX_get_expl_policy
|
||||
#undef X509_STORE_CTX_get0_current_issuer
|
||||
#define X509_STORE_CTX_get0_current_issuer X509_STORE_CTX_get0_cur_issuer
|
||||
|
||||
/* Hack some long CRYPTO names */
|
||||
#undef CRYPTO_set_dynlock_destroy_callback
|
||||
#define CRYPTO_set_dynlock_destroy_callback CRYPTO_set_dynlock_destroy_cb
|
||||
#undef CRYPTO_set_dynlock_create_callback
|
||||
#define CRYPTO_set_dynlock_create_callback CRYPTO_set_dynlock_create_cb
|
||||
#undef CRYPTO_set_dynlock_lock_callback
|
||||
#define CRYPTO_set_dynlock_lock_callback CRYPTO_set_dynlock_lock_cb
|
||||
#undef CRYPTO_get_dynlock_lock_callback
|
||||
#define CRYPTO_get_dynlock_lock_callback CRYPTO_get_dynlock_lock_cb
|
||||
#undef CRYPTO_get_dynlock_destroy_callback
|
||||
#define CRYPTO_get_dynlock_destroy_callback CRYPTO_get_dynlock_destroy_cb
|
||||
#undef CRYPTO_get_dynlock_create_callback
|
||||
#define CRYPTO_get_dynlock_create_callback CRYPTO_get_dynlock_create_cb
|
||||
#undef CRYPTO_set_locked_mem_ex_functions
|
||||
#define CRYPTO_set_locked_mem_ex_functions CRYPTO_set_locked_mem_ex_funcs
|
||||
#undef CRYPTO_get_locked_mem_ex_functions
|
||||
#define CRYPTO_get_locked_mem_ex_functions CRYPTO_get_locked_mem_ex_funcs
|
||||
|
||||
/* Hack some long SSL names */
|
||||
#undef SSL_CTX_set_default_verify_paths
|
||||
#define SSL_CTX_set_default_verify_paths SSL_CTX_set_def_verify_paths
|
||||
#undef SSL_get_ex_data_X509_STORE_CTX_idx
|
||||
#define SSL_get_ex_data_X509_STORE_CTX_idx SSL_get_ex_d_X509_STORE_CTX_idx
|
||||
#undef SSL_add_file_cert_subjects_to_stack
|
||||
#define SSL_add_file_cert_subjects_to_stack SSL_add_file_cert_subjs_to_stk
|
||||
#undef SSL_add_dir_cert_subjects_to_stack
|
||||
#define SSL_add_dir_cert_subjects_to_stack SSL_add_dir_cert_subjs_to_stk
|
||||
#undef SSL_CTX_use_certificate_chain_file
|
||||
#define SSL_CTX_use_certificate_chain_file SSL_CTX_use_cert_chain_file
|
||||
#undef SSL_CTX_set_cert_verify_callback
|
||||
#define SSL_CTX_set_cert_verify_callback SSL_CTX_set_cert_verify_cb
|
||||
#undef SSL_CTX_set_default_passwd_cb_userdata
|
||||
#define SSL_CTX_set_default_passwd_cb_userdata SSL_CTX_set_def_passwd_cb_ud
|
||||
#undef SSL_COMP_get_compression_methods
|
||||
#define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods
|
||||
#undef ssl_add_clienthello_renegotiate_ext
|
||||
#define ssl_add_clienthello_renegotiate_ext ssl_add_clienthello_reneg_ext
|
||||
#undef ssl_add_serverhello_renegotiate_ext
|
||||
#define ssl_add_serverhello_renegotiate_ext ssl_add_serverhello_reneg_ext
|
||||
#undef ssl_parse_clienthello_renegotiate_ext
|
||||
#define ssl_parse_clienthello_renegotiate_ext ssl_parse_clienthello_reneg_ext
|
||||
#undef ssl_parse_serverhello_renegotiate_ext
|
||||
#define ssl_parse_serverhello_renegotiate_ext ssl_parse_serverhello_reneg_ext
|
||||
#undef SSL_srp_server_param_with_username
|
||||
#define SSL_srp_server_param_with_username SSL_srp_server_param_with_un
|
||||
#undef SSL_CTX_set_srp_client_pwd_callback
|
||||
#define SSL_CTX_set_srp_client_pwd_callback SSL_CTX_set_srp_client_pwd_cb
|
||||
#undef SSL_CTX_set_srp_verify_param_callback
|
||||
#define SSL_CTX_set_srp_verify_param_callback SSL_CTX_set_srp_vfy_param_cb
|
||||
#undef SSL_CTX_set_srp_username_callback
|
||||
#define SSL_CTX_set_srp_username_callback SSL_CTX_set_srp_un_cb
|
||||
#undef ssl_add_clienthello_use_srtp_ext
|
||||
#define ssl_add_clienthello_use_srtp_ext ssl_add_clihello_use_srtp_ext
|
||||
#undef ssl_add_serverhello_use_srtp_ext
|
||||
#define ssl_add_serverhello_use_srtp_ext ssl_add_serhello_use_srtp_ext
|
||||
#undef ssl_parse_clienthello_use_srtp_ext
|
||||
#define ssl_parse_clienthello_use_srtp_ext ssl_parse_clihello_use_srtp_ext
|
||||
#undef ssl_parse_serverhello_use_srtp_ext
|
||||
#define ssl_parse_serverhello_use_srtp_ext ssl_parse_serhello_use_srtp_ext
|
||||
#undef SSL_CTX_set_next_protos_advertised_cb
|
||||
#define SSL_CTX_set_next_protos_advertised_cb SSL_CTX_set_next_protos_adv_cb
|
||||
#undef SSL_CTX_set_next_proto_select_cb
|
||||
#define SSL_CTX_set_next_proto_select_cb SSL_CTX_set_next_proto_sel_cb
|
||||
#undef ssl3_cbc_record_digest_supported
|
||||
#define ssl3_cbc_record_digest_supported ssl3_cbc_record_digest_support
|
||||
#undef ssl_check_clienthello_tlsext_late
|
||||
#define ssl_check_clienthello_tlsext_late ssl_check_clihello_tlsext_late
|
||||
#undef ssl_check_clienthello_tlsext_early
|
||||
#define ssl_check_clienthello_tlsext_early ssl_check_clihello_tlsext_early
|
||||
|
||||
/* Hack some long ENGINE names */
|
||||
#undef ENGINE_get_default_BN_mod_exp_crt
|
||||
#define ENGINE_get_default_BN_mod_exp_crt ENGINE_get_def_BN_mod_exp_crt
|
||||
#undef ENGINE_set_default_BN_mod_exp_crt
|
||||
#define ENGINE_set_default_BN_mod_exp_crt ENGINE_set_def_BN_mod_exp_crt
|
||||
#undef ENGINE_set_load_privkey_function
|
||||
#define ENGINE_set_load_privkey_function ENGINE_set_load_privkey_fn
|
||||
#undef ENGINE_get_load_privkey_function
|
||||
#define ENGINE_get_load_privkey_function ENGINE_get_load_privkey_fn
|
||||
#undef ENGINE_unregister_pkey_asn1_meths
|
||||
#define ENGINE_unregister_pkey_asn1_meths ENGINE_unreg_pkey_asn1_meths
|
||||
#undef ENGINE_register_all_pkey_asn1_meths
|
||||
#define ENGINE_register_all_pkey_asn1_meths ENGINE_reg_all_pkey_asn1_meths
|
||||
#undef ENGINE_set_default_pkey_asn1_meths
|
||||
#define ENGINE_set_default_pkey_asn1_meths ENGINE_set_def_pkey_asn1_meths
|
||||
#undef ENGINE_get_pkey_asn1_meth_engine
|
||||
#define ENGINE_get_pkey_asn1_meth_engine ENGINE_get_pkey_asn1_meth_eng
|
||||
#undef ENGINE_set_load_ssl_client_cert_function
|
||||
#define ENGINE_set_load_ssl_client_cert_function \
|
||||
ENGINE_set_ld_ssl_clnt_cert_fn
|
||||
#undef ENGINE_get_ssl_client_cert_function
|
||||
#define ENGINE_get_ssl_client_cert_function ENGINE_get_ssl_client_cert_fn
|
||||
|
||||
/* Hack some long OCSP names */
|
||||
#undef OCSP_REQUEST_get_ext_by_critical
|
||||
#define OCSP_REQUEST_get_ext_by_critical OCSP_REQUEST_get_ext_by_crit
|
||||
#undef OCSP_BASICRESP_get_ext_by_critical
|
||||
#define OCSP_BASICRESP_get_ext_by_critical OCSP_BASICRESP_get_ext_by_crit
|
||||
#undef OCSP_SINGLERESP_get_ext_by_critical
|
||||
#define OCSP_SINGLERESP_get_ext_by_critical OCSP_SINGLERESP_get_ext_by_crit
|
||||
|
||||
/* Hack some long DES names */
|
||||
#undef _ossl_old_des_ede3_cfb64_encrypt
|
||||
#define _ossl_old_des_ede3_cfb64_encrypt _ossl_odes_ede3_cfb64_encrypt
|
||||
#undef _ossl_old_des_ede3_ofb64_encrypt
|
||||
#define _ossl_old_des_ede3_ofb64_encrypt _ossl_odes_ede3_ofb64_encrypt
|
||||
|
||||
/* Hack some long EVP names */
|
||||
#undef OPENSSL_add_all_algorithms_noconf
|
||||
#define OPENSSL_add_all_algorithms_noconf OPENSSL_add_all_algo_noconf
|
||||
#undef OPENSSL_add_all_algorithms_conf
|
||||
#define OPENSSL_add_all_algorithms_conf OPENSSL_add_all_algo_conf
|
||||
#undef EVP_PKEY_meth_set_verify_recover
|
||||
#define EVP_PKEY_meth_set_verify_recover EVP_PKEY_meth_set_vrfy_recover
|
||||
|
||||
/* Hack some long EC names */
|
||||
#undef EC_GROUP_set_point_conversion_form
|
||||
#define EC_GROUP_set_point_conversion_form EC_GROUP_set_point_conv_form
|
||||
#undef EC_GROUP_get_point_conversion_form
|
||||
#define EC_GROUP_get_point_conversion_form EC_GROUP_get_point_conv_form
|
||||
#undef EC_GROUP_clear_free_all_extra_data
|
||||
#define EC_GROUP_clear_free_all_extra_data EC_GROUP_clr_free_all_xtra_data
|
||||
#undef EC_KEY_set_public_key_affine_coordinates
|
||||
#define EC_KEY_set_public_key_affine_coordinates \
|
||||
EC_KEY_set_pub_key_aff_coords
|
||||
#undef EC_POINT_set_Jprojective_coordinates_GFp
|
||||
#define EC_POINT_set_Jprojective_coordinates_GFp \
|
||||
EC_POINT_set_Jproj_coords_GFp
|
||||
#undef EC_POINT_get_Jprojective_coordinates_GFp
|
||||
#define EC_POINT_get_Jprojective_coordinates_GFp \
|
||||
EC_POINT_get_Jproj_coords_GFp
|
||||
#undef EC_POINT_set_affine_coordinates_GFp
|
||||
#define EC_POINT_set_affine_coordinates_GFp EC_POINT_set_affine_coords_GFp
|
||||
#undef EC_POINT_get_affine_coordinates_GFp
|
||||
#define EC_POINT_get_affine_coordinates_GFp EC_POINT_get_affine_coords_GFp
|
||||
#undef EC_POINT_set_compressed_coordinates_GFp
|
||||
#define EC_POINT_set_compressed_coordinates_GFp EC_POINT_set_compr_coords_GFp
|
||||
#undef EC_POINT_set_affine_coordinates_GF2m
|
||||
#define EC_POINT_set_affine_coordinates_GF2m EC_POINT_set_affine_coords_GF2m
|
||||
#undef EC_POINT_get_affine_coordinates_GF2m
|
||||
#define EC_POINT_get_affine_coordinates_GF2m EC_POINT_get_affine_coords_GF2m
|
||||
#undef EC_POINT_set_compressed_coordinates_GF2m
|
||||
#define EC_POINT_set_compressed_coordinates_GF2m \
|
||||
EC_POINT_set_compr_coords_GF2m
|
||||
#undef ec_GF2m_simple_group_clear_finish
|
||||
#define ec_GF2m_simple_group_clear_finish ec_GF2m_simple_grp_clr_finish
|
||||
#undef ec_GF2m_simple_group_check_discriminant
|
||||
#define ec_GF2m_simple_group_check_discriminant ec_GF2m_simple_grp_chk_discrim
|
||||
#undef ec_GF2m_simple_point_clear_finish
|
||||
#define ec_GF2m_simple_point_clear_finish ec_GF2m_simple_pt_clr_finish
|
||||
#undef ec_GF2m_simple_point_set_to_infinity
|
||||
#define ec_GF2m_simple_point_set_to_infinity ec_GF2m_simple_pt_set_to_inf
|
||||
#undef ec_GF2m_simple_points_make_affine
|
||||
#define ec_GF2m_simple_points_make_affine ec_GF2m_simple_pts_make_affine
|
||||
#undef ec_GF2m_simple_point_set_affine_coordinates
|
||||
#define ec_GF2m_simple_point_set_affine_coordinates \
|
||||
ec_GF2m_smp_pt_set_af_coords
|
||||
#undef ec_GF2m_simple_point_get_affine_coordinates
|
||||
#define ec_GF2m_simple_point_get_affine_coordinates \
|
||||
ec_GF2m_smp_pt_get_af_coords
|
||||
#undef ec_GF2m_simple_set_compressed_coordinates
|
||||
#define ec_GF2m_simple_set_compressed_coordinates \
|
||||
ec_GF2m_smp_set_compr_coords
|
||||
#undef ec_GFp_simple_group_set_curve_GFp
|
||||
#define ec_GFp_simple_group_set_curve_GFp ec_GFp_simple_grp_set_curve_GFp
|
||||
#undef ec_GFp_simple_group_get_curve_GFp
|
||||
#define ec_GFp_simple_group_get_curve_GFp ec_GFp_simple_grp_get_curve_GFp
|
||||
#undef ec_GFp_simple_group_clear_finish
|
||||
#define ec_GFp_simple_group_clear_finish ec_GFp_simple_grp_clear_finish
|
||||
#undef ec_GFp_simple_group_set_generator
|
||||
#define ec_GFp_simple_group_set_generator ec_GFp_simple_grp_set_generator
|
||||
#undef ec_GFp_simple_group_get0_generator
|
||||
#define ec_GFp_simple_group_get0_generator ec_GFp_simple_grp_gt0_generator
|
||||
#undef ec_GFp_simple_group_get_cofactor
|
||||
#define ec_GFp_simple_group_get_cofactor ec_GFp_simple_grp_get_cofactor
|
||||
#undef ec_GFp_simple_point_clear_finish
|
||||
#define ec_GFp_simple_point_clear_finish ec_GFp_simple_pt_clear_finish
|
||||
#undef ec_GFp_simple_point_set_to_infinity
|
||||
#define ec_GFp_simple_point_set_to_infinity ec_GFp_simple_pt_set_to_inf
|
||||
#undef ec_GFp_simple_points_make_affine
|
||||
#define ec_GFp_simple_points_make_affine ec_GFp_simple_pts_make_affine
|
||||
#undef ec_GFp_simple_set_Jprojective_coordinates_GFp
|
||||
#define ec_GFp_simple_set_Jprojective_coordinates_GFp \
|
||||
ec_GFp_smp_set_Jproj_coords_GFp
|
||||
#undef ec_GFp_simple_get_Jprojective_coordinates_GFp
|
||||
#define ec_GFp_simple_get_Jprojective_coordinates_GFp \
|
||||
ec_GFp_smp_get_Jproj_coords_GFp
|
||||
#undef ec_GFp_simple_point_set_affine_coordinates_GFp
|
||||
#define ec_GFp_simple_point_set_affine_coordinates_GFp \
|
||||
ec_GFp_smp_pt_set_af_coords_GFp
|
||||
#undef ec_GFp_simple_point_get_affine_coordinates_GFp
|
||||
#define ec_GFp_simple_point_get_affine_coordinates_GFp \
|
||||
ec_GFp_smp_pt_get_af_coords_GFp
|
||||
#undef ec_GFp_simple_set_compressed_coordinates_GFp
|
||||
#define ec_GFp_simple_set_compressed_coordinates_GFp \
|
||||
ec_GFp_smp_set_compr_coords_GFp
|
||||
#undef ec_GFp_simple_point_set_affine_coordinates
|
||||
#define ec_GFp_simple_point_set_affine_coordinates \
|
||||
ec_GFp_smp_pt_set_af_coords
|
||||
#undef ec_GFp_simple_point_get_affine_coordinates
|
||||
#define ec_GFp_simple_point_get_affine_coordinates \
|
||||
ec_GFp_smp_pt_get_af_coords
|
||||
#undef ec_GFp_simple_set_compressed_coordinates
|
||||
#define ec_GFp_simple_set_compressed_coordinates \
|
||||
ec_GFp_smp_set_compr_coords
|
||||
#undef ec_GFp_simple_group_check_discriminant
|
||||
#define ec_GFp_simple_group_check_discriminant ec_GFp_simple_grp_chk_discrim
|
||||
|
||||
/* Hack som long STORE names */
|
||||
#undef STORE_method_set_initialise_function
|
||||
#define STORE_method_set_initialise_function STORE_meth_set_initialise_fn
|
||||
#undef STORE_method_set_cleanup_function
|
||||
#define STORE_method_set_cleanup_function STORE_meth_set_cleanup_fn
|
||||
#undef STORE_method_set_generate_function
|
||||
#define STORE_method_set_generate_function STORE_meth_set_generate_fn
|
||||
#undef STORE_method_set_modify_function
|
||||
#define STORE_method_set_modify_function STORE_meth_set_modify_fn
|
||||
#undef STORE_method_set_revoke_function
|
||||
#define STORE_method_set_revoke_function STORE_meth_set_revoke_fn
|
||||
#undef STORE_method_set_delete_function
|
||||
#define STORE_method_set_delete_function STORE_meth_set_delete_fn
|
||||
#undef STORE_method_set_list_start_function
|
||||
#define STORE_method_set_list_start_function STORE_meth_set_list_start_fn
|
||||
#undef STORE_method_set_list_next_function
|
||||
#define STORE_method_set_list_next_function STORE_meth_set_list_next_fn
|
||||
#undef STORE_method_set_list_end_function
|
||||
#define STORE_method_set_list_end_function STORE_meth_set_list_end_fn
|
||||
#undef STORE_method_set_update_store_function
|
||||
#define STORE_method_set_update_store_function STORE_meth_set_update_store_fn
|
||||
#undef STORE_method_set_lock_store_function
|
||||
#define STORE_method_set_lock_store_function STORE_meth_set_lock_store_fn
|
||||
#undef STORE_method_set_unlock_store_function
|
||||
#define STORE_method_set_unlock_store_function STORE_meth_set_unlock_store_fn
|
||||
#undef STORE_method_get_initialise_function
|
||||
#define STORE_method_get_initialise_function STORE_meth_get_initialise_fn
|
||||
#undef STORE_method_get_cleanup_function
|
||||
#define STORE_method_get_cleanup_function STORE_meth_get_cleanup_fn
|
||||
#undef STORE_method_get_generate_function
|
||||
#define STORE_method_get_generate_function STORE_meth_get_generate_fn
|
||||
#undef STORE_method_get_modify_function
|
||||
#define STORE_method_get_modify_function STORE_meth_get_modify_fn
|
||||
#undef STORE_method_get_revoke_function
|
||||
#define STORE_method_get_revoke_function STORE_meth_get_revoke_fn
|
||||
#undef STORE_method_get_delete_function
|
||||
#define STORE_method_get_delete_function STORE_meth_get_delete_fn
|
||||
#undef STORE_method_get_list_start_function
|
||||
#define STORE_method_get_list_start_function STORE_meth_get_list_start_fn
|
||||
#undef STORE_method_get_list_next_function
|
||||
#define STORE_method_get_list_next_function STORE_meth_get_list_next_fn
|
||||
#undef STORE_method_get_list_end_function
|
||||
#define STORE_method_get_list_end_function STORE_meth_get_list_end_fn
|
||||
#undef STORE_method_get_update_store_function
|
||||
#define STORE_method_get_update_store_function STORE_meth_get_update_store_fn
|
||||
#undef STORE_method_get_lock_store_function
|
||||
#define STORE_method_get_lock_store_function STORE_meth_get_lock_store_fn
|
||||
#undef STORE_method_get_unlock_store_function
|
||||
#define STORE_method_get_unlock_store_function STORE_meth_get_unlock_store_fn
|
||||
|
||||
/* Hack some long TS names */
|
||||
#undef TS_RESP_CTX_set_status_info_cond
|
||||
#define TS_RESP_CTX_set_status_info_cond TS_RESP_CTX_set_stat_info_cond
|
||||
#undef TS_RESP_CTX_set_clock_precision_digits
|
||||
#define TS_RESP_CTX_set_clock_precision_digits TS_RESP_CTX_set_clk_prec_digits
|
||||
#undef TS_CONF_set_clock_precision_digits
|
||||
#define TS_CONF_set_clock_precision_digits TS_CONF_set_clk_prec_digits
|
||||
|
||||
/* Hack some long CMS names */
|
||||
#undef CMS_RecipientInfo_ktri_get0_algs
|
||||
#define CMS_RecipientInfo_ktri_get0_algs CMS_RecipInfo_ktri_get0_algs
|
||||
#undef CMS_RecipientInfo_ktri_get0_signer_id
|
||||
#define CMS_RecipientInfo_ktri_get0_signer_id CMS_RecipInfo_ktri_get0_sigr_id
|
||||
#undef CMS_OtherRevocationInfoFormat_it
|
||||
#define CMS_OtherRevocationInfoFormat_it CMS_OtherRevocInfoFormat_it
|
||||
#undef CMS_KeyAgreeRecipientIdentifier_it
|
||||
#define CMS_KeyAgreeRecipientIdentifier_it CMS_KeyAgreeRecipIdentifier_it
|
||||
#undef CMS_OriginatorIdentifierOrKey_it
|
||||
#define CMS_OriginatorIdentifierOrKey_it CMS_OriginatorIdOrKey_it
|
||||
#undef cms_SignerIdentifier_get0_signer_id
|
||||
#define cms_SignerIdentifier_get0_signer_id cms_SignerId_get0_signer_id
|
||||
|
||||
/* Hack some long DTLS1 names */
|
||||
#undef dtls1_retransmit_buffered_messages
|
||||
#define dtls1_retransmit_buffered_messages dtls1_retransmit_buffered_msgs
|
||||
|
||||
/* Hack some long SRP names */
|
||||
#undef SRP_generate_server_master_secret
|
||||
#define SRP_generate_server_master_secret SRP_gen_server_master_secret
|
||||
#undef SRP_generate_client_master_secret
|
||||
#define SRP_generate_client_master_secret SRP_gen_client_master_secret
|
||||
|
||||
/* Hack some long UI names */
|
||||
#undef UI_method_get_prompt_constructor
|
||||
#define UI_method_get_prompt_constructor UI_method_get_prompt_constructr
|
||||
#undef UI_method_set_prompt_constructor
|
||||
#define UI_method_set_prompt_constructor UI_method_set_prompt_constructr
|
||||
|
||||
#endif /* defined OPENSSL_SYS_VMS */
|
||||
|
||||
|
||||
/* Case insensitive linking causes problems.... */
|
||||
#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)
|
||||
#undef ERR_load_CRYPTO_strings
|
||||
#define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings
|
||||
#undef OCSP_crlID_new
|
||||
#define OCSP_crlID_new OCSP_crlID2_new
|
||||
|
||||
#undef d2i_ECPARAMETERS
|
||||
#define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS
|
||||
#undef i2d_ECPARAMETERS
|
||||
#define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS
|
||||
#undef d2i_ECPKPARAMETERS
|
||||
#define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS
|
||||
#undef i2d_ECPKPARAMETERS
|
||||
#define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
|
||||
|
||||
/* These functions do not seem to exist! However, I'm paranoid...
|
||||
Original command in x509v3.h:
|
||||
These functions are being redefined in another directory,
|
||||
and clash when the linker is case-insensitive, so let's
|
||||
hide them a little, by giving them an extra 'o' at the
|
||||
beginning of the name... */
|
||||
#undef X509v3_cleanup_extensions
|
||||
#define X509v3_cleanup_extensions oX509v3_cleanup_extensions
|
||||
#undef X509v3_add_extension
|
||||
#define X509v3_add_extension oX509v3_add_extension
|
||||
#undef X509v3_add_netscape_extensions
|
||||
#define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
|
||||
#undef X509v3_add_standard_extensions
|
||||
#define X509v3_add_standard_extensions oX509v3_add_standard_extensions
|
||||
|
||||
/* This one clashes with CMS_data_create */
|
||||
#undef cms_Data_create
|
||||
#define cms_Data_create priv_cms_Data_create
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! defined HEADER_VMS_IDHACKS_H */
|
||||
Binary file not shown.
Binary file not shown.
+28
-31
@@ -54,42 +54,39 @@ static const char rcsid[]="$Id: getopt_long.c,v 1.1 2009/10/16 19:50:28 rodney E
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#include <err.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Windows needs warnx(). We change the definition though:
|
||||
* 1. (another) global is defined, opterrmsg, which holds the error message
|
||||
* 2. errors are always printed out on stderr w/o the program name
|
||||
* Note that opterrmsg always gets set no matter what opterr is set to. The
|
||||
* error message will not be printed if opterr is 0 as usual.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
char opterrmsg[128]; /* last error message is stored here */
|
||||
|
||||
static void warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
_vsnprintf(opterrmsg, 128, fmt, ap);
|
||||
else
|
||||
opterrmsg[0]='\0';
|
||||
va_end(ap);
|
||||
fprintf(stderr, opterrmsg);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
/* Windows needs warnx(). We change the definition though:
|
||||
* 1. (another) global is defined, opterrmsg, which holds the error message
|
||||
* 2. errors are always printed out on stderr w/o the program name
|
||||
* Note that opterrmsg always gets set no matter what opterr is set to. The
|
||||
* error message will not be printed if opterr is 0 as usual.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
char opterrmsg[128]; /* last error message is stored here */
|
||||
|
||||
static void warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
_vsnprintf(opterrmsg, 128, fmt, ap);
|
||||
else
|
||||
opterrmsg[0]='\0';
|
||||
va_end(ap);
|
||||
fprintf(stderr, opterrmsg);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
#endif /*_WIN32*/
|
||||
|
||||
#define REPLACE_GETOPT /* use this getopt as the system getopt(3) */
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
*.h.in~
|
||||
libtool
|
||||
libjansson.a
|
||||
+20
-18
@@ -1,18 +1,20 @@
|
||||
|
||||
noinst_LIBRARIES = libjansson.a
|
||||
|
||||
libjansson_a_SOURCES = \
|
||||
config.h \
|
||||
dump.c \
|
||||
hashtable.c \
|
||||
hashtable.h \
|
||||
jansson.h \
|
||||
jansson_private.h \
|
||||
load.c \
|
||||
strbuffer.c \
|
||||
strbuffer.h \
|
||||
utf.c \
|
||||
utf.h \
|
||||
util.h \
|
||||
value.c
|
||||
|
||||
|
||||
noinst_LIBRARIES = libjansson.a
|
||||
|
||||
libjansson_a_SOURCES = \
|
||||
jansson_private_config.h \
|
||||
dump.c \
|
||||
error.c \
|
||||
hashtable.c hashtable.h \
|
||||
jansson.h \
|
||||
jansson_config.h \
|
||||
jansson_private.h \
|
||||
load.c \
|
||||
memory.c \
|
||||
pack_unpack.c \
|
||||
strbuffer.c strbuffer.h \
|
||||
strconv.c \
|
||||
utf.c utf.h \
|
||||
util.h \
|
||||
value.c
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "jansson"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "petri@digip.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "jansson"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "jansson 1.3"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "jansson"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.3"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.3"
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* #undef inline */
|
||||
#endif
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int32_t */
|
||||
@@ -0,0 +1,98 @@
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([jansson], [2.6], [petri@digip.org])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.10 foreign])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_CONFIG_SRCDIR([value.c])
|
||||
AC_CONFIG_HEADERS([jansson_private_config.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
AM_CONDITIONAL([GCC], [test x$GCC = xyes])
|
||||
|
||||
# Checks for libraries.
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/stat.h sys/time.h sys/types.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_TYPE_INT32_T
|
||||
AC_TYPE_UINT32_T
|
||||
AC_TYPE_LONG_LONG_INT
|
||||
|
||||
AC_C_INLINE
|
||||
case $ac_cv_c_inline in
|
||||
yes) json_inline=inline;;
|
||||
no) json_inline=;;
|
||||
*) json_inline=$ac_cv_c_inline;;
|
||||
esac
|
||||
AC_SUBST([json_inline])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_CHECK_FUNCS([close getpid gettimeofday localeconv open read sched_yield strtoll])
|
||||
|
||||
AC_MSG_CHECKING([for gcc __sync builtins])
|
||||
have_sync_builtins=no
|
||||
AC_TRY_LINK(
|
||||
[], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1);],
|
||||
[have_sync_builtins=yes],
|
||||
)
|
||||
if test "x$have_sync_builtins" = "xyes"; then
|
||||
AC_DEFINE([HAVE_SYNC_BUILTINS], [1],
|
||||
[Define to 1 if gcc's __sync builtins are available])
|
||||
fi
|
||||
AC_MSG_RESULT([$have_sync_builtins])
|
||||
|
||||
AC_MSG_CHECKING([for gcc __atomic builtins])
|
||||
have_atomic_builtins=no
|
||||
AC_TRY_LINK(
|
||||
[], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_ACQ_REL); __atomic_load_n(&v, __ATOMIC_ACQUIRE);],
|
||||
[have_atomic_builtins=yes],
|
||||
)
|
||||
if test "x$have_atomic_builtins" = "xyes"; then
|
||||
AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1],
|
||||
[Define to 1 if gcc's __atomic builtins are available])
|
||||
fi
|
||||
AC_MSG_RESULT([$have_atomic_builtins])
|
||||
|
||||
case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in
|
||||
yesyes) json_have_long_long=1;;
|
||||
*) json_have_long_long=0;;
|
||||
esac
|
||||
AC_SUBST([json_have_long_long])
|
||||
|
||||
case "$ac_cv_header_locale_h$ac_cv_func_localeconv" in
|
||||
yesyes) json_have_localeconv=1;;
|
||||
*) json_have_localeconv=0;;
|
||||
esac
|
||||
AC_SUBST([json_have_localeconv])
|
||||
|
||||
# Features
|
||||
AC_ARG_ENABLE([urandom],
|
||||
[AS_HELP_STRING([--disable-urandom],
|
||||
[Don't use /dev/urandom to seed the hash function])],
|
||||
[use_urandom=$enableval], [use_urandom=yes])
|
||||
|
||||
if test "x$use_urandom" = xyes; then
|
||||
AC_DEFINE([USE_URANDOM], [1],
|
||||
[Define to 1 if /dev/urandom should be used for seeding the hash function])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([windows-cryptoapi],
|
||||
[AS_HELP_STRING([--disable-windows-cryptoapi],
|
||||
[Don't use CryptGenRandom to seed the hash function])],
|
||||
[use_windows_cryptoapi=$enableval], [use_windows_cryptoapi=yes])
|
||||
|
||||
if test "x$use_windows_cryptoapi" = xyes; then
|
||||
AC_DEFINE([USE_WINDOWS_CRYPTOAPI], [1],
|
||||
[Define to 1 if CryptGenRandom should be used for seeding the hash function])
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
+70
-74
@@ -1,17 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <jansson.h>
|
||||
#include "jansson.h"
|
||||
#include "jansson_private.h"
|
||||
#include "strbuffer.h"
|
||||
#include "utf.h"
|
||||
@@ -19,21 +22,17 @@
|
||||
#define MAX_INTEGER_STR_LENGTH 100
|
||||
#define MAX_REAL_STR_LENGTH 100
|
||||
|
||||
typedef int (*dump_func)(const char *buffer, int size, void *data);
|
||||
|
||||
struct string
|
||||
{
|
||||
char *buffer;
|
||||
int length;
|
||||
int size;
|
||||
struct object_key {
|
||||
size_t serial;
|
||||
const char *key;
|
||||
};
|
||||
|
||||
static int dump_to_strbuffer(const char *buffer, int size, void *data)
|
||||
static int dump_to_strbuffer(const char *buffer, size_t size, void *data)
|
||||
{
|
||||
return strbuffer_append_bytes((strbuffer_t *)data, buffer, size);
|
||||
}
|
||||
|
||||
static int dump_to_file(const char *buffer, int size, void *data)
|
||||
static int dump_to_file(const char *buffer, size_t size, void *data)
|
||||
{
|
||||
FILE *dest = (FILE *)data;
|
||||
if(fwrite(buffer, size, 1, dest) != 1)
|
||||
@@ -41,10 +40,10 @@ static int dump_to_file(const char *buffer, int size, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 256 spaces (the maximum indentation size) */
|
||||
static char whitespace[] = " ";
|
||||
/* 32 spaces (the maximum indentation size) */
|
||||
static const char whitespace[] = " ";
|
||||
|
||||
static int dump_indent(unsigned long flags, int depth, int space, dump_func dump, void *data)
|
||||
static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data)
|
||||
{
|
||||
if(JSON_INDENT(flags) > 0)
|
||||
{
|
||||
@@ -66,7 +65,7 @@ static int dump_indent(unsigned long flags, int depth, int space, dump_func dump
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_string(const char *str, int ascii, dump_func dump, void *data)
|
||||
static int dump_string(const char *str, json_dump_callback_t dump, void *data, size_t flags)
|
||||
{
|
||||
const char *pos, *end;
|
||||
int32_t codepoint;
|
||||
@@ -91,8 +90,12 @@ static int dump_string(const char *str, int ascii, dump_func dump, void *data)
|
||||
if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20)
|
||||
break;
|
||||
|
||||
/* slash */
|
||||
if((flags & JSON_ESCAPE_SLASH) && codepoint == '/')
|
||||
break;
|
||||
|
||||
/* non-ASCII */
|
||||
if(ascii && codepoint > 0x7F)
|
||||
if((flags & JSON_ENSURE_ASCII) && codepoint > 0x7F)
|
||||
break;
|
||||
|
||||
pos = end;
|
||||
@@ -106,7 +109,7 @@ static int dump_string(const char *str, int ascii, dump_func dump, void *data)
|
||||
if(end == pos)
|
||||
break;
|
||||
|
||||
/* handle \, ", and control codes */
|
||||
/* handle \, /, ", and control codes */
|
||||
length = 2;
|
||||
switch(codepoint)
|
||||
{
|
||||
@@ -117,6 +120,7 @@ static int dump_string(const char *str, int ascii, dump_func dump, void *data)
|
||||
case '\n': text = "\\n"; break;
|
||||
case '\r': text = "\\r"; break;
|
||||
case '\t': text = "\\t"; break;
|
||||
case '/': text = "\\/"; break;
|
||||
default:
|
||||
{
|
||||
/* codepoint is in BMP */
|
||||
@@ -155,20 +159,23 @@ static int dump_string(const char *str, int ascii, dump_func dump, void *data)
|
||||
|
||||
static int object_key_compare_keys(const void *key1, const void *key2)
|
||||
{
|
||||
return strcmp((*(const object_key_t **)key1)->key,
|
||||
(*(const object_key_t **)key2)->key);
|
||||
return strcmp(((const struct object_key *)key1)->key,
|
||||
((const struct object_key *)key2)->key);
|
||||
}
|
||||
|
||||
static int object_key_compare_serials(const void *key1, const void *key2)
|
||||
{
|
||||
return (*(const object_key_t **)key1)->serial -
|
||||
(*(const object_key_t **)key2)->serial;
|
||||
size_t a = ((const struct object_key *)key1)->serial;
|
||||
size_t b = ((const struct object_key *)key2)->serial;
|
||||
|
||||
return a < b ? -1 : a == b ? 0 : 1;
|
||||
}
|
||||
|
||||
static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
dump_func dump, void *data)
|
||||
static int do_dump(const json_t *json, size_t flags, int depth,
|
||||
json_dump_callback_t dump, void *data)
|
||||
{
|
||||
int ascii = flags & JSON_ENSURE_ASCII ? 1 : 0;
|
||||
if(!json)
|
||||
return -1;
|
||||
|
||||
switch(json_typeof(json)) {
|
||||
case JSON_NULL:
|
||||
@@ -185,8 +192,10 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
char buffer[MAX_INTEGER_STR_LENGTH];
|
||||
int size;
|
||||
|
||||
size = snprintf(buffer, MAX_INTEGER_STR_LENGTH, "%d", json_integer_value(json));
|
||||
if(size >= MAX_INTEGER_STR_LENGTH)
|
||||
size = snprintf(buffer, MAX_INTEGER_STR_LENGTH,
|
||||
"%" JSON_INTEGER_FORMAT,
|
||||
json_integer_value(json));
|
||||
if(size < 0 || size >= MAX_INTEGER_STR_LENGTH)
|
||||
return -1;
|
||||
|
||||
return dump(buffer, size, data);
|
||||
@@ -196,31 +205,17 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
{
|
||||
char buffer[MAX_REAL_STR_LENGTH];
|
||||
int size;
|
||||
double value = json_real_value(json);
|
||||
|
||||
size = snprintf(buffer, MAX_REAL_STR_LENGTH, "%.17g",
|
||||
json_real_value(json));
|
||||
if(size >= MAX_REAL_STR_LENGTH)
|
||||
size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value);
|
||||
if(size < 0)
|
||||
return -1;
|
||||
|
||||
/* Make sure there's a dot or 'e' in the output. Otherwise
|
||||
a real is converted to an integer when decoding */
|
||||
if(strchr(buffer, '.') == NULL &&
|
||||
strchr(buffer, 'e') == NULL)
|
||||
{
|
||||
if(size + 2 >= MAX_REAL_STR_LENGTH) {
|
||||
/* No space to append ".0" */
|
||||
return -1;
|
||||
}
|
||||
buffer[size] = '.';
|
||||
buffer[size + 1] = '0';
|
||||
size += 2;
|
||||
}
|
||||
|
||||
return dump(buffer, size, data);
|
||||
}
|
||||
|
||||
case JSON_STRING:
|
||||
return dump_string(json_string_value(json), ascii, dump, data);
|
||||
return dump_string(json_string_value(json), dump, data, flags);
|
||||
|
||||
case JSON_ARRAY:
|
||||
{
|
||||
@@ -306,20 +301,20 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
|
||||
if(flags & JSON_SORT_KEYS || flags & JSON_PRESERVE_ORDER)
|
||||
{
|
||||
const object_key_t **keys;
|
||||
unsigned int size;
|
||||
unsigned int i;
|
||||
struct object_key *keys;
|
||||
size_t size, i;
|
||||
int (*cmp_func)(const void *, const void *);
|
||||
|
||||
size = json_object_size(json);
|
||||
keys = malloc(size * sizeof(object_key_t *));
|
||||
keys = jsonp_malloc(size * sizeof(struct object_key));
|
||||
if(!keys)
|
||||
goto object_error;
|
||||
|
||||
i = 0;
|
||||
while(iter)
|
||||
{
|
||||
keys[i] = jsonp_object_iter_fullkey(iter);
|
||||
keys[i].serial = hashtable_iter_serial(iter);
|
||||
keys[i].key = json_object_iter_key(iter);
|
||||
iter = json_object_iter_next((json_t *)json, iter);
|
||||
i++;
|
||||
}
|
||||
@@ -330,22 +325,22 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
else
|
||||
cmp_func = object_key_compare_serials;
|
||||
|
||||
qsort((void*)keys, size, sizeof(object_key_t *), cmp_func);
|
||||
qsort(keys, size, sizeof(struct object_key), cmp_func);
|
||||
|
||||
for(i = 0; i < size; i++)
|
||||
{
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
key = keys[i]->key;
|
||||
key = keys[i].key;
|
||||
value = json_object_get(json, key);
|
||||
assert(value);
|
||||
|
||||
dump_string(key, ascii, dump, data);
|
||||
dump_string(key, dump, data, flags);
|
||||
if(dump(separator, separator_length, data) ||
|
||||
do_dump(value, flags, depth + 1, dump, data))
|
||||
{
|
||||
free((void*)keys);
|
||||
jsonp_free(keys);
|
||||
goto object_error;
|
||||
}
|
||||
|
||||
@@ -354,7 +349,7 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
if(dump(",", 1, data) ||
|
||||
dump_indent(flags, depth + 1, 1, dump, data))
|
||||
{
|
||||
free((void*)keys);
|
||||
jsonp_free(keys);
|
||||
goto object_error;
|
||||
}
|
||||
}
|
||||
@@ -362,13 +357,13 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
{
|
||||
if(dump_indent(flags, depth, 0, dump, data))
|
||||
{
|
||||
free((void*)keys);
|
||||
jsonp_free(keys);
|
||||
goto object_error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free((void*)keys);
|
||||
jsonp_free(keys);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -378,7 +373,7 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
{
|
||||
void *next = json_object_iter_next((json_t *)json, iter);
|
||||
|
||||
dump_string(json_object_iter_key(iter), ascii, dump, data);
|
||||
dump_string(json_object_iter_key(iter), dump, data, flags);
|
||||
if(dump(separator, separator_length, data) ||
|
||||
do_dump(json_object_iter_value(iter), flags, depth + 1,
|
||||
dump, data))
|
||||
@@ -414,38 +409,29 @@ static int do_dump(const json_t *json, unsigned long flags, int depth,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *json_dumps(const json_t *json, unsigned long flags)
|
||||
char *json_dumps(const json_t *json, size_t flags)
|
||||
{
|
||||
strbuffer_t strbuff;
|
||||
char *result;
|
||||
|
||||
if(!json_is_array(json) && !json_is_object(json))
|
||||
return NULL;
|
||||
|
||||
if(strbuffer_init(&strbuff))
|
||||
return NULL;
|
||||
|
||||
if(do_dump(json, flags, 0, dump_to_strbuffer, (void *)&strbuff)) {
|
||||
strbuffer_close(&strbuff);
|
||||
return NULL;
|
||||
}
|
||||
if(json_dump_callback(json, dump_to_strbuffer, (void *)&strbuff, flags))
|
||||
result = NULL;
|
||||
else
|
||||
result = jsonp_strdup(strbuffer_value(&strbuff));
|
||||
|
||||
result = strdup(strbuffer_value(&strbuff));
|
||||
strbuffer_close(&strbuff);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int json_dumpf(const json_t *json, FILE *output, unsigned long flags)
|
||||
int json_dumpf(const json_t *json, FILE *output, size_t flags)
|
||||
{
|
||||
if(!json_is_array(json) && !json_is_object(json))
|
||||
return -1;
|
||||
|
||||
return do_dump(json, flags, 0, dump_to_file, (void *)output);
|
||||
return json_dump_callback(json, dump_to_file, (void *)output, flags);
|
||||
}
|
||||
|
||||
int json_dump_file(const json_t *json, const char *path, unsigned long flags)
|
||||
int json_dump_file(const json_t *json, const char *path, size_t flags)
|
||||
{
|
||||
int result;
|
||||
|
||||
@@ -458,3 +444,13 @@ int json_dump_file(const json_t *json, const char *path, unsigned long flags)
|
||||
fclose(output);
|
||||
return result;
|
||||
}
|
||||
|
||||
int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags)
|
||||
{
|
||||
if(!(flags & JSON_ENCODE_ANY)) {
|
||||
if(!json_is_array(json) && !json_is_object(json))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return do_dump(json, flags, 0, callback, data);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <string.h>
|
||||
#include "jansson_private.h"
|
||||
|
||||
void jsonp_error_init(json_error_t *error, const char *source)
|
||||
{
|
||||
if(error)
|
||||
{
|
||||
error->text[0] = '\0';
|
||||
error->line = -1;
|
||||
error->column = -1;
|
||||
error->position = 0;
|
||||
if(source)
|
||||
jsonp_error_set_source(error, source);
|
||||
else
|
||||
error->source[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void jsonp_error_set_source(json_error_t *error, const char *source)
|
||||
{
|
||||
size_t length;
|
||||
|
||||
if(!error || !source)
|
||||
return;
|
||||
|
||||
length = strlen(source);
|
||||
if(length < JSON_ERROR_SOURCE_LENGTH)
|
||||
strcpy(error->source, source);
|
||||
else {
|
||||
size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
|
||||
strcpy(error->source, "...");
|
||||
strcpy(error->source + 3, source + extra);
|
||||
}
|
||||
}
|
||||
|
||||
void jsonp_error_set(json_error_t *error, int line, int column,
|
||||
size_t position, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msg);
|
||||
jsonp_error_vset(error, line, column, position, msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void jsonp_error_vset(json_error_t *error, int line, int column,
|
||||
size_t position, const char *msg, va_list ap)
|
||||
{
|
||||
if(!error)
|
||||
return;
|
||||
|
||||
if(error->text[0] != '\0') {
|
||||
/* error already set */
|
||||
return;
|
||||
}
|
||||
|
||||
error->line = line;
|
||||
error->column = column;
|
||||
error->position = position;
|
||||
|
||||
vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);
|
||||
error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
}
|
||||
+72
-91
@@ -1,35 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <jansson_config.h> /* for JSON_INLINE */
|
||||
#include "jansson_private.h" /* for container_of() */
|
||||
#include "hashtable.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
typedef struct hashtable_list list_t;
|
||||
typedef struct hashtable_pair pair_t;
|
||||
typedef struct hashtable_bucket bucket_t;
|
||||
|
||||
#define container_of(ptr_, type_, member_) \
|
||||
((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
|
||||
|
||||
#define list_to_pair(list_) container_of(list_, pair_t, list)
|
||||
|
||||
static inline void list_init(list_t *list)
|
||||
/* From http://www.cse.yorku.ca/~oz/hash.html */
|
||||
static size_t hash_str(const void *ptr)
|
||||
{
|
||||
const char *str = (const char *)ptr;
|
||||
|
||||
size_t hash = 5381;
|
||||
size_t c;
|
||||
|
||||
while((c = (size_t)*str))
|
||||
{
|
||||
hash = ((hash << 5) + hash) + c;
|
||||
str++;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static JSON_INLINE void list_init(list_t *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
static inline void list_insert(list_t *list, list_t *node)
|
||||
static JSON_INLINE void list_insert(list_t *list, list_t *node)
|
||||
{
|
||||
node->next = list;
|
||||
node->prev = list->prev;
|
||||
@@ -37,13 +48,13 @@ static inline void list_insert(list_t *list, list_t *node)
|
||||
list->prev = node;
|
||||
}
|
||||
|
||||
static inline void list_remove(list_t *list)
|
||||
static JSON_INLINE void list_remove(list_t *list)
|
||||
{
|
||||
list->prev->next = list->next;
|
||||
list->next->prev = list->prev;
|
||||
}
|
||||
|
||||
static inline int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket)
|
||||
static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket)
|
||||
{
|
||||
return bucket->first == &hashtable->list && bucket->first == bucket->last;
|
||||
}
|
||||
@@ -63,22 +74,21 @@ static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket,
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int primes[] = {
|
||||
static const size_t primes[] = {
|
||||
5, 13, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593,
|
||||
49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469,
|
||||
12582917, 25165843, 50331653, 100663319, 201326611, 402653189,
|
||||
805306457, 1610612741
|
||||
};
|
||||
static const unsigned int num_primes = sizeof(primes) / sizeof(unsigned int);
|
||||
|
||||
static inline unsigned int num_buckets(hashtable_t *hashtable)
|
||||
static JSON_INLINE size_t num_buckets(hashtable_t *hashtable)
|
||||
{
|
||||
return primes[hashtable->num_buckets];
|
||||
}
|
||||
|
||||
|
||||
static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
|
||||
const void *key, unsigned int hash)
|
||||
const char *key, size_t hash)
|
||||
{
|
||||
list_t *list;
|
||||
pair_t *pair;
|
||||
@@ -90,7 +100,7 @@ static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
|
||||
while(1)
|
||||
{
|
||||
pair = list_to_pair(list);
|
||||
if(pair->hash == hash && hashtable->cmp_keys(pair->key, key))
|
||||
if(pair->hash == hash && strcmp(pair->key, key) == 0)
|
||||
return pair;
|
||||
|
||||
if(list == bucket->last)
|
||||
@@ -104,11 +114,11 @@ static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
|
||||
|
||||
/* returns 0 on success, -1 if key was not found */
|
||||
static int hashtable_do_del(hashtable_t *hashtable,
|
||||
const void *key, unsigned int hash)
|
||||
const char *key, size_t hash)
|
||||
{
|
||||
pair_t *pair;
|
||||
bucket_t *bucket;
|
||||
unsigned int index;
|
||||
size_t index;
|
||||
|
||||
index = hash % num_buckets(hashtable);
|
||||
bucket = &hashtable->buckets[index];
|
||||
@@ -127,13 +137,9 @@ static int hashtable_do_del(hashtable_t *hashtable,
|
||||
bucket->last = pair->list.prev;
|
||||
|
||||
list_remove(&pair->list);
|
||||
json_decref(pair->value);
|
||||
|
||||
if(hashtable->free_key)
|
||||
hashtable->free_key(pair->key);
|
||||
if(hashtable->free_value)
|
||||
hashtable->free_value(pair->value);
|
||||
|
||||
free(pair);
|
||||
jsonp_free(pair);
|
||||
hashtable->size--;
|
||||
|
||||
return 0;
|
||||
@@ -148,11 +154,8 @@ static void hashtable_do_clear(hashtable_t *hashtable)
|
||||
{
|
||||
next = list->next;
|
||||
pair = list_to_pair(list);
|
||||
if(hashtable->free_key)
|
||||
hashtable->free_key(pair->key);
|
||||
if(hashtable->free_value)
|
||||
hashtable->free_value(pair->value);
|
||||
free(pair);
|
||||
json_decref(pair->value);
|
||||
jsonp_free(pair);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,14 +163,14 @@ static int hashtable_do_rehash(hashtable_t *hashtable)
|
||||
{
|
||||
list_t *list, *next;
|
||||
pair_t *pair;
|
||||
unsigned int i, index, new_size;
|
||||
size_t i, index, new_size;
|
||||
|
||||
free(hashtable->buckets);
|
||||
jsonp_free(hashtable->buckets);
|
||||
|
||||
hashtable->num_buckets++;
|
||||
new_size = num_buckets(hashtable);
|
||||
|
||||
hashtable->buckets = malloc(new_size * sizeof(bucket_t));
|
||||
hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t));
|
||||
if(!hashtable->buckets)
|
||||
return -1;
|
||||
|
||||
@@ -191,47 +194,18 @@ static int hashtable_do_rehash(hashtable_t *hashtable)
|
||||
}
|
||||
|
||||
|
||||
hashtable_t *hashtable_create(key_hash_fn hash_key, key_cmp_fn cmp_keys,
|
||||
free_fn free_key, free_fn free_value)
|
||||
int hashtable_init(hashtable_t *hashtable)
|
||||
{
|
||||
hashtable_t *hashtable = malloc(sizeof(hashtable_t));
|
||||
if(!hashtable)
|
||||
return NULL;
|
||||
|
||||
if(hashtable_init(hashtable, hash_key, cmp_keys, free_key, free_value))
|
||||
{
|
||||
free(hashtable);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
void hashtable_destroy(hashtable_t *hashtable)
|
||||
{
|
||||
hashtable_close(hashtable);
|
||||
free(hashtable);
|
||||
}
|
||||
|
||||
int hashtable_init(hashtable_t *hashtable,
|
||||
key_hash_fn hash_key, key_cmp_fn cmp_keys,
|
||||
free_fn free_key, free_fn free_value)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
hashtable->size = 0;
|
||||
hashtable->num_buckets = 0; /* index to primes[] */
|
||||
hashtable->buckets = malloc(num_buckets(hashtable) * sizeof(bucket_t));
|
||||
hashtable->buckets = jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t));
|
||||
if(!hashtable->buckets)
|
||||
return -1;
|
||||
|
||||
list_init(&hashtable->list);
|
||||
|
||||
hashtable->hash_key = hash_key;
|
||||
hashtable->cmp_keys = cmp_keys;
|
||||
hashtable->free_key = free_key;
|
||||
hashtable->free_value = free_value;
|
||||
|
||||
for(i = 0; i < num_buckets(hashtable); i++)
|
||||
{
|
||||
hashtable->buckets[i].first = hashtable->buckets[i].last =
|
||||
@@ -244,42 +218,45 @@ int hashtable_init(hashtable_t *hashtable,
|
||||
void hashtable_close(hashtable_t *hashtable)
|
||||
{
|
||||
hashtable_do_clear(hashtable);
|
||||
free(hashtable->buckets);
|
||||
jsonp_free(hashtable->buckets);
|
||||
}
|
||||
|
||||
int hashtable_set(hashtable_t *hashtable, void *key, void *value)
|
||||
int hashtable_set(hashtable_t *hashtable,
|
||||
const char *key, size_t serial,
|
||||
json_t *value)
|
||||
{
|
||||
pair_t *pair;
|
||||
bucket_t *bucket;
|
||||
unsigned int hash, index;
|
||||
size_t hash, index;
|
||||
|
||||
/* rehash if the load ratio exceeds 1 */
|
||||
if(hashtable->size >= num_buckets(hashtable))
|
||||
if(hashtable_do_rehash(hashtable))
|
||||
return -1;
|
||||
|
||||
hash = hashtable->hash_key(key);
|
||||
hash = hash_str(key);
|
||||
index = hash % num_buckets(hashtable);
|
||||
bucket = &hashtable->buckets[index];
|
||||
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
||||
|
||||
if(pair)
|
||||
{
|
||||
if(hashtable->free_key)
|
||||
hashtable->free_key(key);
|
||||
if(hashtable->free_value)
|
||||
hashtable->free_value(pair->value);
|
||||
json_decref(pair->value);
|
||||
pair->value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
pair = malloc(sizeof(pair_t));
|
||||
/* offsetof(...) returns the size of pair_t without the last,
|
||||
flexible member. This way, the correct amount is
|
||||
allocated. */
|
||||
pair = jsonp_malloc(offsetof(pair_t, key) + strlen(key) + 1);
|
||||
if(!pair)
|
||||
return -1;
|
||||
|
||||
pair->key = key;
|
||||
pair->value = value;
|
||||
pair->hash = hash;
|
||||
pair->serial = serial;
|
||||
strcpy(pair->key, key);
|
||||
pair->value = value;
|
||||
list_init(&pair->list);
|
||||
|
||||
insert_to_bucket(hashtable, bucket, &pair->list);
|
||||
@@ -289,13 +266,13 @@ int hashtable_set(hashtable_t *hashtable, void *key, void *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *hashtable_get(hashtable_t *hashtable, const void *key)
|
||||
void *hashtable_get(hashtable_t *hashtable, const char *key)
|
||||
{
|
||||
pair_t *pair;
|
||||
unsigned int hash;
|
||||
size_t hash;
|
||||
bucket_t *bucket;
|
||||
|
||||
hash = hashtable->hash_key(key);
|
||||
hash = hash_str(key);
|
||||
bucket = &hashtable->buckets[hash % num_buckets(hashtable)];
|
||||
|
||||
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
||||
@@ -305,15 +282,15 @@ void *hashtable_get(hashtable_t *hashtable, const void *key)
|
||||
return pair->value;
|
||||
}
|
||||
|
||||
int hashtable_del(hashtable_t *hashtable, const void *key)
|
||||
int hashtable_del(hashtable_t *hashtable, const char *key)
|
||||
{
|
||||
unsigned int hash = hashtable->hash_key(key);
|
||||
size_t hash = hash_str(key);
|
||||
return hashtable_do_del(hashtable, key, hash);
|
||||
}
|
||||
|
||||
void hashtable_clear(hashtable_t *hashtable)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
hashtable_do_clear(hashtable);
|
||||
|
||||
@@ -332,13 +309,13 @@ void *hashtable_iter(hashtable_t *hashtable)
|
||||
return hashtable_iter_next(hashtable, &hashtable->list);
|
||||
}
|
||||
|
||||
void *hashtable_iter_at(hashtable_t *hashtable, const void *key)
|
||||
void *hashtable_iter_at(hashtable_t *hashtable, const char *key)
|
||||
{
|
||||
pair_t *pair;
|
||||
unsigned int hash;
|
||||
size_t hash;
|
||||
bucket_t *bucket;
|
||||
|
||||
hash = hashtable->hash_key(key);
|
||||
hash = hash_str(key);
|
||||
bucket = &hashtable->buckets[hash % num_buckets(hashtable)];
|
||||
|
||||
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
||||
@@ -362,18 +339,22 @@ void *hashtable_iter_key(void *iter)
|
||||
return pair->key;
|
||||
}
|
||||
|
||||
size_t hashtable_iter_serial(void *iter)
|
||||
{
|
||||
pair_t *pair = list_to_pair((list_t *)iter);
|
||||
return pair->serial;
|
||||
}
|
||||
|
||||
void *hashtable_iter_value(void *iter)
|
||||
{
|
||||
pair_t *pair = list_to_pair((list_t *)iter);
|
||||
return pair->value;
|
||||
}
|
||||
|
||||
void hashtable_iter_set(hashtable_t *hashtable, void *iter, void *value)
|
||||
void hashtable_iter_set(void *iter, json_t *value)
|
||||
{
|
||||
pair_t *pair = list_to_pair((list_t *)iter);
|
||||
|
||||
if(hashtable->free_value)
|
||||
hashtable->free_value(pair->value);
|
||||
|
||||
json_decref(pair->value);
|
||||
pair->value = value;
|
||||
}
|
||||
+31
-58
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -8,20 +8,20 @@
|
||||
#ifndef HASHTABLE_H
|
||||
#define HASHTABLE_H
|
||||
|
||||
typedef unsigned int (*key_hash_fn)(const void *key);
|
||||
typedef int (*key_cmp_fn)(const void *key1, const void *key2);
|
||||
typedef void (*free_fn)(void *key);
|
||||
|
||||
struct hashtable_list {
|
||||
struct hashtable_list *prev;
|
||||
struct hashtable_list *next;
|
||||
};
|
||||
|
||||
/* "pair" may be a bit confusing a name, but think of it as a
|
||||
key-value pair. In this case, it just encodes some extra data,
|
||||
too */
|
||||
struct hashtable_pair {
|
||||
void *key;
|
||||
void *value;
|
||||
unsigned int hash;
|
||||
size_t hash;
|
||||
struct hashtable_list list;
|
||||
json_t *value;
|
||||
size_t serial;
|
||||
char key[1];
|
||||
};
|
||||
|
||||
struct hashtable_bucket {
|
||||
@@ -30,60 +30,27 @@ struct hashtable_bucket {
|
||||
};
|
||||
|
||||
typedef struct hashtable {
|
||||
unsigned int size;
|
||||
size_t size;
|
||||
struct hashtable_bucket *buckets;
|
||||
unsigned int num_buckets; /* index to primes[] */
|
||||
size_t num_buckets; /* index to primes[] */
|
||||
struct hashtable_list list;
|
||||
|
||||
key_hash_fn hash_key;
|
||||
key_cmp_fn cmp_keys; /* returns non-zero for equal keys */
|
||||
free_fn free_key;
|
||||
free_fn free_value;
|
||||
} hashtable_t;
|
||||
|
||||
/**
|
||||
* hashtable_create - Create a hashtable object
|
||||
*
|
||||
* @hash_key: The key hashing function
|
||||
* @cmp_keys: The key compare function. Returns non-zero for equal and
|
||||
* zero for unequal unequal keys
|
||||
* @free_key: If non-NULL, called for a key that is no longer referenced.
|
||||
* @free_value: If non-NULL, called for a value that is no longer referenced.
|
||||
*
|
||||
* Returns a new hashtable object that should be freed with
|
||||
* hashtable_destroy when it's no longer used, or NULL on failure (out
|
||||
* of memory).
|
||||
*/
|
||||
hashtable_t *hashtable_create(key_hash_fn hash_key, key_cmp_fn cmp_keys,
|
||||
free_fn free_key, free_fn free_value);
|
||||
|
||||
/**
|
||||
* hashtable_destroy - Destroy a hashtable object
|
||||
*
|
||||
* @hashtable: The hashtable
|
||||
*
|
||||
* Destroys a hashtable created with hashtable_create().
|
||||
*/
|
||||
void hashtable_destroy(hashtable_t *hashtable);
|
||||
#define hashtable_key_to_iter(key_) \
|
||||
(&(container_of(key_, struct hashtable_pair, key)->list))
|
||||
|
||||
/**
|
||||
* hashtable_init - Initialize a hashtable object
|
||||
*
|
||||
* @hashtable: The (statically allocated) hashtable object
|
||||
* @hash_key: The key hashing function
|
||||
* @cmp_keys: The key compare function. Returns non-zero for equal and
|
||||
* zero for unequal unequal keys
|
||||
* @free_key: If non-NULL, called for a key that is no longer referenced.
|
||||
* @free_value: If non-NULL, called for a value that is no longer referenced.
|
||||
*
|
||||
* Initializes a statically allocated hashtable object. The object
|
||||
* should be cleared with hashtable_close when it's no longer used.
|
||||
*
|
||||
* Returns 0 on success, -1 on error (out of memory).
|
||||
*/
|
||||
int hashtable_init(hashtable_t *hashtable,
|
||||
key_hash_fn hash_key, key_cmp_fn cmp_keys,
|
||||
free_fn free_key, free_fn free_value);
|
||||
int hashtable_init(hashtable_t *hashtable);
|
||||
|
||||
/**
|
||||
* hashtable_close - Release all resources used by a hashtable object
|
||||
@@ -99,20 +66,19 @@ void hashtable_close(hashtable_t *hashtable);
|
||||
*
|
||||
* @hashtable: The hashtable object
|
||||
* @key: The key
|
||||
* @serial: For addition order of keys
|
||||
* @value: The value
|
||||
*
|
||||
* If a value with the given key already exists, its value is replaced
|
||||
* with the new value.
|
||||
*
|
||||
* Key and value are "stealed" in the sense that hashtable frees them
|
||||
* automatically when they are no longer used. The freeing is
|
||||
* accomplished by calling free_key and free_value functions that were
|
||||
* supplied to hashtable_new. In case one or both of the free
|
||||
* functions is NULL, the corresponding item is not "stealed".
|
||||
* with the new value. Value is "stealed" in the sense that hashtable
|
||||
* doesn't increment its refcount but decreases the refcount when the
|
||||
* value is no longer needed.
|
||||
*
|
||||
* Returns 0 on success, -1 on failure (out of memory).
|
||||
*/
|
||||
int hashtable_set(hashtable_t *hashtable, void *key, void *value);
|
||||
int hashtable_set(hashtable_t *hashtable,
|
||||
const char *key, size_t serial,
|
||||
json_t *value);
|
||||
|
||||
/**
|
||||
* hashtable_get - Get a value associated with a key
|
||||
@@ -122,7 +88,7 @@ int hashtable_set(hashtable_t *hashtable, void *key, void *value);
|
||||
*
|
||||
* Returns value if it is found, or NULL otherwise.
|
||||
*/
|
||||
void *hashtable_get(hashtable_t *hashtable, const void *key);
|
||||
void *hashtable_get(hashtable_t *hashtable, const char *key);
|
||||
|
||||
/**
|
||||
* hashtable_del - Remove a value from the hashtable
|
||||
@@ -132,7 +98,7 @@ void *hashtable_get(hashtable_t *hashtable, const void *key);
|
||||
*
|
||||
* Returns 0 on success, or -1 if the key was not found.
|
||||
*/
|
||||
int hashtable_del(hashtable_t *hashtable, const void *key);
|
||||
int hashtable_del(hashtable_t *hashtable, const char *key);
|
||||
|
||||
/**
|
||||
* hashtable_clear - Clear hashtable
|
||||
@@ -169,7 +135,7 @@ void *hashtable_iter(hashtable_t *hashtable);
|
||||
* Like hashtable_iter() but returns an iterator pointing to a
|
||||
* specific key.
|
||||
*/
|
||||
void *hashtable_iter_at(hashtable_t *hashtable, const void *key);
|
||||
void *hashtable_iter_at(hashtable_t *hashtable, const char *key);
|
||||
|
||||
/**
|
||||
* hashtable_iter_next - Advance an iterator
|
||||
@@ -189,6 +155,13 @@ void *hashtable_iter_next(hashtable_t *hashtable, void *iter);
|
||||
*/
|
||||
void *hashtable_iter_key(void *iter);
|
||||
|
||||
/**
|
||||
* hashtable_iter_serial - Retrieve the serial number pointed to by an iterator
|
||||
*
|
||||
* @iter: The iterator
|
||||
*/
|
||||
size_t hashtable_iter_serial(void *iter);
|
||||
|
||||
/**
|
||||
* hashtable_iter_value - Retrieve the value pointed by an iterator
|
||||
*
|
||||
@@ -202,6 +175,6 @@ void *hashtable_iter_value(void *iter);
|
||||
* @iter: The iterator
|
||||
* @value: The value to set
|
||||
*/
|
||||
void hashtable_iter_set(hashtable_t *hashtable, void *iter, void *value);
|
||||
void hashtable_iter_set(void *iter, json_t *value);
|
||||
|
||||
#endif
|
||||
+130
-49
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -9,23 +9,31 @@
|
||||
#define JANSSON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for size_t */
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define snprintf(...) _snprintf(__VA_ARGS__)
|
||||
#define strdup(x) _strdup(x)
|
||||
#endif
|
||||
#include <jansson_config.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define JSON_INLINE inline
|
||||
#else
|
||||
#define JSON_INLINE inline
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* version */
|
||||
|
||||
#define JANSSON_MAJOR_VERSION 2
|
||||
#define JANSSON_MINOR_VERSION 6
|
||||
#define JANSSON_MICRO_VERSION 0
|
||||
|
||||
/* Micro version is omitted if it's 0 */
|
||||
#define JANSSON_VERSION "2.6"
|
||||
|
||||
/* Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this
|
||||
for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... */
|
||||
#define JANSSON_VERSION_HEX ((JANSSON_MAJOR_VERSION << 16) | \
|
||||
(JANSSON_MINOR_VERSION << 8) | \
|
||||
(JANSSON_MICRO_VERSION << 0))
|
||||
|
||||
|
||||
/* types */
|
||||
|
||||
typedef enum {
|
||||
@@ -39,11 +47,25 @@ typedef enum {
|
||||
JSON_NULL
|
||||
} json_type;
|
||||
|
||||
typedef struct {
|
||||
typedef struct json_t {
|
||||
json_type type;
|
||||
unsigned long refcount;
|
||||
size_t refcount;
|
||||
} json_t;
|
||||
|
||||
#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
|
||||
#if JSON_INTEGER_IS_LONG_LONG
|
||||
#ifdef _WIN32
|
||||
#define JSON_INTEGER_FORMAT "I64d"
|
||||
#else
|
||||
#define JSON_INTEGER_FORMAT "lld"
|
||||
#endif
|
||||
typedef long long json_int_t;
|
||||
#else
|
||||
#define JSON_INTEGER_FORMAT "ld"
|
||||
typedef long json_int_t;
|
||||
#endif /* JSON_INTEGER_IS_LONG_LONG */
|
||||
#endif
|
||||
|
||||
#define json_typeof(json) ((json)->type)
|
||||
#define json_is_object(json) (json && json_typeof(json) == JSON_OBJECT)
|
||||
#define json_is_array(json) (json && json_typeof(json) == JSON_ARRAY)
|
||||
@@ -62,16 +84,17 @@ json_t *json_object(void);
|
||||
json_t *json_array(void);
|
||||
json_t *json_string(const char *value);
|
||||
json_t *json_string_nocheck(const char *value);
|
||||
json_t *json_integer(int value);
|
||||
json_t *json_integer(json_int_t value);
|
||||
json_t *json_real(double value);
|
||||
json_t *json_true(void);
|
||||
json_t *json_false(void);
|
||||
#define json_boolean(val) ((val) ? json_true() : json_false())
|
||||
json_t *json_null(void);
|
||||
|
||||
static JSON_INLINE
|
||||
json_t *json_incref(json_t *json)
|
||||
{
|
||||
if(json && json->refcount != (unsigned int)-1)
|
||||
if(json && json->refcount != (size_t)-1)
|
||||
++json->refcount;
|
||||
return json;
|
||||
}
|
||||
@@ -82,27 +105,54 @@ void json_delete(json_t *json);
|
||||
static JSON_INLINE
|
||||
void json_decref(json_t *json)
|
||||
{
|
||||
if(json && json->refcount != (unsigned int)-1 && --json->refcount == 0)
|
||||
if(json && json->refcount != (size_t)-1 && --json->refcount == 0)
|
||||
json_delete(json);
|
||||
}
|
||||
|
||||
|
||||
/* error reporting */
|
||||
|
||||
#define JSON_ERROR_TEXT_LENGTH 160
|
||||
#define JSON_ERROR_SOURCE_LENGTH 80
|
||||
|
||||
typedef struct {
|
||||
int line;
|
||||
int column;
|
||||
int position;
|
||||
char source[JSON_ERROR_SOURCE_LENGTH];
|
||||
char text[JSON_ERROR_TEXT_LENGTH];
|
||||
} json_error_t;
|
||||
|
||||
|
||||
/* getters, setters, manipulation */
|
||||
|
||||
unsigned int json_object_size(const json_t *object);
|
||||
size_t json_object_size(const json_t *object);
|
||||
json_t *json_object_get(const json_t *object, const char *key);
|
||||
int json_object_set_new(json_t *object, const char *key, json_t *value);
|
||||
int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
|
||||
int json_object_del(json_t *object, const char *key);
|
||||
int json_object_clear(json_t *object);
|
||||
int json_object_update(json_t *object, json_t *other);
|
||||
int json_object_update_existing(json_t *object, json_t *other);
|
||||
int json_object_update_missing(json_t *object, json_t *other);
|
||||
void *json_object_iter(json_t *object);
|
||||
void *json_object_iter_at(json_t *object, const char *key);
|
||||
void *json_object_key_to_iter(const char *key);
|
||||
void *json_object_iter_next(json_t *object, void *iter);
|
||||
const char *json_object_iter_key(void *iter);
|
||||
json_t *json_object_iter_value(void *iter);
|
||||
int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
|
||||
|
||||
#define json_object_foreach(object, key, value) \
|
||||
for(key = json_object_iter_key(json_object_iter(object)); \
|
||||
key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
|
||||
key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
|
||||
|
||||
#define json_array_foreach(array, index, value) \
|
||||
for(index = 0; \
|
||||
index < json_array_size(array) && (value = json_array_get(array, index)); \
|
||||
index++)
|
||||
|
||||
static JSON_INLINE
|
||||
int json_object_set(json_t *object, const char *key, json_t *value)
|
||||
{
|
||||
@@ -115,25 +165,25 @@ int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
|
||||
return json_object_set_new_nocheck(object, key, json_incref(value));
|
||||
}
|
||||
|
||||
static inline
|
||||
static JSON_INLINE
|
||||
int json_object_iter_set(json_t *object, void *iter, json_t *value)
|
||||
{
|
||||
return json_object_iter_set_new(object, iter, json_incref(value));
|
||||
}
|
||||
|
||||
unsigned int json_array_size(const json_t *array);
|
||||
json_t *json_array_get(const json_t *array, unsigned int index);
|
||||
int json_array_set_new(json_t *array, unsigned int index, json_t *value);
|
||||
size_t json_array_size(const json_t *array);
|
||||
json_t *json_array_get(const json_t *array, size_t index);
|
||||
int json_array_set_new(json_t *array, size_t index, json_t *value);
|
||||
int json_array_append_new(json_t *array, json_t *value);
|
||||
int json_array_insert_new(json_t *array, unsigned int index, json_t *value);
|
||||
int json_array_remove(json_t *array, unsigned int index);
|
||||
int json_array_insert_new(json_t *array, size_t index, json_t *value);
|
||||
int json_array_remove(json_t *array, size_t index);
|
||||
int json_array_clear(json_t *array);
|
||||
int json_array_extend(json_t *array, json_t *other);
|
||||
|
||||
static JSON_INLINE
|
||||
int json_array_set(json_t *array, unsigned int index, json_t *value)
|
||||
int json_array_set(json_t *array, size_t ind, json_t *value)
|
||||
{
|
||||
return json_array_set_new(array, index, json_incref(value));
|
||||
return json_array_set_new(array, ind, json_incref(value));
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
@@ -143,22 +193,36 @@ int json_array_append(json_t *array, json_t *value)
|
||||
}
|
||||
|
||||
static JSON_INLINE
|
||||
int json_array_insert(json_t *array, unsigned int index, json_t *value)
|
||||
int json_array_insert(json_t *array, size_t ind, json_t *value)
|
||||
{
|
||||
return json_array_insert_new(array, index, json_incref(value));
|
||||
return json_array_insert_new(array, ind, json_incref(value));
|
||||
}
|
||||
|
||||
const char *json_string_value(const json_t *string);
|
||||
int json_integer_value(const json_t *integer);
|
||||
json_int_t json_integer_value(const json_t *integer);
|
||||
double json_real_value(const json_t *real);
|
||||
double json_number_value(const json_t *json);
|
||||
|
||||
int json_string_set(json_t *string, const char *value);
|
||||
int json_string_set_nocheck(json_t *string, const char *value);
|
||||
int json_integer_set(json_t *integer, int value);
|
||||
int json_integer_set(json_t *integer, json_int_t value);
|
||||
int json_real_set(json_t *real, double value);
|
||||
|
||||
|
||||
/* pack, unpack */
|
||||
|
||||
json_t *json_pack(const char *fmt, ...);
|
||||
json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...);
|
||||
json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap);
|
||||
|
||||
#define JSON_VALIDATE_ONLY 0x1
|
||||
#define JSON_STRICT 0x2
|
||||
|
||||
int json_unpack(json_t *root, const char *fmt, ...);
|
||||
int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...);
|
||||
int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap);
|
||||
|
||||
|
||||
/* equality */
|
||||
|
||||
int json_equal(json_t *value1, json_t *value2);
|
||||
@@ -167,31 +231,48 @@ int json_equal(json_t *value1, json_t *value2);
|
||||
/* copying */
|
||||
|
||||
json_t *json_copy(json_t *value);
|
||||
json_t *json_deep_copy(json_t *value);
|
||||
json_t *json_deep_copy(const json_t *value);
|
||||
|
||||
|
||||
/* loading, printing */
|
||||
/* decoding */
|
||||
|
||||
#define JSON_ERROR_TEXT_LENGTH 160
|
||||
#define JSON_REJECT_DUPLICATES 0x1
|
||||
#define JSON_DISABLE_EOF_CHECK 0x2
|
||||
#define JSON_DECODE_ANY 0x4
|
||||
#define JSON_DECODE_INT_AS_REAL 0x8
|
||||
|
||||
typedef struct {
|
||||
char text[JSON_ERROR_TEXT_LENGTH];
|
||||
int line;
|
||||
} json_error_t;
|
||||
typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
|
||||
|
||||
json_t *json_loads(const char *input, json_error_t *error);
|
||||
json_t *json_loadf(FILE *input, json_error_t *error);
|
||||
json_t *json_load_file(const char *path, json_error_t *error);
|
||||
json_t *json_loads(const char *input, size_t flags, json_error_t *error);
|
||||
json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error);
|
||||
json_t *json_loadf(FILE *input, size_t flags, json_error_t *error);
|
||||
json_t *json_load_file(const char *path, size_t flags, json_error_t *error);
|
||||
json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error);
|
||||
|
||||
#define JSON_INDENT(n) (n & 0xFF)
|
||||
#define JSON_COMPACT 0x100
|
||||
#define JSON_ENSURE_ASCII 0x200
|
||||
#define JSON_SORT_KEYS 0x400
|
||||
#define JSON_PRESERVE_ORDER 0x800
|
||||
|
||||
char *json_dumps(const json_t *json, unsigned long flags);
|
||||
int json_dumpf(const json_t *json, FILE *output, unsigned long flags);
|
||||
int json_dump_file(const json_t *json, const char *path, unsigned long flags);
|
||||
/* encoding */
|
||||
|
||||
#define JSON_INDENT(n) (n & 0x1F)
|
||||
#define JSON_COMPACT 0x20
|
||||
#define JSON_ENSURE_ASCII 0x40
|
||||
#define JSON_SORT_KEYS 0x80
|
||||
#define JSON_PRESERVE_ORDER 0x100
|
||||
#define JSON_ENCODE_ANY 0x200
|
||||
#define JSON_ESCAPE_SLASH 0x400
|
||||
|
||||
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
|
||||
|
||||
char *json_dumps(const json_t *json, size_t flags);
|
||||
int json_dumpf(const json_t *json, FILE *output, size_t flags);
|
||||
int json_dump_file(const json_t *json, const char *path, size_t flags);
|
||||
int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags);
|
||||
|
||||
/* custom memory allocation */
|
||||
|
||||
typedef void *(*json_malloc_t)(size_t);
|
||||
typedef void (*json_free_t)(void *);
|
||||
|
||||
void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*
|
||||
*
|
||||
* This file specifies a part of the site-specific configuration for
|
||||
* Jansson, namely those things that affect the public API in
|
||||
* jansson.h.
|
||||
*
|
||||
* The configure script copies this file to jansson_config.h and
|
||||
* replaces @var@ substitutions by values that fit your system. If you
|
||||
* cannot run the configure script, you can do the value substitution
|
||||
* by hand.
|
||||
*/
|
||||
|
||||
#ifndef JANSSON_CONFIG_H
|
||||
#define JANSSON_CONFIG_H
|
||||
/* If your compiler supports the inline keyword in C, JSON_INLINE is
|
||||
defined to `inline', otherwise empty. In C++, the inline is always
|
||||
supported. */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define JSON_INLINE inline
|
||||
#else
|
||||
#define JSON_INLINE inline
|
||||
#endif
|
||||
|
||||
/* If your compiler supports the `long long` type and the strtoll()
|
||||
library function, JSON_INTEGER_IS_LONG_LONG is defined to 1,
|
||||
otherwise to 0. */
|
||||
#define JSON_INTEGER_IS_LONG_LONG 1
|
||||
|
||||
/* If locale.h and localeconv() are available, define to 1,
|
||||
otherwise to 0. */
|
||||
#define JSON_HAVE_LOCALECONV 1
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2014 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*
|
||||
*
|
||||
* This file specifies a part of the site-specific configuration for
|
||||
* Jansson, namely those things that affect the public API in
|
||||
* jansson.h.
|
||||
*
|
||||
* The configure script copies this file to jansson_config.h and
|
||||
* replaces @var@ substitutions by values that fit your system. If you
|
||||
* cannot run the configure script, you can do the value substitution
|
||||
* by hand.
|
||||
*/
|
||||
|
||||
#ifndef JANSSON_CONFIG_H
|
||||
#define JANSSON_CONFIG_H
|
||||
|
||||
/* If your compiler supports the inline keyword in C, JSON_INLINE is
|
||||
defined to `inline', otherwise empty. In C++, the inline is always
|
||||
supported. */
|
||||
#ifdef __cplusplus
|
||||
#define JSON_INLINE inline
|
||||
#else
|
||||
#define JSON_INLINE @json_inline@
|
||||
#endif
|
||||
|
||||
/* If your compiler supports the `long long` type and the strtoll()
|
||||
library function, JSON_INTEGER_IS_LONG_LONG is defined to 1,
|
||||
otherwise to 0. */
|
||||
#define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@
|
||||
|
||||
/* If locale.h and localeconv() are available, define to 1,
|
||||
otherwise to 0. */
|
||||
#define JSON_HAVE_LOCALECONV @json_have_localeconv@
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -8,23 +8,40 @@
|
||||
#ifndef JANSSON_PRIVATE_H
|
||||
#define JANSSON_PRIVATE_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "jansson.h"
|
||||
#include "hashtable.h"
|
||||
#include "strbuffer.h"
|
||||
|
||||
#define container_of(ptr_, type_, member_) \
|
||||
((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
|
||||
((type_ *)((char *)ptr_ - offsetof(type_, member_)))
|
||||
|
||||
/* On some platforms, max() may already be defined */
|
||||
#ifndef max
|
||||
#define max(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* va_copy is a C99 feature. In C89 implementations, it's sometimes
|
||||
available as __va_copy. If not, memcpy() should do the trick. */
|
||||
#ifndef va_copy
|
||||
#ifdef __va_copy
|
||||
#define va_copy __va_copy
|
||||
#else
|
||||
#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
json_t json;
|
||||
hashtable_t hashtable;
|
||||
unsigned long serial;
|
||||
size_t serial;
|
||||
int visited;
|
||||
} json_object_t;
|
||||
|
||||
typedef struct {
|
||||
json_t json;
|
||||
unsigned int size;
|
||||
unsigned int entries;
|
||||
size_t size;
|
||||
size_t entries;
|
||||
json_t **table;
|
||||
int visited;
|
||||
} json_array_t;
|
||||
@@ -41,7 +58,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
json_t json;
|
||||
int value;
|
||||
json_int_t value;
|
||||
} json_integer_t;
|
||||
|
||||
#define json_to_object(json_) container_of(json_, json_object_t, json)
|
||||
@@ -50,11 +67,27 @@ typedef struct {
|
||||
#define json_to_real(json_) container_of(json_, json_real_t, json)
|
||||
#define json_to_integer(json_) container_of(json_, json_integer_t, json)
|
||||
|
||||
typedef struct {
|
||||
unsigned long serial;
|
||||
char key[];
|
||||
} object_key_t;
|
||||
void jsonp_error_init(json_error_t *error, const char *source);
|
||||
void jsonp_error_set_source(json_error_t *error, const char *source);
|
||||
void jsonp_error_set(json_error_t *error, int line, int column,
|
||||
size_t position, const char *msg, ...);
|
||||
void jsonp_error_vset(json_error_t *error, int line, int column,
|
||||
size_t position, const char *msg, va_list ap);
|
||||
|
||||
const object_key_t *jsonp_object_iter_fullkey(void *iter);
|
||||
/* Locale independent string<->double conversions */
|
||||
int jsonp_strtod(strbuffer_t *strbuffer, double *out);
|
||||
int jsonp_dtostr(char *buffer, size_t size, double value);
|
||||
|
||||
/* Wrappers for custom memory functions */
|
||||
void* jsonp_malloc(size_t size);
|
||||
void jsonp_free(void *ptr);
|
||||
char *jsonp_strndup(const char *str, size_t length);
|
||||
char *jsonp_strdup(const char *str);
|
||||
|
||||
/* Windows compatibility */
|
||||
#ifdef _WIN32
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,140 @@
|
||||
/* jansson_private_config.h. Generated from jansson_private_config.h.in by configure. */
|
||||
/* jansson_private_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if gcc's __atomic builtins are available */
|
||||
/* #undef HAVE_ATOMIC_BUILTINS */
|
||||
|
||||
/* Define to 1 if you have the `close' function. */
|
||||
#define HAVE_CLOSE 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
/* #undef HAVE_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `getpid' function. */
|
||||
#define HAVE_GETPID 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `localeconv' function. */
|
||||
#define HAVE_LOCALECONV 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define to 1 if the system has the type `long long int'. */
|
||||
#define HAVE_LONG_LONG_INT 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `open' function. */
|
||||
#define HAVE_OPEN 1
|
||||
|
||||
/* Define to 1 if you have the `read' function. */
|
||||
#define HAVE_READ 1
|
||||
|
||||
/* Define to 1 if you have the <sched.h> header file. */
|
||||
#define HAVE_SCHED_H 1
|
||||
|
||||
/* Define to 1 if you have the `sched_yield' function. */
|
||||
/* #undef HAVE_SCHED_YIELD */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strtoll' function. */
|
||||
#define HAVE_STRTOLL 1
|
||||
|
||||
/* Define to 1 if gcc's __sync builtins are available */
|
||||
#define HAVE_SYNC_BUILTINS 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "jansson"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "petri@digip.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "jansson"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "jansson 2.6"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "jansson"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.6"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if /dev/urandom should be used for seeding the hash function */
|
||||
#define USE_URANDOM 1
|
||||
|
||||
/* Define to 1 if CryptGenRandom should be used for seeding the hash function
|
||||
*/
|
||||
#define USE_WINDOWS_CRYPTOAPI 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "2.6"
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT32_T */
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
/* #undef inline */
|
||||
#endif
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int32_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint32_t */
|
||||
@@ -0,0 +1,139 @@
|
||||
/* jansson_private_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if gcc's __atomic builtins are available */
|
||||
#undef HAVE_ATOMIC_BUILTINS
|
||||
|
||||
/* Define to 1 if you have the `close' function. */
|
||||
#undef HAVE_CLOSE
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#undef HAVE_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `getpid' function. */
|
||||
#undef HAVE_GETPID
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `localeconv' function. */
|
||||
#undef HAVE_LOCALECONV
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
/* Define to 1 if the system has the type `long long int'. */
|
||||
#undef HAVE_LONG_LONG_INT
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `open' function. */
|
||||
#undef HAVE_OPEN
|
||||
|
||||
/* Define to 1 if you have the `read' function. */
|
||||
#undef HAVE_READ
|
||||
|
||||
/* Define to 1 if you have the <sched.h> header file. */
|
||||
#undef HAVE_SCHED_H
|
||||
|
||||
/* Define to 1 if you have the `sched_yield' function. */
|
||||
#undef HAVE_SCHED_YIELD
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strtoll' function. */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
/* Define to 1 if gcc's __sync builtins are available */
|
||||
#undef HAVE_SYNC_BUILTINS
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if /dev/urandom should be used for seeding the hash function */
|
||||
#undef USE_URANDOM
|
||||
|
||||
/* Define to 1 if CryptGenRandom should be used for seeding the hash function
|
||||
*/
|
||||
#undef USE_WINDOWS_CRYPTOAPI
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
#undef _UINT32_T
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef int32_t
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
#undef uint32_t
|
||||
+393
-195
@@ -1,25 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <jansson.h>
|
||||
#include "jansson.h"
|
||||
#include "jansson_private.h"
|
||||
#include "strbuffer.h"
|
||||
#include "utf.h"
|
||||
|
||||
#define STREAM_STATE_OK 0
|
||||
#define STREAM_STATE_EOF -1
|
||||
#define STREAM_STATE_ERROR -2
|
||||
|
||||
#define TOKEN_INVALID -1
|
||||
#define TOKEN_EOF 0
|
||||
#define TOKEN_STRING 256
|
||||
@@ -29,113 +34,136 @@
|
||||
#define TOKEN_FALSE 260
|
||||
#define TOKEN_NULL 261
|
||||
|
||||
/* read one byte from stream, return EOF on end of file */
|
||||
typedef int (*get_func)(void *data);
|
||||
/* Locale independent versions of isxxx() functions */
|
||||
#define l_isupper(c) ('A' <= (c) && (c) <= 'Z')
|
||||
#define l_islower(c) ('a' <= (c) && (c) <= 'z')
|
||||
#define l_isalpha(c) (l_isupper(c) || l_islower(c))
|
||||
#define l_isdigit(c) ('0' <= (c) && (c) <= '9')
|
||||
#define l_isxdigit(c) \
|
||||
(l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f'))
|
||||
|
||||
/* return non-zero if end of file has been reached */
|
||||
typedef int (*eof_func)(void *data);
|
||||
/* Read one byte from stream, convert to unsigned char, then int, and
|
||||
return. return EOF on end of file. This corresponds to the
|
||||
behaviour of fgetc(). */
|
||||
typedef int (*get_func)(void *data);
|
||||
|
||||
typedef struct {
|
||||
get_func get;
|
||||
eof_func eof;
|
||||
void *data;
|
||||
int stream_pos;
|
||||
char buffer[5];
|
||||
int buffer_pos;
|
||||
size_t buffer_pos;
|
||||
int state;
|
||||
int line;
|
||||
int column, last_column;
|
||||
size_t position;
|
||||
} stream_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
stream_t stream;
|
||||
strbuffer_t saved_text;
|
||||
int token;
|
||||
int line, column;
|
||||
union {
|
||||
char *string;
|
||||
int integer;
|
||||
json_int_t integer;
|
||||
double real;
|
||||
} value;
|
||||
} lex_t;
|
||||
|
||||
#define stream_to_lex(stream) container_of(stream, lex_t, stream)
|
||||
|
||||
|
||||
/*** error reporting ***/
|
||||
|
||||
static void error_init(json_error_t *error)
|
||||
{
|
||||
if(error)
|
||||
{
|
||||
error->text[0] = '\0';
|
||||
error->line = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void error_set(json_error_t *error, const lex_t *lex,
|
||||
const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char text[JSON_ERROR_TEXT_LENGTH];
|
||||
char msg_text[JSON_ERROR_TEXT_LENGTH];
|
||||
char msg_with_context[JSON_ERROR_TEXT_LENGTH];
|
||||
|
||||
if(!error || error->text[0] != '\0') {
|
||||
/* error already set */
|
||||
int line = -1, col = -1;
|
||||
size_t pos = 0;
|
||||
const char *result = msg_text;
|
||||
|
||||
if(!error)
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(ap, msg);
|
||||
vsnprintf(text, JSON_ERROR_TEXT_LENGTH, msg, ap);
|
||||
vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
|
||||
msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
va_end(ap);
|
||||
|
||||
if(lex)
|
||||
{
|
||||
const char *saved_text = strbuffer_value(&lex->saved_text);
|
||||
error->line = lex->line;
|
||||
|
||||
line = lex->stream.line;
|
||||
col = lex->stream.column;
|
||||
pos = lex->stream.position;
|
||||
|
||||
if(saved_text && saved_text[0])
|
||||
{
|
||||
if(lex->saved_text.length <= 20) {
|
||||
snprintf(error->text, JSON_ERROR_TEXT_LENGTH,
|
||||
"%s near '%s'", text, saved_text);
|
||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
|
||||
"%s near '%s'", msg_text, saved_text);
|
||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
result = msg_with_context;
|
||||
}
|
||||
else
|
||||
snprintf(error->text, JSON_ERROR_TEXT_LENGTH, "%s", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(error->text, JSON_ERROR_TEXT_LENGTH,
|
||||
"%s near end of file", text);
|
||||
if(lex->stream.state == STREAM_STATE_ERROR) {
|
||||
/* No context for UTF-8 decoding errors */
|
||||
result = msg_text;
|
||||
}
|
||||
else {
|
||||
snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
|
||||
"%s near end of file", msg_text);
|
||||
msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
||||
result = msg_with_context;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error->line = -1;
|
||||
snprintf(error->text, JSON_ERROR_TEXT_LENGTH, "%s", text);
|
||||
}
|
||||
|
||||
jsonp_error_set(error, line, col, pos, "%s", result);
|
||||
}
|
||||
|
||||
|
||||
/*** lexical analyzer ***/
|
||||
|
||||
static void
|
||||
stream_init(stream_t *stream, get_func get, eof_func eof, void *data)
|
||||
stream_init(stream_t *stream, get_func get, void *data)
|
||||
{
|
||||
stream->get = get;
|
||||
stream->eof = eof;
|
||||
stream->data = data;
|
||||
stream->stream_pos = 0;
|
||||
stream->buffer[0] = '\0';
|
||||
stream->buffer_pos = 0;
|
||||
|
||||
stream->state = STREAM_STATE_OK;
|
||||
stream->line = 1;
|
||||
stream->column = 0;
|
||||
stream->position = 0;
|
||||
}
|
||||
|
||||
static char stream_get(stream_t *stream, json_error_t *error)
|
||||
static int stream_get(stream_t *stream, json_error_t *error)
|
||||
{
|
||||
char c;
|
||||
int c;
|
||||
|
||||
if(stream->state != STREAM_STATE_OK)
|
||||
return stream->state;
|
||||
|
||||
if(!stream->buffer[stream->buffer_pos])
|
||||
{
|
||||
stream->buffer[0] = stream->get(stream->data);
|
||||
c = stream->get(stream->data);
|
||||
if(c == EOF) {
|
||||
stream->state = STREAM_STATE_EOF;
|
||||
return STREAM_STATE_EOF;
|
||||
}
|
||||
|
||||
stream->buffer[0] = c;
|
||||
stream->buffer_pos = 0;
|
||||
|
||||
c = stream->buffer[0];
|
||||
|
||||
if((unsigned char)c >= 0x80 && c != (char)EOF)
|
||||
if(0x80 <= c && c <= 0xFF)
|
||||
{
|
||||
/* multi-byte UTF-8 sequence */
|
||||
int i, count;
|
||||
@@ -152,30 +180,47 @@ static char stream_get(stream_t *stream, json_error_t *error)
|
||||
if(!utf8_check_full(stream->buffer, count, NULL))
|
||||
goto out;
|
||||
|
||||
stream->stream_pos += count;
|
||||
stream->buffer[count] = '\0';
|
||||
}
|
||||
else {
|
||||
else
|
||||
stream->buffer[1] = '\0';
|
||||
stream->stream_pos++;
|
||||
}
|
||||
}
|
||||
|
||||
return stream->buffer[stream->buffer_pos++];
|
||||
c = stream->buffer[stream->buffer_pos++];
|
||||
|
||||
stream->position++;
|
||||
if(c == '\n') {
|
||||
stream->line++;
|
||||
stream->last_column = stream->column;
|
||||
stream->column = 0;
|
||||
}
|
||||
else if(utf8_check_first(c)) {
|
||||
/* track the Unicode character column, so increment only if
|
||||
this is the first character of a UTF-8 sequence */
|
||||
stream->column++;
|
||||
}
|
||||
|
||||
return c;
|
||||
|
||||
out:
|
||||
error_set(error, NULL, "unable to decode byte 0x%x at position %d",
|
||||
(unsigned char)c, stream->stream_pos);
|
||||
|
||||
stream->buffer[0] = EOF;
|
||||
stream->buffer[1] = '\0';
|
||||
stream->buffer_pos = 1;
|
||||
|
||||
return EOF;
|
||||
stream->state = STREAM_STATE_ERROR;
|
||||
error_set(error, stream_to_lex(stream), "unable to decode byte 0x%x", c);
|
||||
return STREAM_STATE_ERROR;
|
||||
}
|
||||
|
||||
static void stream_unget(stream_t *stream, char c)
|
||||
static void stream_unget(stream_t *stream, int c)
|
||||
{
|
||||
if(c == STREAM_STATE_EOF || c == STREAM_STATE_ERROR)
|
||||
return;
|
||||
|
||||
stream->position--;
|
||||
if(c == '\n') {
|
||||
stream->line--;
|
||||
stream->column = stream->last_column;
|
||||
}
|
||||
else if(utf8_check_first(c))
|
||||
stream->column--;
|
||||
|
||||
assert(stream->buffer_pos > 0);
|
||||
stream->buffer_pos--;
|
||||
assert(stream->buffer[stream->buffer_pos] == c);
|
||||
@@ -187,29 +232,41 @@ static int lex_get(lex_t *lex, json_error_t *error)
|
||||
return stream_get(&lex->stream, error);
|
||||
}
|
||||
|
||||
static int lex_eof(lex_t *lex)
|
||||
{
|
||||
return lex->stream.eof(lex->stream.data);
|
||||
}
|
||||
|
||||
static void lex_save(lex_t *lex, char c)
|
||||
static void lex_save(lex_t *lex, int c)
|
||||
{
|
||||
strbuffer_append_byte(&lex->saved_text, c);
|
||||
}
|
||||
|
||||
static int lex_get_save(lex_t *lex, json_error_t *error)
|
||||
{
|
||||
char c = stream_get(&lex->stream, error);
|
||||
lex_save(lex, c);
|
||||
int c = stream_get(&lex->stream, error);
|
||||
if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR)
|
||||
lex_save(lex, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void lex_unget_unsave(lex_t *lex, char c)
|
||||
static void lex_unget(lex_t *lex, int c)
|
||||
{
|
||||
char d;
|
||||
stream_unget(&lex->stream, c);
|
||||
d = strbuffer_pop(&lex->saved_text);
|
||||
assert(c == d);
|
||||
}
|
||||
|
||||
static void lex_unget_unsave(lex_t *lex, int c)
|
||||
{
|
||||
if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR) {
|
||||
/* Since we treat warnings as errors, when assertions are turned
|
||||
* off the "d" variable would be set but never used. Which is
|
||||
* treated as an error by GCC.
|
||||
*/
|
||||
#ifndef NDEBUG
|
||||
char d;
|
||||
#endif
|
||||
stream_unget(&lex->stream, c);
|
||||
#ifndef NDEBUG
|
||||
d =
|
||||
#endif
|
||||
strbuffer_pop(&lex->saved_text);
|
||||
assert(c == d);
|
||||
}
|
||||
}
|
||||
|
||||
static void lex_save_cached(lex_t *lex)
|
||||
@@ -218,6 +275,7 @@ static void lex_save_cached(lex_t *lex)
|
||||
{
|
||||
lex_save(lex, lex->stream.buffer[lex->stream.buffer_pos]);
|
||||
lex->stream.buffer_pos++;
|
||||
lex->stream.position++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,11 +290,11 @@ static int32_t decode_unicode_escape(const char *str)
|
||||
for(i = 1; i <= 4; i++) {
|
||||
char c = str[i];
|
||||
value <<= 4;
|
||||
if(isdigit(c))
|
||||
if(l_isdigit(c))
|
||||
value += c - '0';
|
||||
else if(islower(c))
|
||||
else if(l_islower(c))
|
||||
value += c - 'a' + 10;
|
||||
else if(isupper(c))
|
||||
else if(l_isupper(c))
|
||||
value += c - 'A' + 10;
|
||||
else
|
||||
assert(0);
|
||||
@@ -247,7 +305,7 @@ static int32_t decode_unicode_escape(const char *str)
|
||||
|
||||
static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
{
|
||||
char c;
|
||||
int c;
|
||||
const char *p;
|
||||
char *t;
|
||||
int i;
|
||||
@@ -258,14 +316,15 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
c = lex_get_save(lex, error);
|
||||
|
||||
while(c != '"') {
|
||||
if(c == (char)EOF) {
|
||||
lex_unget_unsave(lex, c);
|
||||
if(lex_eof(lex))
|
||||
error_set(error, lex, "premature end of input");
|
||||
if(c == STREAM_STATE_ERROR)
|
||||
goto out;
|
||||
|
||||
else if(c == STREAM_STATE_EOF) {
|
||||
error_set(error, lex, "premature end of input");
|
||||
goto out;
|
||||
}
|
||||
|
||||
else if((unsigned char)c <= 0x1F) {
|
||||
else if(0 <= c && c <= 0x1F) {
|
||||
/* control character */
|
||||
lex_unget_unsave(lex, c);
|
||||
if(c == '\n')
|
||||
@@ -280,8 +339,7 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
if(c == 'u') {
|
||||
c = lex_get_save(lex, error);
|
||||
for(i = 0; i < 4; i++) {
|
||||
if(!isxdigit(c)) {
|
||||
lex_unget_unsave(lex, c);
|
||||
if(!l_isxdigit(c)) {
|
||||
error_set(error, lex, "invalid escape");
|
||||
goto out;
|
||||
}
|
||||
@@ -292,7 +350,6 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
c == 'f' || c == 'n' || c == 'r' || c == 't')
|
||||
c = lex_get_save(lex, error);
|
||||
else {
|
||||
lex_unget_unsave(lex, c);
|
||||
error_set(error, lex, "invalid escape");
|
||||
goto out;
|
||||
}
|
||||
@@ -308,7 +365,7 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
- two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
|
||||
are converted to 4 bytes
|
||||
*/
|
||||
lex->value.string = malloc(lex->saved_text.length + 1);
|
||||
lex->value.string = jsonp_malloc(lex->saved_text.length + 1);
|
||||
if(!lex->value.string) {
|
||||
/* this is not very nice, since TOKEN_INVALID is returned */
|
||||
goto out;
|
||||
@@ -398,10 +455,22 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
|
||||
return;
|
||||
|
||||
out:
|
||||
free(lex->value.string);
|
||||
jsonp_free(lex->value.string);
|
||||
}
|
||||
|
||||
static int lex_scan_number(lex_t *lex, char c, json_error_t *error)
|
||||
#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
|
||||
#if JSON_INTEGER_IS_LONG_LONG
|
||||
#ifdef _MSC_VER /* Microsoft Visual Studio */
|
||||
#define json_strtoint _strtoi64
|
||||
#else
|
||||
#define json_strtoint strtoll
|
||||
#endif
|
||||
#else
|
||||
#define json_strtoint strtol
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
|
||||
{
|
||||
const char *saved_text;
|
||||
char *end;
|
||||
@@ -414,52 +483,55 @@ static int lex_scan_number(lex_t *lex, char c, json_error_t *error)
|
||||
|
||||
if(c == '0') {
|
||||
c = lex_get_save(lex, error);
|
||||
if(isdigit(c)) {
|
||||
if(l_isdigit(c)) {
|
||||
lex_unget_unsave(lex, c);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else if(isdigit(c)) {
|
||||
else if(l_isdigit(c)) {
|
||||
c = lex_get_save(lex, error);
|
||||
while(isdigit(c))
|
||||
while(l_isdigit(c))
|
||||
c = lex_get_save(lex, error);
|
||||
}
|
||||
else {
|
||||
lex_unget_unsave(lex, c);
|
||||
goto out;
|
||||
lex_unget_unsave(lex, c);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(c != '.' && c != 'E' && c != 'e') {
|
||||
long value;
|
||||
json_int_t value;
|
||||
|
||||
lex_unget_unsave(lex, c);
|
||||
|
||||
saved_text = strbuffer_value(&lex->saved_text);
|
||||
value = strtol(saved_text, &end, 10);
|
||||
|
||||
errno = 0;
|
||||
value = json_strtoint(saved_text, &end, 10);
|
||||
if(errno == ERANGE) {
|
||||
if(value < 0)
|
||||
error_set(error, lex, "too big negative integer");
|
||||
else
|
||||
error_set(error, lex, "too big integer");
|
||||
goto out;
|
||||
}
|
||||
|
||||
assert(end == saved_text + lex->saved_text.length);
|
||||
|
||||
if((value == LONG_MAX && errno == ERANGE) || value > INT_MAX) {
|
||||
error_set(error, lex, "too big integer");
|
||||
goto out;
|
||||
}
|
||||
else if((value == LONG_MIN && errno == ERANGE) || value < INT_MIN) {
|
||||
error_set(error, lex, "too big negative integer");
|
||||
goto out;
|
||||
}
|
||||
|
||||
lex->token = TOKEN_INTEGER;
|
||||
lex->value.integer = (int)value;
|
||||
lex->value.integer = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(c == '.') {
|
||||
c = lex_get(lex, error);
|
||||
if(!isdigit(c))
|
||||
if(!l_isdigit(c)) {
|
||||
lex_unget(lex, c);
|
||||
goto out;
|
||||
}
|
||||
lex_save(lex, c);
|
||||
|
||||
c = lex_get_save(lex, error);
|
||||
while(isdigit(c))
|
||||
while(l_isdigit(c))
|
||||
c = lex_get_save(lex, error);
|
||||
}
|
||||
|
||||
@@ -468,23 +540,19 @@ static int lex_scan_number(lex_t *lex, char c, json_error_t *error)
|
||||
if(c == '+' || c == '-')
|
||||
c = lex_get_save(lex, error);
|
||||
|
||||
if(!isdigit(c)) {
|
||||
if(!l_isdigit(c)) {
|
||||
lex_unget_unsave(lex, c);
|
||||
goto out;
|
||||
}
|
||||
|
||||
c = lex_get_save(lex, error);
|
||||
while(isdigit(c))
|
||||
while(l_isdigit(c))
|
||||
c = lex_get_save(lex, error);
|
||||
}
|
||||
|
||||
lex_unget_unsave(lex, c);
|
||||
|
||||
saved_text = strbuffer_value(&lex->saved_text);
|
||||
value = strtod(saved_text, &end);
|
||||
assert(end == saved_text + lex->saved_text.length);
|
||||
|
||||
if(errno == ERANGE && value != 0) {
|
||||
if(jsonp_strtod(&lex->saved_text, &value)) {
|
||||
error_set(error, lex, "real number overflow");
|
||||
goto out;
|
||||
}
|
||||
@@ -499,29 +567,26 @@ out:
|
||||
|
||||
static int lex_scan(lex_t *lex, json_error_t *error)
|
||||
{
|
||||
char c;
|
||||
int c;
|
||||
|
||||
strbuffer_clear(&lex->saved_text);
|
||||
|
||||
if(lex->token == TOKEN_STRING) {
|
||||
free(lex->value.string);
|
||||
jsonp_free(lex->value.string);
|
||||
lex->value.string = NULL;
|
||||
}
|
||||
|
||||
c = lex_get(lex, error);
|
||||
while(c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
||||
{
|
||||
if(c == '\n')
|
||||
lex->line++;
|
||||
|
||||
c = lex_get(lex, error);
|
||||
|
||||
if(c == STREAM_STATE_EOF) {
|
||||
lex->token = TOKEN_EOF;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(c == (char)EOF) {
|
||||
if(lex_eof(lex))
|
||||
lex->token = TOKEN_EOF;
|
||||
else
|
||||
lex->token = TOKEN_INVALID;
|
||||
if(c == STREAM_STATE_ERROR) {
|
||||
lex->token = TOKEN_INVALID;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -533,17 +598,17 @@ static int lex_scan(lex_t *lex, json_error_t *error)
|
||||
else if(c == '"')
|
||||
lex_scan_string(lex, error);
|
||||
|
||||
else if(isdigit(c) || c == '-') {
|
||||
else if(l_isdigit(c) || c == '-') {
|
||||
if(lex_scan_number(lex, c, error))
|
||||
goto out;
|
||||
}
|
||||
|
||||
else if(isupper(c) || islower(c)) {
|
||||
else if(l_isalpha(c)) {
|
||||
/* eat up the whole identifier for clearer error messages */
|
||||
const char *saved_text;
|
||||
|
||||
c = lex_get_save(lex, error);
|
||||
while(isupper(c) || islower(c))
|
||||
while(l_isalpha(c))
|
||||
c = lex_get_save(lex, error);
|
||||
lex_unget_unsave(lex, c);
|
||||
|
||||
@@ -581,31 +646,29 @@ static char *lex_steal_string(lex_t *lex)
|
||||
return result;
|
||||
}
|
||||
|
||||
static int lex_init(lex_t *lex, get_func get, eof_func eof, void *data)
|
||||
static int lex_init(lex_t *lex, get_func get, void *data)
|
||||
{
|
||||
stream_init(&lex->stream, get, eof, data);
|
||||
stream_init(&lex->stream, get, data);
|
||||
if(strbuffer_init(&lex->saved_text))
|
||||
return -1;
|
||||
|
||||
lex->token = TOKEN_INVALID;
|
||||
lex->line = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lex_close(lex_t *lex)
|
||||
{
|
||||
if(lex->token == TOKEN_STRING)
|
||||
free(lex->value.string);
|
||||
jsonp_free(lex->value.string);
|
||||
strbuffer_close(&lex->saved_text);
|
||||
}
|
||||
|
||||
|
||||
/*** parser ***/
|
||||
|
||||
static json_t *parse_value(lex_t *lex, json_error_t *error);
|
||||
static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error);
|
||||
|
||||
static json_t *parse_object(lex_t *lex, json_error_t *error)
|
||||
static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error)
|
||||
{
|
||||
json_t *object = json_object();
|
||||
if(!object)
|
||||
@@ -628,28 +691,36 @@ static json_t *parse_object(lex_t *lex, json_error_t *error)
|
||||
if(!key)
|
||||
return NULL;
|
||||
|
||||
if(flags & JSON_REJECT_DUPLICATES) {
|
||||
if(json_object_get(object, key)) {
|
||||
jsonp_free(key);
|
||||
error_set(error, lex, "duplicate object key");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
lex_scan(lex, error);
|
||||
if(lex->token != ':') {
|
||||
free(key);
|
||||
jsonp_free(key);
|
||||
error_set(error, lex, "':' expected");
|
||||
goto error;
|
||||
}
|
||||
|
||||
lex_scan(lex, error);
|
||||
value = parse_value(lex, error);
|
||||
value = parse_value(lex, flags, error);
|
||||
if(!value) {
|
||||
free(key);
|
||||
jsonp_free(key);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(json_object_set_nocheck(object, key, value)) {
|
||||
free(key);
|
||||
jsonp_free(key);
|
||||
json_decref(value);
|
||||
goto error;
|
||||
}
|
||||
|
||||
json_decref(value);
|
||||
free(key);
|
||||
jsonp_free(key);
|
||||
|
||||
lex_scan(lex, error);
|
||||
if(lex->token != ',')
|
||||
@@ -670,7 +741,7 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static json_t *parse_array(lex_t *lex, json_error_t *error)
|
||||
static json_t *parse_array(lex_t *lex, size_t flags, json_error_t *error)
|
||||
{
|
||||
json_t *array = json_array();
|
||||
if(!array)
|
||||
@@ -681,7 +752,7 @@ static json_t *parse_array(lex_t *lex, json_error_t *error)
|
||||
return array;
|
||||
|
||||
while(lex->token) {
|
||||
json_t *elem = parse_value(lex, error);
|
||||
json_t *elem = parse_value(lex, flags, error);
|
||||
if(!elem)
|
||||
goto error;
|
||||
|
||||
@@ -710,9 +781,10 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static json_t *parse_value(lex_t *lex, json_error_t *error)
|
||||
static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error)
|
||||
{
|
||||
json_t *json;
|
||||
double value;
|
||||
|
||||
switch(lex->token) {
|
||||
case TOKEN_STRING: {
|
||||
@@ -721,7 +793,15 @@ static json_t *parse_value(lex_t *lex, json_error_t *error)
|
||||
}
|
||||
|
||||
case TOKEN_INTEGER: {
|
||||
json = json_integer(lex->value.integer);
|
||||
if (flags & JSON_DECODE_INT_AS_REAL) {
|
||||
if(jsonp_strtod(&lex->saved_text, &value)) {
|
||||
error_set(error, lex, "real number overflow");
|
||||
return NULL;
|
||||
}
|
||||
json = json_real(value);
|
||||
} else {
|
||||
json = json_integer(lex->value.integer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -743,11 +823,11 @@ static json_t *parse_value(lex_t *lex, json_error_t *error)
|
||||
break;
|
||||
|
||||
case '{':
|
||||
json = parse_object(lex, error);
|
||||
json = parse_object(lex, flags, error);
|
||||
break;
|
||||
|
||||
case '[':
|
||||
json = parse_array(lex, error);
|
||||
json = parse_array(lex, flags, error);
|
||||
break;
|
||||
|
||||
case TOKEN_INVALID:
|
||||
@@ -765,17 +845,37 @@ static json_t *parse_value(lex_t *lex, json_error_t *error)
|
||||
return json;
|
||||
}
|
||||
|
||||
static json_t *parse_json(lex_t *lex, json_error_t *error)
|
||||
static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error)
|
||||
{
|
||||
error_init(error);
|
||||
json_t *result;
|
||||
|
||||
lex_scan(lex, error);
|
||||
if(lex->token != '[' && lex->token != '{') {
|
||||
error_set(error, lex, "'[' or '{' expected");
|
||||
return NULL;
|
||||
if(!(flags & JSON_DECODE_ANY)) {
|
||||
if(lex->token != '[' && lex->token != '{') {
|
||||
error_set(error, lex, "'[' or '{' expected");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return parse_value(lex, error);
|
||||
result = parse_value(lex, flags, error);
|
||||
if(!result)
|
||||
return NULL;
|
||||
|
||||
if(!(flags & JSON_DISABLE_EOF_CHECK)) {
|
||||
lex_scan(lex, error);
|
||||
if(lex->token != TOKEN_EOF) {
|
||||
error_set(error, lex, "end of file expected");
|
||||
json_decref(result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(error) {
|
||||
/* Save the position even though there was no error */
|
||||
error->position = lex->stream.position;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
@@ -794,77 +894,120 @@ static int string_get(void *data)
|
||||
else
|
||||
{
|
||||
stream->pos++;
|
||||
return c;
|
||||
return (unsigned char)c;
|
||||
}
|
||||
}
|
||||
|
||||
static int string_eof(void *data)
|
||||
{
|
||||
string_data_t *stream = (string_data_t *)data;
|
||||
return (stream->data[stream->pos] == '\0');
|
||||
}
|
||||
|
||||
json_t *json_loads(const char *string, json_error_t *error)
|
||||
json_t *json_loads(const char *string, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
json_t *result;
|
||||
string_data_t stream_data;
|
||||
|
||||
string_data_t stream_data = {
|
||||
string,
|
||||
0
|
||||
};
|
||||
jsonp_error_init(error, "<string>");
|
||||
|
||||
if(lex_init(&lex, string_get, string_eof, (void *)&stream_data))
|
||||
if (string == NULL) {
|
||||
error_set(error, NULL, "wrong arguments");
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, error);
|
||||
if(!result)
|
||||
goto out;
|
||||
|
||||
lex_scan(&lex, error);
|
||||
if(lex.token != TOKEN_EOF) {
|
||||
error_set(error, &lex, "end of file expected");
|
||||
json_decref(result);
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
stream_data.data = string;
|
||||
stream_data.pos = 0;
|
||||
|
||||
if(lex_init(&lex, string_get, (void *)&stream_data))
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, flags, error);
|
||||
|
||||
lex_close(&lex);
|
||||
return result;
|
||||
}
|
||||
|
||||
json_t *json_loadf(FILE *input, json_error_t *error)
|
||||
typedef struct
|
||||
{
|
||||
const char *data;
|
||||
size_t len;
|
||||
size_t pos;
|
||||
} buffer_data_t;
|
||||
|
||||
static int buffer_get(void *data)
|
||||
{
|
||||
char c;
|
||||
buffer_data_t *stream = data;
|
||||
if(stream->pos >= stream->len)
|
||||
return EOF;
|
||||
|
||||
c = stream->data[stream->pos];
|
||||
stream->pos++;
|
||||
return (unsigned char)c;
|
||||
}
|
||||
|
||||
json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
json_t *result;
|
||||
buffer_data_t stream_data;
|
||||
|
||||
if(lex_init(&lex, (get_func)fgetc, (eof_func)feof, input))
|
||||
jsonp_error_init(error, "<buffer>");
|
||||
|
||||
if (buffer == NULL) {
|
||||
error_set(error, NULL, "wrong arguments");
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, error);
|
||||
if(!result)
|
||||
goto out;
|
||||
|
||||
lex_scan(&lex, error);
|
||||
if(lex.token != TOKEN_EOF) {
|
||||
error_set(error, &lex, "end of file expected");
|
||||
json_decref(result);
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
stream_data.data = buffer;
|
||||
stream_data.pos = 0;
|
||||
stream_data.len = buflen;
|
||||
|
||||
if(lex_init(&lex, buffer_get, (void *)&stream_data))
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, flags, error);
|
||||
|
||||
lex_close(&lex);
|
||||
return result;
|
||||
}
|
||||
|
||||
json_t *json_load_file(const char *path, json_error_t *error)
|
||||
json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
const char *source;
|
||||
json_t *result;
|
||||
|
||||
if(input == stdin)
|
||||
source = "<stdin>";
|
||||
else
|
||||
source = "<stream>";
|
||||
|
||||
jsonp_error_init(error, source);
|
||||
|
||||
if (input == NULL) {
|
||||
error_set(error, NULL, "wrong arguments");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(lex_init(&lex, (get_func)fgetc, input))
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, flags, error);
|
||||
|
||||
lex_close(&lex);
|
||||
return result;
|
||||
}
|
||||
|
||||
json_t *json_load_file(const char *path, size_t flags, json_error_t *error)
|
||||
{
|
||||
json_t *result;
|
||||
FILE *fp;
|
||||
|
||||
error_init(error);
|
||||
jsonp_error_init(error, path);
|
||||
|
||||
fp = fopen(path, "r");
|
||||
if (path == NULL) {
|
||||
error_set(error, NULL, "wrong arguments");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
if(!fp)
|
||||
{
|
||||
error_set(error, NULL, "unable to open %s: %s",
|
||||
@@ -872,8 +1015,63 @@ json_t *json_load_file(const char *path, json_error_t *error)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = json_loadf(fp, error);
|
||||
result = json_loadf(fp, flags, error);
|
||||
|
||||
fclose(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
#define MAX_BUF_LEN 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char data[MAX_BUF_LEN];
|
||||
size_t len;
|
||||
size_t pos;
|
||||
json_load_callback_t callback;
|
||||
void *arg;
|
||||
} callback_data_t;
|
||||
|
||||
static int callback_get(void *data)
|
||||
{
|
||||
char c;
|
||||
callback_data_t *stream = data;
|
||||
|
||||
if(stream->pos >= stream->len) {
|
||||
stream->pos = 0;
|
||||
stream->len = stream->callback(stream->data, MAX_BUF_LEN, stream->arg);
|
||||
if(stream->len == 0 || stream->len == (size_t)-1)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
c = stream->data[stream->pos];
|
||||
stream->pos++;
|
||||
return (unsigned char)c;
|
||||
}
|
||||
|
||||
json_t *json_load_callback(json_load_callback_t callback, void *arg, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
json_t *result;
|
||||
|
||||
callback_data_t stream_data;
|
||||
|
||||
memset(&stream_data, 0, sizeof(stream_data));
|
||||
stream_data.callback = callback;
|
||||
stream_data.arg = arg;
|
||||
|
||||
jsonp_error_init(error, "<callback>");
|
||||
|
||||
if (callback == NULL) {
|
||||
error_set(error, NULL, "wrong arguments");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(lex_init(&lex, (get_func)callback_get, &stream_data))
|
||||
return NULL;
|
||||
|
||||
result = parse_json(&lex, flags, error);
|
||||
|
||||
lex_close(&lex);
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "jansson.h"
|
||||
#include "jansson_private.h"
|
||||
|
||||
/* memory function pointers */
|
||||
static json_malloc_t do_malloc = malloc;
|
||||
static json_free_t do_free = free;
|
||||
|
||||
void *jsonp_malloc(size_t size)
|
||||
{
|
||||
if(!size)
|
||||
return NULL;
|
||||
|
||||
return (*do_malloc)(size);
|
||||
}
|
||||
|
||||
void jsonp_free(void *ptr)
|
||||
{
|
||||
if(!ptr)
|
||||
return;
|
||||
|
||||
(*do_free)(ptr);
|
||||
}
|
||||
|
||||
char *jsonp_strdup(const char *str)
|
||||
{
|
||||
char *new_str;
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
if(len == (size_t)-1)
|
||||
return NULL;
|
||||
|
||||
new_str = jsonp_malloc(len + 1);
|
||||
if(!new_str)
|
||||
return NULL;
|
||||
|
||||
memcpy(new_str, str, len + 1);
|
||||
return new_str;
|
||||
}
|
||||
|
||||
void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
|
||||
{
|
||||
do_malloc = malloc_fn;
|
||||
do_free = free_fn;
|
||||
}
|
||||
@@ -0,0 +1,762 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2011-2012 Graeme Smecher <graeme.smecher@mail.mcgill.ca>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "jansson.h"
|
||||
#include "jansson_private.h"
|
||||
#include "utf.h"
|
||||
|
||||
typedef struct {
|
||||
int line;
|
||||
int column;
|
||||
size_t pos;
|
||||
char token;
|
||||
} token_t;
|
||||
|
||||
typedef struct {
|
||||
const char *start;
|
||||
const char *fmt;
|
||||
token_t prev_token;
|
||||
token_t token;
|
||||
token_t next_token;
|
||||
json_error_t *error;
|
||||
size_t flags;
|
||||
int line;
|
||||
int column;
|
||||
size_t pos;
|
||||
} scanner_t;
|
||||
|
||||
#define token(scanner) ((scanner)->token.token)
|
||||
|
||||
static const char * const type_names[] = {
|
||||
"object",
|
||||
"array",
|
||||
"string",
|
||||
"integer",
|
||||
"real",
|
||||
"true",
|
||||
"false",
|
||||
"null"
|
||||
};
|
||||
|
||||
#define type_name(x) type_names[json_typeof(x)]
|
||||
|
||||
static const char unpack_value_starters[] = "{[siIbfFOon";
|
||||
|
||||
|
||||
static void scanner_init(scanner_t *s, json_error_t *error,
|
||||
size_t flags, const char *fmt)
|
||||
{
|
||||
s->error = error;
|
||||
s->flags = flags;
|
||||
s->fmt = s->start = fmt;
|
||||
memset(&s->prev_token, 0, sizeof(token_t));
|
||||
memset(&s->token, 0, sizeof(token_t));
|
||||
memset(&s->next_token, 0, sizeof(token_t));
|
||||
s->line = 1;
|
||||
s->column = 0;
|
||||
s->pos = 0;
|
||||
}
|
||||
|
||||
static void next_token(scanner_t *s)
|
||||
{
|
||||
const char *t;
|
||||
s->prev_token = s->token;
|
||||
|
||||
if(s->next_token.line) {
|
||||
s->token = s->next_token;
|
||||
s->next_token.line = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
t = s->fmt;
|
||||
s->column++;
|
||||
s->pos++;
|
||||
|
||||
/* skip space and ignored chars */
|
||||
while(*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') {
|
||||
if(*t == '\n') {
|
||||
s->line++;
|
||||
s->column = 1;
|
||||
}
|
||||
else
|
||||
s->column++;
|
||||
|
||||
s->pos++;
|
||||
t++;
|
||||
}
|
||||
|
||||
s->token.token = *t;
|
||||
s->token.line = s->line;
|
||||
s->token.column = s->column;
|
||||
s->token.pos = s->pos;
|
||||
|
||||
t++;
|
||||
s->fmt = t;
|
||||
}
|
||||
|
||||
static void prev_token(scanner_t *s)
|
||||
{
|
||||
s->next_token = s->token;
|
||||
s->token = s->prev_token;
|
||||
}
|
||||
|
||||
static void set_error(scanner_t *s, const char *source, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
|
||||
jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos,
|
||||
fmt, ap);
|
||||
|
||||
jsonp_error_set_source(s->error, source);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
static json_t *pack(scanner_t *s, va_list *ap);
|
||||
|
||||
|
||||
/* ours will be set to 1 if jsonp_free() must be called for the result
|
||||
afterwards */
|
||||
static char *read_string(scanner_t *s, va_list *ap,
|
||||
const char *purpose, int *ours)
|
||||
{
|
||||
char t;
|
||||
strbuffer_t strbuff;
|
||||
const char *str;
|
||||
size_t length;
|
||||
char *result;
|
||||
|
||||
next_token(s);
|
||||
t = token(s);
|
||||
prev_token(s);
|
||||
|
||||
if(t != '#' && t != '+') {
|
||||
/* Optimize the simple case */
|
||||
str = va_arg(*ap, const char *);
|
||||
|
||||
if(!str) {
|
||||
set_error(s, "<args>", "NULL string argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!utf8_check_string(str, -1)) {
|
||||
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ours = 0;
|
||||
return (char *)str;
|
||||
}
|
||||
|
||||
strbuffer_init(&strbuff);
|
||||
|
||||
while(1) {
|
||||
str = va_arg(*ap, const char *);
|
||||
if(!str) {
|
||||
set_error(s, "<args>", "NULL string argument");
|
||||
strbuffer_close(&strbuff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
next_token(s);
|
||||
|
||||
if(token(s) == '#') {
|
||||
length = va_arg(*ap, int);
|
||||
}
|
||||
else {
|
||||
prev_token(s);
|
||||
length = strlen(str);
|
||||
}
|
||||
|
||||
if(strbuffer_append_bytes(&strbuff, str, length) == -1) {
|
||||
set_error(s, "<internal>", "Out of memory");
|
||||
strbuffer_close(&strbuff);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
next_token(s);
|
||||
if(token(s) != '+') {
|
||||
prev_token(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = strbuffer_steal_value(&strbuff);
|
||||
|
||||
if(!utf8_check_string(result, -1)) {
|
||||
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*ours = 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
static json_t *pack_object(scanner_t *s, va_list *ap)
|
||||
{
|
||||
json_t *object = json_object();
|
||||
next_token(s);
|
||||
|
||||
while(token(s) != '}') {
|
||||
char *key;
|
||||
int ours;
|
||||
json_t *value;
|
||||
|
||||
if(!token(s)) {
|
||||
set_error(s, "<format>", "Unexpected end of format string");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(token(s) != 's') {
|
||||
set_error(s, "<format>", "Expected format 's', got '%c'", token(s));
|
||||
goto error;
|
||||
}
|
||||
|
||||
key = read_string(s, ap, "object key", &ours);
|
||||
if(!key)
|
||||
goto error;
|
||||
|
||||
next_token(s);
|
||||
|
||||
value = pack(s, ap);
|
||||
if(!value)
|
||||
goto error;
|
||||
|
||||
if(json_object_set_new_nocheck(object, key, value)) {
|
||||
if(ours)
|
||||
jsonp_free(key);
|
||||
|
||||
set_error(s, "<internal>", "Unable to add key \"%s\"", key);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(ours)
|
||||
jsonp_free(key);
|
||||
|
||||
next_token(s);
|
||||
}
|
||||
|
||||
return object;
|
||||
|
||||
error:
|
||||
json_decref(object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static json_t *pack_array(scanner_t *s, va_list *ap)
|
||||
{
|
||||
json_t *array = json_array();
|
||||
next_token(s);
|
||||
|
||||
while(token(s) != ']') {
|
||||
json_t *value;
|
||||
|
||||
if(!token(s)) {
|
||||
set_error(s, "<format>", "Unexpected end of format string");
|
||||
goto error;
|
||||
}
|
||||
|
||||
value = pack(s, ap);
|
||||
if(!value)
|
||||
goto error;
|
||||
|
||||
if(json_array_append_new(array, value)) {
|
||||
set_error(s, "<internal>", "Unable to append to array");
|
||||
goto error;
|
||||
}
|
||||
|
||||
next_token(s);
|
||||
}
|
||||
return array;
|
||||
|
||||
error:
|
||||
json_decref(array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static json_t *pack(scanner_t *s, va_list *ap)
|
||||
{
|
||||
switch(token(s)) {
|
||||
case '{':
|
||||
return pack_object(s, ap);
|
||||
|
||||
case '[':
|
||||
return pack_array(s, ap);
|
||||
|
||||
case 's': { /* string */
|
||||
char *str;
|
||||
int ours;
|
||||
json_t *result;
|
||||
|
||||
str = read_string(s, ap, "string", &ours);
|
||||
if(!str)
|
||||
return NULL;
|
||||
|
||||
result = json_string_nocheck(str);
|
||||
if(ours)
|
||||
jsonp_free(str);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
case 'n': /* null */
|
||||
return json_null();
|
||||
|
||||
case 'b': /* boolean */
|
||||
return va_arg(*ap, int) ? json_true() : json_false();
|
||||
|
||||
case 'i': /* integer from int */
|
||||
return json_integer(va_arg(*ap, int));
|
||||
|
||||
case 'I': /* integer from json_int_t */
|
||||
return json_integer(va_arg(*ap, json_int_t));
|
||||
|
||||
case 'f': /* real */
|
||||
return json_real(va_arg(*ap, double));
|
||||
|
||||
case 'O': /* a json_t object; increments refcount */
|
||||
return json_incref(va_arg(*ap, json_t *));
|
||||
|
||||
case 'o': /* a json_t object; doesn't increment refcount */
|
||||
return va_arg(*ap, json_t *);
|
||||
|
||||
default:
|
||||
set_error(s, "<format>", "Unexpected format character '%c'",
|
||||
token(s));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int unpack(scanner_t *s, json_t *root, va_list *ap);
|
||||
|
||||
static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
|
||||
{
|
||||
int ret = -1;
|
||||
int strict = 0;
|
||||
|
||||
/* Use a set (emulated by a hashtable) to check that all object
|
||||
keys are accessed. Checking that the correct number of keys
|
||||
were accessed is not enough, as the same key can be unpacked
|
||||
multiple times.
|
||||
*/
|
||||
hashtable_t key_set;
|
||||
|
||||
if(hashtable_init(&key_set)) {
|
||||
set_error(s, "<internal>", "Out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(root && !json_is_object(root)) {
|
||||
set_error(s, "<validation>", "Expected object, got %s",
|
||||
type_name(root));
|
||||
goto out;
|
||||
}
|
||||
next_token(s);
|
||||
|
||||
while(token(s) != '}') {
|
||||
const char *key;
|
||||
json_t *value;
|
||||
int opt = 0;
|
||||
|
||||
if(strict != 0) {
|
||||
set_error(s, "<format>", "Expected '}' after '%c', got '%c'",
|
||||
(strict == 1 ? '!' : '*'), token(s));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(!token(s)) {
|
||||
set_error(s, "<format>", "Unexpected end of format string");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(token(s) == '!' || token(s) == '*') {
|
||||
strict = (token(s) == '!' ? 1 : -1);
|
||||
next_token(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(token(s) != 's') {
|
||||
set_error(s, "<format>", "Expected format 's', got '%c'", token(s));
|
||||
goto out;
|
||||
}
|
||||
|
||||
key = va_arg(*ap, const char *);
|
||||
if(!key) {
|
||||
set_error(s, "<args>", "NULL object key");
|
||||
goto out;
|
||||
}
|
||||
|
||||
next_token(s);
|
||||
|
||||
if(token(s) == '?') {
|
||||
opt = 1;
|
||||
next_token(s);
|
||||
}
|
||||
|
||||
if(!root) {
|
||||
/* skipping */
|
||||
value = NULL;
|
||||
}
|
||||
else {
|
||||
value = json_object_get(root, key);
|
||||
if(!value && !opt) {
|
||||
set_error(s, "<validation>", "Object item not found: %s", key);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if(unpack(s, value, ap))
|
||||
goto out;
|
||||
|
||||
hashtable_set(&key_set, key, 0, json_null());
|
||||
next_token(s);
|
||||
}
|
||||
|
||||
if(strict == 0 && (s->flags & JSON_STRICT))
|
||||
strict = 1;
|
||||
|
||||
if(root && strict == 1 && key_set.size != json_object_size(root)) {
|
||||
long diff = (long)json_object_size(root) - (long)key_set.size;
|
||||
set_error(s, "<validation>", "%li object item(s) left unpacked", diff);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
hashtable_close(&key_set);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int unpack_array(scanner_t *s, json_t *root, va_list *ap)
|
||||
{
|
||||
size_t i = 0;
|
||||
int strict = 0;
|
||||
|
||||
if(root && !json_is_array(root)) {
|
||||
set_error(s, "<validation>", "Expected array, got %s", type_name(root));
|
||||
return -1;
|
||||
}
|
||||
next_token(s);
|
||||
|
||||
while(token(s) != ']') {
|
||||
json_t *value;
|
||||
|
||||
if(strict != 0) {
|
||||
set_error(s, "<format>", "Expected ']' after '%c', got '%c'",
|
||||
(strict == 1 ? '!' : '*'),
|
||||
token(s));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!token(s)) {
|
||||
set_error(s, "<format>", "Unexpected end of format string");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(token(s) == '!' || token(s) == '*') {
|
||||
strict = (token(s) == '!' ? 1 : -1);
|
||||
next_token(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!strchr(unpack_value_starters, token(s))) {
|
||||
set_error(s, "<format>", "Unexpected format character '%c'",
|
||||
token(s));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!root) {
|
||||
/* skipping */
|
||||
value = NULL;
|
||||
}
|
||||
else {
|
||||
value = json_array_get(root, i);
|
||||
if(!value) {
|
||||
set_error(s, "<validation>", "Array index %lu out of range",
|
||||
(unsigned long)i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(unpack(s, value, ap))
|
||||
return -1;
|
||||
|
||||
next_token(s);
|
||||
i++;
|
||||
}
|
||||
|
||||
if(strict == 0 && (s->flags & JSON_STRICT))
|
||||
strict = 1;
|
||||
|
||||
if(root && strict == 1 && i != json_array_size(root)) {
|
||||
long diff = (long)json_array_size(root) - (long)i;
|
||||
set_error(s, "<validation>", "%li array item(s) left unpacked", diff);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int unpack(scanner_t *s, json_t *root, va_list *ap)
|
||||
{
|
||||
switch(token(s))
|
||||
{
|
||||
case '{':
|
||||
return unpack_object(s, root, ap);
|
||||
|
||||
case '[':
|
||||
return unpack_array(s, root, ap);
|
||||
|
||||
case 's':
|
||||
if(root && !json_is_string(root)) {
|
||||
set_error(s, "<validation>", "Expected string, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
const char **target;
|
||||
|
||||
target = va_arg(*ap, const char **);
|
||||
if(!target) {
|
||||
set_error(s, "<args>", "NULL string argument");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(root)
|
||||
*target = json_string_value(root);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case 'i':
|
||||
if(root && !json_is_integer(root)) {
|
||||
set_error(s, "<validation>", "Expected integer, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
int *target = va_arg(*ap, int*);
|
||||
if(root)
|
||||
*target = (int)json_integer_value(root);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'I':
|
||||
if(root && !json_is_integer(root)) {
|
||||
set_error(s, "<validation>", "Expected integer, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
json_int_t *target = va_arg(*ap, json_int_t*);
|
||||
if(root)
|
||||
*target = json_integer_value(root);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'b':
|
||||
if(root && !json_is_boolean(root)) {
|
||||
set_error(s, "<validation>", "Expected true or false, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
int *target = va_arg(*ap, int*);
|
||||
if(root)
|
||||
*target = json_is_true(root);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'f':
|
||||
if(root && !json_is_real(root)) {
|
||||
set_error(s, "<validation>", "Expected real, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
double *target = va_arg(*ap, double*);
|
||||
if(root)
|
||||
*target = json_real_value(root);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'F':
|
||||
if(root && !json_is_number(root)) {
|
||||
set_error(s, "<validation>", "Expected real or integer, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
double *target = va_arg(*ap, double*);
|
||||
if(root)
|
||||
*target = json_number_value(root);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'O':
|
||||
if(root && !(s->flags & JSON_VALIDATE_ONLY))
|
||||
json_incref(root);
|
||||
/* Fall through */
|
||||
|
||||
case 'o':
|
||||
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
||||
json_t **target = va_arg(*ap, json_t**);
|
||||
if(root)
|
||||
*target = root;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
case 'n':
|
||||
/* Never assign, just validate */
|
||||
if(root && !json_is_null(root)) {
|
||||
set_error(s, "<validation>", "Expected null, got %s",
|
||||
type_name(root));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
set_error(s, "<format>", "Unexpected format character '%c'",
|
||||
token(s));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
json_t *json_vpack_ex(json_error_t *error, size_t flags,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
scanner_t s;
|
||||
va_list ap_copy;
|
||||
json_t *value;
|
||||
|
||||
if(!fmt || !*fmt) {
|
||||
jsonp_error_init(error, "<format>");
|
||||
jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
|
||||
return NULL;
|
||||
}
|
||||
jsonp_error_init(error, NULL);
|
||||
|
||||
scanner_init(&s, error, flags, fmt);
|
||||
next_token(&s);
|
||||
|
||||
va_copy(ap_copy, ap);
|
||||
value = pack(&s, &ap_copy);
|
||||
va_end(ap_copy);
|
||||
|
||||
if(!value)
|
||||
return NULL;
|
||||
|
||||
next_token(&s);
|
||||
if(token(&s)) {
|
||||
json_decref(value);
|
||||
set_error(&s, "<format>", "Garbage after format string");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
|
||||
{
|
||||
json_t *value;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
value = json_vpack_ex(error, flags, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
json_t *json_pack(const char *fmt, ...)
|
||||
{
|
||||
json_t *value;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
value = json_vpack_ex(NULL, 0, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
scanner_t s;
|
||||
va_list ap_copy;
|
||||
|
||||
if(!root) {
|
||||
jsonp_error_init(error, "<root>");
|
||||
jsonp_error_set(error, -1, -1, 0, "NULL root value");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!fmt || !*fmt) {
|
||||
jsonp_error_init(error, "<format>");
|
||||
jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
|
||||
return -1;
|
||||
}
|
||||
jsonp_error_init(error, NULL);
|
||||
|
||||
scanner_init(&s, error, flags, fmt);
|
||||
next_token(&s);
|
||||
|
||||
va_copy(ap_copy, ap);
|
||||
if(unpack(&s, root, &ap_copy)) {
|
||||
va_end(ap_copy);
|
||||
return -1;
|
||||
}
|
||||
va_end(ap_copy);
|
||||
|
||||
next_token(&s);
|
||||
if(token(&s)) {
|
||||
set_error(&s, "<format>", "Garbage after format string");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = json_vunpack_ex(root, error, flags, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int json_unpack(json_t *root, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = json_vunpack_ex(root, NULL, 0, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
+32
-11
@@ -1,25 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jansson_private.h"
|
||||
#include "strbuffer.h"
|
||||
#include "util.h"
|
||||
|
||||
#define STRBUFFER_MIN_SIZE 16
|
||||
#define STRBUFFER_FACTOR 2
|
||||
#define STRBUFFER_SIZE_MAX ((size_t)-1)
|
||||
|
||||
int strbuffer_init(strbuffer_t *strbuff)
|
||||
{
|
||||
strbuff->size = STRBUFFER_MIN_SIZE;
|
||||
strbuff->length = 0;
|
||||
|
||||
strbuff->value = malloc(strbuff->size);
|
||||
strbuff->value = jsonp_malloc(strbuff->size);
|
||||
if(!strbuff->value)
|
||||
return -1;
|
||||
|
||||
@@ -30,7 +34,9 @@ int strbuffer_init(strbuffer_t *strbuff)
|
||||
|
||||
void strbuffer_close(strbuffer_t *strbuff)
|
||||
{
|
||||
free(strbuff->value);
|
||||
if(strbuff->value)
|
||||
jsonp_free(strbuff->value);
|
||||
|
||||
strbuff->size = 0;
|
||||
strbuff->length = 0;
|
||||
strbuff->value = NULL;
|
||||
@@ -50,7 +56,7 @@ const char *strbuffer_value(const strbuffer_t *strbuff)
|
||||
char *strbuffer_steal_value(strbuffer_t *strbuff)
|
||||
{
|
||||
char *result = strbuff->value;
|
||||
strbuffer_init(strbuff);
|
||||
strbuff->value = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -64,16 +70,31 @@ int strbuffer_append_byte(strbuffer_t *strbuff, char byte)
|
||||
return strbuffer_append_bytes(strbuff, &byte, 1);
|
||||
}
|
||||
|
||||
int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, int size)
|
||||
int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size)
|
||||
{
|
||||
if(strbuff->length + size >= strbuff->size)
|
||||
if(size >= strbuff->size - strbuff->length)
|
||||
{
|
||||
strbuff->size = max(strbuff->size * STRBUFFER_FACTOR,
|
||||
strbuff->length + size + 1);
|
||||
size_t new_size;
|
||||
char *new_value;
|
||||
|
||||
strbuff->value = realloc(strbuff->value, strbuff->size);
|
||||
if(!strbuff->value)
|
||||
/* avoid integer overflow */
|
||||
if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR
|
||||
|| size > STRBUFFER_SIZE_MAX - 1
|
||||
|| strbuff->length > STRBUFFER_SIZE_MAX - 1 - size)
|
||||
return -1;
|
||||
|
||||
new_size = max(strbuff->size * STRBUFFER_FACTOR,
|
||||
strbuff->length + size + 1);
|
||||
|
||||
new_value = jsonp_malloc(new_size);
|
||||
if(!new_value)
|
||||
return -1;
|
||||
|
||||
memcpy(new_value, strbuff->value, strbuff->length);
|
||||
|
||||
jsonp_free(strbuff->value);
|
||||
strbuff->value = new_value;
|
||||
strbuff->size = new_size;
|
||||
}
|
||||
|
||||
memcpy(strbuff->value + strbuff->length, data, size);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
typedef struct {
|
||||
char *value;
|
||||
int length; /* bytes used */
|
||||
int size; /* bytes allocated */
|
||||
size_t length; /* bytes used */
|
||||
size_t size; /* bytes allocated */
|
||||
} strbuffer_t;
|
||||
|
||||
int strbuffer_init(strbuffer_t *strbuff);
|
||||
@@ -20,11 +20,13 @@ void strbuffer_close(strbuffer_t *strbuff);
|
||||
void strbuffer_clear(strbuffer_t *strbuff);
|
||||
|
||||
const char *strbuffer_value(const strbuffer_t *strbuff);
|
||||
|
||||
/* Steal the value and close the strbuffer */
|
||||
char *strbuffer_steal_value(strbuffer_t *strbuff);
|
||||
|
||||
int strbuffer_append(strbuffer_t *strbuff, const char *string);
|
||||
int strbuffer_append_byte(strbuffer_t *strbuff, char byte);
|
||||
int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, int size);
|
||||
int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size);
|
||||
|
||||
char strbuffer_pop(strbuffer_t *strbuff);
|
||||
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "jansson_private.h"
|
||||
#include "strbuffer.h"
|
||||
|
||||
/* need jansson_private_config.h to get the correct snprintf */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "jansson_private_config.h"
|
||||
#endif
|
||||
|
||||
#if JSON_HAVE_LOCALECONV
|
||||
#include <locale.h>
|
||||
|
||||
/*
|
||||
- This code assumes that the decimal separator is exactly one
|
||||
character.
|
||||
|
||||
- If setlocale() is called by another thread between the call to
|
||||
localeconv() and the call to sprintf() or strtod(), the result may
|
||||
be wrong. setlocale() is not thread-safe and should not be used
|
||||
this way. Multi-threaded programs should use uselocale() instead.
|
||||
*/
|
||||
|
||||
static void to_locale(strbuffer_t *strbuffer)
|
||||
{
|
||||
const char *point;
|
||||
char *pos;
|
||||
|
||||
point = localeconv()->decimal_point;
|
||||
if(*point == '.') {
|
||||
/* No conversion needed */
|
||||
return;
|
||||
}
|
||||
|
||||
pos = strchr(strbuffer->value, '.');
|
||||
if(pos)
|
||||
*pos = *point;
|
||||
}
|
||||
|
||||
static void from_locale(char *buffer)
|
||||
{
|
||||
const char *point;
|
||||
char *pos;
|
||||
|
||||
point = localeconv()->decimal_point;
|
||||
if(*point == '.') {
|
||||
/* No conversion needed */
|
||||
return;
|
||||
}
|
||||
|
||||
pos = strchr(buffer, *point);
|
||||
if(pos)
|
||||
*pos = '.';
|
||||
}
|
||||
#endif
|
||||
|
||||
int jsonp_strtod(strbuffer_t *strbuffer, double *out)
|
||||
{
|
||||
double value;
|
||||
char *end;
|
||||
|
||||
#if JSON_HAVE_LOCALECONV
|
||||
to_locale(strbuffer);
|
||||
#endif
|
||||
|
||||
errno = 0;
|
||||
value = strtod(strbuffer->value, &end);
|
||||
assert(end == strbuffer->value + strbuffer->length);
|
||||
|
||||
if(errno == ERANGE && value != 0) {
|
||||
/* Overflow */
|
||||
return -1;
|
||||
}
|
||||
|
||||
*out = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int jsonp_dtostr(char *buffer, size_t size, double value)
|
||||
{
|
||||
int ret;
|
||||
char *start, *end;
|
||||
size_t length;
|
||||
|
||||
ret = snprintf(buffer, size, "%.17g", value);
|
||||
if(ret < 0)
|
||||
return -1;
|
||||
|
||||
length = (size_t)ret;
|
||||
if(length >= size)
|
||||
return -1;
|
||||
|
||||
#if JSON_HAVE_LOCALECONV
|
||||
from_locale(buffer);
|
||||
#endif
|
||||
|
||||
/* Make sure there's a dot or 'e' in the output. Otherwise
|
||||
a real is converted to an integer when decoding */
|
||||
if(strchr(buffer, '.') == NULL &&
|
||||
strchr(buffer, 'e') == NULL)
|
||||
{
|
||||
if(length + 3 >= size) {
|
||||
/* No space to append ".0" */
|
||||
return -1;
|
||||
}
|
||||
buffer[length] = '.';
|
||||
buffer[length + 1] = '0';
|
||||
buffer[length + 2] = '\0';
|
||||
length += 2;
|
||||
}
|
||||
|
||||
/* Remove leading '+' from positive exponent. Also remove leading
|
||||
zeros from exponents (added by some printf() implementations) */
|
||||
start = strchr(buffer, 'e');
|
||||
if(start) {
|
||||
start++;
|
||||
end = start + 1;
|
||||
|
||||
if(*start == '-')
|
||||
start++;
|
||||
|
||||
while(*end == '0')
|
||||
end++;
|
||||
|
||||
if(end != start) {
|
||||
memmove(start, end, length - (size_t)(end - buffer));
|
||||
length -= (size_t)(end - start);
|
||||
}
|
||||
}
|
||||
|
||||
return (int)length;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
|
||||
+14
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
@@ -8,14 +8,25 @@
|
||||
#ifndef UTF_H
|
||||
#define UTF_H
|
||||
|
||||
#include <config.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "jansson_private_config.h"
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
/* inttypes.h includes stdint.h in a standard environment, so there's
|
||||
no need to include stdint.h separately. If inttypes.h doesn't define
|
||||
int32_t, it's defined in config.h. */
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
#endif /* HAVE_INTTYPES_H */
|
||||
|
||||
#else /* !HAVE_CONFIG_H */
|
||||
#ifdef _WIN32
|
||||
typedef int int32_t;
|
||||
#else /* !_WIN32 */
|
||||
/* Assume a standard environment */
|
||||
#include <inttypes.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
int utf8_encode(int codepoint, char *buffer, int *size);
|
||||
|
||||
|
||||
+151
-177
@@ -1,25 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
||||
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <jansson.h>
|
||||
#include "jansson.h"
|
||||
#include "hashtable.h"
|
||||
#include "jansson_private.h"
|
||||
#include "utf.h"
|
||||
#include "util.h"
|
||||
|
||||
/* Work around nonstandard isnan() and isinf() implementations */
|
||||
#ifndef isnan
|
||||
static JSON_INLINE int isnan(double x) { return x != x; }
|
||||
#endif
|
||||
#ifndef isinf
|
||||
static JSON_INLINE int isinf(double x) { return !isnan(x) && isnan(x - x); }
|
||||
#endif
|
||||
|
||||
static inline void json_init(json_t *json, json_type type)
|
||||
static JSON_INLINE void json_init(json_t *json, json_type type)
|
||||
{
|
||||
json->type = type;
|
||||
json->refcount = 1;
|
||||
@@ -28,50 +36,16 @@ static inline void json_init(json_t *json, json_type type)
|
||||
|
||||
/*** object ***/
|
||||
|
||||
/* This macro just returns a pointer that's a few bytes backwards from
|
||||
string. This makes it possible to pass a pointer to object_key_t
|
||||
when only the string inside it is used, without actually creating
|
||||
an object_key_t instance. */
|
||||
#define string_to_key(string) container_of(string, object_key_t, key)
|
||||
|
||||
static unsigned int hash_key(const void *ptr)
|
||||
{
|
||||
const char *str = ((const object_key_t *)ptr)->key;
|
||||
|
||||
unsigned int hash = 5381;
|
||||
unsigned int c;
|
||||
|
||||
while((c = (unsigned int)*str))
|
||||
{
|
||||
hash = ((hash << 5) + hash) + c;
|
||||
str++;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static int key_equal(const void *ptr1, const void *ptr2)
|
||||
{
|
||||
return strcmp(((const object_key_t *)ptr1)->key,
|
||||
((const object_key_t *)ptr2)->key) == 0;
|
||||
}
|
||||
|
||||
static void value_decref(void *value)
|
||||
{
|
||||
json_decref((json_t *)value);
|
||||
}
|
||||
|
||||
json_t *json_object(void)
|
||||
{
|
||||
json_object_t *object = malloc(sizeof(json_object_t));
|
||||
json_object_t *object = jsonp_malloc(sizeof(json_object_t));
|
||||
if(!object)
|
||||
return NULL;
|
||||
json_init(&object->json, JSON_OBJECT);
|
||||
|
||||
if(hashtable_init(&object->hashtable, hash_key, key_equal,
|
||||
free, value_decref))
|
||||
if(hashtable_init(&object->hashtable))
|
||||
{
|
||||
free(object);
|
||||
jsonp_free(object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -84,15 +58,15 @@ json_t *json_object(void)
|
||||
static void json_delete_object(json_object_t *object)
|
||||
{
|
||||
hashtable_close(&object->hashtable);
|
||||
free(object);
|
||||
jsonp_free(object);
|
||||
}
|
||||
|
||||
unsigned int json_object_size(const json_t *json)
|
||||
size_t json_object_size(const json_t *json)
|
||||
{
|
||||
json_object_t *object;
|
||||
|
||||
if(!json_is_object(json))
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
object = json_to_object(json);
|
||||
return object->hashtable.size;
|
||||
@@ -106,32 +80,24 @@ json_t *json_object_get(const json_t *json, const char *key)
|
||||
return NULL;
|
||||
|
||||
object = json_to_object(json);
|
||||
return hashtable_get(&object->hashtable, string_to_key(key));
|
||||
return hashtable_get(&object->hashtable, key);
|
||||
}
|
||||
|
||||
int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value)
|
||||
{
|
||||
json_object_t *object;
|
||||
object_key_t *k;
|
||||
|
||||
if(!key || !value)
|
||||
if(!value)
|
||||
return -1;
|
||||
|
||||
if(!json_is_object(json) || json == value)
|
||||
if(!key || !json_is_object(json) || json == value)
|
||||
{
|
||||
json_decref(value);
|
||||
return -1;
|
||||
}
|
||||
object = json_to_object(json);
|
||||
|
||||
k = malloc(sizeof(object_key_t) + strlen(key) + 1);
|
||||
if(!k)
|
||||
return -1;
|
||||
|
||||
k->serial = object->serial++;
|
||||
strcpy(k->key, key);
|
||||
|
||||
if(hashtable_set(&object->hashtable, k, value))
|
||||
if(hashtable_set(&object->hashtable, key, object->serial++, value))
|
||||
{
|
||||
json_decref(value);
|
||||
return -1;
|
||||
@@ -159,7 +125,7 @@ int json_object_del(json_t *json, const char *key)
|
||||
return -1;
|
||||
|
||||
object = json_to_object(json);
|
||||
return hashtable_del(&object->hashtable, string_to_key(key));
|
||||
return hashtable_del(&object->hashtable, key);
|
||||
}
|
||||
|
||||
int json_object_clear(json_t *json)
|
||||
@@ -170,30 +136,56 @@ int json_object_clear(json_t *json)
|
||||
return -1;
|
||||
|
||||
object = json_to_object(json);
|
||||
|
||||
hashtable_clear(&object->hashtable);
|
||||
object->serial = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_object_update(json_t *object, json_t *other)
|
||||
{
|
||||
void *iter;
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
if(!json_is_object(object) || !json_is_object(other))
|
||||
return -1;
|
||||
|
||||
iter = json_object_iter(other);
|
||||
while(iter) {
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
key = json_object_iter_key(iter);
|
||||
value = json_object_iter_value(iter);
|
||||
|
||||
json_object_foreach(other, key, value) {
|
||||
if(json_object_set_nocheck(object, key, value))
|
||||
return -1;
|
||||
}
|
||||
|
||||
iter = json_object_iter_next(other, iter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_object_update_existing(json_t *object, json_t *other)
|
||||
{
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
if(!json_is_object(object) || !json_is_object(other))
|
||||
return -1;
|
||||
|
||||
json_object_foreach(other, key, value) {
|
||||
if(json_object_get(object, key))
|
||||
json_object_set_nocheck(object, key, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_object_update_missing(json_t *object, json_t *other)
|
||||
{
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
if(!json_is_object(object) || !json_is_object(other))
|
||||
return -1;
|
||||
|
||||
json_object_foreach(other, key, value) {
|
||||
if(!json_object_get(object, key))
|
||||
json_object_set_nocheck(object, key, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -218,7 +210,7 @@ void *json_object_iter_at(json_t *json, const char *key)
|
||||
return NULL;
|
||||
|
||||
object = json_to_object(json);
|
||||
return hashtable_iter_at(&object->hashtable, string_to_key(key));
|
||||
return hashtable_iter_at(&object->hashtable, key);
|
||||
}
|
||||
|
||||
void *json_object_iter_next(json_t *json, void *iter)
|
||||
@@ -232,20 +224,12 @@ void *json_object_iter_next(json_t *json, void *iter)
|
||||
return hashtable_iter_next(&object->hashtable, iter);
|
||||
}
|
||||
|
||||
const object_key_t *jsonp_object_iter_fullkey(void *iter)
|
||||
{
|
||||
if(!iter)
|
||||
return NULL;
|
||||
|
||||
return hashtable_iter_key(iter);
|
||||
}
|
||||
|
||||
const char *json_object_iter_key(void *iter)
|
||||
{
|
||||
if(!iter)
|
||||
return NULL;
|
||||
|
||||
return jsonp_object_iter_fullkey(iter)->key;
|
||||
return hashtable_iter_key(iter);
|
||||
}
|
||||
|
||||
json_t *json_object_iter_value(void *iter)
|
||||
@@ -258,38 +242,34 @@ json_t *json_object_iter_value(void *iter)
|
||||
|
||||
int json_object_iter_set_new(json_t *json, void *iter, json_t *value)
|
||||
{
|
||||
json_object_t *object;
|
||||
|
||||
if(!json_is_object(json) || !iter || !value)
|
||||
return -1;
|
||||
|
||||
object = json_to_object(json);
|
||||
hashtable_iter_set(&object->hashtable, iter, value);
|
||||
|
||||
hashtable_iter_set(iter, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *json_object_key_to_iter(const char *key)
|
||||
{
|
||||
if(!key)
|
||||
return NULL;
|
||||
|
||||
return hashtable_key_to_iter(key);
|
||||
}
|
||||
|
||||
static int json_object_equal(json_t *object1, json_t *object2)
|
||||
{
|
||||
void *iter;
|
||||
const char *key;
|
||||
json_t *value1, *value2;
|
||||
|
||||
if(json_object_size(object1) != json_object_size(object2))
|
||||
return 0;
|
||||
|
||||
iter = json_object_iter(object1);
|
||||
while(iter)
|
||||
{
|
||||
const char *key;
|
||||
json_t *value1, *value2;
|
||||
|
||||
key = json_object_iter_key(iter);
|
||||
value1 = json_object_iter_value(iter);
|
||||
json_object_foreach(object1, key, value1) {
|
||||
value2 = json_object_get(object2, key);
|
||||
|
||||
if(!json_equal(value1, value2))
|
||||
return 0;
|
||||
|
||||
iter = json_object_iter_next(object1, iter);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -298,29 +278,21 @@ static int json_object_equal(json_t *object1, json_t *object2)
|
||||
static json_t *json_object_copy(json_t *object)
|
||||
{
|
||||
json_t *result;
|
||||
void *iter;
|
||||
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
result = json_object();
|
||||
if(!result)
|
||||
return NULL;
|
||||
|
||||
iter = json_object_iter(object);
|
||||
while(iter)
|
||||
{
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
key = json_object_iter_key(iter);
|
||||
value = json_object_iter_value(iter);
|
||||
json_object_foreach(object, key, value)
|
||||
json_object_set_nocheck(result, key, value);
|
||||
|
||||
iter = json_object_iter_next(object, iter);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static json_t *json_object_deep_copy(json_t *object)
|
||||
static json_t *json_object_deep_copy(const json_t *object)
|
||||
{
|
||||
json_t *result;
|
||||
void *iter;
|
||||
@@ -329,17 +301,17 @@ static json_t *json_object_deep_copy(json_t *object)
|
||||
if(!result)
|
||||
return NULL;
|
||||
|
||||
iter = json_object_iter(object);
|
||||
while(iter)
|
||||
{
|
||||
/* Cannot use json_object_foreach because object has to be cast
|
||||
non-const */
|
||||
iter = json_object_iter((json_t *)object);
|
||||
while(iter) {
|
||||
const char *key;
|
||||
json_t *value;
|
||||
|
||||
const json_t *value;
|
||||
key = json_object_iter_key(iter);
|
||||
value = json_object_iter_value(iter);
|
||||
json_object_set_new_nocheck(result, key, json_deep_copy(value));
|
||||
|
||||
iter = json_object_iter_next(object, iter);
|
||||
json_object_set_new_nocheck(result, key, json_deep_copy(value));
|
||||
iter = json_object_iter_next((json_t *)object, iter);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -350,7 +322,7 @@ static json_t *json_object_deep_copy(json_t *object)
|
||||
|
||||
json_t *json_array(void)
|
||||
{
|
||||
json_array_t *array = malloc(sizeof(json_array_t));
|
||||
json_array_t *array = jsonp_malloc(sizeof(json_array_t));
|
||||
if(!array)
|
||||
return NULL;
|
||||
json_init(&array->json, JSON_ARRAY);
|
||||
@@ -358,9 +330,9 @@ json_t *json_array(void)
|
||||
array->entries = 0;
|
||||
array->size = 8;
|
||||
|
||||
array->table = malloc(array->size * sizeof(json_t *));
|
||||
array->table = jsonp_malloc(array->size * sizeof(json_t *));
|
||||
if(!array->table) {
|
||||
free(array);
|
||||
jsonp_free(array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -371,16 +343,16 @@ json_t *json_array(void)
|
||||
|
||||
static void json_delete_array(json_array_t *array)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
for(i = 0; i < array->entries; i++)
|
||||
json_decref(array->table[i]);
|
||||
|
||||
free(array->table);
|
||||
free(array);
|
||||
jsonp_free(array->table);
|
||||
jsonp_free(array);
|
||||
}
|
||||
|
||||
unsigned int json_array_size(const json_t *json)
|
||||
size_t json_array_size(const json_t *json)
|
||||
{
|
||||
if(!json_is_array(json))
|
||||
return 0;
|
||||
@@ -388,7 +360,7 @@ unsigned int json_array_size(const json_t *json)
|
||||
return json_to_array(json)->entries;
|
||||
}
|
||||
|
||||
json_t *json_array_get(const json_t *json, unsigned int index)
|
||||
json_t *json_array_get(const json_t *json, size_t index)
|
||||
{
|
||||
json_array_t *array;
|
||||
if(!json_is_array(json))
|
||||
@@ -401,7 +373,7 @@ json_t *json_array_get(const json_t *json, unsigned int index)
|
||||
return array->table[index];
|
||||
}
|
||||
|
||||
int json_array_set_new(json_t *json, unsigned int index, json_t *value)
|
||||
int json_array_set_new(json_t *json, size_t index, json_t *value)
|
||||
{
|
||||
json_array_t *array;
|
||||
|
||||
@@ -427,24 +399,24 @@ int json_array_set_new(json_t *json, unsigned int index, json_t *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void array_move(json_array_t *array, unsigned int dest,
|
||||
unsigned int src, unsigned int count)
|
||||
static void array_move(json_array_t *array, size_t dest,
|
||||
size_t src, size_t count)
|
||||
{
|
||||
memmove(&array->table[dest], &array->table[src], count * sizeof(json_t *));
|
||||
}
|
||||
|
||||
static void array_copy(json_t **dest, unsigned int dpos,
|
||||
json_t **src, unsigned int spos,
|
||||
unsigned int count)
|
||||
static void array_copy(json_t **dest, size_t dpos,
|
||||
json_t **src, size_t spos,
|
||||
size_t count)
|
||||
{
|
||||
memcpy(&dest[dpos], &src[spos], count * sizeof(json_t *));
|
||||
}
|
||||
|
||||
static json_t **json_array_grow(json_array_t *array,
|
||||
unsigned int amount,
|
||||
size_t amount,
|
||||
int copy)
|
||||
{
|
||||
unsigned int new_size;
|
||||
size_t new_size;
|
||||
json_t **old_table, **new_table;
|
||||
|
||||
if(array->entries + amount <= array->size)
|
||||
@@ -453,7 +425,7 @@ static json_t **json_array_grow(json_array_t *array,
|
||||
old_table = array->table;
|
||||
|
||||
new_size = max(array->size + amount, array->size * 2);
|
||||
new_table = malloc(new_size * sizeof(json_t *));
|
||||
new_table = jsonp_malloc(new_size * sizeof(json_t *));
|
||||
if(!new_table)
|
||||
return NULL;
|
||||
|
||||
@@ -462,7 +434,7 @@ static json_t **json_array_grow(json_array_t *array,
|
||||
|
||||
if(copy) {
|
||||
array_copy(array->table, 0, old_table, 0, array->entries);
|
||||
free(old_table);
|
||||
jsonp_free(old_table);
|
||||
return array->table;
|
||||
}
|
||||
|
||||
@@ -494,7 +466,7 @@ int json_array_append_new(json_t *json, json_t *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_array_insert_new(json_t *json, unsigned int index, json_t *value)
|
||||
int json_array_insert_new(json_t *json, size_t index, json_t *value)
|
||||
{
|
||||
json_array_t *array;
|
||||
json_t **old_table;
|
||||
@@ -523,7 +495,7 @@ int json_array_insert_new(json_t *json, unsigned int index, json_t *value)
|
||||
array_copy(array->table, 0, old_table, 0, index);
|
||||
array_copy(array->table, index + 1, old_table, index,
|
||||
array->entries - index);
|
||||
free(old_table);
|
||||
jsonp_free(old_table);
|
||||
}
|
||||
else
|
||||
array_move(array, index + 1, index, array->entries - index);
|
||||
@@ -534,7 +506,7 @@ int json_array_insert_new(json_t *json, unsigned int index, json_t *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int json_array_remove(json_t *json, unsigned int index)
|
||||
int json_array_remove(json_t *json, size_t index)
|
||||
{
|
||||
json_array_t *array;
|
||||
|
||||
@@ -547,7 +519,10 @@ int json_array_remove(json_t *json, unsigned int index)
|
||||
|
||||
json_decref(array->table[index]);
|
||||
|
||||
array_move(array, index, index + 1, array->entries - index);
|
||||
/* If we're removing the last element, nothing has to be moved */
|
||||
if(index < array->entries - 1)
|
||||
array_move(array, index, index + 1, array->entries - index - 1);
|
||||
|
||||
array->entries--;
|
||||
|
||||
return 0;
|
||||
@@ -556,7 +531,7 @@ int json_array_remove(json_t *json, unsigned int index)
|
||||
int json_array_clear(json_t *json)
|
||||
{
|
||||
json_array_t *array;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
if(!json_is_array(json))
|
||||
return -1;
|
||||
@@ -572,7 +547,7 @@ int json_array_clear(json_t *json)
|
||||
int json_array_extend(json_t *json, json_t *other_json)
|
||||
{
|
||||
json_array_t *array, *other;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
if(!json_is_array(json) || !json_is_array(other_json))
|
||||
return -1;
|
||||
@@ -593,7 +568,7 @@ int json_array_extend(json_t *json, json_t *other_json)
|
||||
|
||||
static int json_array_equal(json_t *array1, json_t *array2)
|
||||
{
|
||||
unsigned int i, size;
|
||||
size_t i, size;
|
||||
|
||||
size = json_array_size(array1);
|
||||
if(size != json_array_size(array2))
|
||||
@@ -616,7 +591,7 @@ static int json_array_equal(json_t *array1, json_t *array2)
|
||||
static json_t *json_array_copy(json_t *array)
|
||||
{
|
||||
json_t *result;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
result = json_array();
|
||||
if(!result)
|
||||
@@ -628,10 +603,10 @@ static json_t *json_array_copy(json_t *array)
|
||||
return result;
|
||||
}
|
||||
|
||||
static json_t *json_array_deep_copy(json_t *array)
|
||||
static json_t *json_array_deep_copy(const json_t *array)
|
||||
{
|
||||
json_t *result;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
result = json_array();
|
||||
if(!result)
|
||||
@@ -652,14 +627,14 @@ json_t *json_string_nocheck(const char *value)
|
||||
if(!value)
|
||||
return NULL;
|
||||
|
||||
string = malloc(sizeof(json_string_t));
|
||||
string = jsonp_malloc(sizeof(json_string_t));
|
||||
if(!string)
|
||||
return NULL;
|
||||
json_init(&string->json, JSON_STRING);
|
||||
|
||||
string->value = strdup(value);
|
||||
string->value = jsonp_strdup(value);
|
||||
if(!string->value) {
|
||||
free(string);
|
||||
jsonp_free(string);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -687,12 +662,15 @@ int json_string_set_nocheck(json_t *json, const char *value)
|
||||
char *dup;
|
||||
json_string_t *string;
|
||||
|
||||
dup = strdup(value);
|
||||
if(!json_is_string(json) || !value)
|
||||
return -1;
|
||||
|
||||
dup = jsonp_strdup(value);
|
||||
if(!dup)
|
||||
return -1;
|
||||
|
||||
string = json_to_string(json);
|
||||
free(string->value);
|
||||
jsonp_free(string->value);
|
||||
string->value = dup;
|
||||
|
||||
return 0;
|
||||
@@ -708,8 +686,8 @@ int json_string_set(json_t *json, const char *value)
|
||||
|
||||
static void json_delete_string(json_string_t *string)
|
||||
{
|
||||
free(string->value);
|
||||
free(string);
|
||||
jsonp_free(string->value);
|
||||
jsonp_free(string);
|
||||
}
|
||||
|
||||
static int json_string_equal(json_t *string1, json_t *string2)
|
||||
@@ -717,7 +695,7 @@ static int json_string_equal(json_t *string1, json_t *string2)
|
||||
return strcmp(json_string_value(string1), json_string_value(string2)) == 0;
|
||||
}
|
||||
|
||||
static json_t *json_string_copy(json_t *string)
|
||||
static json_t *json_string_copy(const json_t *string)
|
||||
{
|
||||
return json_string_nocheck(json_string_value(string));
|
||||
}
|
||||
@@ -725,9 +703,9 @@ static json_t *json_string_copy(json_t *string)
|
||||
|
||||
/*** integer ***/
|
||||
|
||||
json_t *json_integer(int value)
|
||||
json_t *json_integer(json_int_t value)
|
||||
{
|
||||
json_integer_t *integer = malloc(sizeof(json_integer_t));
|
||||
json_integer_t *integer = jsonp_malloc(sizeof(json_integer_t));
|
||||
if(!integer)
|
||||
return NULL;
|
||||
json_init(&integer->json, JSON_INTEGER);
|
||||
@@ -736,7 +714,7 @@ json_t *json_integer(int value)
|
||||
return &integer->json;
|
||||
}
|
||||
|
||||
int json_integer_value(const json_t *json)
|
||||
json_int_t json_integer_value(const json_t *json)
|
||||
{
|
||||
if(!json_is_integer(json))
|
||||
return 0;
|
||||
@@ -744,7 +722,7 @@ int json_integer_value(const json_t *json)
|
||||
return json_to_integer(json)->value;
|
||||
}
|
||||
|
||||
int json_integer_set(json_t *json, int value)
|
||||
int json_integer_set(json_t *json, json_int_t value)
|
||||
{
|
||||
if(!json_is_integer(json))
|
||||
return -1;
|
||||
@@ -756,7 +734,7 @@ int json_integer_set(json_t *json, int value)
|
||||
|
||||
static void json_delete_integer(json_integer_t *integer)
|
||||
{
|
||||
free(integer);
|
||||
jsonp_free(integer);
|
||||
}
|
||||
|
||||
static int json_integer_equal(json_t *integer1, json_t *integer2)
|
||||
@@ -764,7 +742,7 @@ static int json_integer_equal(json_t *integer1, json_t *integer2)
|
||||
return json_integer_value(integer1) == json_integer_value(integer2);
|
||||
}
|
||||
|
||||
static json_t *json_integer_copy(json_t *integer)
|
||||
static json_t *json_integer_copy(const json_t *integer)
|
||||
{
|
||||
return json_integer(json_integer_value(integer));
|
||||
}
|
||||
@@ -774,7 +752,12 @@ static json_t *json_integer_copy(json_t *integer)
|
||||
|
||||
json_t *json_real(double value)
|
||||
{
|
||||
json_real_t *real = malloc(sizeof(json_real_t));
|
||||
json_real_t *real;
|
||||
|
||||
if(isnan(value) || isinf(value))
|
||||
return NULL;
|
||||
|
||||
real = jsonp_malloc(sizeof(json_real_t));
|
||||
if(!real)
|
||||
return NULL;
|
||||
json_init(&real->json, JSON_REAL);
|
||||
@@ -793,8 +776,8 @@ double json_real_value(const json_t *json)
|
||||
|
||||
int json_real_set(json_t *json, double value)
|
||||
{
|
||||
if(!json_is_real(json))
|
||||
return 0;
|
||||
if(!json_is_real(json) || isnan(value) || isinf(value))
|
||||
return -1;
|
||||
|
||||
json_to_real(json)->value = value;
|
||||
|
||||
@@ -803,7 +786,7 @@ int json_real_set(json_t *json, double value)
|
||||
|
||||
static void json_delete_real(json_real_t *real)
|
||||
{
|
||||
free(real);
|
||||
jsonp_free(real);
|
||||
}
|
||||
|
||||
static int json_real_equal(json_t *real1, json_t *real2)
|
||||
@@ -811,7 +794,7 @@ static int json_real_equal(json_t *real1, json_t *real2)
|
||||
return json_real_value(real1) == json_real_value(real2);
|
||||
}
|
||||
|
||||
static json_t *json_real_copy(json_t *real)
|
||||
static json_t *json_real_copy(const json_t *real)
|
||||
{
|
||||
return json_real(json_real_value(real));
|
||||
}
|
||||
@@ -822,7 +805,7 @@ static json_t *json_real_copy(json_t *real)
|
||||
double json_number_value(const json_t *json)
|
||||
{
|
||||
if(json_is_integer(json))
|
||||
return json_integer_value(json);
|
||||
return (double)json_integer_value(json);
|
||||
else if(json_is_real(json))
|
||||
return json_real_value(json);
|
||||
else
|
||||
@@ -834,30 +817,21 @@ double json_number_value(const json_t *json)
|
||||
|
||||
json_t *json_true(void)
|
||||
{
|
||||
static json_t the_true = {
|
||||
JSON_TRUE,
|
||||
(unsigned int)-1
|
||||
};
|
||||
static json_t the_true = {JSON_TRUE, (size_t)-1};
|
||||
return &the_true;
|
||||
}
|
||||
|
||||
|
||||
json_t *json_false(void)
|
||||
{
|
||||
static json_t the_false = {
|
||||
JSON_FALSE,
|
||||
(unsigned int)-1
|
||||
};
|
||||
static json_t the_false = {JSON_FALSE, (size_t)-1};
|
||||
return &the_false;
|
||||
}
|
||||
|
||||
|
||||
json_t *json_null(void)
|
||||
{
|
||||
static json_t the_null = {
|
||||
JSON_NULL,
|
||||
(unsigned int)-1
|
||||
};
|
||||
static json_t the_null = {JSON_NULL, (size_t)-1};
|
||||
return &the_null;
|
||||
}
|
||||
|
||||
@@ -946,7 +920,7 @@ json_t *json_copy(json_t *json)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_t *json_deep_copy(json_t *json)
|
||||
json_t *json_deep_copy(const json_t *json)
|
||||
{
|
||||
if(!json)
|
||||
return NULL;
|
||||
@@ -970,7 +944,7 @@ json_t *json_deep_copy(json_t *json)
|
||||
return json_real_copy(json);
|
||||
|
||||
if(json_is_true(json) || json_is_false(json) || json_is_null(json))
|
||||
return json;
|
||||
return (json_t *)json;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
[InternetShortcut]
|
||||
URL=https://developer.nvidia.com/nvapi
|
||||
Binary file not shown.
@@ -0,0 +1,402 @@
|
||||
////////////////////////// NVIDIA SHADER EXTENSIONS /////////////////
|
||||
|
||||
// this file is to be #included in the app HLSL shader code to make
|
||||
// use of nvidia shader extensions
|
||||
|
||||
|
||||
#include "nvHLSLExtnsInternal.h"
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//------------------------- Warp Shuffle Functions ---------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// all functions have variants with width parameter which permits sub-division
|
||||
// of the warp into segments - for example to exchange data between 4 groups of
|
||||
// 8 lanes in a SIMD manner. If width is less than warpSize then each subsection
|
||||
// of the warp behaves as a separate entity with a starting logical lane ID of 0.
|
||||
// A thread may only exchange data with others in its own subsection. Width must
|
||||
// have a value which is a power of 2 so that the warp can be subdivided equally;
|
||||
// results are undefined if width is not a power of 2, or is a number greater
|
||||
// than warpSize.
|
||||
|
||||
//
|
||||
// simple variant of SHFL instruction
|
||||
// returns val from the specified lane
|
||||
// optional width parameter must be a power of two and width <= 32
|
||||
//
|
||||
int NvShfl(int val, uint srcLane, int width = NV_WARP_SIZE)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = val; // variable to be shuffled
|
||||
g_NvidiaExt[index].src0u.y = srcLane; // source lane
|
||||
g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width);
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL;
|
||||
|
||||
// result is returned as the return value of IncrementCounter on fake UAV slot
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
//
|
||||
// Copy from a lane with lower ID relative to caller
|
||||
//
|
||||
int NvShflUp(int val, uint delta, int width = NV_WARP_SIZE)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = val; // variable to be shuffled
|
||||
g_NvidiaExt[index].src0u.y = delta; // relative lane offset
|
||||
g_NvidiaExt[index].src0u.z = (NV_WARP_SIZE - width) << 8; // minIndex = maxIndex for shfl_up (src2[4:0] is expected to be 0)
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_UP;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
//
|
||||
// Copy from a lane with higher ID relative to caller
|
||||
//
|
||||
int NvShflDown(int val, uint delta, int width = NV_WARP_SIZE)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = val; // variable to be shuffled
|
||||
g_NvidiaExt[index].src0u.y = delta; // relative lane offset
|
||||
g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width);
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_DOWN;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
//
|
||||
// Copy from a lane based on bitwise XOR of own lane ID
|
||||
//
|
||||
int NvShflXor(int val, uint laneMask, int width = NV_WARP_SIZE)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = val; // variable to be shuffled
|
||||
g_NvidiaExt[index].src0u.y = laneMask; // laneMask to be XOR'ed with current laneId to get the source lane id
|
||||
g_NvidiaExt[index].src0u.z = __NvGetShflMaskFromWidth(width);
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_SHFL_XOR;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------- Warp Vote Functions---------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// returns 0xFFFFFFFF if the predicate is true for any thread in the warp, returns 0 otherwise
|
||||
uint NvAny(int predicate)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = predicate;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ANY;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
// returns 0xFFFFFFFF if the predicate is true for ALL threads in the warp, returns 0 otherwise
|
||||
uint NvAll(int predicate)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = predicate;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_ALL;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
// returns a mask of all threads in the warp with bits set for threads that have predicate true
|
||||
uint NvBallot(int predicate)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = predicate;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_VOTE_BALLOT;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------- Utility Functions ----------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// returns the lane index of the current thread (thread index in warp)
|
||||
int NvGetLaneId()
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_GET_LANE_ID;
|
||||
return g_NvidiaExt.IncrementCounter();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------- FP16 Atmoic Functions-------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The functions below performs atomic operations on two consecutive fp16
|
||||
// values in the given raw UAV.
|
||||
// The uint paramater 'fp16x2Val' is treated as two fp16 values byteAddress must be multiple of 4
|
||||
// The returned value are the two fp16 values packed into a single uint
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
|
||||
// versions of the above functions taking two fp32 values (internally converted to fp16 values)
|
||||
uint NvInterlockedAddFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWByteAddressBuffer uav, uint byteAddress, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, byteAddress, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The functions below perform atomic operation on a R16G16_FLOAT UAV at the given address
|
||||
// the uint paramater 'fp16x2Val' is treated as two fp16 values
|
||||
// the returned value are the two fp16 values (.x and .y components) packed into a single uint
|
||||
// Warning: Behaviour of these set of functions is undefined if the UAV is not
|
||||
// of R16G16_FLOAT format (might result in app crash or TDR)
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWTexture1D<float2> uav, uint address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture1D<float2> uav, uint address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture1D<float2> uav, uint address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWTexture2D<float2> uav, uint2 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture2D<float2> uav, uint2 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture2D<float2> uav, uint2 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWTexture3D<float2> uav, uint3 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture3D<float2> uav, uint3 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture3D<float2> uav, uint3 address, uint fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
|
||||
// versions taking two fp32 values (internally converted to fp16)
|
||||
uint NvInterlockedAddFp16x2(RWTexture1D<float2> uav, uint address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture1D<float2> uav, uint address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture1D<float2> uav, uint address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWTexture2D<float2> uav, uint2 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture2D<float2> uav, uint2 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture2D<float2> uav, uint2 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint NvInterlockedAddFp16x2(RWTexture3D<float2> uav, uint3 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint NvInterlockedMinFp16x2(RWTexture3D<float2> uav, uint3 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint NvInterlockedMaxFp16x2(RWTexture3D<float2> uav, uint3 address, float2 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x2Tofp16x2(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The functions below perform Atomic operation on a R16G16B16A16_FLOAT UAV at the given address
|
||||
// the uint2 paramater 'fp16x2Val' is treated as four fp16 values
|
||||
// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz
|
||||
// The returned value are the four fp16 values (.xyzw components) packed into uint2
|
||||
// Warning: Behaviour of these set of functions is undefined if the UAV is not
|
||||
// of R16G16B16A16_FLOAT format (might result in app crash or TDR)
|
||||
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture1D<float4> uav, uint address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture1D<float4> uav, uint address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture1D<float4> uav, uint address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture2D<float4> uav, uint2 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture2D<float4> uav, uint2 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture2D<float4> uav, uint2 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture3D<float4> uav, uint3 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture3D<float4> uav, uint3 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture3D<float4> uav, uint3 address, uint2 fp16x2Val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, fp16x2Val, NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
// versions taking four fp32 values (internally converted to fp16)
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture1D<float4> uav, uint address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture1D<float4> uav, uint address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture1D<float4> uav, uint address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture2D<float4> uav, uint2 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture2D<float4> uav, uint2 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture2D<float4> uav, uint2 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedAddFp16x4(RWTexture3D<float4> uav, uint3 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_ADD);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMinFp16x4(RWTexture3D<float4> uav, uint3 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MIN);
|
||||
}
|
||||
|
||||
uint2 NvInterlockedMaxFp16x4(RWTexture3D<float4> uav, uint3 address, float4 val)
|
||||
{
|
||||
return __NvAtomicOpFP16x2(uav, address, __fp32x4Tofp16x4(val), NV_EXTN_ATOM_MAX);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//----------------------------- FP32 Atmoic Functions-------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The functions below performs atomic add on the given UAV treating the value as float
|
||||
// byteAddress must be multiple of 4
|
||||
// The returned value is the value present in memory location before the atomic add
|
||||
|
||||
float NvInterlockedAddFp32(RWByteAddressBuffer uav, uint byteAddress, float val)
|
||||
{
|
||||
return __NvAtomicAddFP32(uav, byteAddress, val);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// The functions below perform atomic add on a R32_FLOAT UAV at the given address
|
||||
// the returned value is the value before performing the atomic add
|
||||
// Warning: Behaviour of these set of functions is undefined if the UAV is not
|
||||
// of R32_FLOAT format (might result in app crash or TDR)
|
||||
|
||||
float NvInterlockedAddFp32(RWTexture1D<float> uav, uint address, float val)
|
||||
{
|
||||
return __NvAtomicAddFP32(uav, address, val);
|
||||
}
|
||||
|
||||
float NvInterlockedAddFp32(RWTexture2D<float> uav, uint2 address, float val)
|
||||
{
|
||||
return __NvAtomicAddFP32(uav, address, val);
|
||||
}
|
||||
|
||||
float NvInterlockedAddFp32(RWTexture3D<float> uav, uint3 address, float val)
|
||||
{
|
||||
return __NvAtomicAddFP32(uav, address, val);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
////////////////////////// NVIDIA SHADER EXTENSIONS /////////////////
|
||||
// internal functions
|
||||
// Functions in this file are not expected to be called by apps directly
|
||||
|
||||
#include "nvShaderExtnEnums.h"
|
||||
|
||||
struct NvShaderExtnStruct
|
||||
{
|
||||
uint opcode; // opcode
|
||||
uint rid; // resource ID
|
||||
uint sid; // sampler ID
|
||||
|
||||
uint4 dst1u; // destination operand 1 (for instructions that need extra destination operands)
|
||||
uint4 padding0[3]; // currently unused
|
||||
|
||||
uint4 src0u; // uint source operand 0
|
||||
uint4 src1u; // uint source operand 0
|
||||
uint4 src2u; // uint source operand 0
|
||||
uint4 dst0u; // uint destination operand
|
||||
|
||||
uint markUavRef; // the next store to UAV is fake and is used only to identify the uav slot
|
||||
float padding1[28];// struct size: 256 bytes
|
||||
};
|
||||
|
||||
// RW structured buffer for Nvidia shader extensions
|
||||
|
||||
// Application needs to define NV_SHADER_EXTN_SLOT as a unused slot, which should be
|
||||
// set using NvAPI_D3D11_SetNvShaderExtnSlot() call before creating the first shader that
|
||||
// uses nvidia shader extensions. E.g before including this file in shader define it as:
|
||||
// #define NV_SHADER_EXTN_SLOT u7
|
||||
|
||||
// Note that other operations to this UAV will be ignored so application
|
||||
// should bind a null resource
|
||||
RWStructuredBuffer<NvShaderExtnStruct> g_NvidiaExt : register( NV_SHADER_EXTN_SLOT );
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// the exposed SHFL instructions accept a mask parameter in src2
|
||||
// To compute lane mask from width of segment:
|
||||
// minLaneID : currentLaneId & src2[12:8]
|
||||
// maxLaneID : minLaneId | (src2[4:0] & ~src2[12:8])
|
||||
// where [minLaneId, maxLaneId] defines the segment where currentLaneId belongs
|
||||
// we always set src2[4:0] to 11111 (0x1F), and set src2[12:8] as (32 - width)
|
||||
int __NvGetShflMaskFromWidth(uint width)
|
||||
{
|
||||
return ((NV_WARP_SIZE - width) << 8) | 0x1F;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
void __NvReferenceUAVForOp(RWByteAddressBuffer uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav.Store(index, 0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<float2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = float2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<float2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = float2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<float2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = float2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<float4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = float4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<float4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = float4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<float4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = float4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<float> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = 0.0f;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<float> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = 0.0f;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<float> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<uint2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = uint2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<uint2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = uint2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<uint2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = uint2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<uint4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = uint4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<uint4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = uint4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<uint4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = uint4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<uint> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = 0;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<uint> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = 0;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<uint> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = 0;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<int2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = int2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<int2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = int2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<int2> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = int2(0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<int4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = int4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<int4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = int4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<int4> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = int4(0,0,0,0);
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture1D<int> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[index] = 0;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture2D<int> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint2(index,index)] = 0;
|
||||
}
|
||||
|
||||
void __NvReferenceUAVForOp(RWTexture3D<int> uav)
|
||||
{
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].markUavRef = 1;
|
||||
uav[uint3(index,index,index)] = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// ATOMIC op sub-opcodes
|
||||
#define NV_EXTN_ATOM_ADD 3
|
||||
#define NV_EXTN_ATOM_MAX 6
|
||||
#define NV_EXTN_ATOM_MIN 7
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// performs Atomic operation on two consecutive fp16 values in the given UAV
|
||||
// the uint paramater 'fp16x2Val' is treated as two fp16 values
|
||||
// the passed sub-opcode 'op' should be an immediate constant
|
||||
// byteAddress must be multiple of 4
|
||||
// the returned value are the two fp16 values packed into a single uint
|
||||
uint __NvAtomicOpFP16x2(RWByteAddressBuffer uav, uint byteAddress, uint fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = byteAddress;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
|
||||
return g_NvidiaExt[index].dst0u.x;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// performs Atomic operation on a R16G16_FLOAT UAV at the given address
|
||||
// the uint paramater 'fp16x2Val' is treated as two fp16 values
|
||||
// the passed sub-opcode 'op' should be an immediate constant
|
||||
// the returned value are the two fp16 values (.x and .y components) packed into a single uint
|
||||
// Warning: Behaviour of these set of functions is undefined if the UAV is not
|
||||
// of R16G16_FLOAT format (might result in app crash or TDR)
|
||||
|
||||
uint __NvAtomicOpFP16x2(RWTexture1D<float2> uav, uint address, uint fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = address;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
|
||||
return g_NvidiaExt[index].dst0u.x;
|
||||
}
|
||||
|
||||
uint __NvAtomicOpFP16x2(RWTexture2D<float2> uav, uint2 address, uint fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xy = address;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
|
||||
return g_NvidiaExt[index].dst0u.x;
|
||||
}
|
||||
|
||||
uint __NvAtomicOpFP16x2(RWTexture3D<float2> uav, uint3 address, uint fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xyz = address;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
|
||||
return g_NvidiaExt[index].dst0u.x;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// performs Atomic operation on a R16G16B16A16_FLOAT UAV at the given address
|
||||
// the uint2 paramater 'fp16x2Val' is treated as four fp16 values
|
||||
// i.e, fp16x2Val.x = uav.xy and fp16x2Val.y = uav.yz
|
||||
// the passed sub-opcode 'op' should be an immediate constant
|
||||
// the returned value are the four fp16 values (.xyzw components) packed into uint2
|
||||
// Warning: Behaviour of these set of functions is undefined if the UAV is not
|
||||
// of R16G16B16A16_FLOAT format (might result in app crash or TDR)
|
||||
|
||||
uint2 __NvAtomicOpFP16x2(RWTexture1D<float4> uav, uint address, uint2 fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
|
||||
// break it down into two fp16x2 atomic ops
|
||||
uint2 retVal;
|
||||
|
||||
// first op has x-coordinate = x * 2
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = address * 2;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.x = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
// second op has x-coordinate = x * 2 + 1
|
||||
index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = address * 2 + 1;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.y = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint2 __NvAtomicOpFP16x2(RWTexture2D<float4> uav, uint2 address, uint2 fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
|
||||
// break it down into two fp16x2 atomic ops
|
||||
uint2 retVal;
|
||||
|
||||
// first op has x-coordinate = x * 2
|
||||
uint2 addressTemp = uint2(address.x * 2, address.y);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xy = addressTemp;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.x = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
// second op has x-coordinate = x * 2 + 1
|
||||
addressTemp.x++;
|
||||
index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xy = addressTemp;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.y = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint2 __NvAtomicOpFP16x2(RWTexture3D<float4> uav, uint3 address, uint2 fp16x2Val, uint atomicOpType)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
|
||||
// break it down into two fp16x2 atomic ops
|
||||
uint2 retVal;
|
||||
|
||||
// first op has x-coordinate = x * 2
|
||||
uint3 addressTemp = uint3(address.x * 2, address.y, address.z);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xyz = addressTemp;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.x;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.x = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
// second op has x-coordinate = x * 2 + 1
|
||||
addressTemp.x++;
|
||||
index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xyz = addressTemp;
|
||||
g_NvidiaExt[index].src1u.x = fp16x2Val.y;
|
||||
g_NvidiaExt[index].src2u.x = atomicOpType;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP16_ATOMIC;
|
||||
retVal.y = g_NvidiaExt[index].dst0u.x;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
uint __fp32x2Tofp16x2(float2 val)
|
||||
{
|
||||
return (f32tof16(val.y)<<16) | f32tof16(val.x) ;
|
||||
}
|
||||
|
||||
uint2 __fp32x4Tofp16x4(float4 val)
|
||||
{
|
||||
return uint2( (f32tof16(val.y)<<16) | f32tof16(val.x), (f32tof16(val.w)<<16) | f32tof16(val.z) ) ;
|
||||
}
|
||||
|
||||
// FP32 Atomic functions
|
||||
|
||||
// performs Atomic operation treating the uav as float (fp32) values
|
||||
// the passed sub-opcode 'op' should be an immediate constant
|
||||
// byteAddress must be multiple of 4
|
||||
float __NvAtomicAddFP32(RWByteAddressBuffer uav, uint byteAddress, float val)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = byteAddress;
|
||||
g_NvidiaExt[index].src1u.x = asuint(val); // passing as uint to make it more convinient for the driver to translate
|
||||
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
|
||||
|
||||
return asfloat(g_NvidiaExt[index].dst0u.x);
|
||||
}
|
||||
|
||||
float __NvAtomicAddFP32(RWTexture1D<float> uav, uint address, float val)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.x = address;
|
||||
g_NvidiaExt[index].src1u.x = asuint(val);
|
||||
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
|
||||
|
||||
return asfloat(g_NvidiaExt[index].dst0u.x);
|
||||
}
|
||||
|
||||
float __NvAtomicAddFP32(RWTexture2D<float> uav, uint2 address, float val)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xy = address;
|
||||
g_NvidiaExt[index].src1u.x = asuint(val);
|
||||
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
|
||||
|
||||
return asfloat(g_NvidiaExt[index].dst0u.x);
|
||||
}
|
||||
|
||||
float __NvAtomicAddFP32(RWTexture3D<float> uav, uint3 address, float val)
|
||||
{
|
||||
__NvReferenceUAVForOp(uav);
|
||||
uint index = g_NvidiaExt.IncrementCounter();
|
||||
g_NvidiaExt[index].src0u.xyz = address;
|
||||
g_NvidiaExt[index].src1u.x = asuint(val);
|
||||
g_NvidiaExt[index].src2u.x = NV_EXTN_ATOM_ADD;
|
||||
g_NvidiaExt[index].opcode = NV_EXTN_OP_FP32_ATOMIC;
|
||||
|
||||
return asfloat(g_NvidiaExt[index].dst0u.x);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////// NVIDIA SHADER EXTENSIONS ////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file can be included both from HLSL shader code as well as C++ code.
|
||||
// The app should call NvAPI_D3D_IsNvShaderExtnOpCodeSupported() to
|
||||
// check for support for every nv shader extension opcode it plans to use
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//---------------------------- NV Shader Extn Version -----------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
#define NV_SHADER_EXTN_VERSION 1
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//---------------------------- Misc constants --------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
#define NV_WARP_SIZE 32
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
//---------------------------- opCode constants ------------------------------//
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
|
||||
#define NV_EXTN_OP_SHFL 1
|
||||
#define NV_EXTN_OP_SHFL_UP 2
|
||||
#define NV_EXTN_OP_SHFL_DOWN 3
|
||||
#define NV_EXTN_OP_SHFL_XOR 4
|
||||
|
||||
#define NV_EXTN_OP_VOTE_ALL 5
|
||||
#define NV_EXTN_OP_VOTE_ANY 6
|
||||
#define NV_EXTN_OP_VOTE_BALLOT 7
|
||||
|
||||
#define NV_EXTN_OP_GET_LANE_ID 8
|
||||
#define NV_EXTN_OP_FP16_ATOMIC 12
|
||||
#define NV_EXTN_OP_FP32_ATOMIC 13
|
||||
+11760
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,371 @@
|
||||
#pragma once
|
||||
|
||||
#define NVAPI_INTERNAL
|
||||
#include "nvapi.h"
|
||||
|
||||
NvAPI_Status nvapi_dll_init();
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU8 valid;
|
||||
NvU8 count;
|
||||
struct
|
||||
{
|
||||
NvU32 pstate; // Assumption
|
||||
NvU32 unknown1[2];
|
||||
NvU32 min_power;
|
||||
NvU32 unknown2[2];
|
||||
NvU32 def_power;
|
||||
NvU32 unknown3[2];
|
||||
NvU32 max_power;
|
||||
NvU32 unknown4; // 0
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_INFO;
|
||||
#define NVAPI_GPU_POWER_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_INFO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 unknown1;
|
||||
NvU32 unknown2;
|
||||
NvU32 power; // percent * 1000
|
||||
NvU32 unknown4;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_STATUS;
|
||||
#define NVAPI_GPU_POWER_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 count;
|
||||
struct {
|
||||
NvU32 unknown1;
|
||||
NvU32 unknown2;
|
||||
NvU32 power; // unsure ?? 85536 to 95055 on 1080, 104825+ on 970
|
||||
NvU32 unknown4;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_POWER_TOPO;
|
||||
#define NVAPI_GPU_POWER_TOPO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_POWER_TOPO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 controller;
|
||||
NvU32 unknown;
|
||||
NvS32 min_temp;
|
||||
NvS32 def_temp;
|
||||
NvS32 max_temp;
|
||||
NvU32 defaultFlags;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_THERMAL_INFO;
|
||||
#define NVAPI_GPU_THERMAL_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_THERMAL_INFO, 2)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
struct {
|
||||
NvU32 controller;
|
||||
NvU32 value;
|
||||
NvU32 flags;
|
||||
} entries[4];
|
||||
} NVAPI_GPU_THERMAL_LIMIT;
|
||||
#define NVAPI_GPU_THERMAL_LIMIT_VER MAKE_NVAPI_VERSION(NVAPI_GPU_THERMAL_LIMIT, 2)
|
||||
|
||||
// Maxwell gpu core voltage reading
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 count; // unsure
|
||||
NvU32 unknown;
|
||||
NvU32 value_uV;
|
||||
NvU32 buf1[30];
|
||||
} NVAPI_VOLT_STATUS; // 140 bytes (1-008c)
|
||||
#define NVAPI_VOLT_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_VOLT_STATUS, 1)
|
||||
|
||||
// Pascal gpu core voltage reading
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 nul[8];
|
||||
NvU32 value_uV;
|
||||
NvU32 buf1[8];
|
||||
} NVAPI_VOLTAGE_STATUS; // 76 bytes (1-004c)
|
||||
#define NVAPI_VOLTAGE_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_VOLTAGE_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 numClocks; // unsure
|
||||
NvU32 nul[8];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 clockType;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
NvU32 h;
|
||||
NvU32 i;
|
||||
NvU32 j;
|
||||
NvS32 rangeMax;
|
||||
NvS32 rangeMin;
|
||||
NvS32 tempMax; // ? unsure
|
||||
NvU32 n;
|
||||
NvU32 o;
|
||||
NvU32 p;
|
||||
NvU32 q;
|
||||
NvU32 r;
|
||||
} entries[32]; // NVAPI_MAX_GPU_CLOCKS ?
|
||||
} NVAPI_CLOCKS_RANGE; // 2344 bytes
|
||||
#define NVAPI_CLOCKS_RANGE_VER MAKE_NVAPI_VERSION(NVAPI_CLOCKS_RANGE, 1)
|
||||
|
||||
// seems to return a clock table mask
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask
|
||||
NvU32 buf0[8];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 b;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 memDelta; // 1 for mem
|
||||
NvU32 gpuDelta; // 1 for gpu
|
||||
} clocks[80 + 23];
|
||||
NvU32 buf1[916];
|
||||
} NVAPI_CLOCK_MASKS; // 6188 bytes
|
||||
#define NVAPI_CLOCK_MASKS_VER MAKE_NVAPI_VERSION(NVAPI_CLOCK_MASKS, 1)
|
||||
|
||||
// contains the gpu/mem clocks deltas
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask (could be 8x 32bits)
|
||||
NvU32 buf0[12];
|
||||
struct {
|
||||
NvU32 a;
|
||||
NvU32 b;
|
||||
NvU32 c;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvS32 freqDelta; // 84000 = +84MHz
|
||||
NvU32 g;
|
||||
NvU32 h;
|
||||
NvU32 i;
|
||||
} gpuDeltas[80];
|
||||
NvU32 memFilled[23]; // maybe only 4 max
|
||||
NvS32 memDeltas[23];
|
||||
NvU32 buf1[1529];
|
||||
} NVAPI_CLOCK_TABLE; // 9248 bytes
|
||||
#define NVAPI_CLOCK_TABLE_VER MAKE_NVAPI_VERSION(NVAPI_CLOCK_TABLE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 mask[4]; // 80 bits mask
|
||||
NvU32 buf0[12];
|
||||
struct {
|
||||
NvU32 a; // 0
|
||||
NvU32 freq_kHz;
|
||||
NvU32 volt_uV;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
} gpuEntries[80];
|
||||
struct {
|
||||
NvU32 a; // 1 for idle values ?
|
||||
NvU32 freq_kHz;
|
||||
NvU32 volt_uV;
|
||||
NvU32 d;
|
||||
NvU32 e;
|
||||
NvU32 f;
|
||||
NvU32 g;
|
||||
} memEntries[23];
|
||||
NvU32 buf1[1064];
|
||||
} NVAPI_VFP_CURVE; // 7208 bytes (1-1c28)
|
||||
#define NVAPI_VFP_CURVE_VER MAKE_NVAPI_VERSION(NVAPI_VFP_CURVE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvS32 percent;
|
||||
NvU32 pad[8];
|
||||
} NVAPI_VOLTBOOST_PERCENT; // 40 bytes (1-0028)
|
||||
#define NVAPI_VOLTBOOST_PERCENT_VER MAKE_NVAPI_VERSION(NVAPI_VOLTBOOST_PERCENT, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags;
|
||||
NvU32 filled; // 1
|
||||
struct {
|
||||
NvU32 volt_uV;
|
||||
NvU32 unknown;
|
||||
} entries[128];
|
||||
// some empty tables then...
|
||||
NvU32 buf1[3888];
|
||||
} NVAPI_VOLTAGES_TABLE; // 16588 bytes (1-40cc)
|
||||
#define NVAPI_VOLTAGES_TABLE_VER MAKE_NVAPI_VERSION(NVAPI_VOLTAGES_TABLE, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 val1; // 7
|
||||
NvU32 val2; // 0x3F (63.)
|
||||
NvU32 pad[16];
|
||||
} NVAPI_GPU_PERF_INFO; // 76 bytes (1-004c)
|
||||
#define NVAPI_GPU_PERF_INFO_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_INFO, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 flags; // 0
|
||||
NvU64 timeRef; // increment with time
|
||||
NvU64 val1; // seen 1 4 5 while mining, 16 else
|
||||
NvU64 val2; // seen 7 and 3
|
||||
NvU64 values[3]; // increment with time
|
||||
NvU32 pad[326]; // empty
|
||||
} NVAPI_GPU_PERF_STATUS; // 1360 bytes (1-0550)
|
||||
#define NVAPI_GPU_PERF_STATUS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_STATUS, 1)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 val1; // 4
|
||||
NvU32 val2; // 2 or 0
|
||||
NvU32 val3; // 2
|
||||
NvU32 val4; // 3
|
||||
NV_GPU_PERF_PSTATE_ID pStateId;
|
||||
NvU32 val6; // 0 or 2
|
||||
NvU32 val7; // 4
|
||||
NvU32 val8; // 0
|
||||
NvU32 memFreq1; // 405000.
|
||||
NvU32 memFreq2; // 405000.
|
||||
NvU32 memFreqMin;// 101250.
|
||||
NvU32 memFreqMax;// 486000.
|
||||
NvU32 zeros[3];
|
||||
NvU32 gpuFreq1; // 696000. Unsure about those
|
||||
NvU32 gpuFreq2; // 696000.
|
||||
NvU32 gpuFreqMin;// 174000.
|
||||
NvU32 gpuFreqMax;// 658000.
|
||||
NvU32 pad[2697];
|
||||
} NVAPI_GPU_PERF_CLOCKS; // 10868 bytes (2-2a74)
|
||||
#define NVAPI_GPU_PERF_CLOCKS_VER MAKE_NVAPI_VERSION(NVAPI_GPU_PERF_CLOCKS, 2)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 level;
|
||||
NvU32 count;
|
||||
NvU32 pad[339]; // (4-0558)
|
||||
} NVAPI_COOLER_SETTINGS;
|
||||
#define NVAPI_COOLER_SETTINGS_VER MAKE_NVAPI_VERSION(NVAPI_COOLER_SETTINGS, 4)
|
||||
|
||||
typedef struct {
|
||||
NvU32 version;
|
||||
NvU32 level; // 0 = auto ?
|
||||
NvU32 count; // 1
|
||||
NvU32 pad[38]; // (1-00a4)
|
||||
} NVAPI_COOLER_LEVEL;
|
||||
#define NVAPI_COOLER_LEVEL_VER MAKE_NVAPI_VERSION(NVAPI_COOLER_LEVEL, 1)
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetInterfaceVersionString(NvAPI_ShortString string);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_PerfPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_PERF_INFO*); // 409D9841 1-004c
|
||||
NvAPI_Status NvAPI_DLL_PerfPoliciesGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_PERF_STATUS*); // 3D358A0C 1-0550
|
||||
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_POWER_INFO*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_STATUS*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerPoliciesSetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_STATUS*);
|
||||
NvAPI_Status NvAPI_DLL_ClientPowerTopologyGetStatus(NvPhysicalGpuHandle, NVAPI_GPU_POWER_TOPO*); // EDCF624E 1-0048
|
||||
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesGetInfo(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_INFO*);
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesGetLimit(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_LIMIT*);
|
||||
NvAPI_Status NvAPI_DLL_ClientThermalPoliciesSetLimit(NvPhysicalGpuHandle, NVAPI_GPU_THERMAL_LIMIT*);
|
||||
|
||||
// Pascal GTX only
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostRanges(NvPhysicalGpuHandle, NVAPI_CLOCKS_RANGE*);
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostMask(NvPhysicalGpuHandle, NVAPI_CLOCK_MASKS*); // 0x507B4B59
|
||||
NvAPI_Status NvAPI_DLL_GetClockBoostTable(NvPhysicalGpuHandle, NVAPI_CLOCK_TABLE*); // 0x23F1B133
|
||||
NvAPI_Status NvAPI_DLL_SetClockBoostTable(NvPhysicalGpuHandle, NVAPI_CLOCK_TABLE*); // 0x0733E009
|
||||
NvAPI_Status NvAPI_DLL_GetVFPCurve(NvPhysicalGpuHandle, NVAPI_VFP_CURVE*); // 0x21537AD4
|
||||
NvAPI_Status NvAPI_DLL_GetCurrentVoltage(NvPhysicalGpuHandle, NVAPI_VOLTAGE_STATUS*); // 0x465F9BCF 1-004c
|
||||
NvAPI_Status NvAPI_DLL_GetCoreVoltageBoostPercent(NvPhysicalGpuHandle, NVAPI_VOLTBOOST_PERCENT*);
|
||||
NvAPI_Status NvAPI_DLL_SetCoreVoltageBoostPercent(NvPhysicalGpuHandle, NVAPI_VOLTBOOST_PERCENT*);
|
||||
|
||||
// Maxwell only
|
||||
NvAPI_Status NvAPI_DLL_GetVoltageDomainsStatus(NvPhysicalGpuHandle, NVAPI_VOLT_STATUS*); // 0xC16C7E2C
|
||||
NvAPI_Status NvAPI_DLL_GetVoltages(NvPhysicalGpuHandle, NVAPI_VOLTAGES_TABLE*); // 0x7D656244 1-40CC
|
||||
NvAPI_Status NvAPI_DLL_GetVoltageStep(NvPhysicalGpuHandle, NVAPI_VOLT_STATUS*); // 0x28766157 1-008C unsure of the name
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetCoolerSettings(NvPhysicalGpuHandle, uint32_t, NVAPI_COOLER_SETTINGS*); // 0xDA141340 4-0558
|
||||
NvAPI_Status NvAPI_DLL_SetCoolerLevels(NvPhysicalGpuHandle, uint32_t, NVAPI_COOLER_LEVEL*); // 0x891FA0AE 1-00A4
|
||||
NvAPI_Status NvAPI_DLL_RestoreCoolerSettings(NvPhysicalGpuHandle, NVAPI_COOLER_SETTINGS*, uint32_t);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetSerialNumber(NvPhysicalGpuHandle, NvAPI_ShortString serial);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_GetPerfClocks(NvPhysicalGpuHandle, uint32_t num, NVAPI_GPU_PERF_CLOCKS* pClocks); // 2-2A74
|
||||
//NvAPI_Status NvAPI_DLL_SetPerfClocks(NvPhysicalGpuHandle, uint32_t num, NVAPI_GPU_PERF_CLOCKS* pClocks); // error
|
||||
|
||||
//invalid..
|
||||
//NvAPI_Status NvAPI_DLL_GetPstateClientLimits(NvPhysicalGpuHandle, NV_GPU_PERF_PSTATE_ID, uint32_t* pLimits);
|
||||
//NvAPI_Status NvAPI_DLL_SetPstateClientLimits(NvPhysicalGpuHandle, NV_GPU_PERF_PSTATE_ID, uint32_t* pLimits);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_SetPstates20v1(NvPhysicalGpuHandle handle, NV_GPU_PERF_PSTATES20_INFO_V1 *pSet);
|
||||
NvAPI_Status NvAPI_DLL_SetPstates20v2(NvPhysicalGpuHandle handle, NV_GPU_PERF_PSTATES20_INFO_V2 *pSet);
|
||||
|
||||
NvAPI_Status NvAPI_DLL_Unload();
|
||||
|
||||
#define NV_ASSERT(x) { NvAPI_Status ret = x; if(ret != NVAPI_OK) return ret; }
|
||||
|
||||
// to reduce stack size, allow to reuse a mem buffer
|
||||
#define NV_INIT_STRUCT_ON(TYPE, var, mem) { \
|
||||
var = (TYPE*) mem; \
|
||||
memset(var, 0, sizeof(TYPE)); \
|
||||
var->version = TYPE##_VER; \
|
||||
}
|
||||
|
||||
// alloc a struct, need free(var)
|
||||
#define NV_INIT_STRUCT_ALLOC(TYPE, var) { \
|
||||
var = (TYPE*) calloc(1, TYPE##_VER & 0xFFFF); \
|
||||
if (var) var->version = TYPE##_VER; \
|
||||
}
|
||||
|
||||
//! Used in NvAPI_I2CReadEx()
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version;
|
||||
NvU32 displayMask; // Display Mask of the concerned display.
|
||||
NvU8 bIsDDCPort; // indicates either the DDC port (TRUE) or the communication port (FALSE) of the concerned display.
|
||||
NvU8 i2cDevAddress; // address of the I2C slave. The address should be shifted left by one. 0x50 -> 0xA0.
|
||||
NvU8* pbI2cRegAddress; // I2C target register address. May be NULL, which indicates no register address should be sent.
|
||||
NvU32 regAddrSize; // size in bytes of target register address. If pbI2cRegAddress is NULL, this field must be 0.
|
||||
NvU8* pbData; // buffer of data which is to be read or written (depending on the command).
|
||||
NvU32 cbRead; // bytes to read ??? seems required on write too
|
||||
NvU32 cbSize; // full size of the data buffer, pbData, to be read or written.
|
||||
NV_I2C_SPEED i2cSpeedKhz; // target speed of the transaction in (kHz) (Chosen from the enum NV_I2C_SPEED).
|
||||
NvU8 portId; // portid on which device is connected (remember to set bIsPortIdSet if this value is set)
|
||||
NvU32 bIsPortIdSet; // set this flag on if and only if portid value is set
|
||||
|
||||
} NV_I2C_INFO_EX;
|
||||
#define NV_I2C_INFO_EX_VER MAKE_NVAPI_VERSION(NV_I2C_INFO_EX,3)
|
||||
/*
|
||||
sample evga x64 call (struct of 0x40 bytes)
|
||||
ReadEx
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 40 00 00 00 00 00 00
|
||||
$+10 58 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 C0 F9 2B 00 00 00 00 00 02 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00
|
||||
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 10 00 00 00 00 00 00
|
||||
$+10 68 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 C0 F9 2B 00 00 00 00 00 01 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00
|
||||
00000000002BF968 > 75 83 CF 3F 01 00 00 00
|
||||
00000000002BF9C0 > 0
|
||||
|
||||
WriteEx
|
||||
$ ==> 40 00 03 00 00 00 00 00 00 8C 00 00 00 00 00 00
|
||||
$+10 30 F9 2B 00 00 00 00 00 01 00 00 00 00 00 00 00
|
||||
$+20 38 F9 2B 00 00 00 00 00 02 00 00 00 FF FF 00 00
|
||||
$+30 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00
|
||||
00000000002BF930 > D1 00 00 00 00 00 00 00
|
||||
00000000002BF938 > 38 00 00 00 00 00 00 00
|
||||
*/
|
||||
|
||||
NvAPI_Status NvAPI_DLL_I2CReadEx(NvPhysicalGpuHandle, NV_I2C_INFO_EX*, NvU32*);
|
||||
NvAPI_Status NvAPI_DLL_I2CWriteEx(NvPhysicalGpuHandle, NV_I2C_INFO_EX*, NvU32*);
|
||||
@@ -0,0 +1,541 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#pragma pack(push,8)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER) && (_MSC_VER > 1399) && !defined(NVAPI_INTERNAL) && !defined(NVAPI_DEPRECATED_OLD)
|
||||
#ifndef __nvapi_deprecated_function
|
||||
#define __nvapi_deprecated_function(message) __declspec(deprecated(message))
|
||||
#endif
|
||||
#ifndef __nvapi_deprecated_datatype
|
||||
#define __nvapi_deprecated_datatype(FirstRelease) __declspec(deprecated("Do not use this data type - it is deprecated in release " #FirstRelease "."))
|
||||
#endif
|
||||
#else
|
||||
#ifndef __nvapi_deprecated_function
|
||||
#define __nvapi_deprecated_function(message)
|
||||
#endif
|
||||
#ifndef __nvapi_deprecated_datatype
|
||||
#define __nvapi_deprecated_datatype(FirstRelease)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* 64-bit types for compilers that support them, plus some obsolete variants */
|
||||
#if defined(__GNUC__) || defined(__arm) || defined(__IAR_SYSTEMS_ICC__) || defined(__ghs__) || defined(_WIN64)
|
||||
typedef unsigned long long NvU64; /* 0 to 18446744073709551615 */
|
||||
typedef long long NvS64; /* -9223372036854775808 to 9223372036854775807 */
|
||||
#else
|
||||
typedef unsigned __int64 NvU64; /* 0 to 18446744073709551615 */
|
||||
typedef __int64 NvS64; /* -9223372036854775808 to 9223372036854775807 */
|
||||
#endif
|
||||
|
||||
// mac os 32-bit still needs this
|
||||
#if (defined(macintosh) || defined(__APPLE__)) && !defined(__LP64__)
|
||||
typedef signed long NvS32; /* -2147483648 to 2147483647 */
|
||||
#else
|
||||
typedef signed int NvS32; /* -2147483648 to 2147483647 */
|
||||
#endif
|
||||
|
||||
#ifndef __unix
|
||||
// mac os 32-bit still needs this
|
||||
#if ( (defined(macintosh) && defined(__LP64__) && (__NVAPI_RESERVED0__)) || \
|
||||
(!defined(macintosh) && defined(__NVAPI_RESERVED0__)) )
|
||||
typedef unsigned int NvU32; /* 0 to 4294967295 */
|
||||
#else
|
||||
typedef unsigned long NvU32; /* 0 to 4294967295 */
|
||||
#endif
|
||||
#else
|
||||
typedef unsigned int NvU32; /* 0 to 4294967295 */
|
||||
#endif
|
||||
|
||||
typedef unsigned long temp_NvU32; /* 0 to 4294967295 */
|
||||
typedef signed short NvS16;
|
||||
typedef unsigned short NvU16;
|
||||
typedef unsigned char NvU8;
|
||||
typedef signed char NvS8;
|
||||
|
||||
/* Boolean type */
|
||||
typedef NvU8 NvBool;
|
||||
#define NV_TRUE ((NvBool)(0 == 0))
|
||||
#define NV_FALSE ((NvBool)(0 != 0))
|
||||
|
||||
|
||||
typedef struct _NV_RECT
|
||||
{
|
||||
NvU32 left;
|
||||
NvU32 top;
|
||||
NvU32 right;
|
||||
NvU32 bottom;
|
||||
} NV_RECT;
|
||||
|
||||
|
||||
|
||||
#define NV_DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
|
||||
|
||||
//! \addtogroup nvapihandles
|
||||
//! NVAPI Handles - These handles are retrieved from various calls and passed in to others in NvAPI
|
||||
//! These are meant to be opaque types. Do not assume they correspond to indices, HDCs,
|
||||
//! display indexes or anything else.
|
||||
//!
|
||||
//! Most handles remain valid until a display re-configuration (display mode set) or GPU
|
||||
//! reconfiguration (going into or out of SLI modes) occurs. If NVAPI_HANDLE_INVALIDATED
|
||||
//! is received by an app, it should discard all handles, and re-enumerate them.
|
||||
//! @{
|
||||
NV_DECLARE_HANDLE(NvDisplayHandle); //!< Display Device driven by NVIDIA GPU(s) (an attached display)
|
||||
NV_DECLARE_HANDLE(NvMonitorHandle); //!< Monitor handle
|
||||
NV_DECLARE_HANDLE(NvUnAttachedDisplayHandle); //!< Unattached Display Device driven by NVIDIA GPU(s)
|
||||
NV_DECLARE_HANDLE(NvLogicalGpuHandle); //!< One or more physical GPUs acting in concert (SLI)
|
||||
NV_DECLARE_HANDLE(NvPhysicalGpuHandle); //!< A single physical GPU
|
||||
NV_DECLARE_HANDLE(NvEventHandle); //!< A handle to an event registration instance
|
||||
NV_DECLARE_HANDLE(NvVisualComputingDeviceHandle); //!< A handle to a Visual Computing Device
|
||||
NV_DECLARE_HANDLE(NvHICHandle); //!< A handle to a Host Interface Card
|
||||
NV_DECLARE_HANDLE(NvGSyncDeviceHandle); //!< A handle to a Sync device
|
||||
NV_DECLARE_HANDLE(NvVioHandle); //!< A handle to an SDI device
|
||||
NV_DECLARE_HANDLE(NvTransitionHandle); //!< A handle to address a single transition request
|
||||
NV_DECLARE_HANDLE(NvAudioHandle); //!< NVIDIA HD Audio Device
|
||||
NV_DECLARE_HANDLE(Nv3DVPContextHandle); //!< A handle for a 3D Vision Pro (3DVP) context
|
||||
NV_DECLARE_HANDLE(Nv3DVPTransceiverHandle); //!< A handle for a 3DVP RF transceiver
|
||||
NV_DECLARE_HANDLE(Nv3DVPGlassesHandle); //!< A handle for a pair of 3DVP RF shutter glasses
|
||||
|
||||
typedef void* StereoHandle; //!< A stereo handle, that corresponds to the device interface
|
||||
|
||||
NV_DECLARE_HANDLE(NvSourceHandle); //!< Unique source handle on the system
|
||||
NV_DECLARE_HANDLE(NvTargetHandle); //!< Unique target handle on the system
|
||||
NV_DECLARE_HANDLE(NVDX_SwapChainHandle); //!< DirectX SwapChain objects
|
||||
static const NVDX_SwapChainHandle NVDX_SWAPCHAIN_NONE = 0;
|
||||
//! @}
|
||||
|
||||
//! \ingroup nvapihandles
|
||||
//! @{
|
||||
#define NVAPI_DEFAULT_HANDLE 0
|
||||
#define NV_BIT(x) (1 << (x))
|
||||
//! @}
|
||||
|
||||
|
||||
|
||||
//! \addtogroup nvapitypes
|
||||
//! @{
|
||||
#define NVAPI_GENERIC_STRING_MAX 4096
|
||||
#define NVAPI_LONG_STRING_MAX 256
|
||||
#define NVAPI_SHORT_STRING_MAX 64
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NvS32 sX;
|
||||
NvS32 sY;
|
||||
NvS32 sWidth;
|
||||
NvS32 sHeight;
|
||||
} NvSBox;
|
||||
|
||||
#ifndef NvGUID_Defined
|
||||
#define NvGUID_Defined
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NvU32 data1;
|
||||
NvU16 data2;
|
||||
NvU16 data3;
|
||||
NvU8 data4[8];
|
||||
} NvGUID, NvLUID;
|
||||
|
||||
#endif //#ifndef NvGUID_Defined
|
||||
|
||||
|
||||
#define NVAPI_MAX_PHYSICAL_GPUS 64
|
||||
#define NVAPI_MAX_PHYSICAL_BRIDGES 100
|
||||
#define NVAPI_PHYSICAL_GPUS 32
|
||||
#define NVAPI_MAX_LOGICAL_GPUS 64
|
||||
#define NVAPI_MAX_AVAILABLE_GPU_TOPOLOGIES 256
|
||||
#define NVAPI_MAX_AVAILABLE_SLI_GROUPS 256
|
||||
#define NVAPI_MAX_GPU_TOPOLOGIES NVAPI_MAX_PHYSICAL_GPUS
|
||||
#define NVAPI_MAX_GPU_PER_TOPOLOGY 8
|
||||
#define NVAPI_MAX_DISPLAY_HEADS 2
|
||||
#define NVAPI_ADVANCED_DISPLAY_HEADS 4
|
||||
#define NVAPI_MAX_DISPLAYS NVAPI_PHYSICAL_GPUS * NVAPI_ADVANCED_DISPLAY_HEADS
|
||||
#define NVAPI_MAX_ACPI_IDS 16
|
||||
#define NVAPI_MAX_VIEW_MODES 8
|
||||
#define NV_MAX_HEADS 4 //!< Maximum heads, each with NVAPI_DESKTOP_RES resolution
|
||||
#define NVAPI_MAX_HEADS_PER_GPU 32
|
||||
|
||||
#define NV_MAX_HEADS 4 //!< Maximum number of heads, each with #NVAPI_DESKTOP_RES resolution
|
||||
#define NV_MAX_VID_STREAMS 4 //!< Maximum number of input video streams, each with a #NVAPI_VIDEO_SRC_INFO
|
||||
#define NV_MAX_VID_PROFILES 4 //!< Maximum number of output video profiles supported
|
||||
|
||||
#define NVAPI_SYSTEM_MAX_DISPLAYS NVAPI_MAX_PHYSICAL_GPUS * NV_MAX_HEADS
|
||||
|
||||
#define NVAPI_SYSTEM_MAX_HWBCS 128
|
||||
#define NVAPI_SYSTEM_HWBC_INVALID_ID 0xffffffff
|
||||
#define NVAPI_MAX_AUDIO_DEVICES 16
|
||||
|
||||
|
||||
typedef char NvAPI_String[NVAPI_GENERIC_STRING_MAX];
|
||||
typedef char NvAPI_LongString[NVAPI_LONG_STRING_MAX];
|
||||
typedef char NvAPI_ShortString[NVAPI_SHORT_STRING_MAX];
|
||||
//! @}
|
||||
|
||||
|
||||
// =========================================================================================
|
||||
//! NvAPI Version Definition \n
|
||||
//! Maintain per structure specific version define using the MAKE_NVAPI_VERSION macro. \n
|
||||
//! Usage: #define NV_GENLOCK_STATUS_VER MAKE_NVAPI_VERSION(NV_GENLOCK_STATUS, 1)
|
||||
//! \ingroup nvapitypes
|
||||
// =========================================================================================
|
||||
#define MAKE_NVAPI_VERSION(typeName,ver) (NvU32)(sizeof(typeName) | ((ver)<<16))
|
||||
|
||||
//! \ingroup nvapitypes
|
||||
#define GET_NVAPI_VERSION(ver) (NvU32)((ver)>>16)
|
||||
|
||||
//! \ingroup nvapitypes
|
||||
#define GET_NVAPI_SIZE(ver) (NvU32)((ver) & 0xffff)
|
||||
|
||||
|
||||
// ====================================================
|
||||
//! NvAPI Status Values
|
||||
//! All NvAPI functions return one of these codes.
|
||||
//! \ingroup nvapistatus
|
||||
// ====================================================
|
||||
|
||||
|
||||
typedef enum _NvAPI_Status
|
||||
{
|
||||
NVAPI_OK = 0, //!< Success. Request is completed.
|
||||
NVAPI_ERROR = -1, //!< Generic error
|
||||
NVAPI_LIBRARY_NOT_FOUND = -2, //!< NVAPI support library cannot be loaded.
|
||||
NVAPI_NO_IMPLEMENTATION = -3, //!< not implemented in current driver installation
|
||||
NVAPI_API_NOT_INITIALIZED = -4, //!< NvAPI_Initialize has not been called (successfully)
|
||||
NVAPI_INVALID_ARGUMENT = -5, //!< The argument/parameter value is not valid or NULL.
|
||||
NVAPI_NVIDIA_DEVICE_NOT_FOUND = -6, //!< No NVIDIA display driver, or NVIDIA GPU driving a display, was found.
|
||||
NVAPI_END_ENUMERATION = -7, //!< No more items to enumerate
|
||||
NVAPI_INVALID_HANDLE = -8, //!< Invalid handle
|
||||
NVAPI_INCOMPATIBLE_STRUCT_VERSION = -9, //!< An argument's structure version is not supported
|
||||
NVAPI_HANDLE_INVALIDATED = -10, //!< The handle is no longer valid (likely due to GPU or display re-configuration)
|
||||
NVAPI_OPENGL_CONTEXT_NOT_CURRENT = -11, //!< No NVIDIA OpenGL context is current (but needs to be)
|
||||
NVAPI_INVALID_POINTER = -14, //!< An invalid pointer, usually NULL, was passed as a parameter
|
||||
NVAPI_NO_GL_EXPERT = -12, //!< OpenGL Expert is not supported by the current drivers
|
||||
NVAPI_INSTRUMENTATION_DISABLED = -13, //!< OpenGL Expert is supported, but driver instrumentation is currently disabled
|
||||
NVAPI_NO_GL_NSIGHT = -15, //!< OpenGL does not support Nsight
|
||||
|
||||
NVAPI_EXPECTED_LOGICAL_GPU_HANDLE = -100, //!< Expected a logical GPU handle for one or more parameters
|
||||
NVAPI_EXPECTED_PHYSICAL_GPU_HANDLE = -101, //!< Expected a physical GPU handle for one or more parameters
|
||||
NVAPI_EXPECTED_DISPLAY_HANDLE = -102, //!< Expected an NV display handle for one or more parameters
|
||||
NVAPI_INVALID_COMBINATION = -103, //!< The combination of parameters is not valid.
|
||||
NVAPI_NOT_SUPPORTED = -104, //!< Requested feature is not supported in the selected GPU
|
||||
NVAPI_PORTID_NOT_FOUND = -105, //!< No port ID was found for the I2C transaction
|
||||
NVAPI_EXPECTED_UNATTACHED_DISPLAY_HANDLE = -106, //!< Expected an unattached display handle as one of the input parameters.
|
||||
NVAPI_INVALID_PERF_LEVEL = -107, //!< Invalid perf level
|
||||
NVAPI_DEVICE_BUSY = -108, //!< Device is busy; request not fulfilled
|
||||
NVAPI_NV_PERSIST_FILE_NOT_FOUND = -109, //!< NV persist file is not found
|
||||
NVAPI_PERSIST_DATA_NOT_FOUND = -110, //!< NV persist data is not found
|
||||
NVAPI_EXPECTED_TV_DISPLAY = -111, //!< Expected a TV output display
|
||||
NVAPI_EXPECTED_TV_DISPLAY_ON_DCONNECTOR = -112, //!< Expected a TV output on the D Connector - HDTV_EIAJ4120.
|
||||
NVAPI_NO_ACTIVE_SLI_TOPOLOGY = -113, //!< SLI is not active on this device.
|
||||
NVAPI_SLI_RENDERING_MODE_NOTALLOWED = -114, //!< Setup of SLI rendering mode is not possible right now.
|
||||
NVAPI_EXPECTED_DIGITAL_FLAT_PANEL = -115, //!< Expected a digital flat panel.
|
||||
NVAPI_ARGUMENT_EXCEED_MAX_SIZE = -116, //!< Argument exceeds the expected size.
|
||||
NVAPI_DEVICE_SWITCHING_NOT_ALLOWED = -117, //!< Inhibit is ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI active.
|
||||
NVAPI_TESTING_CLOCKS_NOT_SUPPORTED = -118, //!< Testing of clocks is not supported.
|
||||
NVAPI_UNKNOWN_UNDERSCAN_CONFIG = -119, //!< The specified underscan config is from an unknown source (e.g. INF)
|
||||
NVAPI_TIMEOUT_RECONFIGURING_GPU_TOPO = -120, //!< Timeout while reconfiguring GPUs
|
||||
NVAPI_DATA_NOT_FOUND = -121, //!< Requested data was not found
|
||||
NVAPI_EXPECTED_ANALOG_DISPLAY = -122, //!< Expected an analog display
|
||||
NVAPI_NO_VIDLINK = -123, //!< No SLI video bridge is present
|
||||
NVAPI_REQUIRES_REBOOT = -124, //!< NVAPI requires a reboot for the settings to take effect
|
||||
NVAPI_INVALID_HYBRID_MODE = -125, //!< The function is not supported with the current Hybrid mode.
|
||||
NVAPI_MIXED_TARGET_TYPES = -126, //!< The target types are not all the same
|
||||
NVAPI_SYSWOW64_NOT_SUPPORTED = -127, //!< The function is not supported from 32-bit on a 64-bit system.
|
||||
NVAPI_IMPLICIT_SET_GPU_TOPOLOGY_CHANGE_NOT_ALLOWED = -128, //!< There is no implicit GPU topology active. Use NVAPI_SetHybridMode to change topology.
|
||||
NVAPI_REQUEST_USER_TO_CLOSE_NON_MIGRATABLE_APPS = -129, //!< Prompt the user to close all non-migratable applications.
|
||||
NVAPI_OUT_OF_MEMORY = -130, //!< Could not allocate sufficient memory to complete the call.
|
||||
NVAPI_WAS_STILL_DRAWING = -131, //!< The previous operation that is transferring information to or from this surface is incomplete.
|
||||
NVAPI_FILE_NOT_FOUND = -132, //!< The file was not found.
|
||||
NVAPI_TOO_MANY_UNIQUE_STATE_OBJECTS = -133, //!< There are too many unique instances of a particular type of state object.
|
||||
NVAPI_INVALID_CALL = -134, //!< The method call is invalid. For example, a method's parameter may not be a valid pointer.
|
||||
NVAPI_D3D10_1_LIBRARY_NOT_FOUND = -135, //!< d3d10_1.dll cannot be loaded.
|
||||
NVAPI_FUNCTION_NOT_FOUND = -136, //!< Couldn't find the function in the loaded DLL.
|
||||
NVAPI_INVALID_USER_PRIVILEGE = -137, //!< Current User is not Admin.
|
||||
NVAPI_EXPECTED_NON_PRIMARY_DISPLAY_HANDLE = -138, //!< The handle corresponds to GDIPrimary.
|
||||
NVAPI_EXPECTED_COMPUTE_GPU_HANDLE = -139, //!< Setting Physx GPU requires that the GPU is compute-capable.
|
||||
NVAPI_STEREO_NOT_INITIALIZED = -140, //!< The Stereo part of NVAPI failed to initialize completely. Check if the stereo driver is installed.
|
||||
NVAPI_STEREO_REGISTRY_ACCESS_FAILED = -141, //!< Access to stereo-related registry keys or values has failed.
|
||||
NVAPI_STEREO_REGISTRY_PROFILE_TYPE_NOT_SUPPORTED = -142, //!< The given registry profile type is not supported.
|
||||
NVAPI_STEREO_REGISTRY_VALUE_NOT_SUPPORTED = -143, //!< The given registry value is not supported.
|
||||
NVAPI_STEREO_NOT_ENABLED = -144, //!< Stereo is not enabled and the function needed it to execute completely.
|
||||
NVAPI_STEREO_NOT_TURNED_ON = -145, //!< Stereo is not turned on and the function needed it to execute completely.
|
||||
NVAPI_STEREO_INVALID_DEVICE_INTERFACE = -146, //!< Invalid device interface.
|
||||
NVAPI_STEREO_PARAMETER_OUT_OF_RANGE = -147, //!< Separation percentage or JPEG image capture quality is out of [0-100] range.
|
||||
NVAPI_STEREO_FRUSTUM_ADJUST_MODE_NOT_SUPPORTED = -148, //!< The given frustum adjust mode is not supported.
|
||||
NVAPI_TOPO_NOT_POSSIBLE = -149, //!< The mosaic topology is not possible given the current state of the hardware.
|
||||
NVAPI_MODE_CHANGE_FAILED = -150, //!< An attempt to do a display resolution mode change has failed.
|
||||
NVAPI_D3D11_LIBRARY_NOT_FOUND = -151, //!< d3d11.dll/d3d11_beta.dll cannot be loaded.
|
||||
NVAPI_INVALID_ADDRESS = -152, //!< Address is outside of valid range.
|
||||
NVAPI_STRING_TOO_SMALL = -153, //!< The pre-allocated string is too small to hold the result.
|
||||
NVAPI_MATCHING_DEVICE_NOT_FOUND = -154, //!< The input does not match any of the available devices.
|
||||
NVAPI_DRIVER_RUNNING = -155, //!< Driver is running.
|
||||
NVAPI_DRIVER_NOTRUNNING = -156, //!< Driver is not running.
|
||||
NVAPI_ERROR_DRIVER_RELOAD_REQUIRED = -157, //!< A driver reload is required to apply these settings.
|
||||
NVAPI_SET_NOT_ALLOWED = -158, //!< Intended setting is not allowed.
|
||||
NVAPI_ADVANCED_DISPLAY_TOPOLOGY_REQUIRED = -159, //!< Information can't be returned due to "advanced display topology".
|
||||
NVAPI_SETTING_NOT_FOUND = -160, //!< Setting is not found.
|
||||
NVAPI_SETTING_SIZE_TOO_LARGE = -161, //!< Setting size is too large.
|
||||
NVAPI_TOO_MANY_SETTINGS_IN_PROFILE = -162, //!< There are too many settings for a profile.
|
||||
NVAPI_PROFILE_NOT_FOUND = -163, //!< Profile is not found.
|
||||
NVAPI_PROFILE_NAME_IN_USE = -164, //!< Profile name is duplicated.
|
||||
NVAPI_PROFILE_NAME_EMPTY = -165, //!< Profile name is empty.
|
||||
NVAPI_EXECUTABLE_NOT_FOUND = -166, //!< Application not found in the Profile.
|
||||
NVAPI_EXECUTABLE_ALREADY_IN_USE = -167, //!< Application already exists in the other profile.
|
||||
NVAPI_DATATYPE_MISMATCH = -168, //!< Data Type mismatch
|
||||
NVAPI_PROFILE_REMOVED = -169, //!< The profile passed as parameter has been removed and is no longer valid.
|
||||
NVAPI_UNREGISTERED_RESOURCE = -170, //!< An unregistered resource was passed as a parameter.
|
||||
NVAPI_ID_OUT_OF_RANGE = -171, //!< The DisplayId corresponds to a display which is not within the normal outputId range.
|
||||
NVAPI_DISPLAYCONFIG_VALIDATION_FAILED = -172, //!< Display topology is not valid so the driver cannot do a mode set on this configuration.
|
||||
NVAPI_DPMST_CHANGED = -173, //!< Display Port Multi-Stream topology has been changed.
|
||||
NVAPI_INSUFFICIENT_BUFFER = -174, //!< Input buffer is insufficient to hold the contents.
|
||||
NVAPI_ACCESS_DENIED = -175, //!< No access to the caller.
|
||||
NVAPI_MOSAIC_NOT_ACTIVE = -176, //!< The requested action cannot be performed without Mosaic being enabled.
|
||||
NVAPI_SHARE_RESOURCE_RELOCATED = -177, //!< The surface is relocated away from video memory.
|
||||
NVAPI_REQUEST_USER_TO_DISABLE_DWM = -178, //!< The user should disable DWM before calling NvAPI.
|
||||
NVAPI_D3D_DEVICE_LOST = -179, //!< D3D device status is D3DERR_DEVICELOST or D3DERR_DEVICENOTRESET - the user has to reset the device.
|
||||
NVAPI_INVALID_CONFIGURATION = -180, //!< The requested action cannot be performed in the current state.
|
||||
NVAPI_STEREO_HANDSHAKE_NOT_DONE = -181, //!< Call failed as stereo handshake not completed.
|
||||
NVAPI_EXECUTABLE_PATH_IS_AMBIGUOUS = -182, //!< The path provided was too short to determine the correct NVDRS_APPLICATION
|
||||
NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED = -183, //!< Default stereo profile is not currently defined
|
||||
NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST = -184, //!< Default stereo profile does not exist
|
||||
NVAPI_CLUSTER_ALREADY_EXISTS = -185, //!< A cluster is already defined with the given configuration.
|
||||
NVAPI_DPMST_DISPLAY_ID_EXPECTED = -186, //!< The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology
|
||||
NVAPI_INVALID_DISPLAY_ID = -187, //!< The input display id is not valid or the monitor associated to it does not support the current operation
|
||||
NVAPI_STREAM_IS_OUT_OF_SYNC = -188, //!< While playing secure audio stream, stream goes out of sync
|
||||
NVAPI_INCOMPATIBLE_AUDIO_DRIVER = -189, //!< Older audio driver version than required
|
||||
NVAPI_VALUE_ALREADY_SET = -190, //!< Value already set, setting again not allowed.
|
||||
NVAPI_TIMEOUT = -191, //!< Requested operation timed out
|
||||
NVAPI_GPU_WORKSTATION_FEATURE_INCOMPLETE = -192, //!< The requested workstation feature set has incomplete driver internal allocation resources
|
||||
NVAPI_STEREO_INIT_ACTIVATION_NOT_DONE = -193, //!< Call failed because InitActivation was not called.
|
||||
NVAPI_SYNC_NOT_ACTIVE = -194, //!< The requested action cannot be performed without Sync being enabled.
|
||||
NVAPI_SYNC_MASTER_NOT_FOUND = -195, //!< The requested action cannot be performed without Sync Master being enabled.
|
||||
NVAPI_INVALID_SYNC_TOPOLOGY = -196, //!< Invalid displays passed in the NV_GSYNC_DISPLAY pointer.
|
||||
NVAPI_ECID_SIGN_ALGO_UNSUPPORTED = -197, //!< The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed driver/hardware does not support the input value.
|
||||
NVAPI_ECID_KEY_VERIFICATION_FAILED = -198, //!< The encrypted public key verification has failed.
|
||||
NVAPI_FIRMWARE_OUT_OF_DATE = -199, //!< The device's firmware is out of date.
|
||||
NVAPI_FIRMWARE_REVISION_NOT_SUPPORTED = -200, //!< The device's firmware is not supported.
|
||||
NVAPI_LICENSE_CALLER_AUTHENTICATION_FAILED = -201, //!< The caller is not authorized to modify the License.
|
||||
NVAPI_D3D_DEVICE_NOT_REGISTERED = -202, //!< The user tried to use a deferred context without registering the device first
|
||||
NVAPI_RESOURCE_NOT_ACQUIRED = -203, //!< Head or SourceId was not reserved for the VR Display before doing the Modeset.
|
||||
NVAPI_TIMING_NOT_SUPPORTED = -204, //!< Provided timing is not supported.
|
||||
NVAPI_HDCP_ENCRYPTION_FAILED = -205, //!< HDCP Encryption Failed for the device. Would be applicable when the device is HDCP Capable.
|
||||
NVAPI_PCLK_LIMITATION_FAILED = -206, //!< Provided mode is over sink device pclk limitation.
|
||||
NVAPI_NO_CONNECTOR_FOUND = -207, //!< No connector on GPU found.
|
||||
} NvAPI_Status;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_SYS_GetDriverAndBranchVersion
|
||||
//
|
||||
//! DESCRIPTION: This API returns display driver version and driver-branch string.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [out] pDriverVersion Contains the driver version after successful return.
|
||||
//! \param [out] szBuildBranchString Contains the driver-branch string after successful return.
|
||||
//!
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT: either pDriverVersion is NULL or enum index too big
|
||||
//! \retval ::NVAPI_OK - completed request
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized
|
||||
//! \retval ::NVAPI_ERROR - miscellaneous error occurred
|
||||
//!
|
||||
//! \ingroup driverapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_SYS_GetDriverAndBranchVersion(NvU32* pDriverVersion, NvAPI_ShortString szBuildBranchString);
|
||||
//! \ingroup driverapi
|
||||
//! Used in NvAPI_GPU_GetMemoryInfo().
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version; //!< Version info
|
||||
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
|
||||
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
|
||||
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
|
||||
|
||||
} NV_DISPLAY_DRIVER_MEMORY_INFO_V1;
|
||||
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Used in NvAPI_GPU_GetMemoryInfo().
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version; //!< Version info
|
||||
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
|
||||
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
|
||||
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
|
||||
NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces.
|
||||
|
||||
} NV_DISPLAY_DRIVER_MEMORY_INFO_V2;
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Used in NvAPI_GPU_GetMemoryInfo().
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version; //!< Version info
|
||||
NvU32 dedicatedVideoMemory; //!< Size(in kb) of the physical framebuffer.
|
||||
NvU32 availableDedicatedVideoMemory; //!< Size(in kb) of the available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 systemVideoMemory; //!< Size(in kb) of system memory the driver allocates at load time.
|
||||
NvU32 sharedSystemMemory; //!< Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations.
|
||||
NvU32 curAvailableDedicatedVideoMemory; //!< Size(in kb) of the current available physical framebuffer for allocating video memory surfaces.
|
||||
NvU32 dedicatedVideoMemoryEvictionsSize; //!< Size(in kb) of the total size of memory released as a result of the evictions.
|
||||
NvU32 dedicatedVideoMemoryEvictionCount; //!< Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free GPU
|
||||
//!< video memory to make room for other allocations.
|
||||
} NV_DISPLAY_DRIVER_MEMORY_INFO_V3;
|
||||
|
||||
//! \ingroup driverapi
|
||||
typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V3 NV_DISPLAY_DRIVER_MEMORY_INFO;
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V1
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_1 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V1,1)
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V2
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V2,2)
|
||||
|
||||
//! \ingroup driverapi
|
||||
//! Macro for constructing the version field of NV_DISPLAY_DRIVER_MEMORY_INFO_V3
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3 MAKE_NVAPI_VERSION(NV_DISPLAY_DRIVER_MEMORY_INFO_V3,3)
|
||||
|
||||
//! \ingroup driverapi
|
||||
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_3
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_GPU_GetMemoryInfo
|
||||
//
|
||||
//! DESCRIPTION: This function retrieves the available driver memory footprint for the specified GPU.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! TCC_SUPPORTED
|
||||
//!
|
||||
//! \since Release: 177
|
||||
//!
|
||||
//! \param [in] hPhysicalGpu Handle of the physical GPU for which the memory information is to be extracted.
|
||||
//! \param [out] pMemoryInfo The memory footprint available in the driver. See NV_DISPLAY_DRIVER_MEMORY_INFO.
|
||||
//!
|
||||
//! \retval NVAPI_INVALID_ARGUMENT pMemoryInfo is NULL.
|
||||
//! \retval NVAPI_OK Call successful.
|
||||
//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found.
|
||||
//! \retval NVAPI_INCOMPATIBLE_STRUCT_VERSION NV_DISPLAY_DRIVER_MEMORY_INFO structure version mismatch.
|
||||
//!
|
||||
//! \ingroup driverapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_GPU_GetMemoryInfo(NvPhysicalGpuHandle hPhysicalGpu, NV_DISPLAY_DRIVER_MEMORY_INFO *pMemoryInfo);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_EnumPhysicalGPUs
|
||||
//
|
||||
//! This function returns an array of physical GPU handles.
|
||||
//! Each handle represents a physical GPU present in the system.
|
||||
//! That GPU may be part of an SLI configuration, or may not be visible to the OS directly.
|
||||
//!
|
||||
//! At least one GPU must be present in the system and running an NVIDIA display driver.
|
||||
//!
|
||||
//! The array nvGPUHandle will be filled with physical GPU handle values. The returned
|
||||
//! gpuCount determines how many entries in the array are valid.
|
||||
//!
|
||||
//! \note In drivers older than 105.00, all physical GPU handles get invalidated on a
|
||||
//! modeset. So the calling applications need to renum the handles after every modeset.\n
|
||||
//! With drivers 105.00 and up, all physical GPU handles are constant.
|
||||
//! Physical GPU handles are constant as long as the GPUs are not physically moved and
|
||||
//! the SBIOS VGA order is unchanged.
|
||||
//!
|
||||
//! For GPU handles in TCC MODE please use NvAPI_EnumTCCPhysicalGPUs()
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher, Mac OS X
|
||||
//!
|
||||
//!
|
||||
//! \par Introduced in
|
||||
//! \since Release: 80
|
||||
//!
|
||||
//! \retval NVAPI_INVALID_ARGUMENT nvGPUHandle or pGpuCount is NULL
|
||||
//! \retval NVAPI_OK One or more handles were returned
|
||||
//! \retval NVAPI_NVIDIA_DEVICE_NOT_FOUND No NVIDIA GPU driving a display was found
|
||||
//! \ingroup gpu
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_EnumPhysicalGPUs(NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
|
||||
NV_DECLARE_HANDLE(NVDX_ObjectHandle); // DX Objects
|
||||
static const NVDX_ObjectHandle NVDX_OBJECT_NONE = 0;
|
||||
|
||||
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D_GetObjectHandleForResource
|
||||
//
|
||||
//! DESCRIPTION: This API gets a handle to a resource.
|
||||
//!
|
||||
//! \param [in] pDev The ID3D11Device, ID3D10Device or IDirect3DDevice9 to use
|
||||
//! \param [in] pResource The ID3D10Resource, ID3D10Resource or IDirect3DResource9 from which
|
||||
//! we want the NvAPI handle
|
||||
//! \param [out] pHandle A handle to the resource
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \return ::NVAPI_OK if the handle was populated.
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D_GetObjectHandleForResource(
|
||||
IUnknown *pDevice,
|
||||
IUnknown *pResource,
|
||||
NVDX_ObjectHandle *pHandle);
|
||||
|
||||
|
||||
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
|
||||
#include"nvapi_lite_salend.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,188 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
#pragma pack(push,8)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__))
|
||||
//! \ingroup dx
|
||||
//! D3D_FEATURE_LEVEL supported - used in NvAPI_D3D11_CreateDevice() and NvAPI_D3D11_CreateDeviceAndSwapChain()
|
||||
typedef enum
|
||||
{
|
||||
NVAPI_DEVICE_FEATURE_LEVEL_NULL = -1,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL_10_0 = 0,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL_10_0_PLUS = 1,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL_10_1 = 2,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL_11_0 = 3,
|
||||
} NVAPI_DEVICE_FEATURE_LEVEL;
|
||||
|
||||
#endif //defined(__cplusplus) && (defined(__d3d10_h__) || defined(__d3d10_1_h__) || defined(__d3d11_h__))
|
||||
#if defined(__cplusplus) && defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D11_CreateDevice
|
||||
//
|
||||
//! DESCRIPTION: This function tries to create a DirectX 11 device. If the call fails (if we are running
|
||||
//! on pre-DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR DirectX 10.0+
|
||||
//! OR DirectX 10.0 device. The function call is the same as D3D11CreateDevice(), but with an extra
|
||||
//! argument (D3D_FEATURE_LEVEL supported by the device) that the function fills in. This argument
|
||||
//! can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel is less than DirecX 10.0.
|
||||
//!
|
||||
//! NOTE: When NvAPI_D3D11_CreateDevice is called with 10+ feature level we have an issue on few set of
|
||||
//! tesla hardware (G80/G84/G86/G92/G94/G96) which does not support all feature level 10+ functionality
|
||||
//! e.g. calling driver with mismatch between RenderTarget and Depth Buffer. App developers should
|
||||
//! take into consideration such limitation when using NVAPI on such tesla hardwares.
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \param [in] pAdapter
|
||||
//! \param [in] DriverType
|
||||
//! \param [in] Software
|
||||
//! \param [in] Flags
|
||||
//! \param [in] *pFeatureLevels
|
||||
//! \param [in] FeatureLevels
|
||||
//! \param [in] SDKVersion
|
||||
//! \param [in] **ppDevice
|
||||
//! \param [in] *pFeatureLevel
|
||||
//! \param [in] **ppImmediateContext
|
||||
//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported
|
||||
//!
|
||||
//! \return NVAPI_OK if the createDevice call succeeded.
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D11_CreateDevice(IDXGIAdapter* pAdapter,
|
||||
D3D_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
CONST D3D_FEATURE_LEVEL *pFeatureLevels,
|
||||
UINT FeatureLevels,
|
||||
UINT SDKVersion,
|
||||
ID3D11Device **ppDevice,
|
||||
D3D_FEATURE_LEVEL *pFeatureLevel,
|
||||
ID3D11DeviceContext **ppImmediateContext,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel);
|
||||
|
||||
|
||||
#endif //defined(__cplusplus) && defined(__d3d11_h__)
|
||||
#if defined(__cplusplus) && defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D11_CreateDeviceAndSwapChain
|
||||
//
|
||||
//! DESCRIPTION: This function tries to create a DirectX 11 device and swap chain. If the call fails (if we are
|
||||
//! running on pre=DirectX 11 hardware), depending on the type of hardware it will try to create a DirectX 10.1 OR
|
||||
//! DirectX 10.0+ OR DirectX 10.0 device. The function call is the same as D3D11CreateDeviceAndSwapChain,
|
||||
//! but with an extra argument (D3D_FEATURE_LEVEL supported by the device) that the function fills
|
||||
//! in. This argument can contain -1 (NVAPI_DEVICE_FEATURE_LEVEL_NULL), if the requested featureLevel
|
||||
//! is less than DirectX 10.0.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \param [in] pAdapter
|
||||
//! \param [in] DriverType
|
||||
//! \param [in] Software
|
||||
//! \param [in] Flags
|
||||
//! \param [in] *pFeatureLevels
|
||||
//! \param [in] FeatureLevels
|
||||
//! \param [in] SDKVersion
|
||||
//! \param [in] *pSwapChainDesc
|
||||
//! \param [in] **ppSwapChain
|
||||
//! \param [in] **ppDevice
|
||||
//! \param [in] *pFeatureLevel
|
||||
//! \param [in] **ppImmediateContext
|
||||
//! \param [in] *pSupportedLevel D3D_FEATURE_LEVEL supported
|
||||
//!
|
||||
//!return NVAPI_OK if the createDevice with swap chain call succeeded.
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D11_CreateDeviceAndSwapChain(IDXGIAdapter* pAdapter,
|
||||
D3D_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
CONST D3D_FEATURE_LEVEL *pFeatureLevels,
|
||||
UINT FeatureLevels,
|
||||
UINT SDKVersion,
|
||||
CONST DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
|
||||
IDXGISwapChain **ppSwapChain,
|
||||
ID3D11Device **ppDevice,
|
||||
D3D_FEATURE_LEVEL *pFeatureLevel,
|
||||
ID3D11DeviceContext **ppImmediateContext,
|
||||
NVAPI_DEVICE_FEATURE_LEVEL *pSupportedLevel);
|
||||
|
||||
|
||||
|
||||
#endif //defined(__cplusplus) && defined(__d3d11_h__)
|
||||
#if defined(__cplusplus) && defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D11_SetDepthBoundsTest
|
||||
//
|
||||
//! DESCRIPTION: This function enables/disables the depth bounds test
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [in] pDeviceOrContext The device or device context to set depth bounds test
|
||||
//! \param [in] bEnable Enable(non-zero)/disable(zero) the depth bounds test
|
||||
//! \param [in] fMinDepth The minimum depth for depth bounds test
|
||||
//! \param [in] fMaxDepth The maximum depth for depth bounds test
|
||||
//! The valid values for fMinDepth and fMaxDepth
|
||||
//! are such that 0 <= fMinDepth <= fMaxDepth <= 1
|
||||
//!
|
||||
//! \return ::NVAPI_OK if the depth bounds test was correcly enabled or disabled
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D11_SetDepthBoundsTest(IUnknown* pDeviceOrContext,
|
||||
NvU32 bEnable,
|
||||
float fMinDepth,
|
||||
float fMaxDepth);
|
||||
|
||||
#endif //defined(__cplusplus) && defined(__d3d11_h__)
|
||||
|
||||
#include"nvapi_lite_salend.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,816 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
#ifndef __NVAPI_EMPTY_SAL
|
||||
#ifdef __nvapi_undef__ecount
|
||||
#undef __ecount
|
||||
#undef __nvapi_undef__ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__bcount
|
||||
#undef __bcount
|
||||
#undef __nvapi_undef__bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in
|
||||
#undef __in
|
||||
#undef __nvapi_undef__in
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount
|
||||
#undef __in_ecount
|
||||
#undef __nvapi_undef__in_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount
|
||||
#undef __in_bcount
|
||||
#undef __nvapi_undef__in_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_z
|
||||
#undef __in_z
|
||||
#undef __nvapi_undef__in_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount_z
|
||||
#undef __in_ecount_z
|
||||
#undef __nvapi_undef__in_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount_z
|
||||
#undef __in_bcount_z
|
||||
#undef __nvapi_undef__in_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_nz
|
||||
#undef __in_nz
|
||||
#undef __nvapi_undef__in_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount_nz
|
||||
#undef __in_ecount_nz
|
||||
#undef __nvapi_undef__in_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount_nz
|
||||
#undef __in_bcount_nz
|
||||
#undef __nvapi_undef__in_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out
|
||||
#undef __out
|
||||
#undef __nvapi_undef__out
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount
|
||||
#undef __out_ecount
|
||||
#undef __nvapi_undef__out_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount
|
||||
#undef __out_bcount
|
||||
#undef __nvapi_undef__out_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_part
|
||||
#undef __out_ecount_part
|
||||
#undef __nvapi_undef__out_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_part
|
||||
#undef __out_bcount_part
|
||||
#undef __nvapi_undef__out_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_full
|
||||
#undef __out_ecount_full
|
||||
#undef __nvapi_undef__out_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_full
|
||||
#undef __out_bcount_full
|
||||
#undef __nvapi_undef__out_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_z
|
||||
#undef __out_z
|
||||
#undef __nvapi_undef__out_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_z_opt
|
||||
#undef __out_z_opt
|
||||
#undef __nvapi_undef__out_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_z
|
||||
#undef __out_ecount_z
|
||||
#undef __nvapi_undef__out_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_z
|
||||
#undef __out_bcount_z
|
||||
#undef __nvapi_undef__out_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_part_z
|
||||
#undef __out_ecount_part_z
|
||||
#undef __nvapi_undef__out_ecount_part_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_part_z
|
||||
#undef __out_bcount_part_z
|
||||
#undef __nvapi_undef__out_bcount_part_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_full_z
|
||||
#undef __out_ecount_full_z
|
||||
#undef __nvapi_undef__out_ecount_full_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_full_z
|
||||
#undef __out_bcount_full_z
|
||||
#undef __nvapi_undef__out_bcount_full_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_nz
|
||||
#undef __out_nz
|
||||
#undef __nvapi_undef__out_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_nz_opt
|
||||
#undef __out_nz_opt
|
||||
#undef __nvapi_undef__out_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_nz
|
||||
#undef __out_ecount_nz
|
||||
#undef __nvapi_undef__out_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_nz
|
||||
#undef __out_bcount_nz
|
||||
#undef __nvapi_undef__out_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout
|
||||
#undef __inout
|
||||
#undef __nvapi_undef__inout
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount
|
||||
#undef __inout_ecount
|
||||
#undef __nvapi_undef__inout_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount
|
||||
#undef __inout_bcount
|
||||
#undef __nvapi_undef__inout_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_part
|
||||
#undef __inout_ecount_part
|
||||
#undef __nvapi_undef__inout_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_part
|
||||
#undef __inout_bcount_part
|
||||
#undef __nvapi_undef__inout_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_full
|
||||
#undef __inout_ecount_full
|
||||
#undef __nvapi_undef__inout_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_full
|
||||
#undef __inout_bcount_full
|
||||
#undef __nvapi_undef__inout_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_z
|
||||
#undef __inout_z
|
||||
#undef __nvapi_undef__inout_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_z
|
||||
#undef __inout_ecount_z
|
||||
#undef __nvapi_undef__inout_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_z
|
||||
#undef __inout_bcount_z
|
||||
#undef __nvapi_undef__inout_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_nz
|
||||
#undef __inout_nz
|
||||
#undef __nvapi_undef__inout_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_nz
|
||||
#undef __inout_ecount_nz
|
||||
#undef __nvapi_undef__inout_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_nz
|
||||
#undef __inout_bcount_nz
|
||||
#undef __nvapi_undef__inout_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__ecount_opt
|
||||
#undef __ecount_opt
|
||||
#undef __nvapi_undef__ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__bcount_opt
|
||||
#undef __bcount_opt
|
||||
#undef __nvapi_undef__bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_opt
|
||||
#undef __in_opt
|
||||
#undef __nvapi_undef__in_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount_opt
|
||||
#undef __in_ecount_opt
|
||||
#undef __nvapi_undef__in_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount_opt
|
||||
#undef __in_bcount_opt
|
||||
#undef __nvapi_undef__in_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_z_opt
|
||||
#undef __in_z_opt
|
||||
#undef __nvapi_undef__in_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount_z_opt
|
||||
#undef __in_ecount_z_opt
|
||||
#undef __nvapi_undef__in_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount_z_opt
|
||||
#undef __in_bcount_z_opt
|
||||
#undef __nvapi_undef__in_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_nz_opt
|
||||
#undef __in_nz_opt
|
||||
#undef __nvapi_undef__in_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_ecount_nz_opt
|
||||
#undef __in_ecount_nz_opt
|
||||
#undef __nvapi_undef__in_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__in_bcount_nz_opt
|
||||
#undef __in_bcount_nz_opt
|
||||
#undef __nvapi_undef__in_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_opt
|
||||
#undef __out_opt
|
||||
#undef __nvapi_undef__out_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_opt
|
||||
#undef __out_ecount_opt
|
||||
#undef __nvapi_undef__out_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_opt
|
||||
#undef __out_bcount_opt
|
||||
#undef __nvapi_undef__out_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_part_opt
|
||||
#undef __out_ecount_part_opt
|
||||
#undef __nvapi_undef__out_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_part_opt
|
||||
#undef __out_bcount_part_opt
|
||||
#undef __nvapi_undef__out_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_full_opt
|
||||
#undef __out_ecount_full_opt
|
||||
#undef __nvapi_undef__out_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_full_opt
|
||||
#undef __out_bcount_full_opt
|
||||
#undef __nvapi_undef__out_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_z_opt
|
||||
#undef __out_ecount_z_opt
|
||||
#undef __nvapi_undef__out_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_z_opt
|
||||
#undef __out_bcount_z_opt
|
||||
#undef __nvapi_undef__out_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_part_z_opt
|
||||
#undef __out_ecount_part_z_opt
|
||||
#undef __nvapi_undef__out_ecount_part_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_part_z_opt
|
||||
#undef __out_bcount_part_z_opt
|
||||
#undef __nvapi_undef__out_bcount_part_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_full_z_opt
|
||||
#undef __out_ecount_full_z_opt
|
||||
#undef __nvapi_undef__out_ecount_full_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_full_z_opt
|
||||
#undef __out_bcount_full_z_opt
|
||||
#undef __nvapi_undef__out_bcount_full_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_ecount_nz_opt
|
||||
#undef __out_ecount_nz_opt
|
||||
#undef __nvapi_undef__out_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__out_bcount_nz_opt
|
||||
#undef __out_bcount_nz_opt
|
||||
#undef __nvapi_undef__out_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_opt
|
||||
#undef __inout_opt
|
||||
#undef __nvapi_undef__inout_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_opt
|
||||
#undef __inout_ecount_opt
|
||||
#undef __nvapi_undef__inout_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_opt
|
||||
#undef __inout_bcount_opt
|
||||
#undef __nvapi_undef__inout_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_part_opt
|
||||
#undef __inout_ecount_part_opt
|
||||
#undef __nvapi_undef__inout_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_part_opt
|
||||
#undef __inout_bcount_part_opt
|
||||
#undef __nvapi_undef__inout_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_full_opt
|
||||
#undef __inout_ecount_full_opt
|
||||
#undef __nvapi_undef__inout_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_full_opt
|
||||
#undef __inout_bcount_full_opt
|
||||
#undef __nvapi_undef__inout_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_z_opt
|
||||
#undef __inout_z_opt
|
||||
#undef __nvapi_undef__inout_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_z_opt
|
||||
#undef __inout_ecount_z_opt
|
||||
#undef __nvapi_undef__inout_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_z_opt
|
||||
#undef __inout_ecount_z_opt
|
||||
#undef __nvapi_undef__inout_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_z_opt
|
||||
#undef __inout_bcount_z_opt
|
||||
#undef __nvapi_undef__inout_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_nz_opt
|
||||
#undef __inout_nz_opt
|
||||
#undef __nvapi_undef__inout_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_ecount_nz_opt
|
||||
#undef __inout_ecount_nz_opt
|
||||
#undef __nvapi_undef__inout_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__inout_bcount_nz_opt
|
||||
#undef __inout_bcount_nz_opt
|
||||
#undef __nvapi_undef__inout_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_ecount
|
||||
#undef __deref_ecount
|
||||
#undef __nvapi_undef__deref_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_bcount
|
||||
#undef __deref_bcount
|
||||
#undef __nvapi_undef__deref_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out
|
||||
#undef __deref_out
|
||||
#undef __nvapi_undef__deref_out
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount
|
||||
#undef __deref_out_ecount
|
||||
#undef __nvapi_undef__deref_out_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount
|
||||
#undef __deref_out_bcount
|
||||
#undef __nvapi_undef__deref_out_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_part
|
||||
#undef __deref_out_ecount_part
|
||||
#undef __nvapi_undef__deref_out_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_part
|
||||
#undef __deref_out_bcount_part
|
||||
#undef __nvapi_undef__deref_out_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_full
|
||||
#undef __deref_out_ecount_full
|
||||
#undef __nvapi_undef__deref_out_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_full
|
||||
#undef __deref_out_bcount_full
|
||||
#undef __nvapi_undef__deref_out_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_z
|
||||
#undef __deref_out_z
|
||||
#undef __nvapi_undef__deref_out_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_z
|
||||
#undef __deref_out_ecount_z
|
||||
#undef __nvapi_undef__deref_out_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_z
|
||||
#undef __deref_out_bcount_z
|
||||
#undef __nvapi_undef__deref_out_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_nz
|
||||
#undef __deref_out_nz
|
||||
#undef __nvapi_undef__deref_out_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_nz
|
||||
#undef __deref_out_ecount_nz
|
||||
#undef __nvapi_undef__deref_out_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_nz
|
||||
#undef __deref_out_bcount_nz
|
||||
#undef __nvapi_undef__deref_out_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout
|
||||
#undef __deref_inout
|
||||
#undef __nvapi_undef__deref_inout
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_z
|
||||
#undef __deref_inout_z
|
||||
#undef __nvapi_undef__deref_inout_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount
|
||||
#undef __deref_inout_ecount
|
||||
#undef __nvapi_undef__deref_inout_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount
|
||||
#undef __deref_inout_bcount
|
||||
#undef __nvapi_undef__deref_inout_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_part
|
||||
#undef __deref_inout_ecount_part
|
||||
#undef __nvapi_undef__deref_inout_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_part
|
||||
#undef __deref_inout_bcount_part
|
||||
#undef __nvapi_undef__deref_inout_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_full
|
||||
#undef __deref_inout_ecount_full
|
||||
#undef __nvapi_undef__deref_inout_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_full
|
||||
#undef __deref_inout_bcount_full
|
||||
#undef __nvapi_undef__deref_inout_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_z
|
||||
#undef __deref_inout_z
|
||||
#undef __nvapi_undef__deref_inout_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_z
|
||||
#undef __deref_inout_ecount_z
|
||||
#undef __nvapi_undef__deref_inout_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_z
|
||||
#undef __deref_inout_bcount_z
|
||||
#undef __nvapi_undef__deref_inout_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_nz
|
||||
#undef __deref_inout_nz
|
||||
#undef __nvapi_undef__deref_inout_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_nz
|
||||
#undef __deref_inout_ecount_nz
|
||||
#undef __nvapi_undef__deref_inout_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_nz
|
||||
#undef __deref_inout_bcount_nz
|
||||
#undef __nvapi_undef__deref_inout_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_ecount_opt
|
||||
#undef __deref_ecount_opt
|
||||
#undef __nvapi_undef__deref_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_bcount_opt
|
||||
#undef __deref_bcount_opt
|
||||
#undef __nvapi_undef__deref_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_opt
|
||||
#undef __deref_out_opt
|
||||
#undef __nvapi_undef__deref_out_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_opt
|
||||
#undef __deref_out_ecount_opt
|
||||
#undef __nvapi_undef__deref_out_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_opt
|
||||
#undef __deref_out_bcount_opt
|
||||
#undef __nvapi_undef__deref_out_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_part_opt
|
||||
#undef __deref_out_ecount_part_opt
|
||||
#undef __nvapi_undef__deref_out_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_part_opt
|
||||
#undef __deref_out_bcount_part_opt
|
||||
#undef __nvapi_undef__deref_out_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_full_opt
|
||||
#undef __deref_out_ecount_full_opt
|
||||
#undef __nvapi_undef__deref_out_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_full_opt
|
||||
#undef __deref_out_bcount_full_opt
|
||||
#undef __nvapi_undef__deref_out_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_z_opt
|
||||
#undef __deref_out_z_opt
|
||||
#undef __nvapi_undef__deref_out_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_z_opt
|
||||
#undef __deref_out_ecount_z_opt
|
||||
#undef __nvapi_undef__deref_out_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_z_opt
|
||||
#undef __deref_out_bcount_z_opt
|
||||
#undef __nvapi_undef__deref_out_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_nz_opt
|
||||
#undef __deref_out_nz_opt
|
||||
#undef __nvapi_undef__deref_out_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_ecount_nz_opt
|
||||
#undef __deref_out_ecount_nz_opt
|
||||
#undef __nvapi_undef__deref_out_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_out_bcount_nz_opt
|
||||
#undef __deref_out_bcount_nz_opt
|
||||
#undef __nvapi_undef__deref_out_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_opt
|
||||
#undef __deref_inout_opt
|
||||
#undef __nvapi_undef__deref_inout_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_opt
|
||||
#undef __deref_inout_ecount_opt
|
||||
#undef __nvapi_undef__deref_inout_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_opt
|
||||
#undef __deref_inout_bcount_opt
|
||||
#undef __nvapi_undef__deref_inout_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_part_opt
|
||||
#undef __deref_inout_ecount_part_opt
|
||||
#undef __nvapi_undef__deref_inout_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_part_opt
|
||||
#undef __deref_inout_bcount_part_opt
|
||||
#undef __nvapi_undef__deref_inout_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_full_opt
|
||||
#undef __deref_inout_ecount_full_opt
|
||||
#undef __nvapi_undef__deref_inout_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_full_opt
|
||||
#undef __deref_inout_bcount_full_opt
|
||||
#undef __nvapi_undef__deref_inout_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_z_opt
|
||||
#undef __deref_inout_z_opt
|
||||
#undef __nvapi_undef__deref_inout_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_z_opt
|
||||
#undef __deref_inout_ecount_z_opt
|
||||
#undef __nvapi_undef__deref_inout_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_z_opt
|
||||
#undef __deref_inout_bcount_z_opt
|
||||
#undef __nvapi_undef__deref_inout_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_nz_opt
|
||||
#undef __deref_inout_nz_opt
|
||||
#undef __nvapi_undef__deref_inout_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_ecount_nz_opt
|
||||
#undef __deref_inout_ecount_nz_opt
|
||||
#undef __nvapi_undef__deref_inout_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_inout_bcount_nz_opt
|
||||
#undef __deref_inout_bcount_nz_opt
|
||||
#undef __nvapi_undef__deref_inout_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_ecount
|
||||
#undef __deref_opt_ecount
|
||||
#undef __nvapi_undef__deref_opt_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_bcount
|
||||
#undef __deref_opt_bcount
|
||||
#undef __nvapi_undef__deref_opt_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out
|
||||
#undef __deref_opt_out
|
||||
#undef __nvapi_undef__deref_opt_out
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_z
|
||||
#undef __deref_opt_out_z
|
||||
#undef __nvapi_undef__deref_opt_out_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount
|
||||
#undef __deref_opt_out_ecount
|
||||
#undef __nvapi_undef__deref_opt_out_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount
|
||||
#undef __deref_opt_out_bcount
|
||||
#undef __nvapi_undef__deref_opt_out_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_part
|
||||
#undef __deref_opt_out_ecount_part
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_part
|
||||
#undef __deref_opt_out_bcount_part
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_full
|
||||
#undef __deref_opt_out_ecount_full
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_full
|
||||
#undef __deref_opt_out_bcount_full
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout
|
||||
#undef __deref_opt_inout
|
||||
#undef __nvapi_undef__deref_opt_inout
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount
|
||||
#undef __deref_opt_inout_ecount
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount
|
||||
#undef __deref_opt_inout_bcount
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_part
|
||||
#undef __deref_opt_inout_ecount_part
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_part
|
||||
#undef __deref_opt_inout_bcount_part
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_part
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_full
|
||||
#undef __deref_opt_inout_ecount_full
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_full
|
||||
#undef __deref_opt_inout_bcount_full
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_full
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_z
|
||||
#undef __deref_opt_inout_z
|
||||
#undef __nvapi_undef__deref_opt_inout_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_z
|
||||
#undef __deref_opt_inout_ecount_z
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_z
|
||||
#undef __deref_opt_inout_bcount_z
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_z
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_nz
|
||||
#undef __deref_opt_inout_nz
|
||||
#undef __nvapi_undef__deref_opt_inout_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_nz
|
||||
#undef __deref_opt_inout_ecount_nz
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_nz
|
||||
#undef __deref_opt_inout_bcount_nz
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_nz
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_ecount_opt
|
||||
#undef __deref_opt_ecount_opt
|
||||
#undef __nvapi_undef__deref_opt_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_bcount_opt
|
||||
#undef __deref_opt_bcount_opt
|
||||
#undef __nvapi_undef__deref_opt_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_opt
|
||||
#undef __deref_opt_out_opt
|
||||
#undef __nvapi_undef__deref_opt_out_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_opt
|
||||
#undef __deref_opt_out_ecount_opt
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_opt
|
||||
#undef __deref_opt_out_bcount_opt
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_part_opt
|
||||
#undef __deref_opt_out_ecount_part_opt
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_part_opt
|
||||
#undef __deref_opt_out_bcount_part_opt
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_full_opt
|
||||
#undef __deref_opt_out_ecount_full_opt
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_full_opt
|
||||
#undef __deref_opt_out_bcount_full_opt
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_z_opt
|
||||
#undef __deref_opt_out_z_opt
|
||||
#undef __nvapi_undef__deref_opt_out_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_z_opt
|
||||
#undef __deref_opt_out_ecount_z_opt
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_z_opt
|
||||
#undef __deref_opt_out_bcount_z_opt
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_nz_opt
|
||||
#undef __deref_opt_out_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_out_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_ecount_nz_opt
|
||||
#undef __deref_opt_out_ecount_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_out_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_out_bcount_nz_opt
|
||||
#undef __deref_opt_out_bcount_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_out_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_opt
|
||||
#undef __deref_opt_inout_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_opt
|
||||
#undef __deref_opt_inout_ecount_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_opt
|
||||
#undef __deref_opt_inout_bcount_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_part_opt
|
||||
#undef __deref_opt_inout_ecount_part_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_part_opt
|
||||
#undef __deref_opt_inout_bcount_part_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_part_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_full_opt
|
||||
#undef __deref_opt_inout_ecount_full_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_full_opt
|
||||
#undef __deref_opt_inout_bcount_full_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_full_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_z_opt
|
||||
#undef __deref_opt_inout_z_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_z_opt
|
||||
#undef __deref_opt_inout_ecount_z_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_z_opt
|
||||
#undef __deref_opt_inout_bcount_z_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_z_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_nz_opt
|
||||
#undef __deref_opt_inout_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_ecount_nz_opt
|
||||
#undef __deref_opt_inout_ecount_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_ecount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_undef__deref_opt_inout_bcount_nz_opt
|
||||
#undef __deref_opt_inout_bcount_nz_opt
|
||||
#undef __nvapi_undef__deref_opt_inout_bcount_nz_opt
|
||||
#endif
|
||||
#ifdef __nvapi_success
|
||||
#undef __success
|
||||
#undef __nvapi_success
|
||||
#endif
|
||||
#ifdef __nvapi__Ret_notnull_
|
||||
#undef __nvapi__Ret_notnull_
|
||||
#undef _Ret_notnull_
|
||||
#endif
|
||||
#ifdef __nvapi__Post_writable_byte_size_
|
||||
#undef __nvapi__Post_writable_byte_size_
|
||||
#undef _Post_writable_byte_size_
|
||||
#endif
|
||||
#ifdef __nvapi_Outptr_
|
||||
#undef __nvapi_Outptr_
|
||||
#undef _Outptr_
|
||||
#endif
|
||||
|
||||
#endif // __NVAPI_EMPTY_SAL
|
||||
@@ -0,0 +1,821 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
// ====================================================
|
||||
// SAL related support
|
||||
// ====================================================
|
||||
|
||||
#ifndef __ecount
|
||||
#define __nvapi_undef__ecount
|
||||
#define __ecount(size)
|
||||
#endif
|
||||
#ifndef __bcount
|
||||
#define __nvapi_undef__bcount
|
||||
#define __bcount(size)
|
||||
#endif
|
||||
#ifndef __in
|
||||
#define __nvapi_undef__in
|
||||
#define __in
|
||||
#endif
|
||||
#ifndef __in_ecount
|
||||
#define __nvapi_undef__in_ecount
|
||||
#define __in_ecount(size)
|
||||
#endif
|
||||
#ifndef __in_bcount
|
||||
#define __nvapi_undef__in_bcount
|
||||
#define __in_bcount(size)
|
||||
#endif
|
||||
#ifndef __in_z
|
||||
#define __nvapi_undef__in_z
|
||||
#define __in_z
|
||||
#endif
|
||||
#ifndef __in_ecount_z
|
||||
#define __nvapi_undef__in_ecount_z
|
||||
#define __in_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __in_bcount_z
|
||||
#define __nvapi_undef__in_bcount_z
|
||||
#define __in_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __in_nz
|
||||
#define __nvapi_undef__in_nz
|
||||
#define __in_nz
|
||||
#endif
|
||||
#ifndef __in_ecount_nz
|
||||
#define __nvapi_undef__in_ecount_nz
|
||||
#define __in_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __in_bcount_nz
|
||||
#define __nvapi_undef__in_bcount_nz
|
||||
#define __in_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __out
|
||||
#define __nvapi_undef__out
|
||||
#define __out
|
||||
#endif
|
||||
#ifndef __out_ecount
|
||||
#define __nvapi_undef__out_ecount
|
||||
#define __out_ecount(size)
|
||||
#endif
|
||||
#ifndef __out_bcount
|
||||
#define __nvapi_undef__out_bcount
|
||||
#define __out_bcount(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_part
|
||||
#define __nvapi_undef__out_ecount_part
|
||||
#define __out_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __out_bcount_part
|
||||
#define __nvapi_undef__out_bcount_part
|
||||
#define __out_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __out_ecount_full
|
||||
#define __nvapi_undef__out_ecount_full
|
||||
#define __out_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_full
|
||||
#define __nvapi_undef__out_bcount_full
|
||||
#define __out_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __out_z
|
||||
#define __nvapi_undef__out_z
|
||||
#define __out_z
|
||||
#endif
|
||||
#ifndef __out_z_opt
|
||||
#define __nvapi_undef__out_z_opt
|
||||
#define __out_z_opt
|
||||
#endif
|
||||
#ifndef __out_ecount_z
|
||||
#define __nvapi_undef__out_ecount_z
|
||||
#define __out_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_z
|
||||
#define __nvapi_undef__out_bcount_z
|
||||
#define __out_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_part_z
|
||||
#define __nvapi_undef__out_ecount_part_z
|
||||
#define __out_ecount_part_z(size,length)
|
||||
#endif
|
||||
#ifndef __out_bcount_part_z
|
||||
#define __nvapi_undef__out_bcount_part_z
|
||||
#define __out_bcount_part_z(size,length)
|
||||
#endif
|
||||
#ifndef __out_ecount_full_z
|
||||
#define __nvapi_undef__out_ecount_full_z
|
||||
#define __out_ecount_full_z(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_full_z
|
||||
#define __nvapi_undef__out_bcount_full_z
|
||||
#define __out_bcount_full_z(size)
|
||||
#endif
|
||||
#ifndef __out_nz
|
||||
#define __nvapi_undef__out_nz
|
||||
#define __out_nz
|
||||
#endif
|
||||
#ifndef __out_nz_opt
|
||||
#define __nvapi_undef__out_nz_opt
|
||||
#define __out_nz_opt
|
||||
#endif
|
||||
#ifndef __out_ecount_nz
|
||||
#define __nvapi_undef__out_ecount_nz
|
||||
#define __out_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_nz
|
||||
#define __nvapi_undef__out_bcount_nz
|
||||
#define __out_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __inout
|
||||
#define __nvapi_undef__inout
|
||||
#define __inout
|
||||
#endif
|
||||
#ifndef __inout_ecount
|
||||
#define __nvapi_undef__inout_ecount
|
||||
#define __inout_ecount(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount
|
||||
#define __nvapi_undef__inout_bcount
|
||||
#define __inout_bcount(size)
|
||||
#endif
|
||||
#ifndef __inout_ecount_part
|
||||
#define __nvapi_undef__inout_ecount_part
|
||||
#define __inout_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __inout_bcount_part
|
||||
#define __nvapi_undef__inout_bcount_part
|
||||
#define __inout_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __inout_ecount_full
|
||||
#define __nvapi_undef__inout_ecount_full
|
||||
#define __inout_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_full
|
||||
#define __nvapi_undef__inout_bcount_full
|
||||
#define __inout_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __inout_z
|
||||
#define __nvapi_undef__inout_z
|
||||
#define __inout_z
|
||||
#endif
|
||||
#ifndef __inout_ecount_z
|
||||
#define __nvapi_undef__inout_ecount_z
|
||||
#define __inout_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_z
|
||||
#define __nvapi_undef__inout_bcount_z
|
||||
#define __inout_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __inout_nz
|
||||
#define __nvapi_undef__inout_nz
|
||||
#define __inout_nz
|
||||
#endif
|
||||
#ifndef __inout_ecount_nz
|
||||
#define __nvapi_undef__inout_ecount_nz
|
||||
#define __inout_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_nz
|
||||
#define __nvapi_undef__inout_bcount_nz
|
||||
#define __inout_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __ecount_opt
|
||||
#define __nvapi_undef__ecount_opt
|
||||
#define __ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __bcount_opt
|
||||
#define __nvapi_undef__bcount_opt
|
||||
#define __bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __in_opt
|
||||
#define __nvapi_undef__in_opt
|
||||
#define __in_opt
|
||||
#endif
|
||||
#ifndef __in_ecount_opt
|
||||
#define __nvapi_undef__in_ecount_opt
|
||||
#define __in_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __in_bcount_opt
|
||||
#define __nvapi_undef__in_bcount_opt
|
||||
#define __in_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __in_z_opt
|
||||
#define __nvapi_undef__in_z_opt
|
||||
#define __in_z_opt
|
||||
#endif
|
||||
#ifndef __in_ecount_z_opt
|
||||
#define __nvapi_undef__in_ecount_z_opt
|
||||
#define __in_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __in_bcount_z_opt
|
||||
#define __nvapi_undef__in_bcount_z_opt
|
||||
#define __in_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __in_nz_opt
|
||||
#define __nvapi_undef__in_nz_opt
|
||||
#define __in_nz_opt
|
||||
#endif
|
||||
#ifndef __in_ecount_nz_opt
|
||||
#define __nvapi_undef__in_ecount_nz_opt
|
||||
#define __in_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __in_bcount_nz_opt
|
||||
#define __nvapi_undef__in_bcount_nz_opt
|
||||
#define __in_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __out_opt
|
||||
#define __nvapi_undef__out_opt
|
||||
#define __out_opt
|
||||
#endif
|
||||
#ifndef __out_ecount_opt
|
||||
#define __nvapi_undef__out_ecount_opt
|
||||
#define __out_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_opt
|
||||
#define __nvapi_undef__out_bcount_opt
|
||||
#define __out_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_part_opt
|
||||
#define __nvapi_undef__out_ecount_part_opt
|
||||
#define __out_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __out_bcount_part_opt
|
||||
#define __nvapi_undef__out_bcount_part_opt
|
||||
#define __out_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __out_ecount_full_opt
|
||||
#define __nvapi_undef__out_ecount_full_opt
|
||||
#define __out_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_full_opt
|
||||
#define __nvapi_undef__out_bcount_full_opt
|
||||
#define __out_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_z_opt
|
||||
#define __nvapi_undef__out_ecount_z_opt
|
||||
#define __out_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_z_opt
|
||||
#define __nvapi_undef__out_bcount_z_opt
|
||||
#define __out_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_part_z_opt
|
||||
#define __nvapi_undef__out_ecount_part_z_opt
|
||||
#define __out_ecount_part_z_opt(size,length)
|
||||
#endif
|
||||
#ifndef __out_bcount_part_z_opt
|
||||
#define __nvapi_undef__out_bcount_part_z_opt
|
||||
#define __out_bcount_part_z_opt(size,length)
|
||||
#endif
|
||||
#ifndef __out_ecount_full_z_opt
|
||||
#define __nvapi_undef__out_ecount_full_z_opt
|
||||
#define __out_ecount_full_z_opt(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_full_z_opt
|
||||
#define __nvapi_undef__out_bcount_full_z_opt
|
||||
#define __out_bcount_full_z_opt(size)
|
||||
#endif
|
||||
#ifndef __out_ecount_nz_opt
|
||||
#define __nvapi_undef__out_ecount_nz_opt
|
||||
#define __out_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __out_bcount_nz_opt
|
||||
#define __nvapi_undef__out_bcount_nz_opt
|
||||
#define __out_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_opt
|
||||
#define __nvapi_undef__inout_opt
|
||||
#define __inout_opt
|
||||
#endif
|
||||
#ifndef __inout_ecount_opt
|
||||
#define __nvapi_undef__inout_ecount_opt
|
||||
#define __inout_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_opt
|
||||
#define __nvapi_undef__inout_bcount_opt
|
||||
#define __inout_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_ecount_part_opt
|
||||
#define __nvapi_undef__inout_ecount_part_opt
|
||||
#define __inout_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __inout_bcount_part_opt
|
||||
#define __nvapi_undef__inout_bcount_part_opt
|
||||
#define __inout_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __inout_ecount_full_opt
|
||||
#define __nvapi_undef__inout_ecount_full_opt
|
||||
#define __inout_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_full_opt
|
||||
#define __nvapi_undef__inout_bcount_full_opt
|
||||
#define __inout_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_z_opt
|
||||
#define __nvapi_undef__inout_z_opt
|
||||
#define __inout_z_opt
|
||||
#endif
|
||||
#ifndef __inout_ecount_z_opt
|
||||
#define __nvapi_undef__inout_ecount_z_opt
|
||||
#define __inout_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_ecount_z_opt
|
||||
#define __nvapi_undef__inout_ecount_z_opt
|
||||
#define __inout_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_z_opt
|
||||
#define __nvapi_undef__inout_bcount_z_opt
|
||||
#define __inout_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_nz_opt
|
||||
#define __nvapi_undef__inout_nz_opt
|
||||
#define __inout_nz_opt
|
||||
#endif
|
||||
#ifndef __inout_ecount_nz_opt
|
||||
#define __nvapi_undef__inout_ecount_nz_opt
|
||||
#define __inout_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __inout_bcount_nz_opt
|
||||
#define __nvapi_undef__inout_bcount_nz_opt
|
||||
#define __inout_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_ecount
|
||||
#define __nvapi_undef__deref_ecount
|
||||
#define __deref_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_bcount
|
||||
#define __nvapi_undef__deref_bcount
|
||||
#define __deref_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_out
|
||||
#define __nvapi_undef__deref_out
|
||||
#define __deref_out
|
||||
#endif
|
||||
#ifndef __deref_out_ecount
|
||||
#define __nvapi_undef__deref_out_ecount
|
||||
#define __deref_out_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount
|
||||
#define __nvapi_undef__deref_out_bcount
|
||||
#define __deref_out_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_part
|
||||
#define __nvapi_undef__deref_out_ecount_part
|
||||
#define __deref_out_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_part
|
||||
#define __nvapi_undef__deref_out_bcount_part
|
||||
#define __deref_out_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_full
|
||||
#define __nvapi_undef__deref_out_ecount_full
|
||||
#define __deref_out_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_full
|
||||
#define __nvapi_undef__deref_out_bcount_full
|
||||
#define __deref_out_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_out_z
|
||||
#define __nvapi_undef__deref_out_z
|
||||
#define __deref_out_z
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_z
|
||||
#define __nvapi_undef__deref_out_ecount_z
|
||||
#define __deref_out_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_z
|
||||
#define __nvapi_undef__deref_out_bcount_z
|
||||
#define __deref_out_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_out_nz
|
||||
#define __nvapi_undef__deref_out_nz
|
||||
#define __deref_out_nz
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_nz
|
||||
#define __nvapi_undef__deref_out_ecount_nz
|
||||
#define __deref_out_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_nz
|
||||
#define __nvapi_undef__deref_out_bcount_nz
|
||||
#define __deref_out_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_inout
|
||||
#define __nvapi_undef__deref_inout
|
||||
#define __deref_inout
|
||||
#endif
|
||||
#ifndef __deref_inout_z
|
||||
#define __nvapi_undef__deref_inout_z
|
||||
#define __deref_inout_z
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount
|
||||
#define __nvapi_undef__deref_inout_ecount
|
||||
#define __deref_inout_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount
|
||||
#define __nvapi_undef__deref_inout_bcount
|
||||
#define __deref_inout_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_part
|
||||
#define __nvapi_undef__deref_inout_ecount_part
|
||||
#define __deref_inout_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_part
|
||||
#define __nvapi_undef__deref_inout_bcount_part
|
||||
#define __deref_inout_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_full
|
||||
#define __nvapi_undef__deref_inout_ecount_full
|
||||
#define __deref_inout_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_full
|
||||
#define __nvapi_undef__deref_inout_bcount_full
|
||||
#define __deref_inout_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_z
|
||||
#define __nvapi_undef__deref_inout_z
|
||||
#define __deref_inout_z
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_z
|
||||
#define __nvapi_undef__deref_inout_ecount_z
|
||||
#define __deref_inout_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_z
|
||||
#define __nvapi_undef__deref_inout_bcount_z
|
||||
#define __deref_inout_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_nz
|
||||
#define __nvapi_undef__deref_inout_nz
|
||||
#define __deref_inout_nz
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_nz
|
||||
#define __nvapi_undef__deref_inout_ecount_nz
|
||||
#define __deref_inout_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_nz
|
||||
#define __nvapi_undef__deref_inout_bcount_nz
|
||||
#define __deref_inout_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_ecount_opt
|
||||
#define __nvapi_undef__deref_ecount_opt
|
||||
#define __deref_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_bcount_opt
|
||||
#define __nvapi_undef__deref_bcount_opt
|
||||
#define __deref_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_opt
|
||||
#define __nvapi_undef__deref_out_opt
|
||||
#define __deref_out_opt
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_opt
|
||||
#define __nvapi_undef__deref_out_ecount_opt
|
||||
#define __deref_out_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_opt
|
||||
#define __nvapi_undef__deref_out_bcount_opt
|
||||
#define __deref_out_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_part_opt
|
||||
#define __nvapi_undef__deref_out_ecount_part_opt
|
||||
#define __deref_out_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_part_opt
|
||||
#define __nvapi_undef__deref_out_bcount_part_opt
|
||||
#define __deref_out_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_full_opt
|
||||
#define __nvapi_undef__deref_out_ecount_full_opt
|
||||
#define __deref_out_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_full_opt
|
||||
#define __nvapi_undef__deref_out_bcount_full_opt
|
||||
#define __deref_out_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_z_opt
|
||||
#define __nvapi_undef__deref_out_z_opt
|
||||
#define __deref_out_z_opt
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_z_opt
|
||||
#define __nvapi_undef__deref_out_ecount_z_opt
|
||||
#define __deref_out_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_z_opt
|
||||
#define __nvapi_undef__deref_out_bcount_z_opt
|
||||
#define __deref_out_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_nz_opt
|
||||
#define __nvapi_undef__deref_out_nz_opt
|
||||
#define __deref_out_nz_opt
|
||||
#endif
|
||||
#ifndef __deref_out_ecount_nz_opt
|
||||
#define __nvapi_undef__deref_out_ecount_nz_opt
|
||||
#define __deref_out_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_out_bcount_nz_opt
|
||||
#define __nvapi_undef__deref_out_bcount_nz_opt
|
||||
#define __deref_out_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_opt
|
||||
#define __nvapi_undef__deref_inout_opt
|
||||
#define __deref_inout_opt
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_opt
|
||||
#define __nvapi_undef__deref_inout_ecount_opt
|
||||
#define __deref_inout_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_opt
|
||||
#define __nvapi_undef__deref_inout_bcount_opt
|
||||
#define __deref_inout_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_part_opt
|
||||
#define __nvapi_undef__deref_inout_ecount_part_opt
|
||||
#define __deref_inout_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_part_opt
|
||||
#define __nvapi_undef__deref_inout_bcount_part_opt
|
||||
#define __deref_inout_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_full_opt
|
||||
#define __nvapi_undef__deref_inout_ecount_full_opt
|
||||
#define __deref_inout_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_full_opt
|
||||
#define __nvapi_undef__deref_inout_bcount_full_opt
|
||||
#define __deref_inout_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_z_opt
|
||||
#define __nvapi_undef__deref_inout_z_opt
|
||||
#define __deref_inout_z_opt
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_z_opt
|
||||
#define __nvapi_undef__deref_inout_ecount_z_opt
|
||||
#define __deref_inout_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_z_opt
|
||||
#define __nvapi_undef__deref_inout_bcount_z_opt
|
||||
#define __deref_inout_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_nz_opt
|
||||
#define __nvapi_undef__deref_inout_nz_opt
|
||||
#define __deref_inout_nz_opt
|
||||
#endif
|
||||
#ifndef __deref_inout_ecount_nz_opt
|
||||
#define __nvapi_undef__deref_inout_ecount_nz_opt
|
||||
#define __deref_inout_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_inout_bcount_nz_opt
|
||||
#define __nvapi_undef__deref_inout_bcount_nz_opt
|
||||
#define __deref_inout_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_ecount
|
||||
#define __nvapi_undef__deref_opt_ecount
|
||||
#define __deref_opt_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_bcount
|
||||
#define __nvapi_undef__deref_opt_bcount
|
||||
#define __deref_opt_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out
|
||||
#define __nvapi_undef__deref_opt_out
|
||||
#define __deref_opt_out
|
||||
#endif
|
||||
#ifndef __deref_opt_out_z
|
||||
#define __nvapi_undef__deref_opt_out_z
|
||||
#define __deref_opt_out_z
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount
|
||||
#define __nvapi_undef__deref_opt_out_ecount
|
||||
#define __deref_opt_out_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount
|
||||
#define __nvapi_undef__deref_opt_out_bcount
|
||||
#define __deref_opt_out_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_part
|
||||
#define __nvapi_undef__deref_opt_out_ecount_part
|
||||
#define __deref_opt_out_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_part
|
||||
#define __nvapi_undef__deref_opt_out_bcount_part
|
||||
#define __deref_opt_out_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_full
|
||||
#define __nvapi_undef__deref_opt_out_ecount_full
|
||||
#define __deref_opt_out_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_full
|
||||
#define __nvapi_undef__deref_opt_out_bcount_full
|
||||
#define __deref_opt_out_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout
|
||||
#define __nvapi_undef__deref_opt_inout
|
||||
#define __deref_opt_inout
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount
|
||||
#define __nvapi_undef__deref_opt_inout_ecount
|
||||
#define __deref_opt_inout_ecount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount
|
||||
#define __nvapi_undef__deref_opt_inout_bcount
|
||||
#define __deref_opt_inout_bcount(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_part
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_part
|
||||
#define __deref_opt_inout_ecount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_part
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_part
|
||||
#define __deref_opt_inout_bcount_part(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_full
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_full
|
||||
#define __deref_opt_inout_ecount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_full
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_full
|
||||
#define __deref_opt_inout_bcount_full(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_z
|
||||
#define __nvapi_undef__deref_opt_inout_z
|
||||
#define __deref_opt_inout_z
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_z
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_z
|
||||
#define __deref_opt_inout_ecount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_z
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_z
|
||||
#define __deref_opt_inout_bcount_z(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_nz
|
||||
#define __nvapi_undef__deref_opt_inout_nz
|
||||
#define __deref_opt_inout_nz
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_nz
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_nz
|
||||
#define __deref_opt_inout_ecount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_nz
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_nz
|
||||
#define __deref_opt_inout_bcount_nz(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_ecount_opt
|
||||
#define __nvapi_undef__deref_opt_ecount_opt
|
||||
#define __deref_opt_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_bcount_opt
|
||||
#define __nvapi_undef__deref_opt_bcount_opt
|
||||
#define __deref_opt_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_opt
|
||||
#define __nvapi_undef__deref_opt_out_opt
|
||||
#define __deref_opt_out_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_opt
|
||||
#define __nvapi_undef__deref_opt_out_ecount_opt
|
||||
#define __deref_opt_out_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_opt
|
||||
#define __nvapi_undef__deref_opt_out_bcount_opt
|
||||
#define __deref_opt_out_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_part_opt
|
||||
#define __nvapi_undef__deref_opt_out_ecount_part_opt
|
||||
#define __deref_opt_out_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_part_opt
|
||||
#define __nvapi_undef__deref_opt_out_bcount_part_opt
|
||||
#define __deref_opt_out_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_full_opt
|
||||
#define __nvapi_undef__deref_opt_out_ecount_full_opt
|
||||
#define __deref_opt_out_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_full_opt
|
||||
#define __nvapi_undef__deref_opt_out_bcount_full_opt
|
||||
#define __deref_opt_out_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_z_opt
|
||||
#define __nvapi_undef__deref_opt_out_z_opt
|
||||
#define __deref_opt_out_z_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_z_opt
|
||||
#define __nvapi_undef__deref_opt_out_ecount_z_opt
|
||||
#define __deref_opt_out_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_z_opt
|
||||
#define __nvapi_undef__deref_opt_out_bcount_z_opt
|
||||
#define __deref_opt_out_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_nz_opt
|
||||
#define __nvapi_undef__deref_opt_out_nz_opt
|
||||
#define __deref_opt_out_nz_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_out_ecount_nz_opt
|
||||
#define __nvapi_undef__deref_opt_out_ecount_nz_opt
|
||||
#define __deref_opt_out_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_out_bcount_nz_opt
|
||||
#define __nvapi_undef__deref_opt_out_bcount_nz_opt
|
||||
#define __deref_opt_out_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_opt
|
||||
#define __nvapi_undef__deref_opt_inout_opt
|
||||
#define __deref_opt_inout_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_opt
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_opt
|
||||
#define __deref_opt_inout_ecount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_opt
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_opt
|
||||
#define __deref_opt_inout_bcount_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_part_opt
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_part_opt
|
||||
#define __deref_opt_inout_ecount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_part_opt
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_part_opt
|
||||
#define __deref_opt_inout_bcount_part_opt(size,length)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_full_opt
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_full_opt
|
||||
#define __deref_opt_inout_ecount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_full_opt
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_full_opt
|
||||
#define __deref_opt_inout_bcount_full_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_z_opt
|
||||
#define __nvapi_undef__deref_opt_inout_z_opt
|
||||
#define __deref_opt_inout_z_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_z_opt
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_z_opt
|
||||
#define __deref_opt_inout_ecount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_z_opt
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_z_opt
|
||||
#define __deref_opt_inout_bcount_z_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_nz_opt
|
||||
#define __nvapi_undef__deref_opt_inout_nz_opt
|
||||
#define __deref_opt_inout_nz_opt
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_ecount_nz_opt
|
||||
#define __nvapi_undef__deref_opt_inout_ecount_nz_opt
|
||||
#define __deref_opt_inout_ecount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __deref_opt_inout_bcount_nz_opt
|
||||
#define __nvapi_undef__deref_opt_inout_bcount_nz_opt
|
||||
#define __deref_opt_inout_bcount_nz_opt(size)
|
||||
#endif
|
||||
#ifndef __success
|
||||
#define __nvapi_success
|
||||
#define __success(epxr)
|
||||
#endif
|
||||
#ifndef _Ret_notnull_
|
||||
#define __nvapi__Ret_notnull_
|
||||
#define _Ret_notnull_
|
||||
#endif
|
||||
#ifndef _Post_writable_byte_size_
|
||||
#define __nvapi__Post_writable_byte_size_
|
||||
#define _Post_writable_byte_size_(n)
|
||||
#endif
|
||||
#ifndef _Outptr_
|
||||
#define __nvapi_Outptr_
|
||||
#define _Outptr_
|
||||
#endif
|
||||
|
||||
|
||||
#define NVAPI_INTERFACE extern __success(return == NVAPI_OK) NvAPI_Status __cdecl
|
||||
@@ -0,0 +1,225 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
#pragma pack(push,8)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// DirectX APIs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//! \ingroup dx
|
||||
//! Used in NvAPI_D3D10_GetCurrentSLIState(), and NvAPI_D3D_GetCurrentSLIState().
|
||||
typedef struct
|
||||
{
|
||||
NvU32 version; //!< Structure version
|
||||
NvU32 maxNumAFRGroups; //!< [OUT] The maximum possible value of numAFRGroups
|
||||
NvU32 numAFRGroups; //!< [OUT] The number of AFR groups enabled in the system
|
||||
NvU32 currentAFRIndex; //!< [OUT] The AFR group index for the frame currently being rendered
|
||||
NvU32 nextFrameAFRIndex; //!< [OUT] What the AFR group index will be for the next frame (i.e. after calling Present)
|
||||
NvU32 previousFrameAFRIndex; //!< [OUT] The AFR group index that was used for the previous frame (~0 if more than one frame has not been rendered yet)
|
||||
NvU32 bIsCurAFRGroupNew; //!< [OUT] Boolean: Is this frame the first time running on the current AFR group
|
||||
|
||||
} NV_GET_CURRENT_SLI_STATE;
|
||||
|
||||
//! \ingroup dx
|
||||
#define NV_GET_CURRENT_SLI_STATE_VER MAKE_NVAPI_VERSION(NV_GET_CURRENT_SLI_STATE,1)
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D_GetCurrentSLIState
|
||||
//
|
||||
//! DESCRIPTION: This function returns the current SLI state for the specified device. The structure
|
||||
//! contains the number of AFR groups, the current AFR group index,
|
||||
//! and what the AFR group index will be for the next frame. \p
|
||||
//! pDevice can be either a IDirect3DDevice9 or ID3D10Device pointer.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 173
|
||||
//!
|
||||
//! \retval NVAPI_OK Completed request
|
||||
//! \retval NVAPI_ERROR Error occurred
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D_GetCurrentSLIState(IUnknown *pDevice, NV_GET_CURRENT_SLI_STATE *pSliState);
|
||||
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D_SetResourceHint
|
||||
//
|
||||
//! \fn NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj,
|
||||
//! NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory,
|
||||
//! NvU32 dwHintName,
|
||||
//! NvU32 *pdwHintValue)
|
||||
//!
|
||||
//! DESCRIPTION: This is a general purpose function for passing down various resource
|
||||
//! related hints to the driver. Hints are divided into categories
|
||||
//! and types within each category.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \param [in] pDev The ID3D10Device or IDirect3DDevice9 that is a using the resource
|
||||
//! \param [in] obj Previously obtained HV resource handle
|
||||
//! \param [in] dwHintCategory Category of the hints
|
||||
//! \param [in] dwHintName A hint within this category
|
||||
//! \param [in] *pdwHintValue Pointer to location containing hint value
|
||||
//!
|
||||
//! \return an int which could be an NvAPI status or DX HRESULT code
|
||||
//!
|
||||
//! \retval ::NVAPI_OK
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT
|
||||
//! \retval ::NVAPI_INVALID_CALL It is illegal to change a hint dynamically when the resource is already bound.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//! \ingroup dx
|
||||
//! Valid categories for NvAPI_D3D_SetResourceHint()
|
||||
typedef enum _NVAPI_D3D_SETRESOURCEHINT_CATEGORY
|
||||
{
|
||||
NVAPI_D3D_SRH_CATEGORY_SLI = 1
|
||||
} NVAPI_D3D_SETRESOURCEHINT_CATEGORY;
|
||||
|
||||
|
||||
//
|
||||
// NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC:
|
||||
// NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USING:
|
||||
|
||||
|
||||
//! \ingroup dx
|
||||
//! Types of SLI hints; \n
|
||||
//! NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC: Valid values : 0 or 1 \n
|
||||
//! Default value: 0 \n
|
||||
//! Explanation: If the value is 1, the driver will not track any rendering operations that would mark this resource as dirty,
|
||||
//! avoiding any form of synchronization across frames rendered in parallel in multiple GPUs in AFR mode.
|
||||
//!
|
||||
//! NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE: Valid values : 0 or 1 \n
|
||||
//! Default value: 0 \n
|
||||
//! Explanation: If the value is 1, the driver will try to perform operations which involved target resource in broadcast,
|
||||
//! where its possible. Hint is static and must be set before resource starts using.
|
||||
typedef enum _NVAPI_D3D_SETRESOURCEHINT_SLI
|
||||
{
|
||||
NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1,
|
||||
NVAPI_D3D_SRH_SLI_ASK_FOR_BROADCAST_USAGE = 2
|
||||
} NVAPI_D3D_SETRESOURCEHINT_SLI;
|
||||
|
||||
//! \ingroup dx
|
||||
NVAPI_INTERFACE NvAPI_D3D_SetResourceHint(IUnknown *pDev, NVDX_ObjectHandle obj,
|
||||
NVAPI_D3D_SETRESOURCEHINT_CATEGORY dwHintCategory,
|
||||
NvU32 dwHintName,
|
||||
NvU32 *pdwHintValue);
|
||||
#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D_BeginResourceRendering
|
||||
//
|
||||
//! \fn NvAPI_D3D_BeginResourceRendering(IUnknown *pDev, NVDX_ObjectHandle obj, NvU32 Flags)
|
||||
//! DESCRIPTION: This function tells the driver that the resource will begin to receive updates. It must be used in combination with NvAPI_D3D_EndResourceRendering().
|
||||
//! The primary use of this function is allow the driver to initiate early inter-frame synchronization of resources while running in AFR SLI mode.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \param [in] pDev The ID3D10Device or IDirect3DDevice9 that is a using the resource
|
||||
//! \param [in] obj Previously obtained HV resource handle
|
||||
//! \param [in] Flags The flags for functionality applied to resource while being used.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values
|
||||
//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! \ingroup dx
|
||||
//! Used in NvAPI_D3D_BeginResourceRendering().
|
||||
typedef enum _NVAPI_D3D_RESOURCERENDERING_FLAG
|
||||
{
|
||||
NVAPI_D3D_RR_FLAG_DEFAULTS = 0x00000000, //!< All bits set to 0 are defaults.
|
||||
NVAPI_D3D_RR_FLAG_FORCE_DISCARD_CONTENT = 0x00000001, //!< (bit 0) The flag forces to discard previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint
|
||||
NVAPI_D3D_RR_FLAG_FORCE_KEEP_CONTENT = 0x00000002, //!< (bit 1) The flag forces to respect previous content of the resource regardless of the NvApiHints_Sli_Disable_InterframeSync hint
|
||||
NVAPI_D3D_RR_FLAG_MULTI_FRAME = 0x00000004 //!< (bit 2) The flag hints the driver that content will be used for many frames. If not specified then the driver assumes that content is used only on the next frame
|
||||
} NVAPI_D3D_RESOURCERENDERING_FLAG;
|
||||
|
||||
//! \ingroup dx
|
||||
NVAPI_INTERFACE NvAPI_D3D_BeginResourceRendering(IUnknown *pDev, NVDX_ObjectHandle obj, NvU32 Flags);
|
||||
|
||||
#endif //defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_D3D_EndResourceRendering
|
||||
//
|
||||
//! DESCRIPTION: This function tells the driver that the resource is done receiving updates. It must be used in combination with
|
||||
//! NvAPI_D3D_BeginResourceRendering().
|
||||
//! The primary use of this function is allow the driver to initiate early inter-frame syncs of resources while running in AFR SLI mode.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 185
|
||||
//!
|
||||
//! \param [in] pDev The ID3D10Device or IDirect3DDevice9 thatis a using the resource
|
||||
//! \param [in] obj Previously obtained HV resource handle
|
||||
//! \param [in] Flags Reserved, must be zero
|
||||
//
|
||||
//! \retval ::NVAPI_OK Function succeeded, if used properly and driver can initiate proper sync'ing of the resources.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT Bad argument(s) or invalid flag values
|
||||
//! \retval ::NVAPI_INVALID_CALL Mismatched begin/end calls
|
||||
//!
|
||||
//! \ingroup dx
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_D3D_EndResourceRendering(IUnknown *pDev, NVDX_ObjectHandle obj, NvU32 Flags);
|
||||
#endif //if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
|
||||
#include"nvapi_lite_salend.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,600 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
#pragma pack(push,8)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_Enable
|
||||
//
|
||||
//! DESCRIPTION: This APU enables stereo mode in the registry.
|
||||
//! Calls to this function affect the entire system.
|
||||
//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect,
|
||||
//! and will return the appropriate error code.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo is now enabled.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_Enable(void);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_Disable
|
||||
//
|
||||
//! DESCRIPTION: This API disables stereo mode in the registry.
|
||||
//! Calls to this function affect the entire system.
|
||||
//! If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect,
|
||||
//! and will return the appropriate error code.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo is now disabled.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_Disable(void);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_IsEnabled
|
||||
//
|
||||
//! DESCRIPTION: This API checks if stereo mode is enabled in the registry.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [out] pIsStereoEnabled Address where the result of the inquiry will be placed.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Check was sucessfully completed and result reflects current state of stereo availability.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_IsEnabled(NvU8 *pIsStereoEnabled);
|
||||
#if defined(_D3D9_H_) || defined(__d3d10_h__) || defined(__d3d11_h__)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_CreateHandleFromIUnknown
|
||||
//
|
||||
//! DESCRIPTION: This API creates a stereo handle that is used in subsequent calls related to a given device interface.
|
||||
//! This must be called before any other NvAPI_Stereo_ function for that handle.
|
||||
//! Multiple devices can be used at one time using multiple calls to this function (one per each device).
|
||||
//!
|
||||
//! HOW TO USE: After the Direct3D device is created, create the stereo handle.
|
||||
//! On call success:
|
||||
//! -# Use all other NvAPI_Stereo_ functions that have stereo handle as first parameter.
|
||||
//! -# After the device interface that corresponds to the the stereo handle is destroyed,
|
||||
//! the application should call NvAPI_DestroyStereoHandle() for that stereo handle.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] pDevice Pointer to IUnknown interface that is IDirect3DDevice9* in DX9, ID3D10Device*.
|
||||
//! \param [out] pStereoHandle Pointer to the newly created stereo handle.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo handle is created for given device interface.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT Provided device interface is invalid.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_CreateHandleFromIUnknown(IUnknown *pDevice, StereoHandle *pStereoHandle);
|
||||
|
||||
#endif // defined(_D3D9_H_) || defined(__d3d10_h__)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_DestroyHandle
|
||||
//
|
||||
//! DESCRIPTION: This API destroys the stereo handle created with one of the NvAPI_Stereo_CreateHandleFrom() functions.
|
||||
//! This should be called after the device corresponding to the handle has been destroyed.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that is to be destroyed.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo handle is destroyed.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_DestroyHandle(StereoHandle stereoHandle);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_Activate
|
||||
//
|
||||
//! DESCRIPTION: This API activates stereo for the device interface corresponding to the given stereo handle.
|
||||
//! Activating stereo is possible only if stereo was enabled previously in the registry.
|
||||
//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect,
|
||||
//! and will return the appropriate error code.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle corresponding to the device interface.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo is turned on.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_Activate(StereoHandle stereoHandle);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_Deactivate
|
||||
//
|
||||
//! DESCRIPTION: This API deactivates stereo for the given device interface.
|
||||
//! If stereo is not activated, then calls to functions that require that stereo is activated have no effect,
|
||||
//! and will return the appropriate error code.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Stereo is turned off.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_Deactivate(StereoHandle stereoHandle);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_IsActivated
|
||||
//
|
||||
//! DESCRIPTION: This API checks if stereo is activated for the given device interface.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [in] pIsStereoOn Address where result of the inquiry will be placed.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK - Check was sucessfully completed and result reflects current state of stereo (on/off).
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR - Something is wrong (generic error).
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_IsActivated(StereoHandle stereoHandle, NvU8 *pIsStereoOn);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_GetSeparation
|
||||
//
|
||||
//! DESCRIPTION: This API gets current separation value (in percents).
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [out] pSeparationPercentage Address of @c float type variable to store current separation percentage in.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Retrieval of separation percentage was successfull.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_GetSeparation(StereoHandle stereoHandle, float *pSeparationPercentage);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetSeparation
|
||||
//
|
||||
//! DESCRIPTION: This API sets separation to given percentage.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [in] newSeparationPercentage New value for separation percentage.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Setting of separation percentage was successfull.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_PARAMETER_OUT_OF_RANGE Given separation percentage is out of [0..100] range.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetSeparation(StereoHandle stereoHandle, float newSeparationPercentage);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_GetConvergence
|
||||
//
|
||||
//! DESCRIPTION: This API gets the current convergence value.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [out] pConvergence Address of @c float type variable to store current convergence value in.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Retrieval of convergence value was successfull.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_GetConvergence(StereoHandle stereoHandle, float *pConvergence);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetConvergence
|
||||
//
|
||||
//! DESCRIPTION: This API sets convergence to the given value.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for the device interface is created via successfull call to the appropriate NvAPI_Stereo_CreateHandleFrom() function.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \since Release: 180
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [in] newConvergence New value for convergence.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Setting of convergence value was successfull.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetConvergence(StereoHandle stereoHandle, float newConvergence);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetActiveEye
|
||||
//
|
||||
//! \fn NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye);
|
||||
//! DESCRIPTION: This API sets the back buffer to left or right in Direct stereo mode.
|
||||
//!
|
||||
//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate
|
||||
//! NvAPI_Stereo_CreateHandleFrom function.
|
||||
//!
|
||||
//! \since Release: 285
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [in] StereoEye Defines active eye in Direct stereo mode
|
||||
//!
|
||||
//! \retval ::NVAPI_OK - Active eye is set.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE - Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED - NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED - Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT - StereoEye parameter has not allowed value.
|
||||
//! \retval ::NVAPI_SET_NOT_ALLOWED - Current stereo mode is not Direct
|
||||
//! \retval ::NVAPI_ERROR - Something is wrong (generic error).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! \ingroup stereoapi
|
||||
typedef enum _NV_StereoActiveEye
|
||||
{
|
||||
NVAPI_STEREO_EYE_RIGHT = 1,
|
||||
NVAPI_STEREO_EYE_LEFT = 2,
|
||||
NVAPI_STEREO_EYE_MONO = 3,
|
||||
} NV_STEREO_ACTIVE_EYE;
|
||||
|
||||
//! \ingroup stereoapi
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetActiveEye(StereoHandle hStereoHandle, NV_STEREO_ACTIVE_EYE StereoEye);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetDriverMode
|
||||
//
|
||||
//! \fn NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode );
|
||||
//! DESCRIPTION: This API sets the 3D stereo driver mode: Direct or Automatic
|
||||
//!
|
||||
//! HOW TO USE: This API must be called before the device is created.
|
||||
//! Applies to DirectX 9 and higher.
|
||||
//!
|
||||
//! \since Release: 285
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [in] mode Defines the 3D stereo driver mode: Direct or Automatic
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Active eye is set.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT mode parameter has not allowed value.
|
||||
//! \retval ::NVAPI_ERROR Something is wrong (generic error).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! \ingroup stereoapi
|
||||
typedef enum _NV_StereoDriverMode
|
||||
{
|
||||
NVAPI_STEREO_DRIVER_MODE_AUTOMATIC = 0,
|
||||
NVAPI_STEREO_DRIVER_MODE_DIRECT = 2,
|
||||
} NV_STEREO_DRIVER_MODE;
|
||||
|
||||
//! \ingroup stereoapi
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetDriverMode( NV_STEREO_DRIVER_MODE mode );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_GetEyeSeparation
|
||||
//
|
||||
//! DESCRIPTION: This API returns eye separation as a ratio of <between eye distance>/<physical screen width>.
|
||||
//!
|
||||
//! HOW TO USE: After the stereo handle for device interface is created via successfull call to appropriate API. Applies only to DirectX 9 and up.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [in] stereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [out] pSeparation Eye separation.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Active eye is set.
|
||||
//! \retval ::NVAPI_STEREO_INVALID_DEVICE_INTERFACE Device interface is not valid. Create again, then attach again.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR (generic error).
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_GetEyeSeparation(StereoHandle hStereoHandle, float *pSeparation );
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_IsWindowedModeSupported
|
||||
//
|
||||
//! DESCRIPTION: This API returns availability of windowed mode stereo
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! \param [out] bSupported(OUT) != 0 - supported, \n
|
||||
//! == 0 - is not supported
|
||||
//!
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Retrieval of frustum adjust mode was successfull.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED NVAPI not initialized.
|
||||
//! \retval ::NVAPI_STEREO_NOT_INITIALIZED Stereo part of NVAPI not initialized.
|
||||
//! \retval ::NVAPI_ERROR Something is wrong (generic error).
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_IsWindowedModeSupported(NvU8* bSupported);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetSurfaceCreationMode
|
||||
//
|
||||
//! \function NvAPI_Stereo_SetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE creationMode)
|
||||
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [in] creationMode New surface creation mode for this device interface.
|
||||
//!
|
||||
//! \since Release: 285
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! DESCRIPTION: This API sets surface creation mode for this device interface.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
|
||||
//!
|
||||
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
|
||||
//! There are no return error codes with specific meaning for this API.
|
||||
//!
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! \ingroup stereoapi
|
||||
typedef enum _NVAPI_STEREO_SURFACECREATEMODE
|
||||
{
|
||||
NVAPI_STEREO_SURFACECREATEMODE_AUTO, //!< Use driver registry profile settings for surface creation mode.
|
||||
NVAPI_STEREO_SURFACECREATEMODE_FORCESTEREO, //!< Always create stereo surfaces.
|
||||
NVAPI_STEREO_SURFACECREATEMODE_FORCEMONO //!< Always create mono surfaces.
|
||||
} NVAPI_STEREO_SURFACECREATEMODE;
|
||||
|
||||
//! \ingroup stereoapi
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE creationMode);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_GetSurfaceCreationMode
|
||||
//
|
||||
//! \function NvAPI_Stereo_GetSurfaceCreationMode(StereoHandle hStereoHandle, NVAPI_STEREO_SURFACECREATEMODE* pCreationMode)
|
||||
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [out] pCreationMode The current creation mode for this device interface.
|
||||
//!
|
||||
//! \since Release: 295
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! DESCRIPTION: This API gets surface creation mode for this device interface.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
|
||||
//!
|
||||
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
|
||||
//! There are no return error codes with specific meaning for this API.
|
||||
//!
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! \ingroup stereoapi
|
||||
NVAPI_INTERFACE NvAPI_Stereo_GetSurfaceCreationMode(__in StereoHandle hStereoHandle, __in NVAPI_STEREO_SURFACECREATEMODE* pCreationMode);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_Debug_WasLastDrawStereoized
|
||||
//
|
||||
//! \param [in] hStereoHandle Stereo handle that corresponds to the device interface.
|
||||
//! \param [out] pWasStereoized Address where result of the inquiry will be placed.
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! DESCRIPTION: This API checks if the last draw call was stereoized. It is a very expensive to call and should be used for debugging purpose *only*.
|
||||
//!
|
||||
//! WHEN TO USE: After the stereo handle for device interface is created via successful call to appropriate NvAPI_Stereo_CreateHandleFrom function.
|
||||
//!
|
||||
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
|
||||
//! There are no return error codes with specific meaning for this API.
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_Debug_WasLastDrawStereoized(__in StereoHandle hStereoHandle, __out NvU8 *pWasStereoized);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_SetDefaultProfile
|
||||
//
|
||||
//!
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! DESCRIPTION: This API defines the stereo profile used by the driver in case the application has no associated profile.
|
||||
//!
|
||||
//! WHEN TO USE: To take effect, this API must be called before D3D device is created. Calling once a device has been created will not affect the current device.
|
||||
//!
|
||||
//! \param [in] szProfileName Default profile name.
|
||||
//!
|
||||
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
|
||||
//! Error codes specific to this API are described below.
|
||||
//!
|
||||
//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName.
|
||||
//! \retval NVAPI_INVALID_ARGUMENT - szProfileName == NULL.
|
||||
//! \retval NVAPI_DEFAULT_STEREO_PROFILE_DOES_NOT_EXIST - Default stereo profile does not exist
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_SetDefaultProfile(__in const char* szProfileName);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Stereo_GetDefaultProfile
|
||||
//
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
//!
|
||||
//! DESCRIPTION: This API retrieves the current default stereo profile.
|
||||
//!
|
||||
//! After call cbSizeOut contain 0 if default profile is not set required buffer size cbSizeOut.
|
||||
//! To get needed buffer size this function can be called with szProfileName==0 and cbSizeIn == 0.
|
||||
//!
|
||||
//! WHEN TO USE: This API can be called at any time.
|
||||
//!
|
||||
//!
|
||||
//! \param [in] cbSizeIn Size of buffer allocated for default stereo profile name.
|
||||
//! \param [out] szProfileName Default stereo profile name.
|
||||
//! \param [out] pcbSizeOut Required buffer size.
|
||||
//! # ==0 - there is no default stereo profile name currently set
|
||||
//! # !=0 - size of buffer required for currently set default stereo profile name including trailing '0'.
|
||||
//!
|
||||
//!
|
||||
//! \return This API can return any of the error codes enumerated in #NvAPI_Status.
|
||||
//! Error codes specific to this API are described below.
|
||||
//!
|
||||
//! \retval NVAPI_SUCCESS - Default stereo profile name has been copied into szProfileName.
|
||||
//! \retval NVAPI_DEFAULT_STEREO_PROFILE_IS_NOT_DEFINED - There is no default stereo profile set at this time.
|
||||
//! \retval NVAPI_INVALID_ARGUMENT - pcbSizeOut == 0 or cbSizeIn >= *pcbSizeOut && szProfileName == 0
|
||||
//! \retval NVAPI_INSUFFICIENT_BUFFER - cbSizeIn < *pcbSizeOut
|
||||
//!
|
||||
//! \ingroup stereoapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Stereo_GetDefaultProfile( __in NvU32 cbSizeIn, __out_bcount_part_opt(cbSizeIn, *pcbSizeOut) char* szProfileName, __out NvU32 *pcbSizeOut);
|
||||
|
||||
#include"nvapi_lite_salend.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,105 @@
|
||||
/************************************************************************************************************************************\
|
||||
|* *|
|
||||
|* Copyright © 2012 NVIDIA Corporation. All rights reserved. *|
|
||||
|* *|
|
||||
|* NOTICE TO USER: *|
|
||||
|* *|
|
||||
|* This software is subject to NVIDIA ownership rights under U.S. and international Copyright laws. *|
|
||||
|* *|
|
||||
|* This software and the information contained herein are PROPRIETARY and CONFIDENTIAL to NVIDIA *|
|
||||
|* and are being provided solely under the terms and conditions of an NVIDIA software license agreement. *|
|
||||
|* Otherwise, you have no rights to use or access this software in any manner. *|
|
||||
|* *|
|
||||
|* If not covered by the applicable NVIDIA software license agreement: *|
|
||||
|* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. *|
|
||||
|* IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. *|
|
||||
|* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *|
|
||||
|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. *|
|
||||
|* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, *|
|
||||
|* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, *|
|
||||
|* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
|
||||
|* *|
|
||||
|* U.S. Government End Users. *|
|
||||
|* This software is a "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
|
||||
|* consisting of "commercial computer software" and "commercial computer software documentation" *|
|
||||
|* as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government only as a commercial end item. *|
|
||||
|* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
|
||||
|* all U.S. Government End Users acquire the software with only those rights set forth herein. *|
|
||||
|* *|
|
||||
|* Any use of this software in individual and commercial software must include, *|
|
||||
|* in the user documentation and internal comments to the code, *|
|
||||
|* the above Disclaimer (as applicable) and U.S. Government End Users Notice. *|
|
||||
|* *|
|
||||
\************************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include"nvapi_lite_salstart.h"
|
||||
#include"nvapi_lite_common.h"
|
||||
#pragma pack(push,8)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//! SUPPORTED OS: Windows XP and higher
|
||||
//!
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_DISP_GetGDIPrimaryDisplayId
|
||||
//
|
||||
//! DESCRIPTION: This API returns the Display ID of the GDI Primary.
|
||||
//!
|
||||
//! \param [out] displayId Display ID of the GDI Primary display.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK: Capabilties have been returned.
|
||||
//! \retval ::NVAPI_NVIDIA_DEVICE_NOT_FOUND: GDI Primary not on an NVIDIA GPU.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT: One or more args passed in are invalid.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED: The NvAPI API needs to be initialized first
|
||||
//! \retval ::NVAPI_NO_IMPLEMENTATION: This entrypoint not available
|
||||
//! \retval ::NVAPI_ERROR: Miscellaneous error occurred
|
||||
//!
|
||||
//! \ingroup dispcontrol
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_DISP_GetGDIPrimaryDisplayId(NvU32* displayId);
|
||||
#define NV_MOSAIC_MAX_DISPLAYS (64)
|
||||
//! SUPPORTED OS: Windows Vista and higher
|
||||
//!
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUNCTION NAME: NvAPI_Mosaic_GetDisplayViewportsByResolution
|
||||
//
|
||||
//! DESCRIPTION: This API returns the viewports that would be applied on
|
||||
//! the requested display.
|
||||
//!
|
||||
//! \param [in] displayId Display ID of a single display in the active
|
||||
//! mosaic topology to query.
|
||||
//! \param [in] srcWidth Width of full display topology. If both
|
||||
//! width and height are 0, the current
|
||||
//! resolution is used.
|
||||
//! \param [in] srcHeight Height of full display topology. If both
|
||||
//! width and height are 0, the current
|
||||
//! resolution is used.
|
||||
//! \param [out] viewports Array of NV_RECT viewports which represent
|
||||
//! the displays as identified in
|
||||
//! NvAPI_Mosaic_EnumGridTopologies. If the
|
||||
//! requested resolution is a single-wide
|
||||
//! resolution, only viewports[0] will
|
||||
//! contain the viewport details, regardless
|
||||
//! of which display is driving the display.
|
||||
//! \param [out] bezelCorrected Returns 1 if the requested resolution is
|
||||
//! bezel corrected. May be NULL.
|
||||
//!
|
||||
//! \retval ::NVAPI_OK Capabilties have been returned.
|
||||
//! \retval ::NVAPI_INVALID_ARGUMENT One or more args passed in are invalid.
|
||||
//! \retval ::NVAPI_API_NOT_INTIALIZED The NvAPI API needs to be initialized first
|
||||
//! \retval ::NVAPI_MOSAIC_NOT_ACTIVE The display does not belong to an active Mosaic Topology
|
||||
//! \retval ::NVAPI_NO_IMPLEMENTATION This entrypoint not available
|
||||
//! \retval ::NVAPI_ERROR Miscellaneous error occurred
|
||||
//!
|
||||
//! \ingroup mosaicapi
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
NVAPI_INTERFACE NvAPI_Mosaic_GetDisplayViewportsByResolution(NvU32 displayId, NvU32 srcWidth, NvU32 srcHeight, NV_RECT viewports[NV_MOSAIC_MAX_DISPLAYS], NvU8* bezelCorrected);
|
||||
|
||||
#include"nvapi_lite_salend.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#pragma pack(pop)
|
||||
Binary file not shown.
@@ -37,6 +37,10 @@
|
||||
#if !defined( PTHREAD_H )
|
||||
#define PTHREAD_H
|
||||
|
||||
#if !defined(HAVE_STRUCT_TIMESPEC) && _MSC_VER >= 1900
|
||||
#define HAVE_STRUCT_TIMESPEC
|
||||
#endif
|
||||
|
||||
/*
|
||||
* See the README file for an explanation of the pthreads-win32 version
|
||||
* numbering scheme and how the DLL is named etc.
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Meant to improve clang 4 / macos compatibility (untested)
|
||||
*/
|
||||
|
||||
#ifndef PTHREAD_BARRIER_H_
|
||||
#define PTHREAD_BARRIER_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef int pthread_barrierattr_t;
|
||||
typedef struct
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
int count;
|
||||
int tripCount;
|
||||
} pthread_barrier_t;
|
||||
|
||||
|
||||
int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
|
||||
{
|
||||
if(count == 0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if(pthread_mutex_init(&barrier->mutex, 0) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(pthread_cond_init(&barrier->cond, 0) < 0)
|
||||
{
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return -1;
|
||||
}
|
||||
barrier->tripCount = count;
|
||||
barrier->count = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_barrier_destroy(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_cond_destroy(&barrier->cond);
|
||||
pthread_mutex_destroy(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_barrier_wait(pthread_barrier_t *barrier)
|
||||
{
|
||||
pthread_mutex_lock(&barrier->mutex);
|
||||
++(barrier->count);
|
||||
if(barrier->count >= barrier->tripCount)
|
||||
{
|
||||
barrier->count = 0;
|
||||
pthread_cond_broadcast(&barrier->cond);
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_cond_wait(&barrier->cond, &(barrier->mutex));
|
||||
pthread_mutex_unlock(&barrier->mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PTHREAD_BARRIER_H_
|
||||
@@ -1,662 +0,0 @@
|
||||
#######################################
|
||||
# Thrust v1.7.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust 1.7.0 introduces a new interface for controlling algorithm execution as
|
||||
well as several new algorithms and performance improvements. With this new
|
||||
interface, users may directly control how algorithms execute as well as details
|
||||
such as the allocation of temporary storage. Key/value versions of thrust::merge
|
||||
and the set operation algorithms have been added, as well stencil versions of
|
||||
partitioning algorithms. thrust::tabulate has been introduced to tabulate the
|
||||
values of functions taking integers. For 32b types, new CUDA merge and set
|
||||
operations provide 2-15x faster performance while a new CUDA comparison sort
|
||||
provides 1.3-4x faster performance. Finally, a new TBB reduce_by_key implementation
|
||||
provides 80% faster performance.
|
||||
|
||||
Breaking API Changes
|
||||
Dispatch
|
||||
Custom user backend systems' tag types must now inherit from the corresponding system's execution_policy template (e.g. thrust::cuda::execution_policy) instead
|
||||
of the tag struct (e.g. thrust::cuda::tag). Otherwise, algorithm specializations will silently go unfound during dispatch.
|
||||
See examples/minimal_custom_backend.cu and examples/cuda/fallback_allocator.cu for usage examples.
|
||||
|
||||
thrust::advance and thrust::distance are no longer dispatched based on iterator system type and thus may no longer be customized.
|
||||
|
||||
Iterators
|
||||
iterator_facade and iterator_adaptor's Pointer template parameters have been eliminated.
|
||||
iterator_adaptor has been moved into the thrust namespace (previously thrust::experimental::iterator_adaptor).
|
||||
iterator_facade has been moved into the thrust namespace (previously thrust::experimental::iterator_facade).
|
||||
iterator_core_access has been moved into the thrust namespace (previously thrust::experimental::iterator_core_access).
|
||||
All iterators' nested pointer typedef (the type of the result of operator->) is now void instead of a pointer type to indicate that such expressions are currently impossible.
|
||||
Floating point counting_iterators' nested difference_type typedef is now a signed integral type instead of a floating point type.
|
||||
|
||||
Other
|
||||
normal_distribution has been moved into the thrust::random namespace (previously thrust::random::experimental::normal_distribution).
|
||||
Placeholder expressions may no longer include the comma operator.
|
||||
|
||||
New Features
|
||||
Execution Policies
|
||||
Users may directly control the dispatch of algorithm invocations with optional execution policy arguments.
|
||||
For example, instead of wrapping raw pointers allocated by cudaMalloc with thrust::device_ptr, the thrust::device execution_policy may be passed as an argument to an algorithm invocation to enable CUDA execution.
|
||||
The following execution policies are supported in this version:
|
||||
|
||||
thrust::host
|
||||
thrust::device
|
||||
thrust::cpp::par
|
||||
thrust::cuda::par
|
||||
thrust::omp::par
|
||||
thrust::tbb::par
|
||||
|
||||
Algorithms
|
||||
free
|
||||
get_temporary_buffer
|
||||
malloc
|
||||
merge_by_key
|
||||
partition with stencil
|
||||
partition_copy with stencil
|
||||
return_temporary_buffer
|
||||
set_difference_by_key
|
||||
set_intersection_by_key
|
||||
set_symmetric_difference_by_key
|
||||
set_union_by_key
|
||||
stable_partition with stencil
|
||||
stable_partition_copy with stencil
|
||||
tabulate
|
||||
|
||||
New Examples
|
||||
uninitialized_vector demonstrates how to use a custom allocator to avoid the automatic initialization of elements in thrust::device_vector.
|
||||
|
||||
Other Enhancements
|
||||
Authors of custom backend systems may manipulate arbitrary state during algorithm dispatch by incorporating it into their execution_policy parameter.
|
||||
Users may control the allocation of temporary storage during algorithm execution by passing standard allocators as parameters via execution policies such as thrust::device.
|
||||
THRUST_DEVICE_SYSTEM_CPP has been added as a compile-time target for the device backend.
|
||||
CUDA merge performance is 2-15x faster.
|
||||
CUDA comparison sort performance is 1.3-4x faster.
|
||||
CUDA set operation performance is 1.5-15x faster.
|
||||
TBB reduce_by_key performance is 80% faster.
|
||||
Several algorithms have been parallelized with TBB.
|
||||
Support for user allocators in vectors has been improved.
|
||||
The sparse_vector example is now implemented with merge_by_key instead of sort_by_key.
|
||||
Warnings have been eliminated in various contexts.
|
||||
Warnings about __host__ or __device__-only functions called from __host__ __device__ functions have been eliminated in various contexts.
|
||||
Documentation about algorithm requirements have been improved.
|
||||
Simplified the minimal_custom_backend example.
|
||||
Simplified the cuda/custom_temporary_allocation example.
|
||||
Simplified the cuda/fallback_allocator example.
|
||||
|
||||
Bug Fixes
|
||||
#248 fix broken counting_iterator<float> behavior with OpenMP
|
||||
#231, #209 fix set operation failures with CUDA
|
||||
#187 fix incorrect occupancy calculation with CUDA
|
||||
#153 fix broken multigpu behavior with CUDA
|
||||
#142 eliminate warning produced by thrust::random::taus88 and MSVC 2010
|
||||
#208 correctly initialize elements in temporary storage when necessary
|
||||
#16 fix compilation error when sorting bool with CUDA
|
||||
#10 fix ambiguous overloads of reinterpret_tag
|
||||
|
||||
Known Issues
|
||||
g++ versions 4.3 and lower may fail to dispatch thrust::get_temporary_buffer correctly causing infinite recursion in examples such as cuda/custom_temporary_allocation.
|
||||
|
||||
Acknowledgments
|
||||
Thanks to Sean Baxter, Bryan Catanzaro, and Manjunath Kudlur for contributing a faster merge implementation for CUDA.
|
||||
Thanks to Sean Baxter for contributing a faster set operation implementation for CUDA.
|
||||
Thanks to Cliff Woolley for contributing a correct occupancy calculation algorithm.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.6.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.6.0 provides an interface for customization and extension and a new
|
||||
backend system based on the Threading Building Blocks library. With this
|
||||
new interface, programmers may customize the behavior of specific algorithms
|
||||
as well as control the allocation of temporary storage or invent entirely new
|
||||
backends. These enhancements also allow multiple different backend systems
|
||||
such as CUDA and OpenMP to coexist within a single program. Support for TBB
|
||||
allows Thrust programs to integrate more naturally into applications which
|
||||
may already employ the TBB task scheduler.
|
||||
|
||||
Breaking API Changes
|
||||
The header <thrust/experimental/cuda/pinned_allocator.h> has been moved to <thrust/system/cuda/experimental/pinned_allocator.h>
|
||||
thrust::experimental::cuda::pinned_allocator has been moved to thrust::cuda::experimental::pinned_allocator
|
||||
The macro THRUST_DEVICE_BACKEND has been renamed THRUST_DEVICE_SYSTEM
|
||||
The macro THRUST_DEVICE_BACKEND_CUDA has been renamed THRUST_DEVICE_SYSTEM_CUDA
|
||||
The macro THRUST_DEVICE_BACKEND_OMP has been renamed THRUST_DEVICE_SYSTEM_OMP
|
||||
thrust::host_space_tag has been renamed thrust::host_system_tag
|
||||
thrust::device_space_tag has been renamed thrust::device_system_tag
|
||||
thrust::any_space_tag has been renamed thrust::any_system_tag
|
||||
thrust::iterator_space has been renamed thrust::iterator_system
|
||||
|
||||
|
||||
New Features
|
||||
Backend Systems
|
||||
Threading Building Blocks (TBB) is now supported
|
||||
Functions
|
||||
for_each_n
|
||||
raw_reference_cast
|
||||
Types
|
||||
pointer
|
||||
reference
|
||||
|
||||
New Examples
|
||||
cuda/custom_temporary_allocation
|
||||
cuda/fallback_allocator
|
||||
device_ptr
|
||||
expand
|
||||
minimal_custom_backend
|
||||
raw_reference_cast
|
||||
set_operations
|
||||
|
||||
Other Enhancements
|
||||
thrust::for_each now returns the end of the input range similar to most other algorithms
|
||||
thrust::pair and thrust::tuple have swap functionality
|
||||
all CUDA algorithms now support large data types
|
||||
iterators may be dereferenced in user __device__ or __global__ functions
|
||||
the safe use of different backend systems is now possible within a single binary
|
||||
|
||||
Bug Fixes
|
||||
#469 min_element and max_element algorithms no longer require a const comparison operator
|
||||
|
||||
Known Issues
|
||||
cudafe++.exe may crash when parsing TBB headers on Windows.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.5.3 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Small bug fixes
|
||||
|
||||
Bug Fixes
|
||||
Avoid warnings about potential race due to __shared__ non-POD variable
|
||||
|
||||
#######################################
|
||||
# Thrust v1.5.2 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Small bug fixes
|
||||
|
||||
Bug Fixes
|
||||
Fixed warning about C-style initialization of structures
|
||||
|
||||
#######################################
|
||||
# Thrust v1.5.1 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Small bug fixes
|
||||
|
||||
Bug Fixes
|
||||
Sorting data referenced by permutation_iterators on CUDA produces invalid results
|
||||
|
||||
#######################################
|
||||
# Thrust v1.5.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.5.0 provides introduces new programmer productivity and performance
|
||||
enhancements. New functionality for creating anonymous "lambda" functions has
|
||||
been added. A faster host sort provides 2-10x faster performance for sorting
|
||||
arithmetic types on (single-threaded) CPUs. A new OpenMP sort provides
|
||||
2.5x-3.0x speedup over the host sort using a quad-core CPU. When sorting
|
||||
arithmetic types with the OpenMP backend the combined performance improvement
|
||||
is 5.9x for 32-bit integers and ranges from 3.0x (64-bit types) to 14.2x
|
||||
(8-bit types). A new CUDA reduce_by_key implementation provides 2-3x faster
|
||||
performance.
|
||||
|
||||
Breaking API Changes
|
||||
device_ptr<void> no longer unsafely converts to device_ptr<T> without an
|
||||
explicit cast. Use the expression
|
||||
device_pointer_cast(static_cast<int*>(void_ptr.get()))
|
||||
to convert, for example, device_ptr<void> to device_ptr<int>.
|
||||
|
||||
New Features
|
||||
Functions
|
||||
stencil-less transform_if
|
||||
|
||||
Types
|
||||
lambda placeholders
|
||||
|
||||
New Examples
|
||||
lambda
|
||||
|
||||
Other Enhancements
|
||||
host sort is 2-10x faster for arithmetic types
|
||||
OMP sort provides speedup over host sort
|
||||
reduce_by_key is 2-3x faster
|
||||
reduce_by_key no longer requires O(N) temporary storage
|
||||
CUDA scan algorithms are 10-40% faster
|
||||
host_vector and device_vector are now documented
|
||||
out-of-memory exceptions now provide detailed information from CUDART
|
||||
improved histogram example
|
||||
device_reference now has a specialized swap
|
||||
reduce_by_key and scan algorithms are compatible with discard_iterator
|
||||
|
||||
Removed Functionality
|
||||
|
||||
Bug Fixes
|
||||
#44 allow host_vector to compile when value_type uses __align__
|
||||
#198 allow adjacent_difference to permit safe in-situ operation
|
||||
#303 make thrust thread-safe
|
||||
#313 avoid race conditions in device_vector::insert
|
||||
#314 avoid unintended adl invocation when dispatching copy
|
||||
#365 fix merge and set operation failures
|
||||
|
||||
Known Issues
|
||||
None
|
||||
|
||||
Acknowledgments
|
||||
Thanks to Manjunath Kudlur for contributing his Carbon library, from which the lambda functionality is derived.
|
||||
Thanks to Jean-Francois Bastien for suggesting a fix for issue 303.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.4.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.4.0 provides support for CUDA 4.0 in addition to many feature
|
||||
and performance improvements. New set theoretic algorithms operating on
|
||||
sorted sequences have been added. Additionally, a new fancy iterator
|
||||
allows discarding redundant or otherwise unnecessary output from
|
||||
algorithms, conserving memory storage and bandwidth.
|
||||
|
||||
Breaking API Changes
|
||||
Eliminations
|
||||
thrust/is_sorted.h
|
||||
thrust/utility.h
|
||||
thrust/set_intersection.h
|
||||
thrust/experimental/cuda/ogl_interop_allocator.h and the functionality therein
|
||||
thrust::deprecated::copy_when
|
||||
thrust::deprecated::absolute_value
|
||||
|
||||
New Features
|
||||
Functions
|
||||
copy_n
|
||||
merge
|
||||
set_difference
|
||||
set_symmetric_difference
|
||||
set_union
|
||||
|
||||
Types
|
||||
discard_iterator
|
||||
|
||||
Device support
|
||||
Compute Capability 2.1 GPUs
|
||||
|
||||
New Examples
|
||||
run_length_decoding
|
||||
|
||||
Other Enhancements
|
||||
Compilation warnings are substantially reduced in various contexts.
|
||||
The compilation time of thrust::sort, thrust::stable_sort, thrust::sort_by_key,
|
||||
and thrust::stable_sort_by_key are substantially reduced.
|
||||
A fast sort implementation is used when sorting primitive types with thrust::greater.
|
||||
The performance of thrust::set_intersection is improved.
|
||||
The performance of thrust::fill is improved on SM 1.x devices.
|
||||
A code example is now provided in each algorithm's documentation.
|
||||
thrust::reverse now operates in-place
|
||||
|
||||
Removed Functionality
|
||||
thrust::deprecated::copy_when
|
||||
thrust::deprecated::absolute_value
|
||||
thrust::experimental::cuda::ogl_interop_allocator
|
||||
thrust::gather and thrust::scatter from host to device and vice versa are no longer supported.
|
||||
Operations which modify the elements of a thrust::device_vector are no longer
|
||||
available from source code compiled without nvcc when the device backend is CUDA.
|
||||
Instead, use the idiom from the cpp_interop example.
|
||||
|
||||
Bug Fixes
|
||||
#212 set_intersection works correctly for large input sizes.
|
||||
#275 counting_iterator and constant_iterator work correctly with OpenMP as the
|
||||
backend when compiling with optimization
|
||||
#256 min and max correctly return their first argument as a tie-breaker
|
||||
#248 NDEBUG is interpreted correctly
|
||||
|
||||
Known Issues
|
||||
nvcc may generate code containing warnings when compiling some Thrust algorithms.
|
||||
When compiling with -arch=sm_1x, some Thrust algorithms may cause nvcc to issue
|
||||
benign pointer advisories.
|
||||
When compiling with -arch=sm_1x and -G, some Thrust algorithms may fail to execute correctly.
|
||||
thrust::inclusive_scan, thrust::exclusive_scan, thrust::inclusive_scan_by_key,
|
||||
and thrust::exclusive_scan_by_key are currently incompatible with thrust::discard_iterator.
|
||||
|
||||
Acknowledgments
|
||||
Thanks to David Tarjan for improving the performance of set_intersection.
|
||||
Thanks to Duane Merrill for continued help with sort.
|
||||
Thanks to Nathan Whitehead for help with CUDA Toolkit integration.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.3.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.3.0 provides support for CUDA 3.2 in addition to many feature
|
||||
and performance enhancements.
|
||||
|
||||
Performance of the sort and sort_by_key algorithms is improved by as much
|
||||
as 3x in certain situations. The performance of stream compaction algorithms,
|
||||
such as copy_if, is improved by as much as 2x. Reduction performance is
|
||||
also improved, particularly for small input sizes.
|
||||
|
||||
CUDA errors are now converted to runtime exceptions using the system_error
|
||||
interface. Combined with a debug mode, also new in v1.3, runtime errors
|
||||
can be located with greater precision.
|
||||
|
||||
Lastly, a few header files have been consolidated or renamed for clarity.
|
||||
See the deprecations section below for additional details.
|
||||
|
||||
|
||||
Breaking API Changes
|
||||
Promotions
|
||||
thrust::experimental::inclusive_segmented_scan has been renamed thrust::inclusive_scan_by_key and exposes a different interface
|
||||
thrust::experimental::exclusive_segmented_scan has been renamed thrust::exclusive_scan_by_key and exposes a different interface
|
||||
thrust::experimental::partition_copy has been renamed thrust::partition_copy and exposes a different interface
|
||||
thrust::next::gather has been renamed thrust::gather
|
||||
thrust::next::gather_if has been renamed thrust::gather_if
|
||||
thrust::unique_copy_by_key has been renamed thrust::unique_by_key_copy
|
||||
Deprecations
|
||||
thrust::copy_when has been renamed thrust::deprecated::copy_when
|
||||
thrust::absolute_value has been renamed thrust::deprecated::absolute_value
|
||||
The header thrust/set_intersection.h is now deprecated; use thrust/set_operations.h instead
|
||||
The header thrust/utility.h is now deprecated; use thrust/swap.h instead
|
||||
The header thrust/swap_ranges.h is now deprecated; use thrust/swap.h instead
|
||||
Eliminations
|
||||
thrust::deprecated::gather
|
||||
thrust::deprecated::gather_if
|
||||
thrust/experimental/arch.h and the functions therein
|
||||
thrust/sorting/merge_sort.h
|
||||
thrust/sorting/radix_sort.h
|
||||
|
||||
New Features
|
||||
Functions
|
||||
exclusive_scan_by_key
|
||||
find
|
||||
find_if
|
||||
find_if_not
|
||||
inclusive_scan_by_key
|
||||
is_partitioned
|
||||
is_sorted_until
|
||||
mismatch
|
||||
partition_point
|
||||
reverse
|
||||
reverse_copy
|
||||
stable_partition_copy
|
||||
|
||||
Types
|
||||
system_error and related types
|
||||
experimental::cuda::ogl_interop_allocator
|
||||
bit_and, bit_or, and bit_xor
|
||||
|
||||
Device support
|
||||
gf104-based GPUs
|
||||
|
||||
New Examples
|
||||
opengl_interop.cu
|
||||
repeated_range.cu
|
||||
simple_moving_average.cu
|
||||
sparse_vector.cu
|
||||
strided_range.cu
|
||||
|
||||
Other Enhancements
|
||||
Performance of thrust::sort and thrust::sort_by_key is substantially improved for primitive key types
|
||||
Performance of thrust::copy_if is substantially improved
|
||||
Performance of thrust::reduce and related reductions is improved
|
||||
THRUST_DEBUG mode added
|
||||
Callers of Thrust functions may detect error conditions by catching thrust::system_error, which derives from std::runtime_error
|
||||
The number of compiler warnings generated by Thrust has been substantially reduced
|
||||
Comparison sort now works correctly for input sizes > 32M
|
||||
min & max usage no longer collides with <windows.h> definitions
|
||||
Compiling against the OpenMP backend no longer requires nvcc
|
||||
Performance of device_vector initialized in .cpp files is substantially improved in common cases
|
||||
Performance of thrust::sort_by_key on the host is substantially improved
|
||||
|
||||
Removed Functionality
|
||||
nvcc 2.3 is no longer supported
|
||||
|
||||
Bug Fixes
|
||||
Debug device code now compiles correctly
|
||||
thrust::uninitialized_copy and thrust::unintialized_fill now dispatch constructors on the device rather than the host
|
||||
|
||||
Known Issues
|
||||
#212 set_intersection is known to fail for large input sizes
|
||||
partition_point is known to fail for 64b types with nvcc 3.2
|
||||
|
||||
Acknowledgments
|
||||
Thanks to Duane Merrill for contributing a fast CUDA radix sort implementation
|
||||
Thanks to Erich Elsen for contributing an implementation of find_if
|
||||
Thanks to Andrew Corrigan for contributing changes which allow the OpenMP backend to compile in the absence of nvcc
|
||||
Thanks to Andrew Corrigan, Cliff Wooley, David Coeurjolly, Janick Martinez Esturo, John Bowers, Maxim Naumov, Michael Garland, and Ryuta Suzuki for bug reports
|
||||
Thanks to Cliff Woolley for help with testing
|
||||
|
||||
#######################################
|
||||
# Thrust v1.2.1 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Small fixes for compatibility with CUDA 3.1
|
||||
|
||||
Known Issues
|
||||
inclusive_scan & exclusive_scan may fail with very large types
|
||||
the Microsoft compiler may fail to compile code using both sort and binary search algorithms
|
||||
uninitialized_fill & uninitialized_copy dispatch constructors on the host rather than the device
|
||||
# 109 some algorithms may exhibit poor performance with the OpenMP backend with large numbers (>= 6) of CPU threads
|
||||
default_random_engine::discard is not accelerated with nvcc 2.3
|
||||
nvcc 3.1 may fail to compile code using types derived from thrust::subtract_with_carry_engine, such as thrust::ranlux24 & thrust::ranlux48.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.2.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.2 introduces support for compilation to multicore CPUs
|
||||
and the Ocelot virtual machine, and several new facilities for
|
||||
pseudo-random number generation. New algorithms such as set
|
||||
intersection and segmented reduction have also been added. Lastly,
|
||||
improvements to the robustness of the CUDA backend ensure
|
||||
correctness across a broad set of (uncommon) use cases.
|
||||
|
||||
Breaking API Changes
|
||||
thrust::gather's interface was incorrect and has been removed.
|
||||
The old interface is deprecated but will be preserved for Thrust
|
||||
version 1.2 at thrust::deprecated::gather &
|
||||
thrust::deprecated::gather_if. The new interface is provided at
|
||||
thrust::next::gather & thrust::next::gather_if. The new interface
|
||||
will be promoted to thrust:: in Thrust version 1.3. For more details,
|
||||
please refer to this thread:
|
||||
http://groups.google.com/group/thrust-users/browse_thread/thread/f5f0583cb97b51fd
|
||||
|
||||
The thrust::sorting namespace has been deprecated in favor of the
|
||||
top-level sorting functions, such as thrust::sort() and
|
||||
thrust::sort_by_key().
|
||||
|
||||
New Features
|
||||
Functions
|
||||
reduce_by_key
|
||||
set_intersection
|
||||
tie
|
||||
unique_copy
|
||||
unique_by_key
|
||||
unique_copy_by_key
|
||||
|
||||
Types
|
||||
Random Number Generation
|
||||
discard_block_engine
|
||||
default_random_engine
|
||||
linear_congruential_engine
|
||||
linear_feedback_shift_engine
|
||||
minstd_rand
|
||||
minstd_rand0
|
||||
normal_distribution (experimental)
|
||||
ranlux24
|
||||
ranlux48
|
||||
ranlux24_base
|
||||
ranlux48_base
|
||||
subtract_with_carry_engine
|
||||
taus88
|
||||
uniform_int_distribution
|
||||
uniform_real_distribution
|
||||
xor_combine_engine
|
||||
Functionals
|
||||
project1st
|
||||
project2nd
|
||||
|
||||
Fancy Iterators
|
||||
permutation_iterator
|
||||
reverse_iterator
|
||||
|
||||
Device support
|
||||
Add support for multicore CPUs via OpenMP
|
||||
Add support for Fermi-class GPUs
|
||||
Add support for Ocelot virtual machine
|
||||
|
||||
New Examples
|
||||
cpp_integration
|
||||
histogram
|
||||
mode
|
||||
monte_carlo
|
||||
monte_carlo_disjoint_sequences
|
||||
padded_grid_reduction
|
||||
permutation_iterator
|
||||
row_sum
|
||||
run_length_encoding
|
||||
segmented_scan
|
||||
stream_compaction
|
||||
summary_statistics
|
||||
transform_iterator
|
||||
word_count
|
||||
|
||||
Other Enhancements
|
||||
vector functions operator!=, rbegin, crbegin, rend, crend, data, & shrink_to_fit
|
||||
integer sorting performance is improved when max is large but (max - min) is small and when min is negative
|
||||
performance of inclusive_scan() and exclusive_scan() is improved by 20-25% for primitive types
|
||||
support for nvcc 3.0
|
||||
|
||||
Removed Functionality
|
||||
removed support for equal between host & device sequences
|
||||
removed support for gather() and scatter() between host & device sequences
|
||||
|
||||
Bug Fixes
|
||||
# 8 cause a compiler error if the required compiler is not found rather than a mysterious error at link time
|
||||
# 42 device_ptr & device_reference are classes rather than structs, eliminating warnings on certain platforms
|
||||
# 46 gather & scatter handle any space iterators correctly
|
||||
# 51 thrust::experimental::arch functions gracefully handle unrecognized GPUs
|
||||
# 52 avoid collisions with common user macros such as BLOCK_SIZE
|
||||
# 62 provide better documentation for device_reference
|
||||
# 68 allow built-in CUDA vector types to work with device_vector in pure C++ mode
|
||||
# 102 eliminated a race condition in device_vector::erase
|
||||
various compilation warnings eliminated
|
||||
|
||||
Known Issues
|
||||
inclusive_scan & exclusive_scan may fail with very large types
|
||||
the Microsoft compiler may fail to compile code using both sort and binary search algorithms
|
||||
uninitialized_fill & uninitialized_copy dispatch constructors on the host rather than the device
|
||||
# 109 some algorithms may exhibit poor performance with the OpenMP backend with large numbers (>= 6) of CPU threads
|
||||
default_random_engine::discard is not accelerated with nvcc 2.3
|
||||
|
||||
Acknowledgments
|
||||
Thanks to Gregory Diamos for contributing a CUDA implementation of set_intersection
|
||||
Thanks to Ryuta Suzuki & Gregory Diamos for rigorously testing Thrust's unit tests and examples against Ocelot
|
||||
Thanks to Tom Bradley for contributing an implementation of normal_distribution
|
||||
Thanks to Joseph Rhoads for contributing the example summary_statistics
|
||||
|
||||
#######################################
|
||||
# Thrust v1.1.1 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Small fixes for compatibility with CUDA 2.3a and Mac OSX Snow Leopard.
|
||||
|
||||
#######################################
|
||||
# Thrust v1.1.0 #
|
||||
#######################################
|
||||
|
||||
Summary
|
||||
Thrust v1.1 introduces fancy iterators, binary search functions, and
|
||||
several specialized reduction functions. Experimental support for
|
||||
segmented scan has also been added.
|
||||
|
||||
Breaking API Changes
|
||||
counting_iterator has been moved into the thrust namespace (previously thrust::experimental)
|
||||
|
||||
New Features
|
||||
Functions
|
||||
copy_if
|
||||
lower_bound
|
||||
upper_bound
|
||||
vectorized lower_bound
|
||||
vectorized upper_bound
|
||||
equal_range
|
||||
binary_search
|
||||
vectorized binary_search
|
||||
all_of
|
||||
any_of
|
||||
none_of
|
||||
minmax_element
|
||||
advance
|
||||
inclusive_segmented_scan (experimental)
|
||||
exclusive_segmented_scan (experimental)
|
||||
|
||||
Types
|
||||
pair
|
||||
tuple
|
||||
device_malloc_allocator
|
||||
|
||||
Fancy Iterators
|
||||
constant_iterator
|
||||
counting_iterator
|
||||
transform_iterator
|
||||
zip_iterator
|
||||
|
||||
New Examples
|
||||
computing the maximum absolute difference between vectors
|
||||
computing the bounding box of a two-dimensional point set
|
||||
sorting multiple arrays together (lexicographical sorting)
|
||||
constructing a summed area table
|
||||
using zip_iterator to mimic an array of structs
|
||||
using constant_iterator to increment array values
|
||||
|
||||
Other Enhancements
|
||||
added pinned memory allocator (experimental)
|
||||
added more methods to host_vector & device_vector (issue #4)
|
||||
added variant of remove_if with a stencil argument (issue #29)
|
||||
scan and reduce use cudaFuncGetAttributes to determine grid size
|
||||
exceptions are reported when temporary device arrays cannot be allocated
|
||||
|
||||
Bug Fixes
|
||||
#5 make vector work for larger data types
|
||||
#9 stable_partition_copy doesn't respect OutputIterator concept semantics
|
||||
#10 scans should return OutputIterator
|
||||
#16 make algorithms work for larger data types
|
||||
#27 dispatch radix_sort even when comp=less<T> is explicitly provided
|
||||
|
||||
Known Issues
|
||||
Using functors with Thrust entry points may not compile on Mac OSX with gcc-4.0.1
|
||||
uninitialized_copy & uninitialized_fill dispatch constructors on the host rather than the device.
|
||||
inclusive_scan, inclusive_scan_by_key, exclusive_scan, and exclusive_scan_by_key may fail when used with large types with the CUDA 3.1 driver
|
||||
|
||||
|
||||
#######################################
|
||||
# Thrust v1.0.0 #
|
||||
#######################################
|
||||
|
||||
Breaking API changes
|
||||
Rename top level namespace komrade to thrust.
|
||||
Move partition_copy() & stable_partition_copy() into thrust::experimental namespace until we can easily provide the standard interface.
|
||||
Rename range() to sequence() to avoid collision with Boost.Range.
|
||||
Rename copy_if() to copy_when() due to semantic differences with C++0x copy_if().
|
||||
|
||||
New Features
|
||||
Add C++0x style cbegin() & cend() methods to host_vector & device_vector.
|
||||
Add transform_if function.
|
||||
Add stencil versions of replace_if() & replace_copy_if().
|
||||
Allow counting_iterator to work with for_each().
|
||||
Allow types with constructors in comparison sort & reduce.
|
||||
|
||||
Other Enhancements
|
||||
merge_sort and stable_merge_sort are now 2 to 5x faster when executed on the parallel device.
|
||||
|
||||
Bug fixes
|
||||
Workaround an issue where an incremented iterator causes nvcc to crash. (Komrade issue #6)
|
||||
Fix an issue where const_iterators could not be passed to transform. (Komrade issue #7)
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2012 NVIDIA Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file adjacent_difference.h
|
||||
* \brief Compute difference between consecutive elements of a range
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thrust/detail/config.h>
|
||||
#include <thrust/detail/execution_policy.h>
|
||||
|
||||
namespace thrust
|
||||
{
|
||||
|
||||
|
||||
/*! \addtogroup transformations Transformations
|
||||
* \{
|
||||
*/
|
||||
|
||||
|
||||
/*! \p adjacent_difference calculates the differences of adjacent elements in the
|
||||
* range <tt>[first, last)</tt>. That is, <tt>\*first</tt> is assigned to
|
||||
* <tt>\*result</tt>, and, for each iterator \p i in the range
|
||||
* <tt>[first + 1, last)</tt>, the difference of <tt>\*i</tt> and <tt>*(i - 1)</tt>
|
||||
* is assigned to <tt>\*(result + (i - first))</tt>.
|
||||
*
|
||||
* This version of \p adjacent_difference uses <tt>operator-</tt> to calculate
|
||||
* differences.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the input range.
|
||||
* \param last The end of the input range.
|
||||
* \param result The beginning of the output range.
|
||||
* \return The iterator <tt>result + (last - first)</tt>
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \c x and \c y are objects of \p InputIterator's \c value_type, then \c x - \c is defined,
|
||||
* and \p InputIterator's \c value_type is convertible to a type in \p OutputIterator's set of \c value_types,
|
||||
* and the return type of <tt>x - y</tt> is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \remark Note that \p result is permitted to be the same iterator as \p first. This is
|
||||
* useful for computing differences "in place".
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p adjacent_difference to compute
|
||||
* the difference between adjacent elements of a range using the \p thrust::device execution policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/adjacent_difference.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
|
||||
* thrust::device_vector<int> d_data(h_data, h_data + 8);
|
||||
* thrust::device_vector<int> d_result(8);
|
||||
*
|
||||
* thrust::adjacent_difference(thrust::device, d_data.begin(), d_data.end(), d_result.begin());
|
||||
*
|
||||
* // d_result is now [1, 1, -1, 1, -1, 1, -1, 1]
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/adjacent_difference.html
|
||||
* \see inclusive_scan
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
||||
OutputIterator adjacent_difference(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first, InputIterator last,
|
||||
OutputIterator result);
|
||||
|
||||
/*! \p adjacent_difference calculates the differences of adjacent elements in the
|
||||
* range <tt>[first, last)</tt>. That is, <tt>*first</tt> is assigned to
|
||||
* <tt>\*result</tt>, and, for each iterator \p i in the range
|
||||
* <tt>[first + 1, last)</tt>, <tt>binary_op(\*i, \*(i - 1))</tt> is assigned to
|
||||
* <tt>\*(result + (i - first))</tt>.
|
||||
*
|
||||
* This version of \p adjacent_difference uses the binary function \p binary_op to
|
||||
* calculate differences.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the input range.
|
||||
* \param last The end of the input range.
|
||||
* \param result The beginning of the output range.
|
||||
* \param binary_op The binary function used to compute differences.
|
||||
* \return The iterator <tt>result + (last - first)</tt>
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator's \c value_type is convertible to \p BinaryFunction's \c first_argument_type and \c second_argument_type,
|
||||
* and \p InputIterator's \c value_type is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
* \tparam BinaryFunction's \c result_type is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
*
|
||||
* \remark Note that \p result is permitted to be the same iterator as \p first. This is
|
||||
* useful for computing differences "in place".
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p adjacent_difference to compute
|
||||
* the sum between adjacent elements of a range using the \p thrust::device execution policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/adjacent_difference.h>
|
||||
* #include <thrust/functional.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
|
||||
* thrust::device_vector<int> d_data(h_data, h_data + 8);
|
||||
* thrust::device_vector<int> d_result(8);
|
||||
*
|
||||
* thrust::adjacent_difference(thrust::device, d_data.begin(), d_data.end(), d_result.begin(), thrust::plus<int>());
|
||||
*
|
||||
* // d_data is now [1, 3, 3, 3, 3, 3, 3, 3]
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/adjacent_difference.html
|
||||
* \see inclusive_scan
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename BinaryFunction>
|
||||
OutputIterator adjacent_difference(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryFunction binary_op);
|
||||
|
||||
/*! \p adjacent_difference calculates the differences of adjacent elements in the
|
||||
* range <tt>[first, last)</tt>. That is, <tt>\*first</tt> is assigned to
|
||||
* <tt>\*result</tt>, and, for each iterator \p i in the range
|
||||
* <tt>[first + 1, last)</tt>, the difference of <tt>\*i</tt> and <tt>*(i - 1)</tt>
|
||||
* is assigned to <tt>\*(result + (i - first))</tt>.
|
||||
*
|
||||
* This version of \p adjacent_difference uses <tt>operator-</tt> to calculate
|
||||
* differences.
|
||||
*
|
||||
* \param first The beginning of the input range.
|
||||
* \param last The end of the input range.
|
||||
* \param result The beginning of the output range.
|
||||
* \return The iterator <tt>result + (last - first)</tt>
|
||||
*
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \c x and \c y are objects of \p InputIterator's \c value_type, then \c x - \c is defined,
|
||||
* and \p InputIterator's \c value_type is convertible to a type in \p OutputIterator's set of \c value_types,
|
||||
* and the return type of <tt>x - y</tt> is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \remark Note that \p result is permitted to be the same iterator as \p first. This is
|
||||
* useful for computing differences "in place".
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p adjacent_difference to compute
|
||||
* the difference between adjacent elements of a range.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/adjacent_difference.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
|
||||
* thrust::device_vector<int> d_data(h_data, h_data + 8);
|
||||
* thrust::device_vector<int> d_result(8);
|
||||
*
|
||||
* thrust::adjacent_difference(d_data.begin(), d_data.end(), d_result.begin());
|
||||
*
|
||||
* // d_result is now [1, 1, -1, 1, -1, 1, -1, 1]
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/adjacent_difference.html
|
||||
* \see inclusive_scan
|
||||
*/
|
||||
template <typename InputIterator, typename OutputIterator>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result);
|
||||
|
||||
/*! \p adjacent_difference calculates the differences of adjacent elements in the
|
||||
* range <tt>[first, last)</tt>. That is, <tt>*first</tt> is assigned to
|
||||
* <tt>\*result</tt>, and, for each iterator \p i in the range
|
||||
* <tt>[first + 1, last)</tt>, <tt>binary_op(\*i, \*(i - 1))</tt> is assigned to
|
||||
* <tt>\*(result + (i - first))</tt>.
|
||||
*
|
||||
* This version of \p adjacent_difference uses the binary function \p binary_op to
|
||||
* calculate differences.
|
||||
*
|
||||
* \param first The beginning of the input range.
|
||||
* \param last The end of the input range.
|
||||
* \param result The beginning of the output range.
|
||||
* \param binary_op The binary function used to compute differences.
|
||||
* \return The iterator <tt>result + (last - first)</tt>
|
||||
*
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator's \c value_type is convertible to \p BinaryFunction's \c first_argument_type and \c second_argument_type,
|
||||
* and \p InputIterator's \c value_type is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
* \tparam BinaryFunction's \c result_type is convertible to a type in \p OutputIterator's set of \c value_types.
|
||||
*
|
||||
* \remark Note that \p result is permitted to be the same iterator as \p first. This is
|
||||
* useful for computing differences "in place".
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p adjacent_difference to compute
|
||||
* the sum between adjacent elements of a range.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/adjacent_difference.h>
|
||||
* #include <thrust/functional.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
|
||||
* thrust::device_vector<int> d_data(h_data, h_data + 8);
|
||||
* thrust::device_vector<int> d_result(8);
|
||||
*
|
||||
* thrust::adjacent_difference(d_data.begin(), d_data.end(), d_result.begin(), thrust::plus<int>());
|
||||
*
|
||||
* // d_data is now [1, 3, 3, 3, 3, 3, 3, 3]
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/adjacent_difference.html
|
||||
* \see inclusive_scan
|
||||
*/
|
||||
template <typename InputIterator, typename OutputIterator, typename BinaryFunction>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryFunction binary_op);
|
||||
|
||||
/*! \}
|
||||
*/
|
||||
|
||||
} // end namespace thrust
|
||||
|
||||
#include <thrust/detail/adjacent_difference.inl>
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2012 NVIDIA Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file advance.h
|
||||
* \brief Advance an iterator by a given distance.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thrust/detail/config.h>
|
||||
|
||||
namespace thrust
|
||||
{
|
||||
|
||||
|
||||
/*! \addtogroup iterators
|
||||
* \{
|
||||
*/
|
||||
|
||||
/*! \p advance(i, n) increments the iterator \p i by the distance \p n.
|
||||
* If <tt>n > 0</tt> it is equivalent to executing <tt>++i</tt> \p n
|
||||
* times, and if <tt>n < 0</tt> it is equivalent to executing <tt>--i</tt>
|
||||
* \p n times. If <tt>n == 0</tt>, the call has no effect.
|
||||
*
|
||||
* \param i The iterator to be advanced.
|
||||
* \param n The distance by which to advance the iterator.
|
||||
*
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
|
||||
* \tparam Distance is an integral type that is convertible to \p InputIterator's distance type.
|
||||
*
|
||||
* \pre \p n shall be negative only for bidirectional and random access iterators.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p advance to increment
|
||||
* an iterator a given number of times.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/advance.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* thrust::device_vector<int> vec(13);
|
||||
* thrust::device_vector<int>::iterator iter = vec.begin();
|
||||
*
|
||||
* thrust::advance(iter, 7);
|
||||
*
|
||||
* // iter - vec.begin() == 7
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/advance.html
|
||||
*/
|
||||
template <typename InputIterator, typename Distance>
|
||||
void advance(InputIterator& i, Distance n);
|
||||
|
||||
/*! \} // end iterators
|
||||
*/
|
||||
|
||||
} // end thrust
|
||||
|
||||
#include <thrust/detail/advance.inl>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,505 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2012 NVIDIA Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file copy.h
|
||||
* \brief Copies elements from one range to another
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thrust/detail/config.h>
|
||||
#include <thrust/detail/execution_policy.h>
|
||||
|
||||
namespace thrust
|
||||
{
|
||||
|
||||
/*! \addtogroup algorithms
|
||||
*/
|
||||
|
||||
/*! \addtogroup copying
|
||||
* \ingroup algorithms
|
||||
* \{
|
||||
*/
|
||||
|
||||
|
||||
/*! \p copy copies elements from the range [\p first, \p last) to the range
|
||||
* [\p result, \p result + (\p last - \p first)). That is, it performs
|
||||
* the assignments *\p result = *\p first, *(\p result + \c 1) = *(\p first + \c 1),
|
||||
* and so on. Generally, for every integer \c n from \c 0 to \p last - \p first, \p copy
|
||||
* performs the assignment *(\p result + \c n) = *(\p first + \c n). Unlike
|
||||
* \c std::copy, \p copy offers no guarantee on order of operation. As a result,
|
||||
* calling \p copy with overlapping source and destination ranges has undefined
|
||||
* behavior.
|
||||
*
|
||||
* The return value is \p result + (\p last - \p first).
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the sequence to copy.
|
||||
* \param last The end of the sequence to copy.
|
||||
* \param result The destination sequence.
|
||||
* \return The end of the destination sequence.
|
||||
* \see http://www.sgi.com/tech/stl/copy.html
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c OutputIterator's \c value_type.
|
||||
* \tparam OutputIterator must be a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \pre \p result may be equal to \p first, but \p result shall not be in the range <tt>[first, last)</tt> otherwise.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy
|
||||
* to copy from one range to another using the \p thrust::device parallelization policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
*
|
||||
* thrust::device_vector<int> vec0(100);
|
||||
* thrust::device_vector<int> vec1(100);
|
||||
* ...
|
||||
*
|
||||
* thrust::copy(thrust::device, vec0.begin(), vec0.end(), vec1.begin());
|
||||
*
|
||||
* // vec1 is now a copy of vec0
|
||||
* \endcode
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
||||
OutputIterator copy(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result);
|
||||
|
||||
|
||||
/*! \p copy_n copies elements from the range <tt>[first, first + n)</tt> to the range
|
||||
* <tt>[result, result + n)</tt>. That is, it performs the assignments <tt>*result = *first, *(result + 1) = *(first + 1)</tt>,
|
||||
* and so on. Generally, for every integer \c i from \c 0 to \c n, \p copy
|
||||
* performs the assignment *(\p result + \c i) = *(\p first + \c i). Unlike
|
||||
* \c std::copy_n, \p copy_n offers no guarantee on order of operation. As a result,
|
||||
* calling \p copy_n with overlapping source and destination ranges has undefined
|
||||
* behavior.
|
||||
*
|
||||
* The return value is \p result + \p n.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the range to copy.
|
||||
* \param n The number of elements to copy.
|
||||
* \param result The beginning destination range.
|
||||
* \return The end of the destination range.
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c OutputIterator's \c value_type.
|
||||
* \tparam Size is an integral type.
|
||||
* \tparam OutputIterator must be a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \pre \p result may be equal to \p first, but \p result shall not be in the range <tt>[first, first + n)</tt> otherwise.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy
|
||||
* to copy from one range to another using the \p thrust::device parallelization policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* size_t n = 100;
|
||||
* thrust::device_vector<int> vec0(n);
|
||||
* thrust::device_vector<int> vec1(n);
|
||||
* ...
|
||||
* thrust::copy_n(thrust::device, vec0.begin(), n, vec1.begin());
|
||||
*
|
||||
* // vec1 is now a copy of vec0
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/copy_n.html
|
||||
* \see thrust::copy
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename Size, typename OutputIterator>
|
||||
OutputIterator copy_n(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first,
|
||||
Size n,
|
||||
OutputIterator result);
|
||||
|
||||
|
||||
|
||||
/*! \p copy copies elements from the range [\p first, \p last) to the range
|
||||
* [\p result, \p result + (\p last - \p first)). That is, it performs
|
||||
* the assignments *\p result = *\p first, *(\p result + \c 1) = *(\p first + \c 1),
|
||||
* and so on. Generally, for every integer \c n from \c 0 to \p last - \p first, \p copy
|
||||
* performs the assignment *(\p result + \c n) = *(\p first + \c n). Unlike
|
||||
* \c std::copy, \p copy offers no guarantee on order of operation. As a result,
|
||||
* calling \p copy with overlapping source and destination ranges has undefined
|
||||
* behavior.
|
||||
*
|
||||
* The return value is \p result + (\p last - \p first).
|
||||
*
|
||||
* \param first The beginning of the sequence to copy.
|
||||
* \param last The end of the sequence to copy.
|
||||
* \param result The destination sequence.
|
||||
* \return The end of the destination sequence.
|
||||
* \see http://www.sgi.com/tech/stl/copy.html
|
||||
*
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c OutputIterator's \c value_type.
|
||||
* \tparam OutputIterator must be a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \pre \p result may be equal to \p first, but \p result shall not be in the range <tt>[first, last)</tt> otherwise.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy
|
||||
* to copy from one range to another.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
*
|
||||
* thrust::device_vector<int> vec0(100);
|
||||
* thrust::device_vector<int> vec1(100);
|
||||
* ...
|
||||
*
|
||||
* thrust::copy(vec0.begin(), vec0.end(),
|
||||
* vec1.begin());
|
||||
*
|
||||
* // vec1 is now a copy of vec0
|
||||
* \endcode
|
||||
*/
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
OutputIterator copy(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result);
|
||||
|
||||
/*! \p copy_n copies elements from the range <tt>[first, first + n)</tt> to the range
|
||||
* <tt>[result, result + n)</tt>. That is, it performs the assignments <tt>*result = *first, *(result + 1) = *(first + 1)</tt>,
|
||||
* and so on. Generally, for every integer \c i from \c 0 to \c n, \p copy
|
||||
* performs the assignment *(\p result + \c i) = *(\p first + \c i). Unlike
|
||||
* \c std::copy_n, \p copy_n offers no guarantee on order of operation. As a result,
|
||||
* calling \p copy_n with overlapping source and destination ranges has undefined
|
||||
* behavior.
|
||||
*
|
||||
* The return value is \p result + \p n.
|
||||
*
|
||||
* \param first The beginning of the range to copy.
|
||||
* \param n The number of elements to copy.
|
||||
* \param result The beginning destination range.
|
||||
* \return The end of the destination range.
|
||||
*
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c OutputIterator's \c value_type.
|
||||
* \tparam Size is an integral type.
|
||||
* \tparam OutputIterator must be a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
*
|
||||
* \pre \p result may be equal to \p first, but \p result shall not be in the range <tt>[first, first + n)</tt> otherwise.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy
|
||||
* to copy from one range to another.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* size_t n = 100;
|
||||
* thrust::device_vector<int> vec0(n);
|
||||
* thrust::device_vector<int> vec1(n);
|
||||
* ...
|
||||
* thrust::copy_n(vec0.begin(), n, vec1.begin());
|
||||
*
|
||||
* // vec1 is now a copy of vec0
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/copy_n.html
|
||||
* \see thrust::copy
|
||||
*/
|
||||
template<typename InputIterator, typename Size, typename OutputIterator>
|
||||
OutputIterator copy_n(InputIterator first,
|
||||
Size n,
|
||||
OutputIterator result);
|
||||
|
||||
/*! \} // end copying
|
||||
*/
|
||||
|
||||
/*! \addtogroup stream_compaction
|
||||
* \{
|
||||
*/
|
||||
|
||||
|
||||
/*! This version of \p copy_if copies elements from the range <tt>[first,last)</tt>
|
||||
* to a range beginning at \ presult, except that any element which causes \p pred
|
||||
* to be \p pred to be \c false is not copied.
|
||||
*
|
||||
* More precisely, for every integer \c n such that <tt>0 <= n < last-first</tt>,
|
||||
* \p copy_if performs the assignment <tt>*result = *(first+n)</tt> and \p result
|
||||
* is advanced one position if <tt>pred(*(first+n))</tt>. Otherwise, no assignment
|
||||
* occurs and \p result is not advanced.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p system.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the sequence from which to copy.
|
||||
* \param last The end of the sequence from which to copy.
|
||||
* \param result The beginning of the sequence into which to copy.
|
||||
* \param pred The predicate to test on every value of the range <tt>[first, last)</tt>.
|
||||
* \return <tt>result + n</tt>, where \c n is equal to the number of times \p pred
|
||||
* evaluated to \c true in the range <tt>[first, last)</tt>.
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator's \c value_type is convertible to \p Predicate's \c argument_type.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
* \tparam Predicate is a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* \pre The ranges <tt>[first, last)</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy_if to perform stream compaction
|
||||
* to copy even numbers to an output range using the \p thrust::host parallelization policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* struct is_even
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(const int x)
|
||||
* {
|
||||
* return (x % 2) == 0;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* const int N = 6;
|
||||
* int V[N] = {-2, 0, -1, 0, 1, 2};
|
||||
* int result[4];
|
||||
*
|
||||
* thrust::copy_if(thrust::host, V, V + N, result, is_even());
|
||||
*
|
||||
* // V remains {-2, 0, -1, 0, 1, 2}
|
||||
* // result is now {-2, 0, 0, 2}
|
||||
* \endcode
|
||||
*
|
||||
* \see \c remove_copy_if
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
|
||||
OutputIterator copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
Predicate pred);
|
||||
|
||||
|
||||
|
||||
/*! This version of \p copy_if copies elements from the range <tt>[first,last)</tt>
|
||||
* to a range beginning at \ presult, except that any element which causes \p pred
|
||||
* to be \p pred to be \c false is not copied.
|
||||
*
|
||||
* More precisely, for every integer \c n such that <tt>0 <= n < last-first</tt>,
|
||||
* \p copy_if performs the assignment <tt>*result = *(first+n)</tt> and \p result
|
||||
* is advanced one position if <tt>pred(*(first+n))</tt>. Otherwise, no assignment
|
||||
* occurs and \p result is not advanced.
|
||||
*
|
||||
* \param first The beginning of the sequence from which to copy.
|
||||
* \param last The end of the sequence from which to copy.
|
||||
* \param result The beginning of the sequence into which to copy.
|
||||
* \param pred The predicate to test on every value of the range <tt>[first, last)</tt>.
|
||||
* \return <tt>result + n</tt>, where \c n is equal to the number of times \p pred
|
||||
* evaluated to \c true in the range <tt>[first, last)</tt>.
|
||||
*
|
||||
* \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator's \c value_type is convertible to \p Predicate's \c argument_type.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output Iterator</a>.
|
||||
* \tparam Predicate is a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* \pre The ranges <tt>[first, last)</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy_if to perform stream compaction
|
||||
* to copy even numbers to an output range.
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* ...
|
||||
* struct is_even
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(const int x)
|
||||
* {
|
||||
* return (x % 2) == 0;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* const int N = 6;
|
||||
* int V[N] = {-2, 0, -1, 0, 1, 2};
|
||||
* int result[4];
|
||||
*
|
||||
* thrust::copy_if(V, V + N, result, is_even());
|
||||
*
|
||||
* // V remains {-2, 0, -1, 0, 1, 2}
|
||||
* // result is now {-2, 0, 0, 2}
|
||||
* \endcode
|
||||
*
|
||||
* \see \c remove_copy_if
|
||||
*/
|
||||
template<typename InputIterator,
|
||||
typename OutputIterator,
|
||||
typename Predicate>
|
||||
OutputIterator copy_if(InputIterator first,
|
||||
InputIterator last,
|
||||
OutputIterator result,
|
||||
Predicate pred);
|
||||
|
||||
|
||||
/*! This version of \p copy_if copies elements from the range <tt>[first,last)</tt>
|
||||
* to a range beginning at \p result, except that any element whose corresponding stencil
|
||||
* element causes \p pred to be \c false is not copied.
|
||||
*
|
||||
* More precisely, for every integer \c n such that <tt>0 <= n < last-first</tt>,
|
||||
* \p copy_if performs the assignment <tt>*result = *(first+n)</tt> and \p result
|
||||
* is advanced one position if <tt>pred(*(stencil+n))</tt>. Otherwise, no assignment
|
||||
* occurs and \p result is not advanced.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the sequence from which to copy.
|
||||
* \param last The end of the sequence from which to copy.
|
||||
* \param stencil The beginning of the stencil sequence.
|
||||
* \param result The beginning of the sequence into which to copy.
|
||||
* \param pred The predicate to test on every value of the range <tt>[stencil, stencil + (last-first))</tt>.
|
||||
* \return <tt>result + n</tt>, where \c n is equal to the number of times \p pred
|
||||
* evaluated to \c true in the range <tt>[stencil, stencil + (last-first))</tt>.
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
|
||||
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator2's \c value_type is convertible to \p Predicate's \c argument_type.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator">Output Iterator</a>.
|
||||
* \tparam Predicate is a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* \pre The ranges <tt>[first, last)</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
* \pre The ranges <tt>[stencil, stencil + (last - first))</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy_if to perform stream compaction
|
||||
* to copy numbers to an output range when corresponding stencil elements are even using the \p thrust::host execution policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* struct is_even
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(const int x)
|
||||
* {
|
||||
* return (x % 2) == 0;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* int N = 6;
|
||||
* int data[N] = { 0, 1, 2, 3, 4, 5};
|
||||
* int stencil[N] = {-2, 0, -1, 0, 1, 2};
|
||||
* int result[4];
|
||||
*
|
||||
* thrust::copy_if(thrust::host, data, data + N, stencil, result, is_even());
|
||||
*
|
||||
* // data remains = { 0, 1, 2, 3, 4, 5};
|
||||
* // stencil remains = {-2, 0, -1, 0, 1, 2};
|
||||
* // result is now { 0, 1, 3, 5}
|
||||
* \endcode
|
||||
*
|
||||
* \see \c remove_copy_if
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator, typename Predicate>
|
||||
OutputIterator copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator1 first,
|
||||
InputIterator1 last,
|
||||
InputIterator2 stencil,
|
||||
OutputIterator result,
|
||||
Predicate pred);
|
||||
|
||||
|
||||
/*! This version of \p copy_if copies elements from the range <tt>[first,last)</tt>
|
||||
* to a range beginning at \p result, except that any element whose corresponding stencil
|
||||
* element causes \p pred to be \c false is not copied.
|
||||
*
|
||||
* More precisely, for every integer \c n such that <tt>0 <= n < last-first</tt>,
|
||||
* \p copy_if performs the assignment <tt>*result = *(first+n)</tt> and \p result
|
||||
* is advanced one position if <tt>pred(*(stencil+n))</tt>. Otherwise, no assignment
|
||||
* occurs and \p result is not advanced.
|
||||
*
|
||||
* \param first The beginning of the sequence from which to copy.
|
||||
* \param last The end of the sequence from which to copy.
|
||||
* \param stencil The beginning of the stencil sequence.
|
||||
* \param result The beginning of the sequence into which to copy.
|
||||
* \param pred The predicate to test on every value of the range <tt>[stencil, stencil + (last-first))</tt>.
|
||||
* \return <tt>result + n</tt>, where \c n is equal to the number of times \p pred
|
||||
* evaluated to \c true in the range <tt>[stencil, stencil + (last-first))</tt>.
|
||||
*
|
||||
* \tparam InputIterator1 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
|
||||
* \tparam InputIterator2 is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>,
|
||||
* and \p InputIterator2's \c value_type is convertible to \p Predicate's \c argument_type.
|
||||
* \tparam OutputIterator is a model of <a href="http://www.sgi.com/tech/stl/OutputIterator">Output Iterator</a>.
|
||||
* \tparam Predicate is a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* \pre The ranges <tt>[first, last)</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
* \pre The ranges <tt>[stencil, stencil + (last - first))</tt> and <tt>[result, result + (last - first))</tt> shall not overlap.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p copy_if to perform stream compaction
|
||||
* to copy numbers to an output range when corresponding stencil elements are even:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/copy.h>
|
||||
* ...
|
||||
* struct is_even
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(const int x)
|
||||
* {
|
||||
* return (x % 2) == 0;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* int N = 6;
|
||||
* int data[N] = { 0, 1, 2, 3, 4, 5};
|
||||
* int stencil[N] = {-2, 0, -1, 0, 1, 2};
|
||||
* int result[4];
|
||||
*
|
||||
* thrust::copy_if(data, data + N, stencil, result, is_even());
|
||||
*
|
||||
* // data remains = { 0, 1, 2, 3, 4, 5};
|
||||
* // stencil remains = {-2, 0, -1, 0, 1, 2};
|
||||
* // result is now { 0, 1, 3, 5}
|
||||
* \endcode
|
||||
*
|
||||
* \see \c remove_copy_if
|
||||
*/
|
||||
template<typename InputIterator1,
|
||||
typename InputIterator2,
|
||||
typename OutputIterator,
|
||||
typename Predicate>
|
||||
OutputIterator copy_if(InputIterator1 first,
|
||||
InputIterator1 last,
|
||||
InputIterator2 stencil,
|
||||
OutputIterator result,
|
||||
Predicate pred);
|
||||
|
||||
/*! \} // end stream_compaction
|
||||
*/
|
||||
|
||||
} // end namespace thrust
|
||||
|
||||
#include <thrust/detail/copy.h>
|
||||
#include <thrust/detail/copy_if.h>
|
||||
|
||||
@@ -1,231 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2012 NVIDIA Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file count.h
|
||||
* \brief Counting elements in a range
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thrust/detail/config.h>
|
||||
#include <thrust/detail/execution_policy.h>
|
||||
#include <thrust/iterator/iterator_traits.h>
|
||||
|
||||
namespace thrust
|
||||
{
|
||||
|
||||
|
||||
/*! \addtogroup algorithms
|
||||
*/
|
||||
|
||||
/*! \addtogroup reductions
|
||||
* \ingroup algorithms
|
||||
* \{
|
||||
*/
|
||||
|
||||
/*! \addtogroup counting
|
||||
* \ingroup reductions
|
||||
* \{
|
||||
*/
|
||||
|
||||
|
||||
/*! \p count finds the number of elements in <tt>[first,last)</tt> that are equal
|
||||
* to \p value. More precisely, \p count returns the number of iterators \c i in
|
||||
* <tt>[first, last)</tt> such that <tt>*i == value</tt>.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the sequence.
|
||||
* \param last The end of the sequence.
|
||||
* \param value The value to be counted.
|
||||
* \return The number of elements equal to \p value.
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be a model of must be a model of <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>.
|
||||
* \tparam EqualityComparable must be a model of <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a> and can be compared for equality with \c InputIterator's \c value_type
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p count to
|
||||
* count the number of instances in a range of a value of interest using the \p thrust::device execution policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/count.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* // put 3 1s in a device_vector
|
||||
* thrust::device_vector<int> vec(5,0);
|
||||
* vec[1] = 1;
|
||||
* vec[3] = 1;
|
||||
* vec[4] = 1;
|
||||
*
|
||||
* // count the 1s
|
||||
* int result = thrust::count(thrust::device, vec.begin(), vec.end(), 1);
|
||||
* // result == 3
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/count.html
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename EqualityComparable>
|
||||
typename thrust::iterator_traits<InputIterator>::difference_type
|
||||
count(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, InputIterator first, InputIterator last, const EqualityComparable& value);
|
||||
|
||||
|
||||
|
||||
/*! \p count finds the number of elements in <tt>[first,last)</tt> that are equal
|
||||
* to \p value. More precisely, \p count returns the number of iterators \c i in
|
||||
* <tt>[first, last)</tt> such that <tt>*i == value</tt>.
|
||||
*
|
||||
* \param first The beginning of the sequence.
|
||||
* \param last The end of the sequence.
|
||||
* \param value The value to be counted.
|
||||
* \return The number of elements equal to \p value.
|
||||
*
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be a model of must be a model of <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a>.
|
||||
* \tparam EqualityComparable must be a model of <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality Comparable</a> and can be compared for equality with \c InputIterator's \c value_type
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p count to
|
||||
* count the number of instances in a range of a value of interest.
|
||||
* \code
|
||||
* #include <thrust/count.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* // put 3 1s in a device_vector
|
||||
* thrust::device_vector<int> vec(5,0);
|
||||
* vec[1] = 1;
|
||||
* vec[3] = 1;
|
||||
* vec[4] = 1;
|
||||
*
|
||||
* // count the 1s
|
||||
* int result = thrust::count(vec.begin(), vec.end(), 1);
|
||||
* // result == 3
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/count.html
|
||||
*/
|
||||
template <typename InputIterator, typename EqualityComparable>
|
||||
typename thrust::iterator_traits<InputIterator>::difference_type
|
||||
count(InputIterator first, InputIterator last, const EqualityComparable& value);
|
||||
|
||||
|
||||
/*! \p count_if finds the number of elements in <tt>[first,last)</tt> for which
|
||||
* a predicate is \c true. More precisely, \p count_if returns the number of iterators
|
||||
* \c i in <tt>[first, last)</tt> such that <tt>pred(*i) == true</tt>.
|
||||
*
|
||||
* The algorithm's execution is parallelized as determined by \p exec.
|
||||
*
|
||||
* \param exec The execution policy to use for parallelization.
|
||||
* \param first The beginning of the sequence.
|
||||
* \param last The end of the sequence.
|
||||
* \param pred The predicate.
|
||||
* \return The number of elements where \p pred is \c true.
|
||||
*
|
||||
* \tparam DerivedPolicy The name of the derived execution policy.
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c Predicate's \c argument_type.
|
||||
* \tparam Predicate must be a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p count to
|
||||
* count the number of odd numbers in a range using the \p thrust::device execution policy:
|
||||
*
|
||||
* \code
|
||||
* #include <thrust/count.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* #include <thrust/execution_policy.h>
|
||||
* ...
|
||||
* struct is_odd
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(int &x)
|
||||
* {
|
||||
* return x & 1;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* // fill a device_vector with even & odd numbers
|
||||
* thrust::device_vector<int> vec(5);
|
||||
* vec[0] = 0;
|
||||
* vec[1] = 1;
|
||||
* vec[2] = 2;
|
||||
* vec[3] = 3;
|
||||
* vec[4] = 4;
|
||||
*
|
||||
* // count the odd elements in vec
|
||||
* int result = thrust::count_if(thrust::device, vec.begin(), vec.end(), is_odd());
|
||||
* // result == 2
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/count.html
|
||||
*/
|
||||
template<typename DerivedPolicy, typename InputIterator, typename Predicate>
|
||||
typename thrust::iterator_traits<InputIterator>::difference_type
|
||||
count_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
|
||||
/*! \p count_if finds the number of elements in <tt>[first,last)</tt> for which
|
||||
* a predicate is \c true. More precisely, \p count_if returns the number of iterators
|
||||
* \c i in <tt>[first, last)</tt> such that <tt>pred(*i) == true</tt>.
|
||||
*
|
||||
* \param first The beginning of the sequence.
|
||||
* \param last The end of the sequence.
|
||||
* \param pred The predicate.
|
||||
* \return The number of elements where \p pred is \c true.
|
||||
*
|
||||
* \tparam InputIterator must be a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> and \c InputIterator's \c value_type must be convertible to \c Predicate's \c argument_type.
|
||||
* \tparam Predicate must be a model of <a href="http://www.sgi.com/tech/stl/Predicate.html">Predicate</a>.
|
||||
*
|
||||
* The following code snippet demonstrates how to use \p count to
|
||||
* count the number of odd numbers in a range.
|
||||
* \code
|
||||
* #include <thrust/count.h>
|
||||
* #include <thrust/device_vector.h>
|
||||
* ...
|
||||
* struct is_odd
|
||||
* {
|
||||
* __host__ __device__
|
||||
* bool operator()(int &x)
|
||||
* {
|
||||
* return x & 1;
|
||||
* }
|
||||
* };
|
||||
* ...
|
||||
* // fill a device_vector with even & odd numbers
|
||||
* thrust::device_vector<int> vec(5);
|
||||
* vec[0] = 0;
|
||||
* vec[1] = 1;
|
||||
* vec[2] = 2;
|
||||
* vec[3] = 3;
|
||||
* vec[4] = 4;
|
||||
*
|
||||
* // count the odd elements in vec
|
||||
* int result = thrust::count_if(vec.begin(), vec.end(), is_odd());
|
||||
* // result == 2
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.sgi.com/tech/stl/count.html
|
||||
*/
|
||||
template <typename InputIterator, typename Predicate>
|
||||
typename thrust::iterator_traits<InputIterator>::difference_type
|
||||
count_if(InputIterator first, InputIterator last, Predicate pred);
|
||||
|
||||
/*! \} // end counting
|
||||
* \} // end reductions
|
||||
*/
|
||||
|
||||
} // end thrust
|
||||
|
||||
#include <thrust/detail/count.inl>
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008-2012 NVIDIA Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/*! \file adjacent_difference.inl
|
||||
* \brief Inline file for adjacent_difference.h
|
||||
*/
|
||||
|
||||
#include <thrust/detail/config.h>
|
||||
#include <thrust/system/detail/generic/select_system.h>
|
||||
#include <thrust/system/detail/generic/adjacent_difference.h>
|
||||
#include <thrust/system/detail/adl/adjacent_difference.h>
|
||||
|
||||
namespace thrust
|
||||
{
|
||||
|
||||
|
||||
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
||||
OutputIterator adjacent_difference(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
{
|
||||
using thrust::system::detail::generic::adjacent_difference;
|
||||
|
||||
return adjacent_difference(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result);
|
||||
} // end adjacent_difference()
|
||||
|
||||
|
||||
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename BinaryFunction>
|
||||
OutputIterator adjacent_difference(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
|
||||
InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryFunction binary_op)
|
||||
{
|
||||
using thrust::system::detail::generic::adjacent_difference;
|
||||
|
||||
return adjacent_difference(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result, binary_op);
|
||||
} // end adjacent_difference()
|
||||
|
||||
|
||||
template <typename InputIterator, typename OutputIterator>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result)
|
||||
{
|
||||
using thrust::system::detail::generic::select_system;
|
||||
|
||||
typedef typename thrust::iterator_system<InputIterator>::type System1;
|
||||
typedef typename thrust::iterator_system<OutputIterator>::type System2;
|
||||
|
||||
System1 system1;
|
||||
System2 system2;
|
||||
|
||||
return thrust::adjacent_difference(select_system(system1, system2), first, last, result);
|
||||
} // end adjacent_difference()
|
||||
|
||||
|
||||
template <typename InputIterator, typename OutputIterator, typename BinaryFunction>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryFunction binary_op)
|
||||
{
|
||||
using thrust::system::detail::generic::select_system;
|
||||
|
||||
typedef typename thrust::iterator_system<InputIterator>::type System1;
|
||||
typedef typename thrust::iterator_system<OutputIterator>::type System2;
|
||||
|
||||
System1 system1;
|
||||
System2 system2;
|
||||
|
||||
return thrust::adjacent_difference(select_system(system1, system2), first, last, result, binary_op);
|
||||
} // end adjacent_difference()
|
||||
|
||||
|
||||
} // end namespace thrust
|
||||
|
||||
Loaded 100 of 1079 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user