340 Commits
Author SHA1 Message Date
Tanguy Pruvot b6422c763e import klaus bitcoin algo, update README
Note: cant be used to solo mine bitcoin ! :p
2015-06-18 05:09:35 +02:00
Tanguy Pruvot 22685f528a import credits algo (SHA256-168) 2015-06-18 05:09:35 +02:00
Tanguy Pruvot 576884b199 refactor: move pool functions in pools.cpp
ccminer.cpp begins to be too big...
2015-06-18 04:44:52 +02:00
Tanguy Pruvot 9f5744d4c0 luffa/cube: fine tuning of maxregcount for the 750Ti
This allow to get 69 regs used (tested on linux) 69 or 72 make
the compiler to use 64 regs which is not enough on the 750Ti
for optimal performance...
2015-06-17 03:58:31 +02:00
Tanguy Pruvot 634bea21f5 luffa/cube: unroll 1 really required on the 9xx 2015-06-17 03:39:48 +02:00
Tanguy Pruvot 42bcb91ca0 x11: update sp luffa/cube to get closer x11 speeds..
i had to clean it... lot of unused defines...
2015-06-17 02:31:15 +02:00
Tanguy Pruvot 4709668995 jh512: rewrite and optimize with asm swap
5% improvement by the vshl asm swap functions, mixed shl+add inst.,

Add also xchg(x, y) func and XCHG(x, y) define in cuda_helper for later use...

other jh changes are mainly for the beauty of the code...

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-06-16 08:20:48 +02:00
Tanguy Pruvot 79ee0ec264 zr5: some pok cleanup...
rename the var and only show warnings with --debug
2015-06-13 04:41:18 +02:00
Tanguy Pruvot d764b5cca2 lyra2: improve a bit the speed on SM 5.2
(simplified sp commit)
2015-06-13 01:31:40 +02:00
Tanguy Pruvot b72b4c5a5f api: fix summary sums with multi pools
and allow to get pool infos with the pool number as parameter

samples telnet queries: pool|0 pool|1
2015-06-12 18:05:53 +02:00
Tanguy Pruvot 268c89f9a2 zr5: fix launch bounds with pok xor 2015-06-12 18:01:35 +02:00
Tanguy Pruvot 2907a7c678 zr5: add support for pok mining (getwork)
I dont store txs on biggest transactions to reduce memory usage.

In this case, the pok bool is not enabled for the bloc...

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-06-12 08:24:50 +02:00
Tanguy Pruvot fcd3e4336b skein: restore secNonce support on sm 5+
Add a sanity check in common checkhash function to prevent the problem again...
2015-06-11 01:00:59 +02:00
Tanguy Pruvot 48b3f119be uint256: remove include where not required 2015-06-11 00:47:51 +02:00
Tanguy Pruvot efd507fb3b vstudio: add missing ssl/crypto includes for bignum 2015-06-11 00:17:44 +02:00
Tanguy Pruvot 39238f077d diff: import bitcoin bignum class for conversions
BIGNUM is defined in OpenSSL...
2015-06-11 00:03:19 +02:00
Tanguy Pruvot 5636e2be5e remove double reference to luffa algo
doomcoin is dead but the luffa algo is still used (Joincoin)..

keep doom as alias for compat... rename functions...
2015-06-10 22:10:16 +02:00
Tanguy Pruvot d25b42e41b Add diff-multiplier (-m) option
Remove -v and -m short params specific to heavycoin
 Add --diff-multiplier (-m) and rename --diff to --diff-factor (-f)

 --diff is kept for compat, but no more in help

This prevent using weird values like -f 0.0000125
2015-06-10 21:14:36 +02:00
Tanguy Pruvot 3e419abf84 qubit: implement cpu precalc (klaust)
improve qubit (+5%) deep and doom (+10%) hashrate

based on klausT code, simplified...
2015-06-10 19:46:17 +02:00
Tanguy Pruvot a55b148ecc windows: fix missing off_t include 2015-06-08 16:58:12 +02:00
Tanguy Pruvot cf077902d0 skein: fix sm5 secNonce and disable it on wallets 2015-06-08 16:58:12 +02:00
Tanguy Pruvot 82908b3f67 vstudio: regroup options and revove AVX requirement
+ openmp for scrypt code...
2015-06-08 16:58:07 +02:00
Tanguy Pruvot b02f79b58b lyra2: recover the kH/s lost in last commit 2015-06-06 00:25:04 +00:00
Tanguy Pruvot 2b43d57d42 lyra2: simplify skein code (no perf changes) 2015-06-05 23:32:43 +02:00
Tanguy Pruvot e95712a2ea lyra2: reduce blake message len. 2015-06-05 22:40:29 +02:00
Tanguy Pruvot ed4927fcd0 quark/x11: set signed int hashPosition vars to off_t
groestl (and keccak?) seems faster with 64bit vars (off_t or int64_t)...
2015-06-05 22:03:05 +02:00
Tanguy Pruvot 555504bd98 some changes related to wait stats 2015-06-05 20:36:48 +02:00
Tanguy Pruvot 2ea4635ef7 windows: scan time debug log was casted to 64bits int 2015-05-31 20:33:31 +02:00
Tanguy Pruvot 76b63b5a71 print the right cuda version 2015-05-31 19:00:20 +02:00
Tanguy Pruvot e791039592 check work restart status in miner thread
also reduce a bit possible duplicate shares...
2015-05-30 13:20:35 +02:00
Tanguy Pruvot 98f2f8c745 nvml warning fix and disable scrypt gpu test 2015-05-29 15:39:41 +02:00
Tanguy Pruvot c2f319fa86 multipool: fix some params like time-limit 2015-05-29 15:38:45 +02:00
Tanguy Pruvot ebe95aac2f bmw512: cleanup after cuda 7 bug fix 2015-05-29 14:32:23 +02:00
Tanguy Pruvot 52df82917a cuda: fix uint2 substract operator 2015-05-29 14:32:13 +02:00
Tanguy Pruvot 0224d4705e skein: fix wrong hashes seen on x11 with cuda 7
Look like a stream synch problem, not related to cuda 7 headers or cudart

The threadfence() added doesnt changes performances, and could also
be related to the random cpu validation errors... so keep it for all.

Note: the 80-bytes variant used in skein2 doesn't seems affected.
2015-05-29 12:16:54 +02:00
Tanguy Pruvot 123fe287b6 x11: temporary workaround for cuda 7.0 2015-05-28 21:19:24 +02:00
Tanguy Pruvot 85394cf22b cuda: reduce possible segfaults on exit
not perfect but helps...
2015-05-28 15:58:38 +02:00
Tanguy Pruvot 0c545eb724 nvml: check available memory clocks and fix param for -d 1
"-d 1 --gpu-clock 1200" was not working
2015-05-28 07:49:31 +02:00
Tanguy Pruvot f2c7a45e47 nvml: fix pstate api, nvmlDeviceGetPerformanceState works
on linux, 346.72
2015-05-28 07:10:00 +02:00
Tanguy Pruvot 75d721adb9 stratum: check if we have multiple pools to failover 2015-05-28 06:50:21 +02:00
Tanguy Pruvot e99ff6c15b nvml: clocks cleanup + pstate check (still not supported) 2015-05-28 06:47:23 +02:00
Tanguy Pruvot cbd7865a79 nvml: check supported graphics clocks...
and use reset application clocks api
2015-05-27 18:15:38 +02:00
Tanguy Pruvot a08056ed2a linux: reset modified application clocks 2015-05-27 15:50:10 +02:00
Tanguy Pruvot c9d110e543 linux: allow to set application clocks
Since linux driver 346.72, nvidia-smi allow to query gpu/mem clocks

Tested ok on the Asus Strix 970, but fails on the Gigabyte 750 Ti

system could require first persistence mode and app clock unlock :
    nvidia-smi -pm 1
    nvidia-smi -acp 0

supported values are displayed by
    nvidia-smi -q -d SUPPORTED_CLOCKS

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-05-27 14:34:39 +02:00
Tanguy Pruvot 7500af78eb linux: add build notes for fedora 22 2015-05-27 11:59:28 +02:00
Tanguy Pruvot 5be1521294 Increase max password size to 128 chars (nicehash)
--pass="f0=0;f2=0;f3=2.7;f4=1.9;f5=99;f6=1.8;f7=7.9;f8=0;f9=0.45;f10=0;f11=4.3;f12=3.9"
2015-05-26 15:39:41 +02:00
Tanguy Pruvot b165cc32e6 v1.6.4 2015-05-26 12:29:03 +02:00
Tanguy Pruvot 2d5755d1ef linux: add missing scrypt jansson includes 2015-05-26 10:56:23 +02:00
Tanguy Pruvot 90c26c8418 multipool: prevent last longpoll http errors on switch 2015-05-26 10:13:57 +02:00
Tanguy Pruvot 692041aa74 multipool: allow failover switch from getwork 2015-05-26 09:51:46 +02:00
Tanguy Pruvot 0618c2abc3 fix for vstudio 2015-05-26 09:51:46 +02:00
Tanguy Pruvot b2b76f8006 stratum: check stratum_gen_work result
and remove useless purge test...
2015-05-25 07:43:39 +02:00
Tanguy Pruvot f1a55b3388 algo aliases, fix max-diff param without pool config 2015-05-25 03:17:53 +02:00
Tanguy Pruvot 58a5ccfd6a Prepare the 1.6.4 release... 2015-05-23 05:28:28 +02:00
Tanguy Pruvot bbd2c704f9 multipool: Squashed commit (v2)
commit a9d3c1ffdb
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu May 21 05:39:24 2015 +0200

    multipool: last changes before squashed merge

    and fix net diff on wallets.. was longpoll specific

commit a63f0024f3
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu May 21 05:02:27 2015 +0200

    update api sample for the protocol 1.5

commit adda14b22e
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu May 21 04:43:25 2015 +0200

    stats: store pool number in scanlog

commit e1a0274b01
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu May 21 03:36:15 2015 +0200

    api: switchpool and new pool stats variables (API v1.5)

    add accepted/rej by pool, wait time on conditional, net diff and rate

    also add scantime per pool config option and do some pool cleanup..

commit 1a30450ad2
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Wed May 20 06:39:09 2015 +0200

    prevent concurrent pool switching

    and limit condtionnal wait messages to the first thread/device

commit e3922c7a33
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Wed May 20 05:39:45 2015 +0200

    add some pool rotate options, like pool time-limit

    update sample pools.conf for time rotation

commit 312bd90541
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Wed May 20 04:31:19 2015 +0200

    do not try to restart threads from threads

    Start inconditionally the stratum and longpoll threads,
    these threads are just waiting a tq_push() if unused...

    so add some checks to know if vars are set for the right pool

commit d4a9428fef
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Wed May 20 01:06:31 2015 +0200

    pools: add name and removed attributes

    also increase max defined pools to 8

    to be tested on windows..

commit d840d683ec
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue May 19 22:33:11 2015 +0200

    parse json config file pools array

commit d6c29b1f7f
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue May 19 03:29:30 2015 +0200

    multi-pools: prepare storage/switch of credentials

    for the moment:
    - allow the storage of multiple -o params (and user/pass)
    - allow a failover pool on connection failed
    - switch to the next pool with the "seturl" api remote command
    - longpoll to stratum switch (reverse to check...)

    todo: mix stratum/getwork, new api commands, json config...

commit 2d6b3fddf6
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Fri May 22 08:26:40 2015 +0200

    multipool: increase stability, but not 100% perfect

    several problems fixed:
    - submit to the pool set in work (source pool)
    - longpoll curl timeout could be too high and could lock the switch
    - mutexes cant be copied on windows (stratum global var to fully remove later)

    I linked the -T timeout option to curl and tried to remove all fixed timeout values

commit 6fd935c369
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Fri May 22 11:23:07 2015 +0200

    stratum: remove last rpc_ vars in stratum thread

commit ee9c821525
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat May 23 03:53:50 2015 +0200

    stratum: do not alloc empty merkle tree

commit 69852a2874
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat May 23 04:25:12 2015 +0200

    stratum: properly free jobs on disconnect

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-05-23 05:28:12 +02:00
Tanguy Pruvot 298573b45d Drop Whirlpool and whirpoolx algos, no more used...
Vanillacoin is now PoS only
2015-05-19 01:05:38 +02:00
Tanguy Pruvot 7456acc01c netdiff: quark is specific too, qubit is normal 2015-05-19 00:36:37 +02:00
Tanguy Pruvot a2b6488c01 Compute and display network diff (nbits) if max-diff
was only made on the wallets with getmininginfo

Todo: double check for all algos/pools

tested ok on x11, lyra2, skein, skein2, zr5 stratum/longpoll

Scrypt-Jane pool net diff seems incorrect, disabled
Neoscrypt could be different also (untested, disabled)...
2015-05-18 08:17:45 +02:00
Tanguy Pruvot 87a521ac14 some clean up 2015-05-18 05:41:54 +02:00
Tanguy Pruvot d7abd01bf4 scrypt(titan): small kernel code optimisations 2015-05-18 00:12:55 +02:00
Tanguy Pruvot b1bddb54d6 scrypt: reduce cpu usage (flush/sync)
and do some minimal keccak changes (for jane)
2015-05-18 00:11:48 +02:00
Tanguy Pruvot 9aace79718 scrypt: clean some defines
and prevent error reports on Ctrl+C
2015-05-17 19:45:00 +02:00
Tanguy Pruvot d9b0312897 x64: fix some size_t warnings 2015-05-17 04:56:42 +02:00
Tanguy Pruvot c418eff4e9 api: auto bind to first available port
when default port is used, else keep trying for one minute

This allow to auto-detect processes iterating 4068,69,70...
2015-05-16 04:56:01 +02:00
Tanguy Pruvot 374cd50f00 start 1.6.4 work... 2015-05-15 22:11:37 +02:00
Tanguy Pruvot 809cd3dc42 Allow to retrieve benchmark results with a time-limit
sample command line :
ccminer -a x11 -d 0 --benchmark --time-limit 30 2>result.txt
2015-05-15 22:09:28 +02:00
Tanguy Pruvot 4daaf1908d some cleanup... 2015-05-15 21:45:43 +02:00
Tanguy Pruvot 0d89236fd4 windows: do not trap CTRL_CLOSE event 2015-05-15 01:20:51 +02:00
Tanguy Pruvot 0ab02df9e2 fix some warnings... seen in vstudio... 2015-05-15 00:15:34 +02:00
Tanguy Pruvot b4ab64e5f3 prepare the 1.6.3 release 2015-05-14 23:42:11 +02:00
Tanguy Pruvot 76f8fbabae stratum: prevent gpu scans before a job is retrieved
and remove loopcnt var, can be done with firstwork_time
2015-05-14 23:36:25 +02:00
Tanguy Pruvot 51abf151ee internal opt_extranonce param, not linked to cmdline... 2015-05-14 21:22:00 +02:00
Tanguy Pruvot 477d3bfd7c summer is close, start conditional mining
add params --max-temp 75, --max-rate 112.5M and --max-diff 5.0 (best for solo mining)

Note: not all the wallets are reporting the network mining difficulty and hashrate
2015-05-14 20:41:42 +02:00
Tanguy Pruvot 051ba521be skein2: minimal host changes 2015-05-14 19:38:03 +02:00
Tanguy Pruvot fbafe814dd update README 2015-05-12 21:41:14 +02:00
Tanguy Pruvot 4c3892f268 Merged skeincoin algo for SM5+ devices
Should give same or better than SP and klaus versions

Keep old code for older devices and skein2 compat

Linux perf: 750Ti 78MH/s and GTX 970 260MH/s

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-05-12 21:32:33 +02:00
Tanguy Pruvot 3955eb7a1d windows: implement background option
was only for linux, so reduce usage difference

beware, no way to turn it back to visible yet...

to prevent hiding your console, you can use :
start ccminer -B -c ccminer.conf
2015-05-12 18:54:35 +02:00
Tanguy Pruvot 7bf256c81c cuda_helper: define UINT32_MAX if not defined
seems not defined on slackware...
2015-05-12 18:05:09 +02:00
Tanguy Pruvot 2f541065fb cuda_helper: rename correctly hiword/loword functions 2015-05-12 17:13:58 +02:00
Tanguy Pruvot b35a6742fe cuda_helper: properly ifdef for vstudio c++ compat 2015-05-12 05:33:57 +02:00
Tanguy Pruvot 4b4564ff93 vstudio: move root algos in CUDA filter 2015-05-12 04:49:53 +02:00
Tanguy Pruvot afe57f8341 rename skein2 to c++, no cuda kernel code
and some other changes...
2015-05-12 04:41:11 +02:00
Tanguy Pruvot ff27ccb80e stats: simplify the storage filter
the gpu id key filter was useless, use thread ids...
2015-05-12 02:40:50 +02:00
Tanguy Pruvot 7c769211a8 intensity: fix value on multi-threaded devices
Set the value for all threads when using -i 20 -d 0,0,0 ...
2015-05-12 02:40:50 +02:00
Tanguy Pruvot 12fd78e2be config: remove AVX/2 entries, not for us 2015-05-12 02:40:50 +02:00
Tanguy Pruvot be478bd725 groestl: tabs to space + arch check 2015-05-12 02:40:50 +02:00
Tanguy Pruvot 74e94fa1ec myriad/groestl: some more cleanup + tabs... 2015-05-10 20:20:50 +02:00
Tanguy Pruvot 03c3b7d341 Various algos cleanup + lyra2 sec nonce fix 2015-05-10 18:49:22 +02:00
Tanguy Pruvot 34fd408440 lyra2: get a second nonce per gpu scan 2015-05-10 03:20:13 +02:00
Tanguy Pruvot 954dbf2388 neoscrypt: last vstudio bool warnings fix 2015-05-09 20:59:28 +02:00
Tanguy Pruvot c722fafe49 neoscrypt: reduce gpu reg count with sp precalc
also prevent bool in cuda prototype, linkage mismatch in vstudio... sigh
2015-05-09 20:45:32 +02:00
Tanguy Pruvot 1b31f11252 neoscrypt: cleanup...
My SM 3.0 functions are ok but djm34 implementation uses too much registers
for this arch...
2015-05-09 19:42:23 +02:00
Tanguy Pruvot 7c7f40a634 neoscrypt: attempt to recode shift256R for SM 3.0 2015-05-08 23:42:24 +02:00
Tanguy Pruvot 6bb128c055 neoscrypt: strip cuda_vectors.h useless functions
fix build break for SM 3.0 (but neoscrypt is not yet compatible)
2015-05-08 21:02:40 +02:00
Tanguy Pruvot 75313cbf1c neoscrypt: put all files in same vs filter 2015-05-05 16:25:18 +02:00
Tanguy Pruvot 73af5c583c neoscrypt: fixes for windows 2015-05-05 16:15:53 +02:00
Tanguy Pruvot 464c45034a neoscrypt: more code lifting... 2015-05-04 15:36:28 +02:00
Tanguy Pruvot e1b274ef65 neoscrypt: fix bad source file ext (cu/cpp) 2015-05-04 13:37:56 +02:00
Tanguy Pruvot 15584e4f05 neoscrypt: adapt for visual studio compat
todo: fix SM 3.0 builds
2015-05-03 15:53:02 +02:00
Tanguy Pruvot 65c1d787e7 add neoscrypt based on djm34 work
indent, link --intensity, and some clean up

Tested speed on linux ~= 160kH/s on a 750Ti (Black Edition)

To be continued...
2015-05-03 14:38:15 +02:00
Tanguy Pruvot 2113be6eec blake80: some changes and launch bounds, no perf changes 2015-04-24 14:12:21 +02:00
Tanguy Pruvot d1966cc085 remove dyn alloc of thr_hashrates 2015-04-24 12:12:45 +02:00
Tanguy Pruvot 3d3f2e2cb5 warnings: use the right device id (device_map[thr_id]) 2015-04-23 09:41:56 +02:00
Tanguy Pruvot b1e9277611 start 1.6.3... 2015-04-23 08:18:04 +02:00
Tanguy Pruvot d2ced77ae8 zr5: disable reset on validation errors
cudaResetDevice() do a segfault, to check later...
2015-04-23 08:14:55 +02:00
Tanguy Pruvot 7cd74cb212 scrypt: remove an unused file 2015-04-21 19:11:11 +02:00
Tanguy Pruvot 7edc02633f linux: return to SM 5.0 only default
and tag version 1.6.2
2015-04-21 17:52:09 +02:00
Tanguy Pruvot 22c28ccbef scrypt: strip keccak/blake 256 remains 2015-04-21 17:43:25 +02:00
Tanguy Pruvot a0c8bd8be4 update readme for release 2015-04-21 17:04:14 +02:00
Tanguy Pruvot e74d5884b4 scrypt: final cleanup for 1.6.2 release 2015-04-21 16:56:22 +02:00
Tanguy Pruvot ca9ec1b803 scrypt: compile also titan kernel with recent SM 2015-04-21 16:18:21 +02:00
Tanguy Pruvot a6d88abbc9 scrypt: finish scrypt-jane algo import 2015-04-21 13:20:35 +02:00
Tanguy Pruvot 9208888c57 scrypt: assign specific compute models to the kernels 2015-04-21 11:12:41 +02:00
Tanguy Pruvot 4f379803d3 scrypt: remove some unused functions/algo checks
there was remains of blake algo
2015-04-21 09:51:09 +02:00
Tanguy Pruvot 1ad34dc13d reset: take care of multi-threaded gpus (-d 0,0)
to be tested... could create problems when reset in a chain like x11...
2015-04-21 09:12:43 +02:00
Tanguy Pruvot c7698afb4a scrypt: add --interactive option
also tested batchsize and texturecache but seems useless,
they can be tested/tuned directly in kernel variants...

Note: -i cuduminer param is already used in ccminer (--intensity)
2015-04-19 15:25:14 +02:00
Tanguy Pruvot c6a94c9998 Add time-limit option and exit codes
based on cudaminer implementation...
2015-04-19 12:16:01 +02:00
Tanguy Pruvot b8b810f30d scrypt: autotune, launch-config and lookup-gap options
also enhance scrypt variants algo checks to be case insensitive
2015-04-19 11:37:30 +02:00
Tanguy Pruvot 9dc78da2ee import and adapt scrypt from cudaminer project
scrypt-jane under work...
2015-04-18 18:24:55 +02:00
Tanguy Pruvot 275a028935 skein: compute midstate first
"Real" optimization based on KlausT precalc
2015-04-16 02:11:37 +02:00
Tanguy Pruvot e7ae27137e x11/qubit: remove some extra MyStreamSynchronize
only one per loop is required to prevent 100% cpu usage
2015-04-15 05:30:22 +02:00
Tanguy Pruvot 163430daae Skein/Skein2 SM 3.0 devices support
+ code cleanup

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-04-15 01:27:48 +02:00
Tanguy Pruvot d58d53f2b2 update README, small changes, prepare release 1.6.1
still need a SM 3.0 fix for skein...
2015-04-14 23:28:00 +02:00
Tanguy Pruvot 7963dbb438 skein2 algo for woodcoin
Also known as Double Skein

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-04-14 02:03:58 +02:00
Tanguy Pruvot 48515ad707 groestl: rename included cuda files 2015-04-06 23:46:34 +02:00
Tanguy Pruvot 0fceca6ffe zr5: reinit the card correctly on errors
previous method was doing a segfault...
2015-04-06 23:46:34 +02:00
Tanguy Pruvot dcdafd8732 zr5: enhance pok hash system
And store some vars on the device to reduce proc params
2015-04-04 02:45:54 +02:00
Tanguy Pruvot 7c25f6dc0a zr5: disable some of the stratum stale work checks 2015-03-28 15:23:03 +01:00
Tanguy Pruvot 37395eefe4 skein: restore previous x11 speed 2015-03-28 13:32:08 +01:00
Tanguy Pruvot 6d74256c2d pluck: some cleanup 2015-03-28 12:04:53 +01:00
Tanguy Pruvot 4f43abb402 bmw512: indent and restore SM 3.0 compat
could be also the source of the problem seen with CUDA 7

restored the code before sp/klaus changes for SM 3.0 devices...
2015-03-28 12:01:50 +01:00
Tanguy Pruvot 38e6672d70 Allow test of SM 2.1/3.0 binaries on newer cards
Implementation based on klausT work.. a bit different

This code must be placed in a common .cu file,
cuda.cpp is not compiled with nvcc and doesnt allow cuda code...
2015-03-28 12:00:53 +01:00
Tanguy Pruvot 4426700e31 Add the -n (--ndevs) option like cgminer 2015-03-27 15:24:44 +01:00
Tanguy Pruvot f86784ee56 Add skein algo (Skeincoin, Myriad, Unat...)
SKEIN512 + SHA256

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-03-27 15:24:27 +01:00
Tanguy Pruvot a37e909db9 Add zr5 algo (for SM 3.5+)
uint4 copy + keccak cleanup, groestl: small uint4 opt

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-03-27 15:16:25 +01:00
Tanguy Pruvot 5988e945ef some cleanup and longpoll changes 2015-03-27 08:03:26 +01:00
Tanguy Pruvot 9734186a37 jh512: import and improve klaus and sp changes
did not import the extra final function, which should stay compatible
with the common cuda_check_hash()
2015-03-20 05:36:40 +01:00
Tanguy Pruvot e7567332f4 pluck: fix SM 3.0 compilation 2015-03-19 03:13:07 +01:00
KlausT ae8e863591 remove uint32_t cast 2015-03-12 01:01:47 +01:00
Tanguy Pruvot 35cc5908ee windows: return to normal priority, fix json decref
the jansson error seems only seen in windows debug mode
2015-03-10 19:14:15 +01:00
Tanguy Pruvot 8b1137d5ec solo: get mining infos (diff/net hashrate)
will be exported in the api too...
2015-03-10 04:19:49 +01:00
Tanguy Pruvot 7f00bce5ae longpoll: auto disable gbt when not supported 2015-03-10 01:09:47 +01:00
Tanguy Pruvot 4acb9c5743 git: remove auto generated cpuminer-config.h.in 2015-03-09 14:25:43 +01:00
Tanguy Pruvot 86a31172b0 cputest: dont share mem of buf and scratchpad
and change algo names color to green...
2015-03-09 03:08:51 +01:00
Tanguy Pruvot 2c2269dcb6 cputest: cleanup + calloc 2015-03-09 02:49:11 +01:00
Tanguy Pruvot 5e42389b4b pluck: finish the algo, add cpu validation 2015-03-09 02:21:44 +01:00
Tanguy Pruvot d6a421ae10 whirlpoolx: windows stay fluent with intensity 20 2015-03-08 23:00:59 +01:00
Tanguy Pruvot ebd23bcc66 whirlpoolx: real fix for multi gpus
Main problem was the arrays allocations which should be made per cpu

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-03-08 22:56:04 +01:00
Tanguy Pruvot c1cfb3a131 cmdline: fix multi-gpu intensity
the comma presence check was wrong...
2015-03-08 16:45:09 +01:00
Tanguy Pruvot 77c737ff72 various small changes and update readme 2015-03-08 16:33:53 +01:00
Tanguy Pruvot 7939dce0aa pluck: adaptation from djm repo
remains the cpu validation check to do...

throughput for this algo is divided by 128 to keep same kind of intensity values (default 18.0)
2015-03-08 15:16:11 +01:00
Tanguy Pruvot 10d4f4a96a whirlpoolx: try to fix linux hashrates
bug reported by PVMining with a lot of cards (not seen here)
2015-03-08 14:21:39 +01:00
Tanguy Pruvot f8f46bfe5b whirlpoolx: fix for multi-gpu support
add also cputest entry and do some cleanup...
2015-03-07 16:33:04 +01:00
Tanguy Pruvot 0019936328 Import Whirlpoolx algo from alexis78 repo
remove trailing spaces and move to x15 folder
2015-03-07 14:06:33 +01:00
Tanguy Pruvot 0f604439f5 api: fix high port numbers
and convert ccminer.rc from utf-16 to Latin1 (doesnt want utf-8),
required for git diff/merge/rebase...
2015-03-05 18:29:17 +01:00
Tanguy Pruvot 7048300ab8 enhance 64bit builds performance
x11 perf is now close to x86 binary, but its not the case on all algos.

Add also a build.cmd script to remember how to build on windows cmdline
2015-03-05 18:18:56 +01:00
Tanguy Pruvot 3ed1c552bd cuda: always disable asm for host code 2015-03-05 18:15:52 +01:00
Tanguy Pruvot 9c4158aadb debug: x11 algo traces for cuda 7 problem 2015-03-02 16:29:46 +01:00
Tanguy Pruvot 7fd594c922 dos2unix install-sh script (make install-strip) 2015-03-02 11:51:28 +01:00
Tanguy Pruvot e17d19cf26 increase default priority to above normal
This enhances the hashrate when mining together with a cpu miner,
and doesn't slow down the machine, ccminer doesn't use a lot of cpu.

Note: this value doesn't require Admin rights on windows, unlike highest ones.
2015-03-02 11:51:28 +01:00
Tanguy Pruvot e6112e878d cleanup: use unsigned throughput parameters
Yes, its a big commit, was waiting 1.6 to do that...
Sorry for your possible merge issues ;)
2015-02-28 14:05:09 +01:00
Tanguy Pruvot 81fd04a208 hashrate: Remove some extra units and allow 4 digits
to keep current X11 output (sample: 2950.01 kH/s)
2015-02-22 11:46:21 +00:00
Erik Mossberg c41d9e7bb6 hashrate: format units based on the value size 2015-02-22 11:46:21 +00:00
Tanguy Pruvot a537fa304c Add basic API remote control
only allowed if --api-remote parameter or config key is set

and fix possible problem with urls containing user:password@

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-02-13 06:57:44 +01:00
Tanguy Pruvot 836e9bd535 qubit: fix difficulty factor for yaamp 2015-02-11 23:55:03 +01:00
Tanguy Pruvot 20e6ee1062 qubit: fix difficulty factor for yaamp 2015-02-11 18:42:04 +01:00
Tanguy Pruvot 09c3ac6b4b linux: fix missing dirname include 2015-02-11 18:36:57 +01:00
Tanguy Pruvot 5dd2534df9 Handle a default config file (ccminer.conf)
This allow to "debug" easily in visual studio (without project changes)

Prepare version 1.5.3, update README
2015-02-11 01:34:56 +01:00
KlausT bb71232f18 don't call timeEndPeriod twice 2015-02-09 18:27:54 +01:00
Tanguy Pruvot 00803b0b8d Revert "I use CUDA7 on windows"
This reverts commit a74df25834.
2015-02-08 18:41:40 +01:00
Tanguy Pruvot a74df25834 I use CUDA7 on windows 2015-02-08 18:41:28 +01:00
Tanguy Pruvot e3fc059bd7 Hide cpu binding log messages 2015-02-08 18:39:20 +01:00
Tanguy Pruvot 2d5e8aaced anime: fix uint2 error (bmw) 2015-02-08 18:32:42 +01:00
Tanguy Pruvot 10a5e13fb3 Add windows icon and version 2015-02-08 18:31:46 +01:00
KlausT a452c330dd quark: remove unused variables 2015-02-02 10:41:14 +01:00
Tanguy Pruvot 872a55a180 Remove debug printf in cpu mask feature 2015-01-27 11:31:28 +01:00
Tanguy Pruvot c7d3498bd8 myr-gr: clean up 2015-01-24 17:20:13 +01:00
Tanguy Pruvot 3938dce740 api: one decimal is enough for intensity
and fix windows build... missing __func define
2015-01-24 12:45:06 +01:00
Tanguy Pruvot 26b51a557b Allow different intensity per device
and clean the old variables, no more required
2015-01-24 11:17:29 +01:00
Tanguy Pruvot 768b5ccb76 import bmw512 uint2 changes from sp
+ some cleanup... 15KH/s won (750Ti)
2015-01-24 08:02:41 +01:00
Tanguy Pruvot 9f2dd3ee60 Remove some useless conversions
do not impact perfs neither...
2015-01-24 08:00:22 +01:00
Tanguy Pruvot 45206e49c1 hamsi: TPB of 128 give better results (+10kh) 2015-01-24 07:17:12 +01:00
Tanguy Pruvot bba2df56d5 cpu-affinity: linux thread affinity was not set correctly 2015-01-23 04:59:19 +01:00
Tanguy Pruvot 833238cae5 cpu-affinity: fix windows process cpu affinity mask 2015-01-23 02:49:30 +01:00
Tanguy Pruvot dfa9f63886 api: report intensity and throughput for each thread
even when no parameter is set (default set in each algo code)
2015-01-22 06:36:22 +01:00
Tanguy Pruvot 2a5233f56e api: report throughput when default 2015-01-22 06:28:59 +01:00
Tanguy Pruvot bec89724d5 logs: prevent multiple warnings 2015-01-22 05:55:50 +01:00
Tanguy Pruvot cafd4477d7 Handle a maximum of 16 gpus (vs 8 before)
Some cards have 2 gpus on board...
2015-01-22 04:55:27 +01:00
Tanguy Pruvot 65cefa4a7d cpu-priority: fix for windows process 2015-01-22 03:09:03 +01:00
Tanguy Pruvot c3b6162899 Add cpu priority and affinity parameters
priority param value is from 0 (default idle like before) to 5 (highest)

affinity could be enhanced to set multiple cores... todo

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2015-01-22 02:08:05 +01:00
Tanguy Pruvot 6500160fe1 api: add cuda threads count 2015-01-19 00:59:25 +01:00
Tanguy Pruvot b521acb480 groestl: use sp bitslice enhancement, prepare SM 2.x variant
todo: simd512 SM 2.x variant (shfl op), and groestl/myriad functions
2015-01-19 00:42:14 +01:00
Tanguy Pruvot 29c3db5dc6 fix linux configure 2015-01-17 20:10:50 +01:00
Tanguy Pruvot ec454dd78c api: add fan rpm (windows nvapi only) 2014-12-26 15:33:55 +01:00
Tanguy Pruvot f761531436 Fix to build with nvcc in path (crux) 2014-12-26 15:28:32 +00:00
Tanguy Pruvot 5cbf239d8a api: add kernel version for linux 2014-12-26 15:20:03 +00:00
Tanguy Pruvot b3188669e2 lyra2: cleanup
quickly tested with a SM 3.0 binary...
2014-12-20 13:10:33 +01:00
Tanguy Pruvot da2e2528a7 uint2: fix SM 3.0 ROR and ROL
Not sure its the fastest way, but it works for offsets 0-63 + 64

Also note than asm SM 3.5+ doesn't support ROR with offset 64
2014-12-19 21:45:40 +01:00
Tanguy Pruvot 2dce6733a7 pentablake: cleanup 2014-12-19 20:05:55 +01:00
Tanguy Pruvot f08bd79a6e Intelligent duplicate shares check
Only enabled on first duplicate share
2014-12-19 12:49:04 +01:00
KlausT 756ea89ecd lyra2 +100kh for GTX970 2014-12-19 11:59:00 +01:00
Tanguy Pruvot 150d6eb290 qubit: fix wrong pool difficulty
hmm... this is weird, should be 256 but make bad shares on pool diff 2
2014-12-19 09:43:35 +01:00
Tanguy Pruvot 90efbdcece simd cleanup 2014-12-19 09:16:55 +01:00
Tanguy Pruvot ec5a48f420 x11: small simd512 gpu_expand improvement 2014-12-19 09:16:55 +01:00
Tanguy Pruvot a66d78e692 reduce lyra2 blake and pentablake cpu load 2014-12-19 09:16:55 +01:00
Tanguy Pruvot 010eba1760 start 1.5.2 dev 2014-12-19 09:16:55 +01:00
Tanguy Pruvot 9b5d3bf528 Fix whirl algo 2014-12-19 09:16:51 +01:00
Tanguy Pruvot ac9b0d27ee Release final 1.5.1 2014-12-17 01:30:42 +01:00
Tanguy Pruvot 63e3387dbb lyra2: add sm30 device compat (skein256) 2014-12-16 14:19:07 +01:00
Tanguy Pruvot 1e24e4899c skein: uint2 optimisation with SM 3.0 compat (+15KH)
Thanks to sp and djm34 for this fast uint64 storage alternative
2014-12-16 13:52:54 +01:00
Tanguy Pruvot 2585e10814 keccak uint2 optimisation for SM>3.0 (x11 +40KH/s)
based on djm34 keccak 256-bit changes, and keep SM3.0 compat

affect most other algos too (quark, nist5, x13...)
2014-12-15 11:34:03 +01:00
Tanguy Pruvot fa7d744a6c lyra2: make_uint2 and set pool difficulty 2014-12-15 09:48:27 +01:00
Tanguy Pruvot 7a0f7ab276 solo: stop submit of solved blocs (stale work)
rejects in solo mode often means "generated block is stale" (see Debug.log)

Most of current wallets only reports "rejected" reason without explanations.

So prevent this common error,
you can turn off this gbt feature (height check) with --no-gbt option.
2014-12-08 06:31:07 +01:00
Tanguy Pruvot d09ec41251 api: allow -b <ip>, and set bind retry to 20sec
before, only -b <ip:port>, <port> or 0 (disable) was allowed

easier to set -b 0.0.0.0 with default port
2014-12-08 04:13:41 +01:00
Tanguy Pruvot 70743eb48d solo: get bloc height and trap more errors
and disable multiple nonce on wallets,
a bloc cant be resolved twice ;)

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-12-07 16:53:05 +01:00
Tanguy Pruvot 49a73971c4 Enhance stale work detection + throughput fixes
seems to resolve solo mining lock on share.
export also computed solo work diff in api (not perfect)

In high rate algos, throughput should be unsigned...
This fixes keccak, blake and doom problems

And change terminal color of debug lines, to be selectable in putty,
color code is not supported in windows but selection is ok there.
2014-12-07 12:58:41 +01:00
Tanguy Pruvot f9bba0ff1a lyra2: small changes and code cleanup 2014-12-07 09:04:03 +01:00
Tanguy Pruvot ef8a73d6aa keccak: not compatible with second nonces (was broken)
Use djm34 new uint2 method to get a +40% boost (115 to 153MH/s)
2014-12-06 13:55:13 +01:00
Tanguy Pruvot 78f2dd6ffd lyra2: reduce default intensity on windows 2014-12-06 13:03:25 +01:00
Tanguy Pruvot 5db46b74b5 lyra2: fix cpu hash + validation 2014-12-06 11:51:25 +01:00
Tanguy Pruvot c5b349e079 Add Lyra2 algo, based on Vertcoin published code
Seems to be djm34 work, i recognize the code style ;)

Code was cleaned/indented and adapted to my fork...

Only usable on the test pool until 16 december 2014!
2014-12-06 11:28:26 +01:00
Tanguy Pruvot 6c7fce187b x11: use KlausT optimisation (+20 KHs)
But use a define in AES to use or not device initial memcpy

I already tried to use everywhere direct device constants
and its not faster for big arrays (difference is small)

also change launch bounds to reduce spills (72 regs)

to check on windows too, could improve the perf... or not
2014-12-06 04:14:36 +01:00
Tanguy Pruvot c3bdb623e8 Check and submit multiple nonces in one loop
Added to most algos, checkhash function scans a big range
and can find multiple nonces at once if the difficulty is low.

Stop ignoring them, submit second one if found...

Clean the draft code for rc=2 implemented for blake and pentablake

btw... fix the reduced displayed hashrate when a nonce is found...

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-12-05 15:53:40 +00:00
Tanguy Pruvot f387898ead Prepare multiple nonces support in one loop (if found)
Tested on x11 which find sometimes 3 nonces in one call,
actually they are ignored because only the biggest was kept...

This commit doesnt fix that, but will allow to enhance shares rate later...
2014-12-05 10:16:06 +01:00
Tanguy Pruvot a186a4df8b websocket: enhance histo sample for 2 GPUs 2014-12-03 09:53:23 +01:00
Tanguy Pruvot 543de0a73c api: add support for websocket calls
Allow to directly get api data in HTML5

Tested on Chrome... IE>=10 required, not tested

IE11 seems buggy on connection close...  todo

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-12-03 08:35:27 +01:00
Tanguy Pruvot 2dcf983290 solo: remove remains of stale debug logs 2014-12-01 06:05:03 +01:00
Tanguy Pruvot 56ed0fed05 blake: remove hashharder workaround 2014-12-01 05:58:01 +01:00
Tanguy Pruvot 118a6be361 checkhash: simplify the common function
use klaus trivial function, the old code has always been a bit weird..

split cuda_check_cpu_hash_64 in two functions, keep old for branched stuff
2014-12-01 00:20:40 +01:00
KlausT cc9df2d361 use ROTL32 in x14_shabal
no impacts on perf but easier to read
2014-11-30 20:31:19 +01:00
Tanguy Pruvot 56170bb32e nvml: cleanup and check api restrictions
there was too much wrap_ prefixes, internal cleanup

SetAPIRestriction reports success but we can not query/set app clocks
2014-11-29 09:13:00 +01:00
Tanguy Pruvot c218c3f514 quark/anime: +100KH, bmw tpb was not correct
This small change also enhance a bit x11..17 algos
2014-11-28 22:18:48 +01:00
Tanguy Pruvot 8ad180cc70 various small changes
heavy: reduce by 256 threads default intensity to all -i 20
cuda: put static thread init bools outside the code (made once)
api: fix nvml header to build without
2014-11-28 20:57:35 +01:00
Tanguy Pruvot f524917bef update readme and openssl (1.0.1i) 2014-11-27 12:01:11 +01:00
Tanguy Pruvot 1b65cd05cc heavy: add error checks, fix strict aliasing and linux
The core problem was the cuda hefty Thread per block set to high
but took me several hours to find that...

btw... +25% in heavy 12500 with 256 threads per block... vs 128 & 512
if max reg count is set to 80...
2014-11-27 09:14:59 +01:00
Tanguy Pruvot 1032f191bf api: update sample php ui with pool
and report pstate in hwinfo only
2014-11-27 00:48:40 +01:00
Tanguy Pruvot 6ae28162db various extern cleanup + api history uids and gpu SM
uids could be useful to create graphes from history data

Note: please do a clean build after this commit (changes in miner.h)
2014-11-26 11:55:42 +01:00
Tanguy Pruvot cb3f893a85 nvml: fully disable it on windows
The DLL exists for x64 targets but seems not loadable

The nvml.cpp code was wrote to support both NVAPI and NVML on windows
because both apis have unique "features". like Fan RPM vs Fan Percent
2014-11-26 09:57:58 +01:00
Tanguy Pruvot d3258d8bcd syslog: allow to set a custom prefix
will allow kopiemtu livecd internal monitor to set it to cpuminer
2014-11-25 22:37:38 +01:00
Tanguy Pruvot 9b1ff1280e Allow intermediate intensity (decimals)
Sample with -i 18.5
  Adding 131072 threads to intensity 18, 393216 cuda threads

And with -i 19.5
  Adding 262144 threads to intensity 19, 786432 cuda threads
2014-11-25 19:57:56 +01:00
Tanguy Pruvot 9a97f0cf6e api: fix size_t printf exception in vstudio 2014-11-25 18:24:01 +01:00
Tanguy Pruvot 7e15f31706 api: pool query (uptime, ping, discon., url and user) 2014-11-25 17:39:02 +01:00
Tanguy Pruvot 71f9003901 x13: use tsiv hamsi implementation (+70KH) 2014-11-24 23:01:41 +01:00
Tanguy Pruvot 3e8457d76c api: add device uuid (nvml), and OS in hwinfo
move nvdriver to sys infos (unique on system)

prepare pool query
2014-11-24 21:20:26 +01:00
Tanguy Pruvot dc5d1b112d api: add scanlog command to monitor scan ranges
will be used for external debugging...
2014-11-24 20:26:41 +01:00
Tanguy Pruvot 1dfbe6dfb5 stratum: yaamp answer to extranonce subscribe lately
Fix for the extranonce feature, can also make the miner more stable
2014-11-24 20:14:15 +01:00
Tanguy Pruvot 484bbc4b15 api: restore bios, can be useful to identify
We have no way yet to identify a MSI 750 from a Gigabyte one...
2014-11-24 14:32:34 +01:00
Tanguy Pruvot aec310d4a7 nvml: grab nvidia driver version string too 2014-11-24 00:27:49 +01:00
Tanguy Pruvot d0ad1017e9 nvapi: get vid/pid like nvml + driver version
remove vbios revision, goal was to find the vendor...
2014-11-24 00:08:14 +01:00
Tanguy Pruvot a33058b554 vstudio: reduce diff, try Klaus options 2014-11-23 22:11:46 +01:00
Tanguy Pruvot 858c3d9370 jansson: use config.h new name (like v2.7)
to prevent config.h conflicts
2014-11-23 22:11:46 +01:00
Tanguy Pruvot 2300326b7a jansson: fix version header 2014-11-23 21:20:16 +01:00
Tanguy Pruvot d0316220dd simd512: restore full maxwell power (typo) 2014-11-23 21:19:35 +01:00
KlausT 1fcde52afd small groestl optimizations 2014-11-23 20:46:55 +01:00
KlausT ac641a0761 delete compat/thrust
why was it even included here in the first place?
It's part of the CUDA Toolkit
2014-11-23 19:13:32 +01:00
Tanguy Pruvot c88750332c simd512: restore SM3/3.5 perfs
Simple change which affect all algos based on SIMD512

fresh, qubit, s3, x11 to x17...
2014-11-23 19:07:06 +01:00
Tanguy Pruvot f42bb85785 nvml: vid/pid was reversed 2014-11-23 11:17:52 +01:00
Tanguy Pruvot e2ac7a2a75 api: add nvapi and nvml ids for C# tools 2014-11-23 11:12:58 +01:00
Tanguy Pruvot aa74aa33e2 api: fix hwinfo gpus 2014-11-23 10:50:25 +01:00
Tanguy Pruvot 84d7d926c9 nvml: fix hwinfo gpu vendor/product id
subsys ids are wrong... so use generic one
2014-11-23 10:45:32 +01:00
Tanguy Pruvot d7c13b0611 stratum: handle standard method if extranonce is ignored
seen on yamp.com pools
2014-11-23 09:22:25 +01:00
Tanguy Pruvot 6699b8a71f nvml: fix windows build 2014-11-23 08:39:55 +01:00
Tanguy Pruvot 9a8b7ff0d7 api: add cpu temp/freq (linux) 2014-11-23 08:26:38 +01:00
Tanguy Pruvot 1fcdeab53b stats: rework stats map key to fix sort order
to fix histo api command without param
2014-11-23 08:07:21 +01:00
Tanguy Pruvot 7bb86defcc nvml: clean up and fix retorted bus id bug in api 2014-11-23 07:33:36 +01:00
Tanguy Pruvot 94c9945fe6 cubeluffa: Fix indent and add some static prefixes
use git "show -w <commithash>" to see changes

Duplicated functions in merged Cube+Luffa could be cross linked without
2014-11-23 07:17:20 +01:00
sp-hash f0d91ab8a6 Luffa and simd merged to one kernal.
Small echo rewrite. +10KHASH on the 650(compute 3.0)

tpruvot: add Linux Makefile - Force to 80 registers (else -30KH/s)

Note : the hashrate seems more constant with this change
2014-11-23 07:04:07 +01:00
Tanguy Pruvot b824a63cde affinity: do not mix cpu count with gpu one
and update the old var with active gpus if -d is set
2014-11-22 22:14:20 +01:00
Tanguy Pruvot 3be08ad944 update readme (api, current changes, credits) 2014-11-22 16:43:49 +01:00
Tanguy Pruvot e72c6d4785 Update jansson windows sources to 2.6
There was sometimes problems with float values close to 0 (like 0.001)
2014-11-22 16:20:10 +01:00
Tanguy Pruvot 5a869d1c63 stratum: difficulty can be buggy with values close to zero
bug seen on windows with xpool.ca (x11)
2014-11-22 14:01:03 +01:00
Tanguy Pruvot 2ea9da1415 stratum: add more checks on request id 2014-11-22 13:30:42 +01:00
sp-hash 7d88e5cca1 Faster Simd
On maxwell compress1 and compress2 can be run in one run instead of two.(750TI + 20KHASH)
2014-11-22 03:25:49 +01:00
Tanguy Pruvot 7ce3fed611 extranonce: ignore subscribe timeout, not the parse errors 2014-11-22 03:25:49 +01:00
Tanguy Pruvot 5ddc8de9da stratum: handle optional mining.set_extranonce
allow pools to switch more coins without reconnect

Tested ok on a nicehash x11 pool

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-22 01:42:55 +01:00
sp-hash 26b9fe3586 faster x15, +23KH or 4ms on whirpool (30ms vs 34ms)
tpruvot: i didnt pick the asm replace_hiword, slower on linux
2014-11-20 19:19:27 +01:00
Tanguy Pruvot 73f22b237a Prepare trap of hardware/mem failures 2014-11-20 18:44:25 +01:00
Tanguy Pruvot 1bc4e7e942 api: add mem size and freq to hwinfo query 2014-11-20 15:54:56 +01:00
Tanguy Pruvot 3ad4be7de0 api: export gpu freq on linux too + hwinfo command 2014-11-19 16:16:27 +01:00
Tanguy Pruvot b24b65a9c9 api: add gpu pci bus id, unified id + bloc height 2014-11-18 16:25:44 +01:00
Tanguy Pruvot 17cf3767e9 api: also fix nvapi mapping and double swap on histo 2014-11-18 03:34:23 +01:00
Tanguy Pruvot 582c971f2b api: fix histo gpu/thr id mismatch 2014-11-17 19:11:26 +01:00
Tanguy Pruvot b4ef7b981f scan range: add boundary check, cant be > UINT32_MAX 2014-11-17 16:51:36 +01:00
Tanguy Pruvot 047e79a9fc api: add meminfo query to debug mem storages 2014-11-17 16:17:53 +01:00
Tanguy Pruvot 6a9b8a5ab2 hashlog: use work objects, put struct in miner.h 2014-11-17 15:58:11 +01:00
Tanguy Pruvot bdfce54c3b x11: restore default intensity to 19 on windows 2014-11-17 14:48:55 +01:00
Tanguy Pruvot fe4ad36b73 intensity: sign warnings fixes min(i,u) 2014-11-17 14:48:55 +01:00
Tanguy Pruvot f5e77452f0 stratum: prevent a booo when receiving a new block
seems to works in solo mode too...

note: anime wallet to check, different problem without reject-reason
2014-11-17 02:59:08 +01:00
Tanguy Pruvot d062f93bf5 cuda: revert to SM 5.0 only by default 2014-11-17 00:32:38 +01:00
Tanguy Pruvot dca216f992 min() and max(a,b) are not defined on linux,
in fact max exists in jansson includes (in tree only)

Add them to miner.h
2014-11-17 00:23:18 +01:00
Tanguy Pruvot c859041993 quark/blake512 opt. pointed by sp without asm
indeed, the pragma unroll doesnt always make things faster

asm part... to check later
2014-11-17 00:01:32 +01:00
Tanguy Pruvot 438308b3a2 Rework benchmark mode and min/max range
Was maybe my fault, but the benchmark mode was
always recomputing from nonce 0.

Also fix blake if -d 1 is used (one thread but second gpu)

stats: do not use thread id as key, prefer gpu id...
2014-11-16 23:28:18 +01:00
Tanguy Pruvot 11dbbcc12d checkhash: some work on a faster variant (wip)
This should not be used for all algos... not enabled yet

todo: multiple nounces or blake32 style checkup
2014-11-16 17:37:02 +01:00
Tanguy Pruvot 14a41959f8 x11: switch to intensity 20 for SM>=5.2 750+970 2014-11-16 17:34:50 +01:00
Tanguy Pruvot 44a551c52e hashrate: ignore first loop speed (often lowered) 2014-11-16 17:34:50 +01:00
Tanguy Pruvot 59391e25ec api: fix includes after a test on mingw (cpuminer) 2014-11-16 17:34:50 +01:00
Tanguy Pruvot ae29d984c1 vstudio: clean the project file 2014-11-16 17:34:50 +01:00
Tanguy Pruvot fdd5d29071 x11: shavite and echo from sp (now ok on win32)
Previous echo commit was only increasing linux performance, and reducing
windows perf compared to the 1.4.9, this one seems to give at least
the 1.4.9 on windows, and the same on linux...

Shavite optimisation seems ok on both (use now 64 registers)

the launch_bounds will force the number of registers, so remove specific
Makefile rules on linux...

manual "cherry pick" with fixed line endings and some adaptations
2014-11-16 17:34:50 +01:00
Tanguy Pruvot 89aaafad2c prepare 1.5.0 2014-11-16 03:35:47 +01:00
sp-hash e18a54e8fc sp echo optimisation + cleanup
Original Commit :
Removed sharedmem and reduced calculations with precalcing (ECHO hash).
750ti + 20KHASH(x11)

tpruvot notes:
Real change is more of 10 KH/s on stock clocks (but real)
launch bounds disabled, no perf increase with 64 registers
2014-11-16 03:08:46 +01:00
Tanguy Pruvot 851a26c2a2 api-sample: use non blocking sockets
fix php warnings and enable cpuminer compat
2014-11-15 21:47:17 +01:00
Tanguy Pruvot c7008f3f6c update readme for final 1.4.9 (fix)
A dev version was released on http://cryptomining-blog.com/

Please update, the previous one has some bugs when using multiple
gpus and the API format has changed!
2014-11-15 03:40:39 +01:00
Tanguy Pruvot 2aea2c3ccc nvml: attempt to use another clock function
But no way, even recent 346 driver series or 343. Seems limited to
Tesla products...
2014-11-15 02:48:36 +01:00
Tanguy Pruvot 3e43553735 api: export card labels and count, renames stats command
renammed to "threads", stats was too much generic
2014-11-14 23:38:16 +01:00
Tanguy Pruvot 7a2fe83aaa nvapi: match gpu index with pci/x bus id
mapping by Name was a quick test...
2014-11-14 22:03:00 +01:00
Tanguy Pruvot cc05128ae3 api: fix histo thread param 2014-11-14 20:30:42 +01:00
Tanguy Pruvot 124dc6ea57 nvapi: fix mapping of devices 2014-11-14 19:33:24 +01:00
Tanguy Pruvot 3652c708b9 api: add histo command and difficulty
enhance multi-gpu stats and fix nvapi indexes

change syslog prefix to ccminer (cpuminer remains)

api 1.1 modified - not officially released yet
2014-11-14 19:09:48 +01:00
Tanguy Pruvot e82f5d4d75 restore divided hashrate for quark and jackpot
The previous way it was done was not correct (hashdone divided/2)

So add a factor 0.5 to the computed hashrate... to stay comparable
2014-11-14 13:45:02 +01:00
Tanguy Pruvot 3d2260acc4 stats: add support for current freq and pstate
windows only via nvapi, if nvml function is not supported
2014-11-14 02:48:27 +01:00
Tanguy Pruvot e139736a2f api: better compat with telnet + help command
handle "\r\n" and terminate connection if command is not known
2014-11-14 01:32:10 +01:00
Tanguy Pruvot 63eb163e32 api: update sample rig ui
totals, readable uptime, autorefresh
2014-11-13 23:18:07 +01:00
Tanguy Pruvot 3dcfa5d84f api: add a sample rig web ui (php) 2014-11-13 21:09:42 +01:00
Tanguy Pruvot dedcd06207 stats: fix typo for multigpu 2014-11-13 19:50:58 +01:00
Tanguy Pruvot 15eea1bc81 api: add nvapi for windows binaries
nvml.dll doesnt exists for 32bit binaries! use nvapi to get infos

seems to have more/different features than NVML... like pstate etc..

This is nvapi r343 : https://developer.nvidia.com/nvapi

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-13 19:01:36 +01:00
Tanguy Pruvot e40a7a720c ccminer: rename main file and switch to C++
There was a different behavior on linux and visual studio

That was making it hard to link functions correctly

That remove some ifdef / extern "C" requirements

note about x86 releases, x86 nvml.dll is not installed on Windows x64!
2014-11-13 16:11:35 +01:00
Tanguy Pruvot 49f3c454c2 Add nvml for GPU monitoring (squashed)
Based on mwhite73 <marvin.white@gmail.com> implementation

  Linked to the api system

  Also fix Makefile to support standard c++ files
  This prevent nvcc use without device code

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-13 14:36:18 +01:00
Tanguy Pruvot 1118d6c3db update readme and config.json for the 1.4.8 2014-11-12 17:53:22 +01:00
Tanguy Pruvot 2e0bc5e133 api: add api-bind param -b 0.0.0.0:4068
possible values :

 5000 or :5000 to use port 5000 (local only)
  0.0.0.0:5000 to allow connections from the network
127.0.0.1:4068 to only allow local connections (default)

Use -b 0 to disable the API system.

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-12 17:36:02 +01:00
Tanguy Pruvot 11a4bb1797 api: changes in data, global stuff in summary
PS: still under dev, wait the final 1.4.8 ;)
2014-11-12 16:49:44 +01:00
Tanguy Pruvot f58b2d3d21 api: fixes for windows (to finish) 2014-11-12 12:56:20 +01:00
Tanguy Pruvot 4958ce6007 api: add a basic stats api on port 2068
you can use PHP api-example.php as a json wrapper...

to be tested on windows...

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-12 12:23:11 +01:00
Tanguy Pruvot e1c84da07f stats: fix multi gpu value + add average parameter (-N) 2014-11-12 08:03:40 +01:00
Tanguy Pruvot 3550d6a889 Release 1.4.7
Note: Heavy and Mjollnir are broken on linux (only)...

To check in the next version... 4 hours i try to fix that without
success. djm34 variant seems ok but also make a lot of rejects.
2014-11-12 02:12:01 +01:00
Tanguy Pruvot 0317706464 config: handle ints, reals and false 2014-11-11 20:57:41 +01:00
Tanguy Pruvot 66845a9b36 vstudio: fix intellisense base types warnings 2014-11-11 20:19:50 +01:00
Tanguy Pruvot 88c8fa2973 config: fix -c param (json file) 2014-11-11 19:44:10 +01:00
Tanguy Pruvot b128312efb cuda: store device SM in a global var
sample usage made for blake and fugue (higher intensity for SM5.2)

add these to cuda_helper and clean unused code
2014-11-11 19:11:16 +01:00
Tanguy Pruvot 99bbe380fd stats: reduce the average samples count to 20 2014-11-11 18:29:21 +01:00
Tanguy Pruvot 51b4f32420 stats: ignore erroneous data 2014-11-11 17:59:45 +01:00
Tanguy Pruvot 64cfe358cb stats: make them work also in vstudio 2014-11-11 17:44:31 +01:00
Tanguy Pruvot ec709af62f Store and display average hashrate (benchmark + on share)
Displayed data is the average of the last 50 scans in the 5 last minutes

Also move cuda common functions in a new file (cuda.cu)

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-11 16:43:23 +01:00
Tanguy Pruvot 8259ed7f29 heavy fix for linux 2014-11-10 21:07:09 +01:00
Tanguy Pruvot 7a4e1bb327 Reduce keccak, deep & anime intensity + handle groestl -i param
default intensity was the max supported by the card, and perf is
not really better. I prefer to let it one under for cards with lower
memory (1GB)
2014-11-10 18:08:23 +01:00
Tanguy Pruvot 98451267d8 vstudio: std::min fix 2014-11-10 17:06:39 +01:00
Tanguy Pruvot 7acf987aba Add intensity to last algos and fix quark speed 2014-11-10 16:56:03 +01:00
Tanguy Pruvot a35b150b7f fix for jackpot hash
max nounce was too low (bad cpu miner copy/paste i guess)

hash speed was not right also... (was divided per 2)
2014-11-10 14:22:10 +01:00
Tanguy Pruvot 2ab1e3700f update readme 2014-11-09 22:31:12 +01:00
Tanguy Pruvot 11c5ec810d Handle intensity param in all algos
and add a check related to start/max nounce params
2014-11-09 22:27:32 +01:00
Tanguy Pruvot 9f62014690 Add intensity parameter (-i 0:31)
Like cgminer, the value equals to 1 << n
if 0, we keep the default value defined in algo (19 for Xn algos)

19 = 524288 threads per gpu call

GTX 970 and 980 handle a higher number of threads compared to the 750 Ti

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
2014-11-09 22:21:11 +01:00
936 changed files with 60046 additions and 115354 deletions

No files matched your search

+43 -65
View File
@@ -16,7 +16,6 @@ extern "C" {
/* 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;
@@ -38,12 +37,6 @@ extern "C" void blake256hash(void *output, const void *input, int8_t rounds = 14
#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
@@ -55,13 +48,13 @@ __device__ static uint32_t prevsum = 0;
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];
/* 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 uint32_t extra_results[NBN] = { MAXU };
static uint32_t extra_results[NBN] = { UINT32_MAX };
/* prefer uint32_t to prevent size conversions = speed +5/10 % */
__constant__
@@ -252,8 +245,8 @@ __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;
const uint32_t threadsperblock = TPB;
uint32_t result = UINT32_MAX;
dim3 grid((threads + threadsperblock-1)/threadsperblock);
dim3 block(threadsperblock);
@@ -264,9 +257,8 @@ uint32_t blake256_cpu_hash_80(const int thr_id, const uint32_t threads, const ui
return result;
blake256_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNonce, d_resNonce[thr_id], highTarget, crcsum, (int) rounds);
cudaDeviceSynchronize();
MyStreamSynchronize(NULL, 0, thr_id);
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];
@@ -311,12 +303,10 @@ void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uin
blake256_compress(h, ending, 640, rounds);
//if (h[7] == 0 && high64 <= highTarget) {
if (h[7] == 0) {
if (h[7] == 0 && cuda_swab32(h[6]) <= 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;
}
@@ -325,14 +315,14 @@ void blake256_gpu_hash_16(const uint32_t threads, const uint32_t startNonce, uin
#else
resNonce[0] = nonce;
#endif
if (trace) {
#ifdef _DEBUG
if (trace) {
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
}
#endif
}
}
}
@@ -341,8 +331,8 @@ __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;
const uint32_t threadsperblock = TPB;
uint32_t result = UINT32_MAX;
dim3 grid((threads + threadsperblock-1)/threadsperblock);
dim3 block(threadsperblock);
@@ -352,9 +342,8 @@ static uint32_t blake256_cpu_hash_16(const int thr_id, const uint32_t threads, c
return result;
blake256_gpu_hash_16 <<<grid, block>>> (threads, startNonce, d_resNonce[thr_id], highTarget, (int) rounds, opt_tracegpu);
cudaDeviceSynchronize();
MyStreamSynchronize(NULL, 0, thr_id);
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];
@@ -388,38 +377,29 @@ void blake256_cpu_setBlock_16(uint32_t *penddata, const uint32_t *midstate, cons
}
#endif
static bool init[MAX_GPUS] = { 0 };
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
uint64_t targetHigh = ((uint64_t*)ptarget)[3];
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 intensity = (device_sm[device_map[thr_id]] > 500) ? 22 : 20;
uint32_t throughput = device_intensity(thr_id, __func__, 1U << intensity);
throughput = min(throughput, 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)
if (opt_benchmark) {
targetHigh = 0x1ULL << 32;
((uint32_t*)ptarget)[6] = swab32(0xff);
}
if (opt_tracegpu) {
/* test call from util.c */
@@ -429,11 +409,10 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
}
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)));
if (active_gpus > 1)
cudaSetDevice(device_map[thr_id]);
CUDA_CALL_OR_RET_X(cudaMallocHost(&h_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
CUDA_CALL_OR_RET_X(cudaMalloc(&d_resNonce[thr_id], NBN * sizeof(uint32_t)), 0);
init[thr_id] = true;
}
@@ -456,7 +435,7 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
// GPU FULL HASH
blake256_cpu_hash_80(thr_id, throughput, pdata[19], targetHigh, crcsum, blakerounds);
#endif
if (foundNonce != MAXU)
if (foundNonce != UINT32_MAX)
{
uint32_t vhashcpu[8];
uint32_t Htarg = (uint32_t)targetHigh;
@@ -468,37 +447,36 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
blake256hash(vhashcpu, endiandata, blakerounds);
//applog(LOG_BLUE, "%08x %16llx", vhashcpu[6], targetHigh);
if (vhashcpu[6] <= Htarg /*&& fulltest(vhashcpu, ptarget)*/)
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
pdata[19] = foundNonce;
*hashes_done = pdata[19] - first_nonce + 1;
#if NBN > 1
if (extra_results[0] != UINT32_MAX) {
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!");
pdata[21] = extra_results[0];
applog(LOG_BLUE, "1:%x 2:%x", foundNonce, extra_results[0]);
*hashes_done = max(*hashes_done, extra_results[0] - first_nonce + 1);
rc = 2;
} else {
extra_results[0] = MAXU;
}
extra_results[0] = UINT32_MAX;
}
#endif
//applog_hash((uint8_t*)ptarget);
//applog_compare_hash((uint8_t*)vhashcpu,(uint8_t*)ptarget);
goto exit_scan;
return rc;
}
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);
applog_hash((uchar*)ptarget);
applog_compare_hash((uchar*)vhashcpu, (uchar*)ptarget);
applog(LOG_WARNING, "GPU #%d: result for nonce %08x does not validate on CPU!", device_map[thr_id], foundNonce);
}
}
if ((uint64_t) pdata[19] + throughput > (uint64_t) max_nonce) {
pdata[19] = max_nonce;
break;
}
@@ -506,7 +484,7 @@ extern "C" int scanhash_blake256(int thr_id, uint32_t *pdata, const uint32_t *pt
} while (!work_restart[thr_id].restart);
exit_scan:
*hashes_done = pdata[19] - first_nonce + 1; // (+1 to prevent locks)
*hashes_done = pdata[19] - first_nonce;
return rc;
}
+247
View File
@@ -0,0 +1,247 @@
/**
* Blake-256 Cuda Kernel (Tested on SM 5.0)
*
* Tanguy Pruvot - Nov. 2014
*/
extern "C" {
#include "sph/sph_blake.h"
}
#include "cuda_helper.h"
#include <memory.h>
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
};
#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); \
}
/* 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];
}
}
__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);
}
+17 -26
View File
@@ -8,14 +8,8 @@
#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];
__constant__ uint32_t GPUstate[30]; // Single GPU
__constant__ uint32_t pTarget[8]; // Single GPU
@@ -554,7 +548,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 +561,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 +571,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 +687,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;
@@ -724,10 +718,9 @@ fugue256_gpu_hash(int thr_id, int threads, uint32_t startNounce, void *outputHas
cudaBindTexture(NULL, &texname, texmem, &channelDesc, texsize ); }
void fugue256_cpu_init(int thr_id, int threads)
__host__
void fugue256_cpu_init(int thr_id, uint32_t 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);
@@ -736,33 +729,31 @@ void fugue256_cpu_init(int thr_id, int threads)
// 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));
cudaMalloc(&d_resultNonce[thr_id], sizeof(uint32_t));
}
__host__ void fugue256_cpu_setBlock(int thr_id, void *data, void *pTargetIn)
__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
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, sizeof(uint32_t) * 8);
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, int 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);
+322
View File
@@ -0,0 +1,322 @@
#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];
__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
texture<unsigned int, 1, cudaReadModeElementType> t0up2;
texture<unsigned int, 1, cudaReadModeElementType> t0dn2;
texture<unsigned int, 1, cudaReadModeElementType> t1up2;
texture<unsigned int, 1, cudaReadModeElementType> t1dn2;
texture<unsigned int, 1, cudaReadModeElementType> t2up2;
texture<unsigned int, 1, cudaReadModeElementType> t2dn2;
texture<unsigned int, 1, cudaReadModeElementType> t3up2;
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_hash32(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(texname, texmem, texsource, texsize) \
unsigned int *texmem; \
cudaMalloc(&texmem, texsize); \
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(t0up2, d_T0up, T0up_cpu, sizeof(uint32_t) * 256);
texDef(t0dn2, d_T0dn, T0dn_cpu, sizeof(uint32_t) * 256);
texDef(t1up2, d_T1up, T1up_cpu, sizeof(uint32_t) * 256);
texDef(t1dn2, d_T1dn, T1dn_cpu, sizeof(uint32_t) * 256);
texDef(t2up2, d_T2up, T2up_cpu, sizeof(uint32_t) * 256);
texDef(t2dn2, d_T2dn, T2dn_cpu, sizeof(uint32_t) * 256);
texDef(t3up2, d_T3up, T3up_cpu, sizeof(uint32_t) * 256);
texDef(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__
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_hash32<<<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);
}
+302
View File
@@ -0,0 +1,302 @@
#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
};
uint32_t *d_nounce[MAX_GPUS];
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_gpu_hash_80(uint32_t threads, uint32_t startNounce, void *outputHash, 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__
uint32_t keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_outputHash, int order)
{
uint32_t result = UINT32_MAX;
cudaMemset(d_KNonce[thr_id], 0xff, sizeof(uint32_t));
const uint32_t threadsperblock = 128;
dim3 grid((threads + threadsperblock-1)/threadsperblock);
dim3 block(threadsperblock);
size_t shared_size = 0;
keccak256_gpu_hash_80<<<grid, block, shared_size>>>(threads, startNounce, d_outputHash, d_KNonce[thr_id]);
MyStreamSynchronize(NULL, order, thr_id);
cudaMemcpy(d_nounce[thr_id], d_KNonce[thr_id], sizeof(uint32_t), cudaMemcpyDeviceToHost);
cudaThreadSynchronize();
result = *d_nounce[thr_id];
return result;
}
__global__ __launch_bounds__(256,3)
void keccak256_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_cpu_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_gpu_hash_32 <<<grid, block>>> (threads, startNounce, d_outputHash);
MyStreamSynchronize(NULL, order, thr_id);
}
__host__
void keccak256_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_cpu_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], sizeof(uint32_t)));
CUDA_SAFE_CALL(cudaMallocHost(&d_nounce[thr_id], 1*sizeof(uint32_t)));
}
+299
View File
@@ -0,0 +1,299 @@
#include <memory.h>
#include "cuda_helper.h"
static __constant__ uint64_t SKEIN_IV512_256[8] = {
0xCCD044A12FDB3E13, 0xE83590301A79A9EB,
0x55AEA0614F816E6F, 0x2A2767A4AE9B94DB,
0xEC06025E74DD7683, 0xE7A436CDC4746251,
0xC36FBAF9393AD185, 0x3EEDBA1833EDFC13
};
static __constant__ uint2 vSKEIN_IV512_256[8] = {
{ 0x2FDB3E13, 0xCCD044A1 },
{ 0x1A79A9EB, 0xE8359030 },
{ 0x4F816E6F, 0x55AEA061 },
{ 0xAE9B94DB, 0x2A2767A4 },
{ 0x74DD7683, 0xEC06025E },
{ 0xC4746251, 0xE7A436CD },
{ 0x393AD185, 0xC36FBAF9 },
{ 0x33EDFC13, 0x3EEDBA18 }
};
static __constant__ int8_t ROT256[8][4] = {
46, 36, 19, 37,
33, 27, 14, 42,
17, 49, 36, 39,
44, 9, 54, 56,
39, 30, 34, 24,
13, 50, 10, 17,
25, 29, 39, 43,
8, 35, 56, 22,
};
static __constant__ uint2 t12[6] = {
{ 0x20, 0 },
{ 0, 0xf0000000 },
{ 0x20, 0xf0000000 },
{ 0x08, 0 },
{ 0, 0xff000000 },
{ 0x08, 0xff000000 }
};
static __constant__ uint2 skein_ks_parity = { 0xA9FC1A22, 0x1BD11BDA };
static __constant__ uint64_t skein_ks_parity64 = 0x1BD11BDAA9FC1A22ull;
static __forceinline__ __device__
void Round512v35(uint2 &p0, uint2 &p1, uint2 &p2, uint2 &p3, uint2 &p4, uint2 &p5, uint2 &p6, uint2 &p7, int ROT)
{
p0 += p1; p1 = ROL2(p1, ROT256[ROT][0]) ^ p0;
p2 += p3; p3 = ROL2(p3, ROT256[ROT][1]) ^ p2;
p4 += p5; p5 = ROL2(p5, ROT256[ROT][2]) ^ p4;
p6 += p7; p7 = ROL2(p7, ROT256[ROT][3]) ^ p6;
}
static __forceinline__ __device__
void Round_8_512v35(uint2 *ks, uint2 *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, 0);
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 1);
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 2);
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 3);
p0 += ks[(R+0) % 9]; /* inject the key schedule value */
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, 4);
Round512v35(p2, p1, p4, p7, p6, p5, p0, p3, 5);
Round512v35(p4, p1, p6, p3, p0, p5, p2, p7, 6);
Round512v35(p6, p1, p0, p7, p2, p5, p4, p3, 7);
p0 += ks[(R+1) % 9]; /* inject the key schedule value */
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);
}
__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)
{
uint2 h[9], t[3] = { t12[0], t12[1], t12[2] };
h[8] = skein_ks_parity;
for (int i = 0; i<8; i++) {
h[i] = vSKEIN_IV512_256[i];
h[8] ^= h[i];
}
uint2 dt0 = vectorize(outputHash[thread]);
uint2 dt1 = vectorize(outputHash[threads + thread]);
uint2 dt2 = vectorize(outputHash[threads*2 + thread]);
uint2 dt3 = vectorize(outputHash[threads*3 + thread]);
uint2 p0 = h[0] + dt0;
uint2 p1 = h[1] + dt1;
uint2 p2 = h[2] + dt2;
uint2 p3 = h[3] + dt3;
uint2 p4 = h[4];
uint2 p5 = h[5] + t[0];
uint2 p6 = h[6] + t[1];
uint2 p7 = h[7];
#pragma unroll 9
for (int i = 1; i<19; i+=2) {
Round_8_512v35(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_parity;
#pragma unroll 8
for (int i = 0; i<8; i++) {
h[8] ^= h[i];
}
t[0] = t12[3];
t[1] = t12[4];
t[2] = t12[5];
p5 += t[0];
p6 += t[1];
#pragma unroll 9
for (int i = 1; i<19; i+=2) {
Round_8_512v35(h, t, p0, p1, p2, p3, p4, p5, p6, p7, i);
}
outputHash[thread] = devectorize(p0);
outputHash[threads + thread] = devectorize(p1);
outputHash[threads*2 + thread] = devectorize(p2);
outputHash[threads*3 + 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, int ROT)
{
p0 += p1; p1 = ROTL64(p1, ROT256[ROT][0]) ^ p0;
p2 += p3; p3 = ROTL64(p3, ROT256[ROT][1]) ^ p2;
p4 += p5; p5 = ROTL64(p5, ROT256[ROT][2]) ^ p4;
p6 += p7; p7 = ROTL64(p7, ROT256[ROT][3]) ^ 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, 0);
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 1);
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 2);
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 3);
p0 += ks[(R+0) % 9]; /* inject the key schedule value */
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, 4);
Round512v30(p2, p1, p4, p7, p6, p5, p0, p3, 5);
Round512v30(p4, p1, p6, p3, p0, p5, p2, p7, 6);
Round512v30(p6, p1, p0, p7, p2, p5, p4, p3, 7);
p0 += ks[(R+1) % 9]; /* inject the key schedule value */
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;
}
__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[9], t[3];
h[8] = skein_ks_parity64;
for (int i = 0; i<8; i++) {
h[i] = SKEIN_IV512_256[i];
h[8] ^= h[i];
}
t[0] = devectorize(t12[0]);
t[1] = devectorize(t12[1]);
t[2] = devectorize(t12[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 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] = devectorize(t12[3]);
t[1] = devectorize(t12[4]);
t[2] = devectorize(t12[5]);
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;
dim3 grid((threads + threadsperblock - 1) / threadsperblock);
dim3 block(threadsperblock);
// only 1kH/s perf change between kernels on a 960...
if (device_sm[device_map[thr_id]] > 300 && cuda_arch[device_map[thr_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);
}
+20 -29
View File
@@ -14,22 +14,18 @@ extern "C"
#include "cuda_helper.h"
// in cpu-miner.c
extern int device_map[8];
static uint32_t *d_hash[MAX_GPUS];
static uint32_t *d_hash[8];
extern void keccak256_cpu_init(int thr_id, int threads);
extern void keccak256_cpu_init(int thr_id, uint32_t threads);
extern void keccak256_setBlock_80(void *pdata,const void *ptarget);
extern uint32_t keccak256_cpu_hash_80(int thr_id, int threads, uint32_t startNounce, uint32_t *d_hash, int order);
extern uint32_t keccak256_cpu_hash_80(int thr_id, uint32_t threads, uint32_t startNounce, uint32_t *d_hash, 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;
uint32_t hash[16];
sph_keccak256_init(&ctx_keccak);
sph_keccak256 (&ctx_keccak, input, 80);
sph_keccak256_close(&ctx_keccak, (void*) hash);
@@ -37,24 +33,23 @@ extern "C" void keccak256_hash(void *state, const void *input)
memcpy(state, hash, 32);
}
static bool init[MAX_GPUS] = { 0 };
extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce,
unsigned long *hashes_done)
{
const uint32_t first_nonce = pdata[19];
uint32_t throughput = device_intensity(thr_id, __func__, 1U << 21); // 256*256*8*4
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x000f;
((uint32_t*)ptarget)[7] = 0x0005;
const uint32_t Htarg = ptarget[7];
const int throughput = 256*256*8*8;
static bool init[8] = {0,0,0,0,0,0,0,0};
if (!init[thr_id]) {
cudaSetDevice(device_map[thr_id]);
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput));
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], throughput * 64));
keccak256_cpu_init(thr_id, throughput);
init[thr_id] = true;
@@ -62,35 +57,32 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
uint32_t endiandata[20];
for (int k=0; k < 20; k++) {
be32enc(&endiandata[k], ((uint32_t*)pdata)[k]);
be32enc(&endiandata[k], pdata[k]);
}
keccak256_setBlock_80((void*)endiandata, ptarget);
do {
int order = 0;
*hashes_done = pdata[19] - first_nonce + throughput;
uint32_t foundNonce = keccak256_cpu_hash_80(thr_id, throughput, pdata[19], d_hash[thr_id], order++);
if (foundNonce != 0xffffffff)
if (foundNonce != UINT32_MAX)
{
uint32_t vhash64[8];
uint32_t _ALIGN(64) vhash64[8];
be32enc(&endiandata[19], foundNonce);
keccak256_hash(vhash64, endiandata);
if (vhash64[7] <= Htarg && fulltest(vhash64, ptarget)) {
if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) {
pdata[19] = foundNonce;
*hashes_done = foundNonce - first_nonce + 1;
return 1;
} else {
applog(LOG_DEBUG, "GPU #%d: result for nounce %08x does not validate on CPU!", thr_id, foundNonce);
}
else {
applog(LOG_WARNING, "GPU #%d: result for nounce %08x does not validate on CPU!", device_map[thr_id], foundNonce);
}
}
if ((uint64_t) pdata[19] + throughput > (uint64_t) max_nonce) {
pdata[19] = max_nonce;
if ((uint64_t) pdata[19] + throughput > max_nonce) {
break;
}
@@ -98,6 +90,5 @@ extern "C" int scanhash_keccak256(int thr_id, uint32_t *pdata,
} while (!work_restart[thr_id].restart);
*hashes_done = pdata[19] - first_nonce + 1;
return 0;
}
+32 -1
View File
@@ -8,4 +8,35 @@ need to be installed on your system for autogen.sh to work)
where your CUDA 6.5 toolkit is installed (usually /usr/local/cuda,
but some distros may have a different default location)
See README.txt
** How to compile on Fedora 22 (2015) **
# Step 1: gcc and dependencies
dnf install gcc gcc-c++ automake
dnf install jansson-devel openssl-devel libcurl-devel
# Step 2: nvidia drivers (Download common linux drivers from nvidia site)
dnf install kernel-devel
modprobe -r nouveau
./NVIDIA-Linux-x86_64-346.72.run
# Step 3: CUDA SDK (Download from nvidia archive)
dnf install cuda-repo-fedora20-6-5-prod-6.5-19.x86_64.rpm
dnf install cuda-minimal-build-6-5.x86_64
# add the nvcc binary path to the system
ln -s /usr/local/cuda-6.5 /usr/local/cuda
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 warning with gcc 5.1
edit the file /usr/local/cuda/include/host_config.h
and comment/delete the line 82 : #error -- unsupported GNU version! gcc 4.9
./build.sh
./ccminer -n
+31 -32
View File
@@ -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,12 @@ __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];
cuda_compactTestFunction_t h_JackpotTrueFunction[MAX_GPUS], h_JackpotFalseFunction[MAX_GPUS];
// Setup-Funktionen
__host__ void jackpot_compactTest_cpu_init(int thr_id, int threads)
__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));
@@ -66,7 +60,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 +174,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 +192,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 +229,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 +244,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 +300,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 +339,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 +351,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
View File
File diff suppressed because it is too large. Load diff
+56 -46
View File
@@ -10,37 +10,37 @@ extern "C"
#include "miner.h"
#include "cuda_helper.h"
extern int device_map[8];
static uint32_t *d_hash[MAX_GPUS];
static uint32_t *d_hash[8];
extern void jackpot_keccak512_cpu_init(int thr_id, int threads);
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, int threads, uint32_t startNounce, uint32_t *d_hash, int order);
extern void jackpot_keccak512_cpu_hash(int thr_id, uint32_t 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_blake512_cpu_init(int thr_id, uint32_t threads);
extern void quark_blake512_cpu_hash_64(int thr_id, uint32_t 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_groestl512_cpu_init(int thr_id, uint32_t threads);
extern void quark_groestl512_cpu_hash_64(int thr_id, uint32_t 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_jh512_cpu_init(int thr_id, uint32_t threads);
extern void quark_jh512_cpu_hash_64(int thr_id, uint32_t 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 quark_skein512_cpu_init(int thr_id, uint32_t threads);
extern void quark_skein512_cpu_hash_64(int thr_id, uint32_t 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,
extern void jackpot_compactTest_cpu_init(int thr_id, uint32_t threads);
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);
// 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];
static uint32_t *d_branch1Nonces[MAX_GPUS];
static uint32_t *d_branch2Nonces[MAX_GPUS];
static uint32_t *d_branch3Nonces[MAX_GPUS];
// Original jackpothash Funktion aus einem miner Quelltext
extern "C" unsigned int jackpothash(void *state, const void *input)
@@ -85,8 +85,7 @@ extern "C" unsigned int jackpothash(void *state, const void *input)
return round;
}
extern bool opt_benchmark;
static bool init[MAX_GPUS] = { 0 };
extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce,
@@ -94,37 +93,39 @@ extern "C" int scanhash_jackpot(int thr_id, uint32_t *pdata,
{
const uint32_t first_nonce = pdata[19];
uint32_t throughput = device_intensity(thr_id, __func__, 1U << 20);
throughput = min(throughput, max_nonce - first_nonce);
if (opt_benchmark)
((uint32_t*)ptarget)[7] = 0x0000ff;
((uint32_t*)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]);
// Konstanten kopieren, Speicher belegen
cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput);
CUDA_SAFE_CALL(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);
CUDA_SAFE_CALL(cudaMalloc(&d_jackpotNonces[thr_id], 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 +136,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 +207,41 @@ 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++);
*hashes_done = pdata[19] - first_nonce + throughput;
uint32_t foundNonce = cuda_check_hash_branch(thr_id, nrm3, pdata[19], d_branch3Nonces[thr_id], d_hash[thr_id], order++);
if (foundNonce != 0xffffffff)
{
unsigned int rounds;
uint32_t vhash64[8];
be32enc(&endiandata[19], foundNonce);
// diese jackpothash Funktion gibt die Zahl der Runden zurück
rounds = jackpothash(vhash64, endiandata);
if ((vhash64[7]<=Htarg) && fulltest(vhash64, ptarget)) {
jackpothash(vhash64, endiandata);
if (vhash64[7] <= ptarget[7] && fulltest(vhash64, ptarget)) {
int res = 1;
uint32_t secNonce = cuda_check_hash_suppl(thr_id, throughput, pdata[19], d_hash[thr_id], 1);
if (secNonce != 0) {
pdata[21] = secNonce;
res++;
}
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;
return res;
} else {
applog(LOG_INFO, "GPU #%d: result for nonce $%08X does not validate on CPU (%d rounds)!", thr_id, foundNonce, rounds);
applog(LOG_WARNING, "GPU #%d: result for nonce %08x does not validate on CPU!",
device_map[thr_id], foundNonce);
}
}
if ((uint64_t) pdata[19] + throughput > max_nonce) {
*hashes_done = pdata[19] - first_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 + 1)/2;
return 0;
}
+81 -29
View File
@@ -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,20 @@ else
JANSSON_INCLUDES=
endif
EXTRA_DIST = autogen.sh README.txt LICENSE.txt \
cudaminer.sln cudaminer.vcxproj cudaminer.vcxproj.filters \
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 cpuminer-config.h.in
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 bignum.cpp \
api.cpp hashlog.cpp nvml.cpp stats.cpp sysinfos.cpp cuda.cpp \
heavy/heavy.cu \
heavy/cuda_blake512.cu heavy/cuda_blake512.h \
heavy/cuda_combine.cu heavy/cuda_combine.h \
@@ -25,54 +28,76 @@ 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 \
fuguecoin.cpp Algo256/cuda_fugue256.cu sph/fugue.c uint256.h \
groestlcoin.cpp cuda_groestlcoin.cu cuda_groestlcoin.h \
myriadgroestl.cpp cuda_myriadgroestl.cu \
lyra2/Lyra2.c lyra2/Sponge.c \
lyra2/lyra2RE.cu lyra2/cuda_lyra2.cu \
Algo256/cuda_blake256.cu Algo256/cuda_groestl256.cu Algo256/cuda_keccak256.cu Algo256/cuda_skein256.cu \
Algo256/blake256.cu Algo256/keccak256.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 \
neoscrypt/neoscrypt.cpp neoscrypt/neoscrypt-cpu.c neoscrypt/cuda_neoscrypt.cu \
cuda_nist5.cu pentablake.cu skein.cu cuda_skeincoin.cu skein2.cpp zr5.cu \
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/cubehash.c sph/echo.c sph/luffa.c sph/sha2.c sph/sha256d.c sph/shavite.c sph/simd.c \
sph/hamsi.c sph/hamsi_helper.c sph/sph_hamsi.h \
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 \
sha256/bitcoin.cu sha256/cuda_bitcoin.cu \
sha256/credits.cu sha256/cuda_credits.cu \
pluck/pluck.cu pluck/cuda_pluck.cu \
qubit/qubit.cu qubit/qubit_luffa512.cu qubit/deep.cu qubit/luffa.cu \
x11/x11.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 \
x13/x13.cu x13/cuda_x13_hamsi512.cu x13/cuda_x13_fugue512.cu \
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
# 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) -DSCRYPT_KECCAK512 -DSCRYPT_CHACHA -DSCRYPT_CHOOSE_COMPILETIME
nvcc_ARCH = -gencode=arch=compute_50,code=\"sm_50,compute_50\"
nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\"
#nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\"
#nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\"
#nvcc_ARCH += -gencode=arch=compute_20,code=\"sm_21,compute_20\"
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 $<
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 +106,51 @@ 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 $<
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_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_20,code=\"sm_21,compute_20\" -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_20,code=\"sm_20,compute_20\" -o $@ -c $<
scrypt/fermi_kernel.o: scrypt/fermi_kernel.cu
$(NVCC) $(JANSSON_INCLUDES) -I. @CUDA_INCLUDES@ @CUDA_CFLAGS@ -gencode=arch=compute_20,code=\"sm_21,compute_20\" -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 $<
skein2.o: skein2.cu
$(NVCC) $(nvcc_FLAGS) --maxrregcount=64 -o $@ -c $<
+5 -3
View File
@@ -1,9 +1,9 @@
ccminer
=======
Based on Christian Buchner's &amp; Christian H.'s CUDA project
Based on Christian Buchner's &amp; Christian H.'s CUDA project, no more active on github recently.
Fork by tpruvot@github with X14,X15,X17,WHIRL and Blake256 support (NEOS + BlakeCoin), and some others, check the [README.txt](README.txt)
Fork by tpruvot@github with X14,X15,X17,Blake256,BlakeCoin,Lyra2RE,Skein,ZR5 and others, check the [README.txt](README.txt)
BTC donation address: 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
[![tip for next commit](https://tip4commit.com/projects/927.svg)](https://tip4commit.com/github/tpruvot/ccminer)
@@ -30,5 +30,7 @@ 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.
On Linux, you can use the helper ./build.sh (edit it if required)
There is also an old [Tutorial for windows](http://cudamining.co.uk/url/tutorials/id/3) on [CudaMining](http://cudamining.co.uk) website.
+185 -28
View File
@@ -1,16 +1,15 @@
ccMiner release 1.4.7-tpruvot (Nov 2014) - "Blake update"
ccMiner release 1.6.x-tpruvot (Jun 2015) - "SHA and ..."
---------------------------------------------------------------
***************************************************************
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
BTC : 1AJdfCpLWPNoAMDfHF1wD5y8VgKSSTHxPo
DRK : XeVrkPrWB7pDbdFLfKhF1Z3xpqhsx6wkH3
NEOS : NaEcVrdzoCWHUYXb7X8QoafoKS9UV69Yk4
XST : S9TqZucWgT6ajZLDBxQnHUtmkotCEHn9z9
ZRC : ZEcubH2xp2mpuwxMjy7wZThr5AzLGu3mqT
DJM34:
BTC donation address: 1NENYmxwZGHsKFmyjTc5WferTn5VTFb7Ze
@@ -25,6 +24,7 @@ cbuchner v1.2:
This is a CUDA accelerated mining application which handle :
Credits
HeavyCoin & MjollnirCoin
FugueCoin
GroestlCoin & Myriad-Groestl
@@ -32,12 +32,20 @@ JackpotCoin
QuarkCoin family & AnimeCoin
TalkCoin
DarkCoin and other X11 coins
NEOS blake (256 14-rounds)
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)
Scrypt and Scrypt:N
Scrypt-Jane (Chacha)
Skein (Skein + SHA)
Woodcoin (Double Skein)
Vertcoin Lyra2RE
Ziftrcoin (ZR5)
where some of these coins have a VERY NOTABLE nVidia advantage
over competing AMD (OpenCL Only) implementations.
@@ -52,13 +60,15 @@ 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)
bitcoin use to mine SHA-256d coins
blake use to mine Saffroncoin (Blake 256)
blakecoin use to mine Old Blake 256
credits use to mine Credits [CRE]
deep use to mine Deepcoin
dmd-gr use to mine Diamond-Groestl
fresh use to mine Freshcoin
@@ -67,28 +77,40 @@ its command line interface and options.
heavy use to mine Heavycoin
jackpot use to mine Jackpotcoin
keccak use to mine Maxcoin
luffa use to mine Doomcoin
luffa use to mine Joincoin
lyra2 use to mine Vertcoin
mjollnir use to mine Mjollnircoin
myr-gr use to mine Myriad-Groest
neoscrypt use to mine FeatherCoin
nist5 use to mine TalkCoin
penta use to mine Joincoin / Pentablake
pluck use to mine Supcoin
quark use to mine Quarkcoin
qubit use to mine Qubit Algo
qubit use to mine Qubit
scrypt use to mine Scrypt coins
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
whirl use to mine Whirlcoin
skein use to mine Skeincoin
skein2 use to mine Woodcoin
x11 use to mine DarkCoin
x14 use to mine X14Coin
x15 use to mine Halcyon
x17 use to mine X17
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
-f, --diff-factor Divide difficulty by this factor (default 1.0)
-m, --diff-multiplier Multiply difficulty by this value (default 1.0)
--vote=VOTE block reward vote (for HeavyCoin)
--trust-pool trust the max block reward vote (maxvote) sent by the pool
-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,63 +120,198 @@ 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)
--time-limit maximum time [s] to mine before exiting the program.
-T, --timeout=N network timeout, in seconds (default: 270)
-s, --scantime=N upper bound on time spent scanning current work when
long polling is unavailable, in seconds (default: 5)
-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 IP/Port for the miner API (default: 127.0.0.1:4068)
--api-remote Allow remote control
--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
-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
-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.
--no-autotune disable auto-tuning of kernel launch parameters
>>> 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 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
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 <<<
Nov 2014 v1.4.7
June 2015 v1.6.5
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
Optimize qubit, deep and luffa algos
Compatibility with CUDA 7.0 (but slower hashrate)
Various improvements on multipool and cmdline parameters
Import Credits (djm34) and Bitcoin (klaus) "SHA256" 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 +407,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
+1003
View File
File diff suppressed because it is too large. Load diff
+259
View File
@@ -0,0 +1,259 @@
<?php
/* ccminer API sample UI (API 1.5) */
$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',
);
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['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['POOLS'] = 'Pools';
$intl['TEMP'] = 'T°c';
$intl['FAN'] = 'Fan %';
$intl['FREQ'] = 'Freq.';
$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'].'&nbsp;'.$data['VER'];
break;
case 'FREQ':
$val = sprintf("%d MHz", 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 '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; }
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>&copy; 2014-2015 <a href="http://github.com/tpruvot/ccminer">tpruvot@github</a></p>
</div>
</body>
</html>
+137
View File
@@ -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";
?>
+130
View File
@@ -0,0 +1,130 @@
<!DOCTYPE HTML>
<html>
<head>
<script src="//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>
+26
View File
@@ -0,0 +1,26 @@
/**
* Wrapper to OpenSSL BIGNUM used by net diff (nBits)
*/
#include <stdio.h>
#include "uint256.h"
#include "bignum.hpp"
#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);
}
+602
View File
@@ -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 BN_get_word(this);
}
unsigned int getuint() const
{
return BN_get_word(this);
}
int getint() const
{
unsigned long n = 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 < (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, 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 = 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, 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 = 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, 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 = 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(), 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 = BN_get_word(this) << 8*(3-nSize);
else
{
CBigNum bn;
BN_rshift(&bn, this, 8*(nSize-3));
nCompact = 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
-441
View File
@@ -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 */
+4
View File
@@ -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
+19
View File
@@ -0,0 +1,19 @@
{
"_comment1" : "Possible keys are the long options (ccminer --help)",
"_comment2" : "todo: support /* comments */",
"algo" : "blake",
"intensity": 19,
"api-bind": "127.0.0.1:4068",
"statsavg": 20,
"quiet" : false,
"debug" : false,
"protocol" : false,
"cpu-priority" : 3,
"url" : "stratum+tcp://stratum.eu.miners-pool.eu:8421",
"user" : "ShGCAFrspnLDo414EzUyJm4k5Qr2Kkrmvh",
"pass" : "x"
}
+3366
View File
File diff suppressed because it is too large. Load diff
+162 -242
View File
@@ -23,34 +23,22 @@
<RootNamespace>ccminer</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>false</CLRSupport>
</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>
<UseDebugLibraries>false</UseDebugLibraries>
<LinkIncremental>false</LinkIncremental>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<CLRSupport>false</CLRSupport>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -68,44 +56,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 +93,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>
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
<TargetMachinePlatform>64</TargetMachinePlatform>
</CudaCompile>
<CudaLink>
<PerformDeviceLink>false</PerformDeviceLink>
@@ -150,37 +133,37 @@
<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>
<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_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
<AdditionalOptions>--ptxas-options="-O2" %(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 +172,40 @@
<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>
<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_35,sm_35;compute_50,sm_50;compute_52,sm_52</CodeGeneration>
<Include>$(NVTOOLSEXT_PATH)\include;..\..\..\Common\C99</Include>
<Optimization>O3</Optimization>
<TargetMachinePlatform>64</TargetMachinePlatform>
</CudaCompile>
<CudaLink>
<Optimization>O3</Optimization>
<PerformDeviceLink>false</PerformDeviceLink>
</CudaLink>
</ItemDefinitionGroup>
@@ -224,27 +213,44 @@
<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" />
<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="pools.cpp" />
<ClCompile Include="util.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" />
<ClInclude Include="neoscrypt\neoscrypt.h" />
<ClCompile Include="neoscrypt\neoscrypt.cpp" />
<ClCompile Include="neoscrypt\neoscrypt-cpu.c" />
<ClInclude Include="neoscrypt\cuda_vectors.h" />
<CudaCompile Include="neoscrypt\cuda_neoscrypt.cu" />
<ClCompile Include="scrypt-jane.cpp" />
<ClCompile Include="scrypt.cpp" />
<ClCompile Include="skein2.cpp" />
<ClCompile Include="sph\aes_helper.c" />
<ClCompile Include="sph\blake.c" />
<ClCompile Include="sph\bmw.c" />
@@ -263,6 +269,7 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="sph\sha2.c" />
<ClCompile Include="sph\sha256d.c" />
<ClCompile Include="sph\sha2big.c" />
<ClCompile Include="sph\shabal.c" />
<ClCompile Include="sph\shavite.c" />
@@ -271,15 +278,21 @@
<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>
</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" />
@@ -287,15 +300,14 @@
<ClInclude Include="cpuminer-config.h" />
<ClInclude Include="cuda_groestlcoin.h" />
<ClInclude Include="cuda_helper.h" />
<ClInclude Include="cuda_vector.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="miner.h" />
<ClInclude Include="nvml.h" />
<ClInclude Include="res\resource.h" />
<ClInclude Include="scrypt\salsa_kernel.h" />
<ClInclude Include="sph\sph_blake.h" />
<ClInclude Include="sph\sph_bmw.h" />
<ClInclude Include="sph\sph_cubehash.h" />
@@ -315,278 +327,186 @@
<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="quark\groestl_transf_quad.h" />
<ClInclude Include="quark\groestl_functions_quad.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="cuda_nist5.cu" />
<CudaCompile Include="sha256\bitcoin.cu" />
<CudaCompile Include="sha256\cuda_bitcoin.cu" />
<CudaCompile Include="sha256\credits.cu" />
<CudaCompile Include="sha256\cuda_credits.cu" />
<CudaCompile Include="scrypt\blake.cu" />
<CudaCompile Include="scrypt\keccak.cu" />
<CudaCompile Include="scrypt\sha256.cu" />
<CudaCompile Include="scrypt\salsa_kernel.cu">
<CodeGeneration>compute_20,sm_21</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_20,sm_21</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_20,sm_21</CodeGeneration>
</CudaCompile>
<CudaCompile Include="scrypt\titan_kernel.cu">
<CodeGeneration>compute_35,sm_35;compute_50,sm_50</CodeGeneration>
</CudaCompile>
<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="JHA\cuda_jha_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="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\keccak256.cu" />
<CudaCompile Include="Algo256\cuda_blake256.cu" />
<CudaCompile Include="Algo256\cuda_fugue256.cu" />
<CudaCompile Include="Algo256\cuda_groestl256.cu" />
<CudaCompile Include="Algo256\cuda_keccak256.cu">
<MaxRegCount>92</MaxRegCount>
</CudaCompile>
<CudaCompile Include="keccak\keccak256.cu" />
<CudaCompile Include="Algo256\cuda_skein256.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="pluck\pluck.cu" />
<CudaCompile Include="pluck\cuda_pluck.cu" />
<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 Include="qubit\luffa.cu">
</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="lyra2\lyra2RE.cu" />
<CudaCompile Include="lyra2\cuda_lyra2.cu" />
<CudaCompile Include="skein.cu">
<MaxRegCount>64</MaxRegCount>
</CudaCompile>
<CudaCompile Include="cuda_skeincoin.cu">
<MaxRegCount>48</MaxRegCount>
</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_cubehash512.cu" />
<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 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">
<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>
<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>
<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="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>
<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>
<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\cuda_x14_shabal512.cu">
</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="x15\cuda_x15_whirlpool.cu">
</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>
<CudaCompile Include="x17\cuda_x17_haval512.cu">
</CudaCompile>
<CudaCompile Include="x17\cuda_x17_sha512.cu">
<MaxRegCount>80</MaxRegCount>
</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">
@@ -599,4 +519,4 @@
<Target Name="AfterClean">
<Delete Files="@(FilesToCopy->'$(OutDir)%(Filename)%(Extension)')" TreatErrorsAsWarnings="true" />
</Target>
</Project>
</Project>
+263 -62
View File
@@ -43,9 +43,6 @@
<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>
@@ -64,9 +61,27 @@
<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\sha256">
<UniqueIdentifier>{6def248f-bf21-43b0-8fd7-f2c749b73e9e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="compat\jansson\dump.c">
@@ -93,27 +108,18 @@
<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>
@@ -159,9 +165,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>
@@ -180,6 +183,9 @@
<ClCompile Include="sph\haval_helper.c">
<Filter>Source Files\sph</Filter>
</ClCompile>
<ClCompile Include="sph\sha256d.c">
<Filter>Source Files\sph</Filter>
</ClCompile>
<ClCompile Include="sph\sha2big.c">
<Filter>Source Files\sph</Filter>
</ClCompile>
@@ -189,6 +195,66 @@
<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>
<ClCompile Include="lyra2\Lyra2.c">
<Filter>Source Files\sph</Filter>
</ClCompile>
<ClCompile Include="lyra2\Sponge.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="bignum.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="compat.h">
@@ -218,9 +284,6 @@
<ClInclude Include="cpuminer-config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="hefty1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="uint256.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -266,27 +329,15 @@
<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.h">
<Filter>Header Files\CUDA</Filter>
</ClInclude>
<ClInclude Include="sph\sph_hamsi.h">
<Filter>Header Files\sph</Filter>
</ClInclude>
@@ -305,20 +356,77 @@
<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\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>
</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>
@@ -331,6 +439,12 @@
<CudaCompile Include="JHA\cuda_jha_compactionTest.cu">
<Filter>Source Files\CUDA\JHA</Filter>
</CudaCompile>
<CudaCompile Include="pluck\pluck.cu">
<Filter>Source Files\CUDA</Filter>
</CudaCompile>
<CudaCompile Include="pluck\cuda_pluck.cu">
<Filter>Source Files\CUDA</Filter>
</CudaCompile>
<CudaCompile Include="quark\cuda_jh512.cu">
<Filter>Source Files\CUDA\quark</Filter>
</CudaCompile>
@@ -382,7 +496,7 @@
<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">
@@ -406,6 +520,9 @@
<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>
@@ -439,9 +556,6 @@
<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>
@@ -457,20 +571,107 @@
<CudaCompile Include="x17\x17.cu">
<Filter>Source Files\CUDA\x17</Filter>
</CudaCompile>
<CudaCompile Include="blake32.cu">
<Filter>Source Files\CUDA</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>
<CudaCompile Include="keccak\keccak256.cu">
<Filter>Source Files\CUDA\keccak</Filter>
</CudaCompile>
<CudaCompile Include="x11\s3.cu">
<Filter>Source Files\CUDA\x11</Filter>
</CudaCompile>
<CudaCompile Include="Algo256\blake256.cu">
<Filter>Source Files\CUDA</Filter>
</CudaCompile>
<CudaCompile Include="Algo256\keccak256.cu">
<Filter>Source Files\CUDA</Filter>
</CudaCompile>
<CudaCompile Include="Algo256\cuda_blake256.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_skein256.cu">
<Filter>Source Files\CUDA\Algo256</Filter>
</CudaCompile>
<CudaCompile Include="lyra2\cuda_lyra2.cu">
<Filter>Source Files\CUDA</Filter>
</CudaCompile>
<CudaCompile Include="lyra2\lyra2RE.cu">
<Filter>Source Files\CUDA</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="sha256\bitcoin.cu">
<Filter>Source Files\CUDA\sha256</Filter>
</CudaCompile>
<CudaCompile Include="sha256\cuda_bitcoin.cu">
<Filter>Source Files\CUDA\sha256</Filter>
</CudaCompile>
<CudaCompile Include="sha256\credits.cu">
<Filter>Source Files\CUDA\sha256</Filter>
</CudaCompile>
<CudaCompile Include="sha256\cuda_credits.cu">
<Filter>Source Files\CUDA\sha256</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>
+58 -2
View File
@@ -5,20 +5,76 @@
#include <windows.h>
extern int opt_priority;
static __inline void sleep(int secs)
{
Sleep(secs * 1000);
}
enum {
PRIO_PROCESS = 0,
PRIO_PROCESS = 0,
};
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;
#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,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 */
+3
View File
@@ -0,0 +1,3 @@
*.h.in~
libtool
libjansson.a
+20 -18
View File
@@ -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
-73
View File
@@ -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 */
+98
View File
@@ -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
View File
@@ -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);
}
+63
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
}
+43
View File
@@ -0,0 +1,43 @@
/*
* 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
#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
+39
View File
@@ -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
+44 -11
View File
@@ -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
+140
View File
@@ -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 */
+139
View File
@@ -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
View File
@@ -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;
}
+56
View File
@@ -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;
}
+762
View File
@@ -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
View File
@@ -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);
+6 -4
View File
@@ -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);
+134
View File
@@ -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 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+2
View File
@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://developer.nvidia.com/nvapi
Binary file not shown.
+402
View File
@@ -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);
}
+472
View File
@@ -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);
}
+38
View File
@@ -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
+10756
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -0,0 +1,2 @@
/* todo: stripped version... or not */
#include "nvapi.h"
+469
View File
@@ -0,0 +1,469 @@
#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
// 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
typedef signed short NvS16;
typedef unsigned short NvU16;
typedef unsigned char NvU8;
typedef signed char NvS8;
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_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
typedef NV_DISPLAY_DRIVER_MEMORY_INFO_V2 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
#define NV_DISPLAY_DRIVER_MEMORY_INFO_VER NV_DISPLAY_DRIVER_MEMORY_INFO_VER_2
///////////////////////////////////////////////////////////////////////////////
//
// 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)
+151
View File
@@ -0,0 +1,151 @@
#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.
//!
//! 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)
+783
View File
@@ -0,0 +1,783 @@
#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
+787
View File
@@ -0,0 +1,787 @@
// ====================================================
// 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
+184
View File
@@ -0,0 +1,184 @@
#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:
//! \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.
typedef enum _NVAPI_D3D_SETRESOURCEHINT_SLI
{
NVAPI_D3D_SRH_SLI_APP_CONTROLLED_INTERFRAME_CONTENT_SYNC = 1
} 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)
+566
View File
@@ -0,0 +1,566 @@
#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)
+71
View File
@@ -0,0 +1,71 @@
#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.
-662
View File
@@ -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)
-244
View File
@@ -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>
-73
View File
@@ -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
-505
View File
@@ -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>
-231
View File
@@ -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
-38
View File
@@ -1,38 +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.inl
* \brief Inline file for advance.h
*/
#include <thrust/detail/config.h>
#include <thrust/advance.h>
#include <thrust/system/detail/generic/advance.h>
namespace thrust
{
template <typename InputIterator, typename Distance>
void advance(InputIterator& i, Distance n)
{
thrust::system::detail::generic::advance(i, n);
} // end advance()
} // end namespace thrust
@@ -1,240 +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.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/detail/type_traits/has_nested_type.h>
#include <thrust/detail/type_traits.h>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
__THRUST_DEFINE_HAS_NESTED_TYPE(has_pointer, pointer)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_pointer, const_pointer)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_reference, reference)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_reference, const_reference)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_void_pointer, void_pointer)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_const_void_pointer, const_void_pointer)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_difference_type, difference_type)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_size_type, size_type)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_move_assignment, propagate_on_container_move_assignment)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_propagate_on_container_swap, propagate_on_container_swap)
__THRUST_DEFINE_HAS_NESTED_TYPE(has_system_type, system_type)
template<typename T>
struct nested_pointer
{
typedef typename T::pointer type;
};
template<typename T>
struct nested_const_pointer
{
typedef typename T::const_pointer type;
};
template<typename T>
struct nested_reference
{
typedef typename T::reference type;
};
template<typename T>
struct nested_const_reference
{
typedef typename T::const_reference type;
};
template<typename T>
struct nested_void_pointer
{
typedef typename T::void_pointer type;
};
template<typename T>
struct nested_const_void_pointer
{
typedef typename T::const_void_pointer type;
};
template<typename T>
struct nested_difference_type
{
typedef typename T::difference_type type;
};
template<typename T>
struct nested_size_type
{
typedef typename T::size_type type;
};
template<typename T>
struct nested_propagate_on_container_copy_assignment
{
typedef typename T::propagate_on_container_copy_assignment type;
};
template<typename T>
struct nested_propagate_on_container_move_assignment
{
typedef typename T::propagate_on_container_move_assignment type;
};
template<typename T>
struct nested_propagate_on_container_swap
{
typedef typename T::propagate_on_container_swap type;
};
template<typename T>
struct nested_system_type
{
typedef typename T::system_type type;
};
} // end allocator_traits_detail
template<typename Alloc>
struct allocator_traits
{
typedef Alloc allocator_type;
typedef typename allocator_type::value_type value_type;
typedef typename eval_if<
allocator_traits_detail::has_pointer<allocator_type>::value,
allocator_traits_detail::nested_pointer<allocator_type>,
identity_<value_type*>
>::type pointer;
private:
template<typename T>
struct rebind_pointer
{
typedef typename pointer_traits<pointer>::template rebind<T>::other type;
};
public:
typedef typename eval_if<
allocator_traits_detail::has_const_pointer<allocator_type>::value,
allocator_traits_detail::nested_const_pointer<allocator_type>,
rebind_pointer<const value_type>
>::type const_pointer;
typedef typename eval_if<
allocator_traits_detail::has_void_pointer<allocator_type>::value,
allocator_traits_detail::nested_void_pointer<allocator_type>,
rebind_pointer<void>
>::type void_pointer;
typedef typename eval_if<
allocator_traits_detail::has_const_void_pointer<allocator_type>::value,
allocator_traits_detail::nested_const_void_pointer<allocator_type>,
rebind_pointer<const void>
>::type const_void_pointer;
typedef typename eval_if<
allocator_traits_detail::has_difference_type<allocator_type>::value,
allocator_traits_detail::nested_difference_type<allocator_type>,
pointer_difference<pointer>
>::type difference_type;
typedef typename eval_if<
allocator_traits_detail::has_size_type<allocator_type>::value,
allocator_traits_detail::nested_size_type<allocator_type>,
make_unsigned<difference_type>
>::type size_type;
typedef typename eval_if<
allocator_traits_detail::has_propagate_on_container_copy_assignment<allocator_type>::value,
allocator_traits_detail::nested_propagate_on_container_copy_assignment<allocator_type>,
identity_<false_type>
>::type propagate_on_container_copy_assignment;
typedef typename eval_if<
allocator_traits_detail::has_propagate_on_container_move_assignment<allocator_type>::value,
allocator_traits_detail::nested_propagate_on_container_move_assignment<allocator_type>,
identity_<false_type>
>::type propagate_on_container_move_assignment;
typedef typename eval_if<
allocator_traits_detail::has_propagate_on_container_swap<allocator_type>::value,
allocator_traits_detail::nested_propagate_on_container_swap<allocator_type>,
identity_<false_type>
>::type propagate_on_container_swap;
typedef typename eval_if<
allocator_traits_detail::has_system_type<allocator_type>::value,
allocator_traits_detail::nested_system_type<allocator_type>,
thrust::iterator_system<pointer>
>::type system_type;
// XXX rebind and rebind_traits are alias templates
// and so are omitted while c++11 is unavailable
inline static pointer allocate(allocator_type &a, size_type n);
inline static pointer allocate(allocator_type &a, size_type n, const_void_pointer hint);
inline static void deallocate(allocator_type &a, pointer p, size_type n);
// XXX should probably change T* to pointer below and then relax later
template<typename T>
inline __host__ __device__ static void construct(allocator_type &a, T *p);
template<typename T, typename Arg1>
inline __host__ __device__ static void construct(allocator_type &a, T *p, const Arg1 &arg1);
template<typename T>
inline __host__ __device__ static void destroy(allocator_type &a, T *p);
inline static size_type max_size(const allocator_type &a);
}; // end allocator_traits
// XXX consider moving this non-standard functionality inside allocator_traits
template<typename Alloc>
struct allocator_system
{
// the type of the allocator's system
typedef typename eval_if<
allocator_traits_detail::has_system_type<Alloc>::value,
allocator_traits_detail::nested_system_type<Alloc>,
thrust::iterator_system<
typename allocator_traits<Alloc>::pointer
>
>::type type;
inline static type &get(Alloc &a);
};
} // end detail
} // end thrust
#include <thrust/detail/allocator/allocator_traits.inl>
@@ -1,287 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/detail/type_traits/has_member_function.h>
#include <thrust/detail/type_traits/is_call_possible.h>
#include <new>
#include <limits>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_allocate_with_hint_impl, allocate)
template<typename Alloc>
class has_member_allocate_with_hint
{
typedef typename allocator_traits<Alloc>::pointer pointer;
typedef typename allocator_traits<Alloc>::size_type size_type;
typedef typename allocator_traits<Alloc>::const_void_pointer const_void_pointer;
public:
typedef typename has_member_allocate_with_hint_impl<Alloc, pointer(size_type,const_void_pointer)>::type type;
static const bool value = type::value;
};
template<typename Alloc>
typename enable_if<
has_member_allocate_with_hint<Alloc>::value,
typename allocator_traits<Alloc>::pointer
>::type
allocate(Alloc &a, typename allocator_traits<Alloc>::size_type n, typename allocator_traits<Alloc>::const_void_pointer hint)
{
return a.allocate(n,hint);
}
template<typename Alloc>
typename disable_if<
has_member_allocate_with_hint<Alloc>::value,
typename allocator_traits<Alloc>::pointer
>::type
allocate(Alloc &a, typename allocator_traits<Alloc>::size_type n, typename allocator_traits<Alloc>::const_void_pointer)
{
return a.allocate(n);
}
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_construct1_impl, construct)
template<typename Alloc, typename T>
struct has_member_construct1
: has_member_construct1_impl<Alloc, void(T*)>
{};
template<typename Alloc, typename T>
inline __host__ __device__
typename enable_if<
has_member_construct1<Alloc,T>::value
>::type
construct(Alloc &a, T *p)
{
a.construct(p);
}
template<typename Alloc, typename T>
inline __host__ __device__
typename disable_if<
has_member_construct1<Alloc,T>::value
>::type
construct(Alloc &a, T *p)
{
::new(static_cast<void*>(p)) T();
}
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_construct2_impl, construct)
template<typename Alloc, typename T, typename Arg1>
struct has_member_construct2
: has_member_construct2_impl<Alloc, void(T*,const Arg1 &)>
{};
template<typename Alloc, typename T, typename Arg1>
inline __host__ __device__
typename enable_if<
has_member_construct2<Alloc,T,Arg1>::value
>::type
construct(Alloc &a, T *p, const Arg1 &arg1)
{
a.construct(p,arg1);
}
template<typename Alloc, typename T, typename Arg1>
inline __host__ __device__
typename disable_if<
has_member_construct2<Alloc,T,Arg1>::value
>::type
construct(Alloc &, T *p, const Arg1 &arg1)
{
::new(static_cast<void*>(p)) T(arg1);
}
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_destroy_impl, destroy)
template<typename Alloc, typename T>
struct has_member_destroy
: has_member_destroy_impl<Alloc, void(T*)>
{};
template<typename Alloc, typename T>
inline __host__ __device__
typename enable_if<
has_member_destroy<Alloc,T>::value
>::type
destroy(Alloc &a, T *p)
{
a.destroy(p);
}
template<typename Alloc, typename T>
inline __host__ __device__
typename disable_if<
has_member_destroy<Alloc,T>::value
>::type
destroy(Alloc &, T *p)
{
p->~T();
}
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_max_size_impl, max_size)
template<typename Alloc>
class has_member_max_size
{
typedef typename allocator_traits<Alloc>::size_type size_type;
public:
typedef typename has_member_max_size_impl<Alloc, size_type(void)>::type type;
static const bool value = type::value;
};
template<typename Alloc>
typename enable_if<
has_member_max_size<Alloc>::value,
typename allocator_traits<Alloc>::size_type
>::type
max_size(const Alloc &a)
{
return a.max_size();
}
template<typename Alloc>
typename disable_if<
has_member_max_size<Alloc>::value,
typename allocator_traits<Alloc>::size_type
>::type
max_size(const Alloc &a)
{
typedef typename allocator_traits<Alloc>::size_type size_type;
return std::numeric_limits<size_type>::max();
}
__THRUST_DEFINE_HAS_MEMBER_FUNCTION(has_member_system_impl, system)
template<typename Alloc>
class has_member_system
{
typedef typename allocator_system<Alloc>::type system_type;
public:
typedef typename has_member_system_impl<Alloc, system_type&(void)>::type type;
static const bool value = type::value;
};
template<typename Alloc>
typename enable_if<
has_member_system<Alloc>::value,
typename allocator_system<Alloc>::type &
>::type
system(Alloc &a)
{
return a.system();
}
template<typename Alloc>
typename disable_if<
has_member_system<Alloc>::value,
typename allocator_system<Alloc>::type &
>::type
system(Alloc &a)
{
// assumes the system is default-constructible
static typename allocator_system<Alloc>::type state;
return state;
}
} // end allocator_traits_detail
template<typename Alloc>
typename allocator_traits<Alloc>::pointer
allocator_traits<Alloc>
::allocate(Alloc &a, typename allocator_traits<Alloc>::size_type n)
{
return a.allocate(n);
}
template<typename Alloc>
typename allocator_traits<Alloc>::pointer
allocator_traits<Alloc>
::allocate(Alloc &a, typename allocator_traits<Alloc>::size_type n, typename allocator_traits<Alloc>::const_void_pointer hint)
{
return allocator_traits_detail::allocate(a, n, hint);
}
template<typename Alloc>
void allocator_traits<Alloc>
::deallocate(Alloc &a, typename allocator_traits<Alloc>::pointer p, typename allocator_traits<Alloc>::size_type n)
{
return a.deallocate(p,n);
}
template<typename Alloc>
template<typename T>
void allocator_traits<Alloc>
::construct(allocator_type &a, T *p)
{
return allocator_traits_detail::construct(a,p);
}
template<typename Alloc>
template<typename T, typename Arg1>
void allocator_traits<Alloc>
::construct(allocator_type &a, T *p, const Arg1 &arg1)
{
return allocator_traits_detail::construct(a,p,arg1);
}
template<typename Alloc>
template<typename T>
void allocator_traits<Alloc>
::destroy(allocator_type &a, T *p)
{
return allocator_traits_detail::destroy(a,p);
}
template<typename Alloc>
typename allocator_traits<Alloc>::size_type
allocator_traits<Alloc>
::max_size(const allocator_type &a)
{
return allocator_traits_detail::max_size(a);
}
template<typename Alloc>
typename allocator_system<Alloc>::type &
allocator_system<Alloc>
::get(Alloc &a)
{
return allocator_traits_detail::system(a);
}
} // end detail
} // end thrust
@@ -1,45 +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.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/execution_policy.h>
namespace thrust
{
namespace detail
{
template<typename System, typename Allocator, typename InputIterator, typename Pointer>
Pointer copy_construct_range(thrust::execution_policy<System> &from_system,
Allocator &a,
InputIterator first,
InputIterator last,
Pointer result);
template<typename System, typename Allocator, typename InputIterator, typename Size, typename Pointer>
Pointer copy_construct_range_n(thrust::execution_policy<System> &from_system,
Allocator &a,
InputIterator first,
Size n,
Pointer result);
} // end detail
} // end thrust
#include <thrust/detail/allocator/copy_construct_range.inl>
@@ -1,298 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/iterator/iterator_traits.h>
#include <thrust/detail/copy.h>
#include <thrust/tuple.h>
#include <thrust/advance.h>
#include <thrust/distance.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/for_each.h>
#include <memory>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
template<typename Allocator, typename InputType, typename OutputType>
struct copy_construct_with_allocator
{
Allocator &a;
copy_construct_with_allocator(Allocator &a)
: a(a)
{}
template<typename Tuple>
inline __host__ __device__
void operator()(Tuple t)
{
const InputType &in = thrust::get<0>(t);
OutputType &out = thrust::get<1>(t);
allocator_traits<Allocator>::construct(a, &out, in);
}
};
template<typename Allocator, typename T>
struct needs_copy_construct_via_allocator
: has_member_construct2<
Allocator,
T,
T
>
{};
// we know that std::allocator::construct's only effect is to call T's
// copy constructor, so we needn't use it for copy construction
template<typename U, typename T>
struct needs_copy_construct_via_allocator<std::allocator<U>, T>
: thrust::detail::false_type
{};
// XXX it's regrettable that this implementation is copied almost
// exactly from system::detail::generic::uninitialized_copy
// perhaps generic::uninitialized_copy could call this routine
// with a default allocator
template<typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Pointer>
typename enable_if_convertible<
FromSystem,
ToSystem,
Pointer
>::type
uninitialized_copy_with_allocator(Allocator &a,
thrust::execution_policy<FromSystem> &from_system,
thrust::execution_policy<ToSystem> &to_system,
InputIterator first,
InputIterator last,
Pointer result)
{
// zip up the iterators
typedef thrust::tuple<InputIterator,Pointer> IteratorTuple;
typedef thrust::zip_iterator<IteratorTuple> ZipIterator;
ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first,result));
ZipIterator end = begin;
// get a zip_iterator pointing to the end
const typename thrust::iterator_difference<InputIterator>::type n = thrust::distance(first,last);
thrust::advance(end,n);
// create a functor
typedef typename iterator_traits<InputIterator>::value_type InputType;
typedef typename iterator_traits<Pointer>::value_type OutputType;
// do the for_each
// note we use to_system to dispatch the for_each
thrust::for_each(to_system, begin, end, copy_construct_with_allocator<Allocator,InputType,OutputType>(a));
// return the end of the output range
return thrust::get<1>(end.get_iterator_tuple());
}
// XXX it's regrettable that this implementation is copied almost
// exactly from system::detail::generic::uninitialized_copy_n
// perhaps generic::uninitialized_copy_n could call this routine
// with a default allocator
template<typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename Pointer>
typename enable_if_convertible<
FromSystem,
ToSystem,
Pointer
>::type
uninitialized_copy_with_allocator_n(Allocator &a,
thrust::execution_policy<FromSystem> &from_system,
thrust::execution_policy<ToSystem> &to_system,
InputIterator first,
Size n,
Pointer result)
{
// zip up the iterators
typedef thrust::tuple<InputIterator,Pointer> IteratorTuple;
typedef thrust::zip_iterator<IteratorTuple> ZipIterator;
ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first,result));
// create a functor
typedef typename iterator_traits<InputIterator>::value_type InputType;
typedef typename iterator_traits<Pointer>::value_type OutputType;
// do the for_each_n
// note we use to_system to dispatch the for_each_n
ZipIterator end = thrust::for_each_n(to_system, begin, n, copy_construct_with_allocator<Allocator,InputType,OutputType>(a));
// return the end of the output range
return thrust::get<1>(end.get_iterator_tuple());
}
template<typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Pointer>
typename disable_if_convertible<
FromSystem,
ToSystem,
Pointer
>::type
uninitialized_copy_with_allocator(Allocator &,
thrust::execution_policy<FromSystem> &from_system,
thrust::execution_policy<ToSystem> &to_system,
InputIterator first,
InputIterator last,
Pointer result)
{
// the systems aren't trivially interoperable
// just call two_system_copy and hope for the best
return thrust::detail::two_system_copy(from_system, to_system, first, last, result);
} // end uninitialized_copy_with_allocator()
template<typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename Pointer>
typename disable_if_convertible<
FromSystem,
ToSystem,
Pointer
>::type
uninitialized_copy_with_allocator_n(Allocator &,
thrust::execution_policy<FromSystem> &from_system,
thrust::execution_policy<ToSystem> &to_system,
InputIterator first,
Size n,
Pointer result)
{
// the systems aren't trivially interoperable
// just call two_system_copy_n and hope for the best
return thrust::detail::two_system_copy_n(from_system, to_system, first, n, result);
} // end uninitialized_copy_with_allocator_n()
template<typename FromSystem, typename Allocator, typename InputIterator, typename Pointer>
typename disable_if<
needs_copy_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value,
Pointer
>::type
copy_construct_range(thrust::execution_policy<FromSystem> &from_system,
Allocator &a,
InputIterator first,
InputIterator last,
Pointer result)
{
typename allocator_system<Allocator>::type &to_system = allocator_system<Allocator>::get(a);
// just call two_system_copy
return thrust::detail::two_system_copy(from_system, to_system, first, last, result);
}
template<typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>
typename disable_if<
needs_copy_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value,
Pointer
>::type
copy_construct_range_n(thrust::execution_policy<FromSystem> &from_system,
Allocator &a,
InputIterator first,
Size n,
Pointer result)
{
typename allocator_system<Allocator>::type &to_system = allocator_system<Allocator>::get(a);
// just call two_system_copy_n
return thrust::detail::two_system_copy_n(from_system, to_system, first, n, result);
}
template<typename FromSystem, typename Allocator, typename InputIterator, typename Pointer>
typename enable_if<
needs_copy_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value,
Pointer
>::type
copy_construct_range(thrust::execution_policy<FromSystem> &from_system,
Allocator &a,
InputIterator first,
InputIterator last,
Pointer result)
{
typename allocator_system<Allocator>::type &to_system = allocator_system<Allocator>::get(a);
return uninitialized_copy_with_allocator(a, from_system, to_system, first, last, result);
}
template<typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>
typename enable_if<
needs_copy_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value,
Pointer
>::type
copy_construct_range_n(thrust::execution_policy<FromSystem> &from_system,
Allocator &a,
InputIterator first,
Size n,
Pointer result)
{
typename allocator_system<Allocator>::type &to_system = allocator_system<Allocator>::get(a);
return uninitialized_copy_with_allocator_n(a, from_system, to_system, first, n, result);
}
} // end allocator_traits_detail
template<typename System, typename Allocator, typename InputIterator, typename Pointer>
Pointer copy_construct_range(thrust::execution_policy<System> &from_system,
Allocator &a,
InputIterator first,
InputIterator last,
Pointer result)
{
return allocator_traits_detail::copy_construct_range(from_system, a, first, last, result);
}
template<typename System, typename Allocator, typename InputIterator, typename Size, typename Pointer>
Pointer copy_construct_range_n(thrust::execution_policy<System> &from_system,
Allocator &a,
InputIterator first,
Size n,
Pointer result)
{
return allocator_traits_detail::copy_construct_range_n(from_system, a, first, n, result);
}
} // end detail
} // end thrust
@@ -1,36 +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.
*/
#pragma once
#include <thrust/detail/config.h>
namespace thrust
{
namespace detail
{
template<typename Allocator, typename Pointer, typename Size>
inline void default_construct_range(Allocator &a, Pointer p, Size n);
} // end detail
} // end thrust
#include <thrust/detail/allocator/default_construct_range.inl>
@@ -1,105 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/detail/type_traits.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/for_each.h>
#include <thrust/uninitialized_fill.h>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
template<typename Allocator>
struct construct1_via_allocator
{
Allocator &a;
construct1_via_allocator(Allocator &a)
: a(a)
{}
template<typename T>
inline __host__ __device__
void operator()(T &x)
{
allocator_traits<Allocator>::construct(a, &x);
}
};
template<typename Allocator, typename T>
struct needs_default_construct_via_allocator
: has_member_construct1<
Allocator,
T
>
{};
// we know that std::allocator::construct's only effect is to call T's
// default constructor, so we needn't use it for default construction
template<typename U, typename T>
struct needs_default_construct_via_allocator<std::allocator<U>, T>
: thrust::detail::false_type
{};
template<typename Allocator, typename Pointer, typename Size>
typename enable_if<
needs_default_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value
>::type
default_construct_range(Allocator &a, Pointer p, Size n)
{
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct1_via_allocator<Allocator>(a));
}
template<typename Allocator, typename Pointer, typename Size>
typename disable_if<
needs_default_construct_via_allocator<
Allocator,
typename pointer_element<Pointer>::type
>::value
>::type
default_construct_range(Allocator &a, Pointer p, Size n)
{
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, typename pointer_element<Pointer>::type());
}
} // end allocator_traits_detail
template<typename Allocator, typename Pointer, typename Size>
void default_construct_range(Allocator &a, Pointer p, Size n)
{
return allocator_traits_detail::default_construct_range(a,p,n);
}
} // end detail
} // end thrust
@@ -1,33 +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.
*/
#pragma once
#include <thrust/detail/config.h>
namespace thrust
{
namespace detail
{
template<typename Allocator, typename Pointer, typename Size>
inline void destroy_range(Allocator &a, Pointer p, Size n);
} // end detail
} // end thrust
#include <thrust/detail/allocator/destroy_range.inl>
@@ -1,158 +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.
*/
#include <thrust/detail/allocator/destroy_range.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/for_each.h>
#include <memory>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
// destroy_range has three cases:
// if Allocator has an effectful member function destroy:
// 1. destroy via the allocator
// else
// 2. if T has a non-trivial destructor, destroy the range without using the allocator
// 3. if T has a trivial destructor, do a no-op
template<typename Allocator, typename T>
struct has_effectful_member_destroy
: has_member_destroy<Allocator,T>
{};
// std::allocator::destroy's only effect is to invoke its argument's destructor
template<typename U, typename T>
struct has_effectful_member_destroy<std::allocator<U>, T>
: thrust::detail::false_type
{};
// case 1: Allocator has an effectful 1-argument member function "destroy"
template<typename Allocator, typename Pointer>
struct enable_if_destroy_range_case1
: thrust::detail::enable_if<
has_effectful_member_destroy<
Allocator,
typename pointer_element<Pointer>::type
>::value
>
{};
// case 2: Allocator has no member function "destroy", but T has a non-trivial destructor
template<typename Allocator, typename Pointer>
struct enable_if_destroy_range_case2
: thrust::detail::enable_if<
!has_effectful_member_destroy<
Allocator,
typename pointer_element<Pointer>::type
>::value &&
!has_trivial_destructor<
typename pointer_element<Pointer>::type
>::value
>
{};
// case 3: Allocator has no member function "destroy", and T has a trivial destructor
template<typename Allocator, typename Pointer>
struct enable_if_destroy_range_case3
: thrust::detail::enable_if<
!has_effectful_member_destroy<
Allocator,
typename pointer_element<Pointer>::type
>::value &&
has_trivial_destructor<
typename pointer_element<Pointer>::type
>::value
>
{};
template<typename Allocator>
struct destroy_via_allocator
{
Allocator &a;
destroy_via_allocator(Allocator &a)
: a(a)
{}
template<typename T>
inline __host__ __device__
void operator()(T &x)
{
allocator_traits<Allocator>::destroy(a, &x);
}
};
// destroy_range case 1: destroy via allocator
template<typename Allocator, typename Pointer, typename Size>
typename enable_if_destroy_range_case1<Allocator,Pointer>::type
destroy_range(Allocator &a, Pointer p, Size n)
{
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, destroy_via_allocator<Allocator>(a));
}
// we must prepare for His coming
struct gozer
{
template<typename T>
inline __host__ __device__
void operator()(T &x)
{
x.~T();
}
};
// destroy_range case 2: destroy without the allocator
template<typename Allocator, typename Pointer, typename Size>
typename enable_if_destroy_range_case2<Allocator,Pointer>::type
destroy_range(Allocator &a, Pointer p, Size n)
{
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, gozer());
}
// destroy_range case 3: no-op
template<typename Allocator, typename Pointer, typename Size>
typename enable_if_destroy_range_case3<Allocator,Pointer>::type
destroy_range(Allocator &, Pointer, Size)
{
// no op
}
} // end allocator_traits_detail
template<typename Allocator, typename Pointer, typename Size>
void destroy_range(Allocator &a, Pointer p, Size n)
{
return allocator_traits_detail::destroy_range(a,p,n);
}
} // end detail
} // end thrust
@@ -1,35 +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.
*/
#pragma once
#include <thrust/detail/config.h>
namespace thrust
{
namespace detail
{
template<typename Allocator, typename Pointer, typename Size, typename T>
inline void fill_construct_range(Allocator &a, Pointer p, Size n, const T &value);
} // end detail
} // end thrust
#include <thrust/detail/allocator/fill_construct_range.inl>
@@ -1,109 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/type_traits.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/for_each.h>
#include <thrust/uninitialized_fill.h>
#include <memory>
namespace thrust
{
namespace detail
{
namespace allocator_traits_detail
{
// fill_construct_range has 2 cases:
// if Allocator has an effectful member function construct:
// 1. construct via the allocator
// else
// 2. construct via uninitialized_fill
template<typename Allocator, typename T, typename Arg1>
struct has_effectful_member_construct2
: has_member_construct2<Allocator,T,Arg1>
{};
// std::allocator::construct's only effect is to invoke placement new
template<typename U, typename T, typename Arg1>
struct has_effectful_member_construct2<std::allocator<U>,T,Arg1>
: thrust::detail::false_type
{};
template<typename Allocator, typename Arg1>
struct construct2_via_allocator
{
Allocator &a;
Arg1 arg;
construct2_via_allocator(Allocator &a, const Arg1 &arg)
: a(a), arg(arg)
{}
template<typename T>
inline __host__ __device__
void operator()(T &x)
{
allocator_traits<Allocator>::construct(a, &x, arg);
}
};
template<typename Allocator, typename Pointer, typename Size, typename T>
typename enable_if<
has_effectful_member_construct2<
Allocator,
typename pointer_element<Pointer>::type,
T
>::value
>::type
fill_construct_range(Allocator &a, Pointer p, Size n, const T &value)
{
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct2_via_allocator<Allocator,T>(a, value));
}
template<typename Allocator, typename Pointer, typename Size, typename T>
typename disable_if<
has_effectful_member_construct2<
Allocator,
typename pointer_element<Pointer>::type,
T
>::value
>::type
fill_construct_range(Allocator &a, Pointer p, Size n, const T &value)
{
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, value);
}
} // end allocator_traits_detail
template<typename Alloc, typename Pointer, typename Size, typename T>
void fill_construct_range(Alloc &a, Pointer p, Size n, const T &value)
{
return allocator_traits_detail::fill_construct_range(a,p,n,value);
}
} // end detail
} // end thrust
@@ -1,52 +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.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/detail/allocator/tagged_allocator.h>
namespace thrust
{
namespace detail
{
template<typename T, typename System, typename Pointer>
class malloc_allocator
: public thrust::detail::tagged_allocator<
T, System, Pointer
>
{
private:
typedef thrust::detail::tagged_allocator<
T, System, Pointer
> super_t;
public:
typedef typename super_t::pointer pointer;
typedef typename super_t::size_type size_type;
pointer allocate(size_type cnt);
void deallocate(pointer p, size_type n);
};
} // end detail
} // end thrust
#include <thrust/detail/allocator/malloc_allocator.inl>
@@ -1,64 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/malloc_allocator.h>
#include <thrust/system/detail/generic/select_system.h>
#include <thrust/system/detail/bad_alloc.h>
#include <thrust/detail/raw_pointer_cast.h>
#include <thrust/detail/malloc_and_free.h>
namespace thrust
{
namespace detail
{
template<typename T, typename System, typename Pointer>
typename malloc_allocator<T,System,Pointer>::pointer
malloc_allocator<T,System,Pointer>
::allocate(typename malloc_allocator<T,System,Pointer>::size_type cnt)
{
using thrust::system::detail::generic::select_system;
// XXX should use a hypothetical thrust::static_pointer_cast here
System system;
pointer result = thrust::malloc<T>(select_system(system), cnt);
if(result.get() == 0)
{
throw thrust::system::detail::bad_alloc("malloc_allocator::allocate: malloc failed");
} // end if
return result;
} // end malloc_allocator::allocate()
template<typename T, typename System, typename Pointer>
void malloc_allocator<T,System,Pointer>
::deallocate(typename malloc_allocator<T,System,Pointer>::pointer p, typename malloc_allocator<T,System,Pointer>::size_type n)
{
using thrust::system::detail::generic::select_system;
System system;
thrust::free(select_system(system), p);
} // end malloc_allocator
} // end detail
} // end thrust
@@ -1,62 +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.
*/
#pragma once
#include <thrust/detail/config.h>
namespace thrust
{
namespace detail
{
template<typename BaseAllocator>
struct no_throw_allocator : BaseAllocator
{
private:
typedef BaseAllocator super_t;
public:
inline no_throw_allocator(const BaseAllocator &other = BaseAllocator())
: super_t(other)
{}
template<typename U>
struct rebind
{
typedef no_throw_allocator<typename super_t::template rebind<U>::other> other;
}; // end rebind
void deallocate(typename super_t::pointer p, typename super_t::size_type n)
{
try
{
super_t::deallocate(p, n);
} // end try
catch(...)
{
// catch anything
} // end catch
} // end deallocate()
inline bool operator==(no_throw_allocator const &other) { return super_t::operator==(other); }
inline bool operator!=(no_throw_allocator const &other) { return super_t::operator!=(other); }
}; // end no_throw_allocator
} // end detail
} // end thrust
@@ -1,101 +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.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/type_traits/pointer_traits.h>
#include <thrust/iterator/iterator_traits.h>
namespace thrust
{
namespace detail
{
template<typename T, typename Tag, typename Pointer> class tagged_allocator;
template<typename Tag, typename Pointer>
class tagged_allocator<void, Tag, Pointer>
{
public:
typedef void value_type;
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<void>::other pointer;
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const void>::other const_pointer;
typedef std::size_t size_type;
typedef typename thrust::detail::pointer_traits<Pointer>::difference_type difference_type;
typedef Tag system_type;
template<typename U>
struct rebind
{
typedef tagged_allocator<U,Tag,Pointer> other;
}; // end rebind
};
template<typename T, typename Tag, typename Pointer>
class tagged_allocator
{
public:
typedef T value_type;
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other pointer;
typedef typename thrust::detail::pointer_traits<Pointer>::template rebind<const T>::other const_pointer;
typedef typename thrust::iterator_reference<pointer>::type reference;
typedef typename thrust::iterator_reference<const_pointer>::type const_reference;
typedef std::size_t size_type;
typedef typename thrust::detail::pointer_traits<pointer>::difference_type difference_type;
typedef Tag system_type;
template<typename U>
struct rebind
{
typedef tagged_allocator<U,Tag,Pointer> other;
}; // end rebind
__host__ __device__
inline tagged_allocator();
__host__ __device__
inline tagged_allocator(const tagged_allocator &);
template<typename U, typename OtherPointer>
__host__ __device__
inline tagged_allocator(const tagged_allocator<U, Tag, OtherPointer> &);
__host__ __device__
inline ~tagged_allocator();
__host__ __device__
pointer address(reference x) const;
__host__ __device__
const_pointer address(const_reference x) const;
size_type max_size() const;
};
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
__host__ __device__
bool operator==(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
__host__ __device__
bool operator!=(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &);
} // end detail
} // end thrust
#include <thrust/detail/allocator/tagged_allocator.inl>
@@ -1,97 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/tagged_allocator.h>
#include <limits>
namespace thrust
{
namespace detail
{
template<typename T, typename Tag, typename Pointer>
tagged_allocator<T,Tag,Pointer>
::tagged_allocator()
{}
template<typename T, typename Tag, typename Pointer>
tagged_allocator<T,Tag,Pointer>
::tagged_allocator(const tagged_allocator<T,Tag,Pointer> &)
{}
template<typename T, typename Tag, typename Pointer>
template<typename U, typename OtherPointer>
tagged_allocator<T,Tag,Pointer>
::tagged_allocator(const tagged_allocator<U,Tag,OtherPointer> &)
{}
template<typename T, typename Tag, typename Pointer>
tagged_allocator<T,Tag,Pointer>
::~tagged_allocator()
{}
template<typename T, typename Tag, typename Pointer>
typename tagged_allocator<T,Tag,Pointer>::pointer
tagged_allocator<T,Tag,Pointer>
::address(reference x) const
{
return &x;
}
template<typename T, typename Tag, typename Pointer>
typename tagged_allocator<T,Tag,Pointer>::const_pointer
tagged_allocator<T,Tag,Pointer>
::address(const_reference x) const
{
return &x;
}
template<typename T, typename Tag, typename Pointer>
typename tagged_allocator<T,Tag,Pointer>::size_type
tagged_allocator<T,Tag,Pointer>
::max_size() const
{
return (std::numeric_limits<size_type>::max)() / sizeof(T);
}
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
__host__ __device__
bool operator==(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &)
{
return true;
}
template<typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>
__host__ __device__
bool operator!=(const tagged_allocator<T1,Pointer1,Tag> &, const tagged_allocator<T2,Pointer2,Tag> &)
{
return false;
}
} // end detail
} // end thrust
@@ -1,75 +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.
*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/tagged_allocator.h>
#include <thrust/detail/allocator/allocator_traits.h>
#include <thrust/pair.h>
#include <thrust/memory.h>
#include <thrust/detail/execution_policy.h>
namespace thrust
{
namespace detail
{
// XXX the pointer parameter given to tagged_allocator should be related to
// the type of the expression get_temporary_buffer(system, n).first
// without decltype, compromise on pointer<T,System>
template<typename T, typename System>
class temporary_allocator
: public thrust::detail::tagged_allocator<
T, System, thrust::pointer<T,System>
>
{
private:
typedef thrust::detail::tagged_allocator<
T, System, thrust::pointer<T,System>
> super_t;
System &m_system;
public:
typedef typename super_t::pointer pointer;
typedef typename super_t::size_type size_type;
inline explicit temporary_allocator(thrust::execution_policy<System> &system) :
super_t(),
m_system(thrust::detail::derived_cast(system))
{}
pointer allocate(size_type cnt);
void deallocate(pointer p, size_type n);
inline System &system()
{
return m_system;
} // end system()
private:
typedef thrust::pair<pointer, size_type> pointer_and_size;
}; // end temporary_allocator
} // end detail
} // end thrust
#include <thrust/detail/allocator/temporary_allocator.inl>
@@ -1,59 +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.
*/
#include <thrust/detail/config.h>
#include <thrust/detail/allocator/temporary_allocator.h>
#include <thrust/detail/temporary_buffer.h>
#include <thrust/system/detail/bad_alloc.h>
namespace thrust
{
namespace detail
{
template<typename T, typename System>
typename temporary_allocator<T,System>::pointer
temporary_allocator<T,System>
::allocate(typename temporary_allocator<T,System>::size_type cnt)
{
pointer_and_size result = thrust::get_temporary_buffer<T>(system(), cnt);
// handle failure
if(result.second < cnt)
{
// deallocate and throw
// note that we pass cnt to deallocate, not a value derived from result.second
deallocate(result.first, cnt);
throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");
} // end if
return result.first;
} // end temporary_allocator::allocate()
template<typename T, typename System>
void temporary_allocator<T,System>
::deallocate(typename temporary_allocator<T,System>::pointer p, typename temporary_allocator<T,System>::size_type n)
{
return thrust::return_temporary_buffer(system(), p);
} // end temporary_allocator
} // end detail
} // end thrust
-458
View File
@@ -1,458 +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 binary_search.inl
* \brief Inline file for binary_search.h.
*/
#include <thrust/detail/config.h>
#include <thrust/binary_search.h>
#include <thrust/iterator/iterator_traits.h>
#include <thrust/system/detail/generic/select_system.h>
#include <thrust/system/detail/generic/binary_search.h>
#include <thrust/system/detail/adl/binary_search.h>
namespace thrust
{
template <typename DerivedPolicy, typename ForwardIterator, typename LessThanComparable>
ForwardIterator lower_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const LessThanComparable &value)
{
using thrust::system::detail::generic::lower_bound;
return lower_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
}
template<typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator lower_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const T &value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::lower_bound;
return lower_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value, comp);
}
template<typename DerivedPolicy, typename ForwardIterator, typename LessThanComparable>
ForwardIterator upper_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const LessThanComparable &value)
{
using thrust::system::detail::generic::upper_bound;
return upper_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
}
template<typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator upper_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const T &value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::upper_bound;
return upper_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value, comp);
}
template <typename DerivedPolicy, typename ForwardIterator, typename LessThanComparable>
bool binary_search(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::binary_search;
return binary_search(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
}
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
bool binary_search(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::binary_search;
return binary_search(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value, comp);
}
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
thrust::pair<ForwardIterator, ForwardIterator>
equal_range(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::equal_range;
return equal_range(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value, comp);
}
template <typename DerivedPolicy, typename ForwardIterator, typename LessThanComparable>
thrust::pair<ForwardIterator, ForwardIterator>
equal_range(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::equal_range;
return equal_range(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator lower_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::lower_bound;
return lower_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator lower_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::lower_bound;
return lower_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output, comp);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator upper_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::upper_bound;
return upper_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator upper_bound(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::upper_bound;
return upper_bound(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output, comp);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator binary_search(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::binary_search;
return binary_search(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output);
}
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator binary_search(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::binary_search;
return binary_search(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, values_first, values_last, output, comp);
}
//////////////////////
// Scalar Functions //
//////////////////////
template <typename ForwardIterator, typename LessThanComparable>
ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::lower_bound(select_system(system), first, last, value);
}
template <typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator lower_bound(ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::lower_bound(select_system(system), first, last, value, comp);
}
template <typename ForwardIterator, typename LessThanComparable>
ForwardIterator upper_bound(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::upper_bound(select_system(system), first, last, value);
}
template <typename ForwardIterator, typename T, typename StrictWeakOrdering>
ForwardIterator upper_bound(ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::upper_bound(select_system(system), first, last, value, comp);
}
template <typename ForwardIterator, typename LessThanComparable>
bool binary_search(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::binary_search(select_system(system), first, last, value);
}
template <typename ForwardIterator, typename T, typename StrictWeakOrdering>
bool binary_search(ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::binary_search(select_system(system), first, last, value, comp);
}
template <typename ForwardIterator, typename LessThanComparable>
thrust::pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first,
ForwardIterator last,
const LessThanComparable& value)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::equal_range(select_system(system), first, last, value);
}
template <typename ForwardIterator, typename T, typename StrictWeakOrdering>
thrust::pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first,
ForwardIterator last,
const T& value,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System;
System system;
return thrust::equal_range(select_system(system), first, last, value, comp);
}
//////////////////////
// Vector Functions //
//////////////////////
template <typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator lower_bound(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::lower_bound(select_system(system1,system2,system3), first, last, values_first, values_last, output);
}
template <typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator lower_bound(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::lower_bound(select_system(system1,system2,system3), first, last, values_first, values_last, output, comp);
}
template <typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator upper_bound(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::upper_bound(select_system(system1,system2,system3), first, last, values_first, values_last, output);
}
template <typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator upper_bound(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::upper_bound(select_system(system1,system2,system3), first, last, values_first, values_last, output, comp);
}
template <typename ForwardIterator, typename InputIterator, typename OutputIterator>
OutputIterator binary_search(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::binary_search(select_system(system1,system2,system3), first, last, values_first, values_last, output);
}
template <typename ForwardIterator, typename InputIterator, typename OutputIterator, typename StrictWeakOrdering>
OutputIterator binary_search(ForwardIterator first,
ForwardIterator last,
InputIterator values_first,
InputIterator values_last,
OutputIterator output,
StrictWeakOrdering comp)
{
using thrust::system::detail::generic::select_system;
typedef typename thrust::iterator_system<ForwardIterator>::type System1;
typedef typename thrust::iterator_system<InputIterator>::type System2;
typedef typename thrust::iterator_system<OutputIterator>::type System3;
System1 system1;
System2 system2;
System3 system3;
return thrust::binary_search(select_system(system1,system2,system3), first, last, values_first, values_last, output, comp);
}
} // end namespace thrust
Loaded 100 of 936 files, more files were not shown because too many files have changed in this diff. Show more