Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/info/licenses/LICENSEAdded+1632
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/info/test/run_test.shAdded+9
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/nv/detail/__preprocessorAdded+176
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/nv/detail/__target_macrosAdded+610
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/allocator_traits.hAdded+350
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/allocator_traits.inlAdded+370
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/copy_construct_range.hAdded+45
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/copy_construct_range.inlAdded+242
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/destroy_range.hAdded+39
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/destroy_range.inlAdded+137
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/fill_construct_range.hAdded+39
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/fill_construct_range.inlAdded+99
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/malloc_allocator.hAdded+53
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/malloc_allocator.inlAdded+68
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/no_throw_allocator.hAdded+76
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/tagged_allocator.hAdded+102
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/tagged_allocator.inlAdded+86
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/temporary_allocator.hAdded+79
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/temporary_allocator.inlAdded+81
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/value_initialize_range.hAdded+39
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/value_initialize_range.inlAdded+98
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/arithmetic.hAdded+255
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/c99math.hAdded+221
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/catrig.hAdded+875
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/catrigf.hAdded+588
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ccosh.hAdded+233
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ccoshf.hAdded+161
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cexp.hAdded+195
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cexpf.hAdded+173
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/clog.hAdded+223
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/clogf.hAdded+210
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/complex.inlAdded+255
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cpow.hAdded+50
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cproj.hAdded+80
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csinh.hAdded+226
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csinhf.hAdded+166
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csqrt.hAdded+177
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csqrtf.hAdded+173
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ctanh.hAdded+208
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ctanhf.hAdded+133
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/math_private.hAdded+138
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/stream.hAdded+73
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/compiler.hAdded+119
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/compiler_fence.hAdded+79
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/config.hAdded+45
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/cpp_compatibility.hAdded+61
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/cpp_dialect.hAdded+100
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/device_system.hAdded+55
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/global_workarounds.hAdded+36
- data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/host_system.hAdded+52
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632End User License Agreement--------------------------
NVIDIA Software License Agreement and CUDA Supplement toSoftware License Agreement.
The CUDA Toolkit End User License Agreement applies to theNVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIADisplay Driver, NVIDIA Nsight tools (Visual Studio Edition),and the associated documentation on CUDA APIs, programmingmodel and development tools. If you do not agree with theterms and conditions of the license agreement, then do notdownload or use the software.
Last updated: January 12, 2024.
Preface-------
The Software License Agreement in Chapter 1 and the Supplementin Chapter 2 contain license terms and conditions that governthe use of NVIDIA toolkit. By accepting this agreement, youagree to comply with all the terms and conditions applicableto the product(s) included herein.
NVIDIA Driver
Description
This package contains the operating system driver andfundamental system software components for NVIDIA GPUs.
NVIDIA CUDA Toolkit
Description
The NVIDIA CUDA Toolkit provides command-line and graphicaltools for building, debugging and optimizing the performanceof applications accelerated by NVIDIA GPUs, runtime and mathlibraries, and documentation including programming guides,user manuals, and API references.
Default Install Location of CUDA Toolkit
Windows platform:
%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v#.#
Linux platform:
/usr/local/cuda-#.#
Mac platform:
/Developer/NVIDIA/CUDA-#.#
NVIDIA CUDA Samples
Description
CUDA Samples are now located inhttps://github.com/nvidia/cuda-samples, which includesinstructions for obtaining, building, and running the samples.They are no longer included in the CUDA toolkit.
NVIDIA Nsight Visual Studio Edition (Windows only)
Description
NVIDIA Nsight Development Platform, Visual Studio Edition is adevelopment environment integrated into Microsoft VisualStudio that provides tools for debugging, profiling, analyzingand optimizing your GPU computing and graphics applications.
Default Install Location of Nsight Visual Studio Edition
Windows platform:
%ProgramFiles(x86)%\NVIDIA Corporation\Nsight Visual Studio Edition #.#
1. License Agreement for NVIDIA Software Development Kits---------------------------------------------------------
Important Notice—Read before downloading, installing,copying or using the licensed software:-------------------------------------------------------
This license agreement, including exhibits attached("Agreement”) is a legal agreement between you and NVIDIACorporation ("NVIDIA") and governs your use of a NVIDIAsoftware development kit (“SDK”).
Each SDK has its own set of software and materials, but hereis a description of the types of items that may be included ina SDK: source code, header files, APIs, data sets and assets(examples include images, textures, models, scenes, videos,native API input/output files), binary software, sample code,libraries, utility programs, programming code anddocumentation.
This Agreement can be accepted only by an adult of legal ageof majority in the country in which the SDK is used.
If you are entering into this Agreement on behalf of a companyor other legal entity, you represent that you have the legalauthority to bind the entity to this Agreement, in which case“you” will mean the entity you represent.
If you don’t have the required age or authority to acceptthis Agreement, or if you don’t accept all the terms andconditions of this Agreement, do not download, install or usethe SDK.
You agree to use the SDK only for purposes that are permittedby (a) this Agreement, and (b) any applicable law, regulationor generally accepted practices or guidelines in the relevantjurisdictions.
1.1. License
1.1.1. License Grant
Subject to the terms of this Agreement, NVIDIA hereby grantsyou a non-exclusive, non-transferable license, without theright to sublicense (except as expressly provided in thisAgreement) to:
1. Install and use the SDK,
2. Modify and create derivative works of sample source code delivered in the SDK, and
3. Distribute those portions of the SDK that are identified in this Agreement as distributable, as incorporated in object code format into a software application that meets the distribution requirements indicated in this Agreement.
1.1.2. Distribution Requirements
These are the distribution requirements for you to exercisethe distribution grant:
1. Your application must have material additional functionality, beyond the included portions of the SDK.
2. The distributable portions of the SDK shall only be accessed by your application.
3. The following notice shall be included in modifications and derivative works of sample source code distributed: “This software contains source code provided by NVIDIA Corporation.”
4. Unless a developer tool is identified in this Agreement as distributable, it is delivered for your internal use only.
5. The terms under which you distribute your application must be consistent with the terms of this Agreement, including (without limitation) terms relating to the license grant and license restrictions and protection of NVIDIA’s intellectual property rights. Additionally, you agree that you will protect the privacy, security and legal rights of your application users.
6. You agree to notify NVIDIA in writing of any known or suspected distribution or use of the SDK not in compliance with the requirements of this Agreement, and to enforce the terms of your agreements with respect to distributed SDK.
1.1.3. Authorized Users
You may allow employees and contractors of your entity or ofyour subsidiary(ies) to access and use the SDK from yoursecure network to perform work on your behalf.
If you are an academic institution you may allow usersenrolled or employed by the academic institution to access anduse the SDK from your secure network.
You are responsible for the compliance with the terms of thisAgreement by your authorized users. If you become aware thatyour authorized users didn’t follow the terms of thisAgreement, you agree to take reasonable steps to resolve thenon-compliance and prevent new occurrences.
1.1.4. Pre-Release SDK
The SDK versions identified as alpha, beta, preview orotherwise as pre-release, may not be fully functional, maycontain errors or design flaws, and may have reduced ordifferent security, privacy, accessibility, availability, andreliability standards relative to commercial versions ofNVIDIA software and materials. Use of a pre-release SDK mayresult in unexpected results, loss of data, project delays orother unpredictable damage or loss.
You may use a pre-release SDK at your own risk, understandingthat pre-release SDKs are not intended for use in productionor business-critical systems.
NVIDIA may choose not to make available a commercial versionof any pre-release SDK. NVIDIA may also choose to abandondevelopment and terminate the availability of a pre-releaseSDK at any time without liability.
1.1.5. Updates
NVIDIA may, at its option, make available patches, workaroundsor other updates to this SDK. Unless the updates are providedwith their separate governing terms, they are deemed part ofthe SDK licensed to you as provided in this Agreement. Youagree that the form and content of the SDK that NVIDIAprovides may change without prior notice to you. While NVIDIAgenerally maintains compatibility between versions, NVIDIA mayin some cases make changes that introduce incompatibilities infuture versions of the SDK.
1.1.6. Components Under Other Licenses
The SDK may come bundled with, or otherwise include or bedistributed with, NVIDIA or third-party components withseparate legal notices or terms as may be described inproprietary notices accompanying the SDK. If and to the extentthere is a conflict between the terms in this Agreement andthe license terms associated with the component, the licenseterms associated with the components control only to theextent necessary to resolve the conflict.
Subject to the other terms of this Agreement, you may use theSDK to develop and test applications released under OpenSource Initiative (OSI) approved open source softwarelicenses.
1.1.7. Reservation of Rights
NVIDIA reserves all rights, title, and interest in and to theSDK, not expressly granted to you under this Agreement.
1.2. Limitations
The following license limitations apply to your use of theSDK:
1. You may not reverse engineer, decompile or disassemble, or remove copyright or other proprietary notices from any portion of the SDK or copies of the SDK.
2. Except as expressly provided in this Agreement, you may not copy, sell, rent, sublicense, transfer, distribute, modify, or create derivative works of any portion of the SDK. For clarity, you may not distribute or sublicense the SDK as a stand-alone product.
3. Unless you have an agreement with NVIDIA for this purpose, you may not indicate that an application created with the SDK is sponsored or endorsed by NVIDIA.
4. You may not bypass, disable, or circumvent any encryption, security, digital rights management or authentication mechanism in the SDK.
5. You may not use the SDK in any manner that would cause it to become subject to an open source software license. As examples, licenses that require as a condition of use, modification, and/or distribution that the SDK be:
a. Disclosed or distributed in source code form;
b. Licensed for the purpose of making derivative works; or
c. Redistributable at no charge.
6. You acknowledge that the SDK as delivered is not tested or certified by NVIDIA for use in connection with the design, construction, maintenance, and/or operation of any system where the use or failure of such system could result in a situation that threatens the safety of human life or results in catastrophic damages (each, a "Critical Application"). Examples of Critical Applications include use in avionics, navigation, autonomous vehicle applications, ai solutions for automotive products, military, medical, life support or other life critical applications. NVIDIA shall not be liable to you or any third party, in whole or in part, for any claims or damages arising from such uses. You are solely responsible for ensuring that any product or service developed with the SDK as a whole includes sufficient features to comply with all applicable legal and regulatory standards and requirements.
7. You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their respective employees, contractors, agents, officers and directors, from and against any and all claims, damages, obligations, losses, liabilities, costs or debt, fines, restitutions and expenses (including but not limited to attorney’s fees and costs incident to establishing the right of indemnification) arising out of or related to products or services that use the SDK in or for Critical Applications, and for use of the SDK outside of the scope of this Agreement or not in compliance with its terms.
8. You may not reverse engineer, decompile or disassemble any portion of the output generated using SDK elements for the purpose of translating such output artifacts to target a non-NVIDIA platform.
1.3. Ownership
1. NVIDIA or its licensors hold all rights, title and interest in and to the SDK and its modifications and derivative works, including their respective intellectual property rights, subject to your rights under Section 1.3.2. This SDK may include software and materials from NVIDIA’s licensors, and these licensors are intended third party beneficiaries that may enforce this Agreement with respect to their intellectual property rights.
2. You hold all rights, title and interest in and to your applications and your derivative works of the sample source code delivered in the SDK, including their respective intellectual property rights, subject to NVIDIA’s rights under Section 1.3.1.
3. You may, but don’t have to, provide to NVIDIA suggestions, feature requests or other feedback regarding the SDK, including possible enhancements or modifications to the SDK. For any feedback that you voluntarily provide, you hereby grant NVIDIA and its affiliates a perpetual, non-exclusive, worldwide, irrevocable license to use, reproduce, modify, license, sublicense (through multiple tiers of sublicensees), and distribute (through multiple tiers of distributors) it without the payment of any royalties or fees to you. NVIDIA will use feedback at its choice. NVIDIA is constantly looking for ways to improve its products, so you may send feedback to NVIDIA through the developer portal at https://developer.nvidia.com.
1.4. No Warranties
THE SDK IS PROVIDED BY NVIDIA “AS IS” AND “WITH ALLFAULTS.” TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA ANDITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KINDOR NATURE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING,BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR THEABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT. NOWARRANTY IS MADE ON THE BASIS OF TRADE USAGE, COURSE OFDEALING OR COURSE OF TRADE.
1.5. Limitation of Liability
TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITSAFFILIATES SHALL NOT BE LIABLE FOR ANY (I) SPECIAL, INCIDENTAL,PUNITIVE OR CONSEQUENTIAL DAMAGES, OR (II) DAMAGES FOR (A) ANY LOST PROFITS, LOSS OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE PRODUCTS, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT OR THE USE OR PERFORMANCE OF THE SDK, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF LIABILITY. IN NO EVENT WILL NVIDIA’S AND ITS AFFILIATESTOTAL CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THISAGREEMENT EXCEED US$10.00. THE NATURE OF THE LIABILITY OR THENUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THISLIMIT.
These exclusions and limitations of liability shall applyregardless if NVIDIA or its affiliates have been advised ofthe possibility of such damages, and regardless of whether aremedy fails its essential purpose. These exclusions andlimitations of liability form an essential basis of thebargain between the parties, and, absent any of theseexclusions or limitations of liability, the provisions of thisAgreement, including, without limitation, the economic terms,would be substantially different.
1.6. Termination
1. This Agreement will continue to apply until terminated by either you or NVIDIA as described below.
2. If you want to terminate this Agreement, you may do so by stopping to use the SDK.
3. NVIDIA may, at any time, terminate this Agreement if:
a. (i) you fail to comply with any term of this Agreement and the non-compliance is not fixed within thirty (30) days following notice from NVIDIA (or immediately if you violate NVIDIA’s intellectual property rights);
b. (ii) you commence or participate in any legal proceeding against NVIDIA with respect to the SDK; or
c. (iii) NVIDIA decides to no longer provide the SDK in a country or, in NVIDIA’s sole discretion, the continued use of it is no longer commercially viable.
4. Upon any termination of this Agreement, you agree to promptly discontinue use of the SDK and destroy all copies in your possession or control. Your prior distributions in accordance with this Agreement are not affected by the termination of this Agreement. Upon written request, you will certify in writing that you have complied with your commitments under this section. Upon any termination of this Agreement all provisions survive except for the license grant provisions.
1.7. General
If you wish to assign this Agreement or your rights andobligations, including by merger, consolidation, dissolutionor operation of law, contact NVIDIA to ask for permission. Anyattempted assignment not approved by NVIDIA in writing shallbe void and of no effect. NVIDIA may assign, delegate ortransfer this Agreement and its rights and obligations, and ifto a non-affiliate you will be notified.
You agree to cooperate with NVIDIA and provide reasonablyrequested information to verify your compliance with thisAgreement.
This Agreement will be governed in all respects by the laws ofthe United States and of the State of Delaware, without regard to theconflicts of laws principles. The United Nations Convention onContracts for the International Sale of Goods is specificallydisclaimed. You agree to all terms of this Agreement in theEnglish language.
The state or federal courts residing in Santa Clara County,California shall have exclusive jurisdiction over any disputeor claim arising out of this Agreement. Notwithstanding this,you agree that NVIDIA shall still be allowed to apply forinjunctive remedies or an equivalent type of urgent legalrelief in any jurisdiction.
If any court of competent jurisdiction determines that anyprovision of this Agreement is illegal, invalid orunenforceable, such provision will be construed as limited tothe extent necessary to be consistent with and fullyenforceable under the law and the remaining provisions willremain in full force and effect. Unless otherwise specified,remedies are cumulative.
Each party acknowledges and agrees that the other is anindependent contractor in the performance of this Agreement.
The SDK has been developed entirely at private expense and is“commercial items” consisting of “commercial computersoftware” and “commercial computer softwaredocumentation” provided with RESTRICTED RIGHTS. Use,duplication or disclosure by the U.S. Government or a U.S.Government subcontractor is subject to the restrictions inthis Agreement pursuant to DFARS 227.7202-3(a) or as set forthin subparagraphs (c)(1) and (2) of the Commercial ComputerSoftware - Restricted Rights clause at FAR 52.227-19, asapplicable. Contractor/manufacturer is NVIDIA, 2788 San TomasExpressway, Santa Clara, CA 95051.
The SDK is subject to United States export laws andregulations. You agree that you will not ship, transfer orexport the SDK into any country, or use the SDK in any manner,prohibited by the United States Bureau of Industry andSecurity or economic sanctions regulations administered by theU.S. Department of Treasury’s Office of Foreign AssetsControl (OFAC), or any applicable export laws, restrictions orregulations. These laws include restrictions on destinations,end users and end use. By accepting this Agreement, youconfirm that you are not located in a country currently embargoed by the U.S. or otherwise prohibited from receiving the SDK under U.S. law.
Any notice delivered by NVIDIA to you under this Agreementwill be delivered via mail, email or fax. You agree that anynotices that NVIDIA sends you electronically will satisfy anylegal communication requirements. Please direct your legalnotices or other correspondence to NVIDIA Corporation, 2788San Tomas Expressway, Santa Clara, California 95051, UnitedStates of America, Attention: Legal Department.
This Agreement and any exhibits incorporated into thisAgreement constitute the entire agreement of the parties withrespect to the subject matter of this Agreement and supersedeall prior negotiations or documentation exchanged between theparties relating to this SDK license. Any additional and/orconflicting terms on documents issued by you are null, void,and invalid. Any amendment or waiver under this Agreementshall be in writing and signed by representatives of bothparties.
2. CUDA Toolkit Supplement to Software License Agreement forNVIDIA Software Development Kits------------------------------------------------------------
The terms in this supplement govern your use of the NVIDIACUDA Toolkit SDK under the terms of your license agreement(“Agreement”) as modified by this supplement. Capitalizedterms used but not defined below have the meaning assigned tothem in the Agreement.
This supplement is an exhibit to the Agreement and isincorporated as an integral part of the Agreement. In theevent of conflict between the terms in this supplement and theterms in the Agreement, the terms in this supplement govern.
2.1. License Scope
The SDK is licensed for you to develop applications only foruse in systems with NVIDIA GPUs.
2.2. Distribution
The portions of the SDK that are distributable under theAgreement are listed in Attachment A.
2.3. Operating Systems
Those portions of the SDK designed exclusively for use on theLinux or FreeBSD operating systems, or other operating systemsderived from the source code to these operating systems, maybe copied and redistributed for use in accordance with thisAgreement, provided that the object code files are notmodified in any way (except for unzipping of compressedfiles).
2.4. Audio and Video Encoders and Decoders
You acknowledge and agree that it is your sole responsibilityto obtain any additional third-party licenses required tomake, have made, use, have used, sell, import, and offer forsale your products or services that include or incorporate anythird-party software and content relating to audio and/orvideo encoders and decoders from, including but not limitedto, Microsoft, Thomson, Fraunhofer IIS, Sisvel S.p.A.,MPEG-LA, and Coding Technologies. NVIDIA does not grant to youunder this Agreement any necessary patent or other rights withrespect to any audio and/or video encoders and decoders.
2.5. Licensing
If the distribution terms in this Agreement are not suitablefor your organization, or for any questions regarding thisAgreement, please contact NVIDIA atnvidia-compute-license-questions@nvidia.com.
2.6. Attachment A
The following CUDA Toolkit files may be distributed withapplications developed by you, including certainvariations of these files that have version number orarchitecture specific information embedded in the file name -as an example only, for release version 9.0 of the 64-bitWindows software, the file cudart64_90.dll is redistributable.
Component
CUDA Runtime
Windows
cudart.dll, cudart_static.lib, cudadevrt.lib
Mac OSX
libcudart.dylib, libcudart_static.a, libcudadevrt.a
Linux
libcudart.so, libcudart_static.a, libcudadevrt.a
Android
libcudart.so, libcudart_static.a, libcudadevrt.a
Component
CUDA FFT Library
Windows
cufft.dll, cufftw.dll, cufft.lib, cufftw.lib
Mac OSX
libcufft.dylib, libcufft_static.a, libcufftw.dylib,libcufftw_static.a
Linux
libcufft.so, libcufft_static.a, libcufftw.so,libcufftw_static.a
Android
libcufft.so, libcufft_static.a, libcufftw.so,libcufftw_static.a
Component
CUDA BLAS Library
Windows
cublas.dll, cublasLt.dll
Mac OSX
libcublas.dylib, libcublasLt.dylib, libcublas_static.a,libcublasLt_static.a
Linux
libcublas.so, libcublasLt.so, libcublas_static.a,libcublasLt_static.a
Android
libcublas.so, libcublasLt.so, libcublas_static.a,libcublasLt_static.a
Component
NVIDIA "Drop-in" BLAS Library
Windows
nvblas.dll
Mac OSX
libnvblas.dylib
Linux
libnvblas.so
Component
CUDA Sparse Matrix Library
Windows
cusparse.dll, cusparse.lib
Mac OSX
libcusparse.dylib, libcusparse_static.a
Linux
libcusparse.so, libcusparse_static.a
Android
libcusparse.so, libcusparse_static.a
Component
CUDA Linear Solver Library
Windows
cusolver.dll, cusolver.lib
Mac OSX
libcusolver.dylib, libcusolver_static.a
Linux
libcusolver.so, libcusolver_static.a
Android
libcusolver.so, libcusolver_static.a
Component
CUDA Random Number Generation Library
Windows
curand.dll, curand.lib
Mac OSX
libcurand.dylib, libcurand_static.a
Linux
libcurand.so, libcurand_static.a
Android
libcurand.so, libcurand_static.a
Component
NVIDIA Performance Primitives Library
Windows
nppc.dll, nppc.lib, nppial.dll, nppial.lib, nppicc.dll,nppicc.lib, nppicom.dll, nppicom.lib, nppidei.dll,nppidei.lib, nppif.dll, nppif.lib, nppig.dll, nppig.lib,nppim.dll, nppim.lib, nppist.dll, nppist.lib, nppisu.dll,nppisu.lib, nppitc.dll, nppitc.lib, npps.dll, npps.lib
Mac OSX
libnppc.dylib, libnppc_static.a, libnppial.dylib,libnppial_static.a, libnppicc.dylib, libnppicc_static.a,libnppicom.dylib, libnppicom_static.a, libnppidei.dylib,libnppidei_static.a, libnppif.dylib, libnppif_static.a,libnppig.dylib, libnppig_static.a, libnppim.dylib,libnppisu_static.a, libnppitc.dylib, libnppitc_static.a,libnpps.dylib, libnpps_static.a
Linux
libnppc.so, libnppc_static.a, libnppial.so,libnppial_static.a, libnppicc.so, libnppicc_static.a,libnppicom.so, libnppicom_static.a, libnppidei.so,libnppidei_static.a, libnppif.so, libnppif_static.alibnppig.so, libnppig_static.a, libnppim.so,libnppim_static.a, libnppist.so, libnppist_static.a,libnppisu.so, libnppisu_static.a, libnppitc.solibnppitc_static.a, libnpps.so, libnpps_static.a
Android
libnppc.so, libnppc_static.a, libnppial.so,libnppial_static.a, libnppicc.so, libnppicc_static.a,libnppicom.so, libnppicom_static.a, libnppidei.so,libnppidei_static.a, libnppif.so, libnppif_static.alibnppig.so, libnppig_static.a, libnppim.so,libnppim_static.a, libnppist.so, libnppist_static.a,libnppisu.so, libnppisu_static.a, libnppitc.solibnppitc_static.a, libnpps.so, libnpps_static.a
Component
NVIDIA JPEG Library
Windows
nvjpeg.lib, nvjpeg.dll
Linux
libnvjpeg.so, libnvjpeg_static.a
Component
Internal common library required for statically linking tocuBLAS, cuSPARSE, cuFFT, cuRAND, nvJPEG and NPP
Mac OSX
libculibos.a
Linux
libculibos.a
Component
NVIDIA Runtime Compilation Library and Header
All
nvrtc.h
Windows
nvrtc.dll, nvrtc-builtins.dll
Mac OSX
libnvrtc.dylib, libnvrtc-builtins.dylib
Linux
libnvrtc.so, libnvrtc-builtins.so, libnvrtc_static.a, libnvrtx-builtins_static.a
Component
NVIDIA Optimizing Compiler Library
Windows
nvvm.dll
Mac OSX
libnvvm.dylib
Linux
libnvvm.so
Component
NVIDIA JIT Linking Library
Windows
libnvJitLink.dll, libnvJitLink.lib
Linux
libnvJitLink.so, libnvJitLink_static.a
Component
NVIDIA Common Device Math Functions Library
Windows
libdevice.10.bc
Mac OSX
libdevice.10.bc
Linux
libdevice.10.bc
Component
CUDA Occupancy Calculation Header Library
All
cuda_occupancy.h
Component
CUDA Half Precision Headers
All
cuda_fp16.h, cuda_fp16.hpp
Component
CUDA Profiling Tools Interface (CUPTI) Library
Windows
cupti.dll
Mac OSX
libcupti.dylib
Linux
libcupti.so
Component
NVIDIA Tools Extension Library
Windows
nvToolsExt.dll, nvToolsExt.lib
Mac OSX
libnvToolsExt.dylib
Linux
libnvToolsExt.so
Component
NVIDIA CUDA Driver Libraries
Linux
libcuda.so, libnvidia-ptxjitcompiler.so, libnvptxcompiler_static.a
Component
NVIDIA CUDA File IO Libraries and Header
All
cufile.h
Linux
libcufile.so, libcufile_rdma.so, libcufile_static.a,libcufile_rdma_static.a
In addition to the rights above, for parties that aredeveloping software intended solely for use on Jetsondevelopment kits or Jetson modules, and running Linux forTegra software, the following shall apply:
* The SDK may be distributed in its entirety, as provided by NVIDIA, and without separation of its components, for you and/or your licensees to create software development kits for use only on the Jetson platform and running Linux for Tegra software.
2.7. Attachment B
Additional Licensing Obligations
The following third party components included in the SOFTWAREare licensed to Licensee pursuant to the following terms andconditions:
1. Licensee's use of the GDB third party component is subject to the terms and conditions of GNU GPL v3:
This product includes copyrighted third-party software licensed under the terms of the GNU General Public License v3 ("GPL v3"). All third-party software packages are copyright by their respective authors. GPL v3 terms and conditions are hereby incorporated into the Agreement by this reference: http://www.gnu.org/licenses/gpl.txt
Consistent with these licensing requirements, the software listed below is provided under the terms of the specified open source software licenses. To obtain source code for software provided under licenses that require redistribution of source code, including the GNU General Public License (GPL) and GNU Lesser General Public License (LGPL), contact oss-requests@nvidia.com. This offer is valid for a period of three (3) years from the date of the distribution of this product by NVIDIA CORPORATION.
Component License CUDA-GDB GPL v3
2. Licensee represents and warrants that any and all third party licensing and/or royalty payment obligations in connection with Licensee's use of the H.264 video codecs are solely the responsibility of Licensee.
3. Licensee's use of the Thrust library is subject to the terms and conditions of the Apache License Version 2.0. All third-party software packages are copyright by their respective authors. Apache License Version 2.0 terms and conditions are hereby incorporated into the Agreement by this reference. http://www.apache.org/licenses/LICENSE-2.0.html
In addition, Licensee acknowledges the following notice: Thrust includes source code from the Boost Iterator, Tuple, System, and Random Number libraries.
Boost Software License - Version 1.0 - August 17th, 2003 . . . . Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4. Licensee's use of the LLVM third party component is subject to the following terms and conditions:
====================================================== LLVM Release License ====================================================== University of Illinois/NCSA Open Source License Copyright (c) 2003-2010 University of Illinois at Urbana-Champaign. All rights reserved. Developed by: LLVM Team University of Illinois at Urbana-Champaign http://llvm.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of the LLVM Team, University of Illinois at Urbana- Champaign, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
5. Licensee's use of the PCRE third party component is subject to the following terms and conditions:
------------ PCRE LICENCE ------------ PCRE is a library of functions to support regular expressions whose syntax and semantics are as close as possible to those of the Perl 5 language. Release 8 of PCRE is distributed under the terms of the "BSD" licence, as specified below. The documentation for PCRE, supplied in the "doc" directory, is distributed under the same terms as the software itself. The basic library functions are written in C and are freestanding. Also included in the distribution is a set of C++ wrapper functions, and a just- in-time compiler that can be used to optimize pattern matching. These are both optional features that can be omitted when the library is built. THE BASIC LIBRARY FUNCTIONS --------------------------- Written by: Philip Hazel Email local part: ph10 Email domain: cam.ac.uk University of Cambridge Computing Service, Cambridge, England. Copyright (c) 1997-2012 University of Cambridge All rights reserved. PCRE JUST-IN-TIME COMPILATION SUPPORT ------------------------------------- Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu Copyright(c) 2010-2012 Zoltan Herczeg All rights reserved. STACK-LESS JUST-IN-TIME COMPILER -------------------------------- Written by: Zoltan Herczeg Email local part: hzmester Emain domain: freemail.hu Copyright(c) 2009-2012 Zoltan Herczeg All rights reserved. THE C++ WRAPPER FUNCTIONS ------------------------- Contributed by: Google Inc. Copyright (c) 2007-2012, Google Inc. All rights reserved.
THE "BSD" LICENCE ----------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Cambridge nor the name of Google Inc. nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6. Some of the cuBLAS library routines were written by or derived from code written by Vasily Volkov and are subject to the Modified Berkeley Software Distribution License as follows:
Copyright (c) 2007-2009, Regents of the University of California All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of California, Berkeley nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 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.
7. Some of the cuBLAS library routines were written by or derived from code written by Davide Barbieri and are subject to the Modified Berkeley Software Distribution License as follows:
Copyright (c) 2008-2009 Davide Barbieri @ University of Rome Tor Vergata. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 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.
8. Some of the cuBLAS library routines were derived from code developed by the University of Tennessee and are subject to the Modified Berkeley Software Distribution License as follows:
Copyright (c) 2010 The University of Tennessee. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer listed in this license in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9. Some of the cuBLAS library routines were written by or derived from code written by Jonathan Hogg and are subject to the Modified Berkeley Software Distribution License as follows:
Copyright (c) 2012, The Science and Technology Facilities Council (STFC). All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the STFC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 STFC 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.
10. Some of the cuBLAS library routines were written by or derived from code written by Ahmad M. Abdelfattah, David Keyes, and Hatem Ltaief, and are subject to the Apache License, Version 2.0, as follows:
-- (C) Copyright 2013 King Abdullah University of Science and Technology Authors: Ahmad Abdelfattah (ahmad.ahmad@kaust.edu.sa) David Keyes (david.keyes@kaust.edu.sa) Hatem Ltaief (hatem.ltaief@kaust.edu.sa) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the King Abdullah University of Science and Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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
11. Some of the cuSPARSE library routines were written by or derived from code written by Li-Wen Chang and are subject to the NCSA Open Source License as follows:
Copyright (c) 2012, University of Illinois. All rights reserved. Developed by: IMPACT Group, University of Illinois, http://impact.crhc.illinois.edu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. * Neither the names of IMPACT Group, University of Illinois, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
12. Some of the cuRAND library routines were written by or derived from code written by Mutsuo Saito and Makoto Matsumoto and are subject to the following license:
Copyright (c) 2009, 2010 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved. Copyright (c) 2011 Mutsuo Saito, Makoto Matsumoto, Hiroshima University and University of Tokyo. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Hiroshima University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13. Some of the cuRAND library routines were derived from code developed by D. E. Shaw Research and are subject to the following license:
Copyright 2010-2011, D. E. Shaw Research. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of D. E. Shaw Research nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14. Some of the Math library routines were written by or derived from code developed by Norbert Juffa and are subject to the following license:
Copyright (c) 2015-2017, Norbert Juffa 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
15. Licensee's use of the lz4 third party component is subject to the following terms and conditions:
Copyright (C) 2011-2013, Yann Collet. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16. The NPP library uses code from the Boost Math Toolkit, and is subject to the following license:
Boost Software License - Version 1.0 - August 17th, 2003 . . . . Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following: The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17. Portions of the Nsight Eclipse Edition is subject to the following license:
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at http:// www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content. If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at http://www.eclipse.org.
18. Some of the cuBLAS library routines uses code from OpenAI, which is subject to the following license:
License URL https://github.com/openai/openai-gemm/blob/master/LICENSE License Text The MIT License Copyright (c) 2016 OpenAI (http://openai.com), 2016 Google Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19. Licensee's use of the Visual Studio Setup Configuration Samples is subject to the following license:
The MIT License (MIT) Copyright (C) Microsoft Corporation. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20. Licensee's use of linmath.h header for CPU functions for GL vector/matrix operations from lunarG is subject to the Apache License Version 2.0.
21. The DX12-CUDA sample uses the d3dx12.h header, which is subject to the MIT license.
22. Components of the driver and compiler used for binary management, including nvFatBin, nvcc, and cuobjdump, use the Zstandard library which is subject to the following license:
BSD License
For Zstandard software
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name Facebook, nor Meta, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
-----------------123456789
set -ex
test -d $PREFIX/targets/x86_64-linux/libtest -d $PREFIX/targets/x86_64-linux/includeexit 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176//===----------------------------------------------------------------------===////// Part of libcu++, the C++ Standard Library for your entire system,// under the Apache License v2.0 with LLVM Exceptions.// See https://llvm.org/LICENSE.txt for license information.// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.////===----------------------------------------------------------------------===//
#if defined(__GNUC__)# pragma GCC system_header#endif
// For all compilers and dialects this header defines:// _NV_EVAL// _NV_IF// _NV_CONCAT_EVAL// For C++11 and up it defines:// _NV_STRIP_PAREN// _NV_DISPATCH_N_ARY// _NV_FIRST_ARG// _NV_REMOVE_PAREN
#if defined(_NV_TARGET_CPP11)# define _NV_EVAL1(...) __VA_ARGS__# define _NV_EVAL(...) _NV_EVAL1(__VA_ARGS__)#else# define _NV_EVAL1(x) x# define _NV_EVAL(x) _NV_EVAL1(x)#endif // C++11
#define _NV_CONCAT_EVAL1(l, r) _NV_EVAL(l##r)#define _NV_CONCAT_EVAL(l, r) _NV_CONCAT_EVAL1(l, r)
#define _NV_IF_0(t, f) f#define _NV_IF_1(t, f) t
#define _NV_IF_BIT(b) _NV_EVAL(_NV_IF_##b)#define _NV_IF__EVAL(fn, t, f) _NV_EVAL(fn(t, f))#define _NV_IF_EVAL(cond, t, f) _NV_IF__EVAL(_NV_IF_BIT(cond), t, f)
#define _NV_IF1(cond, t, f) _NV_IF_EVAL(cond, t, f)#define _NV_IF(cond, t, f) _NV_IF1(_NV_EVAL(cond), _NV_EVAL(t), _NV_EVAL(f))
#if defined(_NV_TARGET_CPP11)
// The below mechanisms were derived from: https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/
# define _NV_ARG32(...) _NV_EVAL(_NV_ARG32_0(__VA_ARGS__))# define _NV_ARG32_0( \ _0, \ _1, \ _2, \ _3, \ _4, \ _5, \ _6, \ _7, \ _8, \ _9, \ _10, \ _11, \ _12, \ _13, \ _14, \ _15, \ _16, \ _17, \ _18, \ _19, \ _20, \ _21, \ _22, \ _23, \ _24, \ _25, \ _26, \ _27, \ _28, \ _29, \ _30, \ _31, \ ...) \ _31
# define _NV_HAS_COMMA(...) \ _NV_ARG32(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
# define _NV_TRIGGER_PARENTHESIS_(...) ,
# define _NV_ISEMPTY(...) \ _NV_ISEMPTY0(/* test if there is just one argument, eventually an empty \ one */ \ _NV_EVAL(_NV_HAS_COMMA(__VA_ARGS__)), /* test if _TRIGGER_PARENTHESIS_ together with the argument \ adds a comma */ \ _NV_EVAL(_NV_HAS_COMMA(_NV_TRIGGER_PARENTHESIS_ __VA_ARGS__)), /* test if the argument together with \ a parenthesis adds a comma */ \ _NV_EVAL(_NV_HAS_COMMA(__VA_ARGS__(/*empty*/))), /* test if placing it between _TRIGGER_PARENTHESIS_ \ and the parenthesis adds a comma */ \ _NV_EVAL(_NV_HAS_COMMA(_NV_TRIGGER_PARENTHESIS_ __VA_ARGS__(/*empty*/))))
# define _NV_PASTE5(_0, _1, _2, _3, _4) _0##_1##_2##_3##_4# define _NV_ISEMPTY0(_0, _1, _2, _3) _NV_HAS_COMMA(_NV_PASTE5(_NV_IS_EMPTY_CASE_, _0, _1, _2, _3))# define _NV_IS_EMPTY_CASE_0001 ,
# define _NV_REMOVE_PAREN(...) _NV_REMOVE_PAREN1(__VA_ARGS__)# define _NV_REMOVE_PAREN1(...) \ _NV_STRIP_PAREN(_NV_IF(_NV_TEST_PAREN(__VA_ARGS__), (_NV_STRIP_PAREN(__VA_ARGS__)), (__VA_ARGS__)))
# define _NV_STRIP_PAREN2(...) __VA_ARGS__# define _NV_STRIP_PAREN1(...) _NV_STRIP_PAREN2 __VA_ARGS__# define _NV_STRIP_PAREN(...) _NV_STRIP_PAREN1(__VA_ARGS__)
# define _NV_TEST_PAREN(...) _NV_TEST_PAREN1(__VA_ARGS__)# define _NV_TEST_PAREN1(...) _NV_TEST_PAREN2(_NV_TEST_PAREN_DUMMY __VA_ARGS__)# define _NV_TEST_PAREN2(...) _NV_TEST_PAREN3(_NV_CONCAT_EVAL(_, __VA_ARGS__))# define _NV_TEST_PAREN3(...) _NV_EVAL(_NV_FIRST_ARG(__VA_ARGS__))
# define __NV_PAREN_YES 1# define __NV_PAREN_NO 0
# define _NV_TEST_PAREN_DUMMY(...) _NV_PAREN_YES# define __NV_TEST_PAREN_DUMMY __NV_PAREN_NO,
# define _NV_FIRST_ARG1(x, ...) x# define _NV_FIRST_ARG(x, ...) _NV_FIRST_ARG1(x)
# define _NV_REMOVE_FIRST_ARGS1(...) __VA_ARGS__# define _NV_REMOVE_FIRST_ARGS(x, ...) _NV_REMOVE_FIRST_ARGS1(__VA_ARGS__)
# define _NV_NUM_ARGS(...) _NV_NUM_ARGS0(__VA_ARGS__)# define _NV_NUM_ARGS0(...) _NV_EVAL(_NV_NUM_ARGS1(__VA_ARGS__))# define _NV_NUM_ARGS1(...) _NV_IF(_NV_ISEMPTY(__VA_ARGS__), 0, _NV_NUM_ARGS2(__VA_ARGS__))# define _NV_NUM_ARGS2(...) \ _NV_ARG32( \ __VA_ARGS__, \ 31, \ 30, \ 29, \ 28, \ 27, \ 26, \ 25, \ 24, \ 23, \ 22, \ 21, \ 20, \ 19, \ 18, \ 17, \ 16, \ 15, \ 14, \ 13, \ 12, \ 11, \ 10, \ 9, \ 8, \ 7, \ 6, \ 5, \ 4, \ 3, \ 2, \ 1, \ 0)
# define _NV_DISPATCH_N_IMPL1(name, ...) _NV_EVAL(name(__VA_ARGS__))# define _NV_DISPATCH_N_IMPL0(depth, name, ...) _NV_DISPATCH_N_IMPL1(_NV_CONCAT_EVAL(name, depth), __VA_ARGS__)# define _NV_DISPATCH_N_IMPL(name, ...) _NV_DISPATCH_N_IMPL0(_NV_NUM_ARGS(__VA_ARGS__), name, __VA_ARGS__)# define _NV_DISPATCH_N_ARY(name, ...) _NV_DISPATCH_N_IMPL(name, __VA_ARGS__)
#endif // C++11123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610//===----------------------------------------------------------------------===////// Part of libcu++, the C++ Standard Library for your entire system,// under the Apache License v2.0 with LLVM Exceptions.// See https://llvm.org/LICENSE.txt for license information.// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.////===----------------------------------------------------------------------===//
#ifndef _NV__TARGET_MACROS#define _NV__TARGET_MACROS
#include <nv/detail/__preprocessor>
#if defined(__GNUC__)# pragma GCC system_header#endif
#define _NV_TARGET_ARCH_TO_SELECTOR_350 nv::target::sm_35#define _NV_TARGET_ARCH_TO_SELECTOR_370 nv::target::sm_37#define _NV_TARGET_ARCH_TO_SELECTOR_500 nv::target::sm_50#define _NV_TARGET_ARCH_TO_SELECTOR_520 nv::target::sm_52#define _NV_TARGET_ARCH_TO_SELECTOR_530 nv::target::sm_53#define _NV_TARGET_ARCH_TO_SELECTOR_600 nv::target::sm_60#define _NV_TARGET_ARCH_TO_SELECTOR_610 nv::target::sm_61#define _NV_TARGET_ARCH_TO_SELECTOR_620 nv::target::sm_62#define _NV_TARGET_ARCH_TO_SELECTOR_700 nv::target::sm_70#define _NV_TARGET_ARCH_TO_SELECTOR_720 nv::target::sm_72#define _NV_TARGET_ARCH_TO_SELECTOR_750 nv::target::sm_75#define _NV_TARGET_ARCH_TO_SELECTOR_800 nv::target::sm_80#define _NV_TARGET_ARCH_TO_SELECTOR_860 nv::target::sm_86#define _NV_TARGET_ARCH_TO_SELECTOR_870 nv::target::sm_87#define _NV_TARGET_ARCH_TO_SELECTOR_890 nv::target::sm_89#define _NV_TARGET_ARCH_TO_SELECTOR_900 nv::target::sm_90#define _NV_TARGET_ARCH_TO_SELECTOR_1000 nv::target::sm_100#define _NV_TARGET_ARCH_TO_SELECTOR_1010 nv::target::sm_101#define _NV_TARGET_ARCH_TO_SELECTOR_1200 nv::target::sm_120
#define _NV_TARGET_ARCH_TO_SM_350 35#define _NV_TARGET_ARCH_TO_SM_370 37#define _NV_TARGET_ARCH_TO_SM_500 50#define _NV_TARGET_ARCH_TO_SM_520 52#define _NV_TARGET_ARCH_TO_SM_530 53#define _NV_TARGET_ARCH_TO_SM_600 60#define _NV_TARGET_ARCH_TO_SM_610 61#define _NV_TARGET_ARCH_TO_SM_620 62#define _NV_TARGET_ARCH_TO_SM_700 70#define _NV_TARGET_ARCH_TO_SM_720 72#define _NV_TARGET_ARCH_TO_SM_750 75#define _NV_TARGET_ARCH_TO_SM_800 80#define _NV_TARGET_ARCH_TO_SM_860 86#define _NV_TARGET_ARCH_TO_SM_870 87#define _NV_TARGET_ARCH_TO_SM_890 89#define _NV_TARGET_ARCH_TO_SM_900 90#define _NV_TARGET_ARCH_TO_SM_1000 100#define _NV_TARGET_ARCH_TO_SM_1010 101#define _NV_TARGET_ARCH_TO_SM_1200 120
// Only enable when compiling for CUDA/stdpar#if defined(_NV_COMPILER_NVCXX) && defined(_NVHPC_CUDA)
# define _NV_TARGET_VAL_SM_35 nv::target::sm_35# define _NV_TARGET_VAL_SM_37 nv::target::sm_37# define _NV_TARGET_VAL_SM_50 nv::target::sm_50# define _NV_TARGET_VAL_SM_52 nv::target::sm_52# define _NV_TARGET_VAL_SM_53 nv::target::sm_53# define _NV_TARGET_VAL_SM_60 nv::target::sm_60# define _NV_TARGET_VAL_SM_61 nv::target::sm_61# define _NV_TARGET_VAL_SM_62 nv::target::sm_62# define _NV_TARGET_VAL_SM_70 nv::target::sm_70# define _NV_TARGET_VAL_SM_72 nv::target::sm_72# define _NV_TARGET_VAL_SM_75 nv::target::sm_75# define _NV_TARGET_VAL_SM_80 nv::target::sm_80# define _NV_TARGET_VAL_SM_86 nv::target::sm_86# define _NV_TARGET_VAL_SM_87 nv::target::sm_87# define _NV_TARGET_VAL_SM_89 nv::target::sm_89# define _NV_TARGET_VAL_SM_90 nv::target::sm_90# define _NV_TARGET_VAL_SM_100 nv::target::sm_100# define _NV_TARGET_VAL_SM_101 nv::target::sm_101# define _NV_TARGET_VAL_SM_120 nv::target::sm_120
# define _NV_TARGET___NV_IS_HOST nv::target::is_host# define _NV_TARGET___NV_IS_DEVICE nv::target::is_device
# define _NV_TARGET___NV_ANY_TARGET (nv::target::any_target)# define _NV_TARGET___NV_NO_TARGET (nv::target::no_target)
# if defined(NV_TARGET_SM_INTEGER_LIST)# define NV_TARGET_MINIMUM_SM_SELECTOR _NV_FIRST_ARG(NV_TARGET_SM_SELECTOR_LIST)# define NV_TARGET_MINIMUM_SM_INTEGER _NV_FIRST_ARG(NV_TARGET_SM_INTEGER_LIST)# define __CUDA_MINIMUM_ARCH__ _NV_CONCAT_EVAL(_NV_FIRST_ARG(NV_TARGET_SM_INTEGER_LIST), 0)# endif
# define _NV_TARGET_PROVIDES(q) nv::target::provides(q)# define _NV_TARGET_IS_EXACTLY(q) nv::target::is_exactly(q)
#elif defined(_NV_COMPILER_NVCC) || defined(_NV_COMPILER_CLANG_CUDA)
# define _NV_TARGET_VAL_SM_35 350# define _NV_TARGET_VAL_SM_37 370# define _NV_TARGET_VAL_SM_50 500# define _NV_TARGET_VAL_SM_52 520# define _NV_TARGET_VAL_SM_53 530# define _NV_TARGET_VAL_SM_60 600# define _NV_TARGET_VAL_SM_61 610# define _NV_TARGET_VAL_SM_62 620# define _NV_TARGET_VAL_SM_70 700# define _NV_TARGET_VAL_SM_72 720# define _NV_TARGET_VAL_SM_75 750# define _NV_TARGET_VAL_SM_80 800# define _NV_TARGET_VAL_SM_86 860# define _NV_TARGET_VAL_SM_87 870# define _NV_TARGET_VAL_SM_89 890# define _NV_TARGET_VAL_SM_90 900# define _NV_TARGET_VAL_SM_100 1000# define _NV_TARGET_VAL_SM_101 1010# define _NV_TARGET_VAL_SM_120 1200
# if defined(__CUDA_ARCH__)# define _NV_TARGET_VAL __CUDA_ARCH__# define NV_TARGET_MINIMUM_SM_SELECTOR _NV_CONCAT_EVAL(_NV_TARGET_ARCH_TO_SELECTOR_, __CUDA_ARCH__)# define NV_TARGET_MINIMUM_SM_INTEGER _NV_CONCAT_EVAL(_NV_TARGET_ARCH_TO_SM_, __CUDA_ARCH__)# define __CUDA_MINIMUM_ARCH__ __CUDA_ARCH__# endif
# if defined(__CUDA_ARCH__)# define _NV_TARGET_IS_HOST 0# define _NV_TARGET_IS_DEVICE 1# else# define _NV_TARGET_IS_HOST 1# define _NV_TARGET_IS_DEVICE 0# endif
# if defined(_NV_TARGET_VAL)# define _NV_DEVICE_CHECK(q) (q)# else# define _NV_DEVICE_CHECK(q) (0)# endif
# define _NV_TARGET_PROVIDES(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL >= q)# define _NV_TARGET_IS_EXACTLY(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL == q)
// NVCC/NVCXX not being used, only host dispatches allowed#else
# define _NV_COMPILER_NVCC
# define _NV_TARGET_VAL_SM_35 350# define _NV_TARGET_VAL_SM_37 370# define _NV_TARGET_VAL_SM_50 500# define _NV_TARGET_VAL_SM_52 520# define _NV_TARGET_VAL_SM_53 530# define _NV_TARGET_VAL_SM_60 600# define _NV_TARGET_VAL_SM_61 610# define _NV_TARGET_VAL_SM_62 620# define _NV_TARGET_VAL_SM_70 700# define _NV_TARGET_VAL_SM_72 720# define _NV_TARGET_VAL_SM_75 750# define _NV_TARGET_VAL_SM_80 800# define _NV_TARGET_VAL_SM_86 860# define _NV_TARGET_VAL_SM_87 870# define _NV_TARGET_VAL_SM_89 890# define _NV_TARGET_VAL_SM_90 900# define _NV_TARGET_VAL_SM_100 1000# define _NV_TARGET_VAL_SM_101 1010# define _NV_TARGET_VAL_SM_120 1200
# define _NV_TARGET_VAL 0
# define _NV_TARGET_IS_HOST 1# define _NV_TARGET_IS_DEVICE 0
# define _NV_DEVICE_CHECK(q) (false)
# define _NV_TARGET_PROVIDES(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL >= q)# define _NV_TARGET_IS_EXACTLY(q) _NV_DEVICE_CHECK(_NV_TARGET_VAL == q)
#endif
#define _NV_TARGET___NV_PROVIDES_SM_35 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_35))#define _NV_TARGET___NV_PROVIDES_SM_37 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_37))#define _NV_TARGET___NV_PROVIDES_SM_50 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_50))#define _NV_TARGET___NV_PROVIDES_SM_52 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_52))#define _NV_TARGET___NV_PROVIDES_SM_53 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_53))#define _NV_TARGET___NV_PROVIDES_SM_60 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_60))#define _NV_TARGET___NV_PROVIDES_SM_61 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_61))#define _NV_TARGET___NV_PROVIDES_SM_62 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_62))#define _NV_TARGET___NV_PROVIDES_SM_70 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_70))#define _NV_TARGET___NV_PROVIDES_SM_72 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_72))#define _NV_TARGET___NV_PROVIDES_SM_75 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_75))#define _NV_TARGET___NV_PROVIDES_SM_80 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_80))#define _NV_TARGET___NV_PROVIDES_SM_86 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_86))#define _NV_TARGET___NV_PROVIDES_SM_87 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_87))#define _NV_TARGET___NV_PROVIDES_SM_89 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_89))#define _NV_TARGET___NV_PROVIDES_SM_90 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_90))#define _NV_TARGET___NV_PROVIDES_SM_100 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_100))#define _NV_TARGET___NV_PROVIDES_SM_101 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_101))#define _NV_TARGET___NV_PROVIDES_SM_120 (_NV_TARGET_PROVIDES(_NV_TARGET_VAL_SM_120))
#define _NV_TARGET___NV_IS_EXACTLY_SM_35 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_35))#define _NV_TARGET___NV_IS_EXACTLY_SM_37 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_37))#define _NV_TARGET___NV_IS_EXACTLY_SM_50 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_50))#define _NV_TARGET___NV_IS_EXACTLY_SM_52 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_52))#define _NV_TARGET___NV_IS_EXACTLY_SM_53 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_53))#define _NV_TARGET___NV_IS_EXACTLY_SM_60 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_60))#define _NV_TARGET___NV_IS_EXACTLY_SM_61 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_61))#define _NV_TARGET___NV_IS_EXACTLY_SM_62 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_62))#define _NV_TARGET___NV_IS_EXACTLY_SM_70 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_70))#define _NV_TARGET___NV_IS_EXACTLY_SM_72 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_72))#define _NV_TARGET___NV_IS_EXACTLY_SM_75 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_75))#define _NV_TARGET___NV_IS_EXACTLY_SM_80 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_80))#define _NV_TARGET___NV_IS_EXACTLY_SM_86 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_86))#define _NV_TARGET___NV_IS_EXACTLY_SM_87 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_87))#define _NV_TARGET___NV_IS_EXACTLY_SM_89 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_89))#define _NV_TARGET___NV_IS_EXACTLY_SM_90 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_90))#define _NV_TARGET___NV_IS_EXACTLY_SM_100 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_100))#define _NV_TARGET___NV_IS_EXACTLY_SM_101 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_101))#define _NV_TARGET___NV_IS_EXACTLY_SM_120 (_NV_TARGET_IS_EXACTLY(_NV_TARGET_VAL_SM_120))
#define NV_PROVIDES_SM_35 __NV_PROVIDES_SM_35#define NV_PROVIDES_SM_37 __NV_PROVIDES_SM_37#define NV_PROVIDES_SM_50 __NV_PROVIDES_SM_50#define NV_PROVIDES_SM_52 __NV_PROVIDES_SM_52#define NV_PROVIDES_SM_53 __NV_PROVIDES_SM_53#define NV_PROVIDES_SM_60 __NV_PROVIDES_SM_60#define NV_PROVIDES_SM_61 __NV_PROVIDES_SM_61#define NV_PROVIDES_SM_62 __NV_PROVIDES_SM_62#define NV_PROVIDES_SM_70 __NV_PROVIDES_SM_70#define NV_PROVIDES_SM_72 __NV_PROVIDES_SM_72#define NV_PROVIDES_SM_75 __NV_PROVIDES_SM_75#define NV_PROVIDES_SM_80 __NV_PROVIDES_SM_80#define NV_PROVIDES_SM_86 __NV_PROVIDES_SM_86#define NV_PROVIDES_SM_87 __NV_PROVIDES_SM_87#define NV_PROVIDES_SM_89 __NV_PROVIDES_SM_89#define NV_PROVIDES_SM_90 __NV_PROVIDES_SM_90#define NV_PROVIDES_SM_100 __NV_PROVIDES_SM_100#define NV_PROVIDES_SM_101 __NV_PROVIDES_SM_101#define NV_PROVIDES_SM_120 __NV_PROVIDES_SM_120
#define NV_IS_EXACTLY_SM_35 __NV_IS_EXACTLY_SM_35#define NV_IS_EXACTLY_SM_37 __NV_IS_EXACTLY_SM_37#define NV_IS_EXACTLY_SM_50 __NV_IS_EXACTLY_SM_50#define NV_IS_EXACTLY_SM_52 __NV_IS_EXACTLY_SM_52#define NV_IS_EXACTLY_SM_53 __NV_IS_EXACTLY_SM_53#define NV_IS_EXACTLY_SM_60 __NV_IS_EXACTLY_SM_60#define NV_IS_EXACTLY_SM_61 __NV_IS_EXACTLY_SM_61#define NV_IS_EXACTLY_SM_62 __NV_IS_EXACTLY_SM_62#define NV_IS_EXACTLY_SM_70 __NV_IS_EXACTLY_SM_70#define NV_IS_EXACTLY_SM_72 __NV_IS_EXACTLY_SM_72#define NV_IS_EXACTLY_SM_75 __NV_IS_EXACTLY_SM_75#define NV_IS_EXACTLY_SM_80 __NV_IS_EXACTLY_SM_80#define NV_IS_EXACTLY_SM_86 __NV_IS_EXACTLY_SM_86#define NV_IS_EXACTLY_SM_87 __NV_IS_EXACTLY_SM_87#define NV_IS_EXACTLY_SM_89 __NV_IS_EXACTLY_SM_89#define NV_IS_EXACTLY_SM_90 __NV_IS_EXACTLY_SM_90#define NV_IS_EXACTLY_SM_100 __NV_IS_EXACTLY_SM_100#define NV_IS_EXACTLY_SM_101 __NV_IS_EXACTLY_SM_101#define NV_IS_EXACTLY_SM_120 __NV_IS_EXACTLY_SM_120
// Disable SM_90a support on non-supporting compilers.// Will re-enable for nvcc below.#define NV_HAS_FEATURE_SM_90a NV_NO_TARGET#define NV_HAS_FEATURE_SM_100a NV_NO_TARGET#define NV_HAS_FEATURE_SM_101a NV_NO_TARGET
#define NV_IS_HOST __NV_IS_HOST#define NV_IS_DEVICE __NV_IS_DEVICE
#define NV_ANY_TARGET __NV_ANY_TARGET#define NV_NO_TARGET __NV_NO_TARGET
// Platform invoke mechanisms#if defined(_NV_COMPILER_NVCXX) && defined(_NVHPC_CUDA)
# define _NV_ARCH_COND(q) (_NV_TARGET_##q)
# define _NV_BLOCK_EXPAND(...) _NV_REMOVE_PAREN(__VA_ARGS__)
# define _NV_TARGET_IF(cond, t, ...) \ (if target _NV_ARCH_COND(cond) { _NV_BLOCK_EXPAND(t) } else {_NV_BLOCK_EXPAND(__VA_ARGS__)})
#elif defined(_NV_COMPILER_NVCC) || defined(_NV_COMPILER_CLANG_CUDA)
# if (_NV_TARGET___NV_IS_EXACTLY_SM_35)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_35 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_35 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_37)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_37 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_37 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_50)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_50 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_50 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_52)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_52 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_52 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_53)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_53 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_53 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_60)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_60 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_60 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_61)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_61 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_61 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_62)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_62 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_62 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_70)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_70 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_70 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_72)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_72 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_72 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_75)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_75 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_75 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_80)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_80 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_80 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_86)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_86 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_86 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_87)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_87 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_87 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_89)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_89 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_89 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_90)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_90 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_90 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_100)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_100 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_100 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_101)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_101 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_101 0# endif
# if (_NV_TARGET___NV_IS_EXACTLY_SM_120)# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_120 1# else# define _NV_TARGET_BOOL___NV_IS_EXACTLY_SM_120 0# endif
// Re-enable sm_90a support in nvcc.# undef NV_HAS_FEATURE_SM_90a# define NV_HAS_FEATURE_SM_90a __NV_HAS_FEATURE_SM_90a# if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 900) && defined(__CUDA_ARCH_FEAT_SM90_ALL))# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_90a 1# else# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_90a 0# endif
// Re-enable sm_100a support in nvcc.# undef NV_HAS_FEATURE_SM_100a# define NV_HAS_FEATURE_SM_100a __NV_HAS_FEATURE_SM_100a# if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 1000) && defined(__CUDA_ARCH_FEAT_SM100_ALL))# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_100a 1# else# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_100a 0# endif
// Re-enable sm_101a support in nvcc.# undef NV_HAS_FEATURE_SM_101a# define NV_HAS_FEATURE_SM_101a __NV_HAS_FEATURE_SM_101a# if (defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 1010) && defined(__CUDA_ARCH_FEAT_SM101_ALL))# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_101a 1# else# define _NV_TARGET_BOOL___NV_HAS_FEATURE_SM_101a 0# endif
# if (_NV_TARGET_IS_HOST)# define _NV_TARGET_BOOL___NV_IS_HOST 1# define _NV_TARGET_BOOL___NV_IS_DEVICE 0# else# define _NV_TARGET_BOOL___NV_IS_HOST 0# define _NV_TARGET_BOOL___NV_IS_DEVICE 1# endif
# define _NV_TARGET_BOOL___NV_ANY_TARGET 1# define _NV_TARGET_BOOL___NV_NO_TARGET 0
// NVCC Greater than stuff
# if (_NV_TARGET___NV_PROVIDES_SM_35)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_35 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_35 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_37)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_37 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_37 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_50)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_50 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_50 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_52)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_52 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_52 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_53)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_53 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_53 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_60)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_60 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_60 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_61)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_61 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_61 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_62)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_62 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_62 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_70)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_70 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_70 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_72)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_72 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_72 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_75)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_75 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_75 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_80)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_80 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_80 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_86)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_86 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_86 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_87)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_87 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_87 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_89)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_89 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_89 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_90)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_90 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_90 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_100)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_100 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_100 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_101)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_101 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_101 0# endif
# if (_NV_TARGET___NV_PROVIDES_SM_120)# define _NV_TARGET_BOOL___NV_PROVIDES_SM_120 1# else# define _NV_TARGET_BOOL___NV_PROVIDES_SM_120 0# endif
# define _NV_ARCH_COND_CAT1(cond) _NV_TARGET_BOOL_##cond# define _NV_ARCH_COND_CAT(cond) _NV_EVAL(_NV_ARCH_COND_CAT1(cond))
# define _NV_TARGET_EMPTY_PARAM ;
# if defined(_NV_TARGET_CPP11)
# define _NV_BLOCK_EXPAND(...) {_NV_REMOVE_PAREN(__VA_ARGS__)}# define _NV_TARGET_IF(cond, t, ...) _NV_IF(_NV_ARCH_COND_CAT(cond), t, __VA_ARGS__)
# else // <C++11 fallback
# define _NV_BLOCK_EXPAND(x) {x}
# define _NV_TARGET_IF(cond, t) _NV_IF(_NV_ARCH_COND_CAT(cond), t, _NV_TARGET_EMPTY_PARAM)# define _NV_TARGET_IF_ELSE(cond, t, f) _NV_IF(_NV_ARCH_COND_CAT(cond), t, f)
# endif
#endif // _NV_COMPILER_NVCC
#if defined(_NV_TARGET_CPP11)
# define _NV_TARGET_DISPATCH_HANDLE0()# define _NV_TARGET_DISPATCH_HANDLE2(q, fn) _NV_TARGET_IF(q, fn)# define _NV_TARGET_DISPATCH_HANDLE4(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE2(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE6(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE4(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE8(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE6(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE10(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE8(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE12(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE10(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE14(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE12(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE16(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE14(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE18(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE16(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE20(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE18(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE22(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE20(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE24(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE22(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE26(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE24(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE28(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE26(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE30(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE28(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE32(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE30(__VA_ARGS__))# define _NV_TARGET_DISPATCH_HANDLE34(q, fn, ...) _NV_TARGET_IF(q, fn, _NV_TARGET_DISPATCH_HANDLE32(__VA_ARGS__))
# define _NV_TARGET_DISPATCH(...) _NV_BLOCK_EXPAND(_NV_DISPATCH_N_ARY(_NV_TARGET_DISPATCH_HANDLE, __VA_ARGS__))
// NV_IF_TARGET supports a false statement provided as a variadic macro# define NV_IF_TARGET(cond, ...) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, __VA_ARGS__))# define NV_IF_ELSE_TARGET(cond, t, f) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, t, f))# define NV_DISPATCH_TARGET(...) _NV_TARGET_DISPATCH(__VA_ARGS__)
#else // <C++11 fallback
// NV_IF_TARGET does not support a fallback false statement in C++03 or C dialects# define NV_IF_TARGET(cond, t) _NV_BLOCK_EXPAND(_NV_TARGET_IF(cond, t))# define NV_IF_ELSE_TARGET(cond, t, f) _NV_BLOCK_EXPAND(_NV_TARGET_IF_ELSE(cond, t, f))
#endif
#endif // _NV__TARGET_MACROS123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350/* * Copyright 2008-2018 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. */
// allocator_traits::rebind_alloc and allocator::rebind_traits are from libc++,// dual licensed under the MIT and the University of Illinois Open Source// Licenses.
#pragma once
#include <thrust/detail/config.h>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <thrust/detail/memory_wrapper.h>#include <thrust/detail/type_traits.h>#include <thrust/detail/type_traits/has_member_function.h>#include <thrust/detail/type_traits/has_nested_type.h>#include <thrust/detail/type_traits/pointer_traits.h>
THRUST_NAMESPACE_BEGINnamespace detail{
// forward declaration for has_member_systemtemplate <typename Alloc>struct allocator_system;
namespace allocator_traits_detail{
__THRUST_DEFINE_HAS_NESTED_TYPE(has_value_type, value_type)__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)__THRUST_DEFINE_HAS_NESTED_TYPE(has_is_always_equal, is_always_equal)__THRUST_DEFINE_HAS_MEMBER_FUNCTION(has_member_system_impl, system)
template <typename Alloc, typename U>struct has_rebind{ using yes_type = char; using no_type = int;
template <typename S> static yes_type test(typename S::template rebind<U>::other*); template <typename S> static no_type test(...);
static bool const value = sizeof(test<U>(0)) == sizeof(yes_type);
using type = thrust::detail::integral_constant<bool, value>;};
_CCCL_SUPPRESS_DEPRECATED_PUSH
// The following fields of std::allocator have been deprecated (since C++17).// There's no way to detect it other than explicit specialization.#if _CCCL_STD_VER >= 2017# define THRUST_SPECIALIZE_DEPRECATED(trait_name) \ template <typename T> \ struct trait_name<std::allocator<T>> : false_type \ {};
THRUST_SPECIALIZE_DEPRECATED(has_is_always_equal)THRUST_SPECIALIZE_DEPRECATED(has_pointer)THRUST_SPECIALIZE_DEPRECATED(has_const_pointer)THRUST_SPECIALIZE_DEPRECATED(has_reference)THRUST_SPECIALIZE_DEPRECATED(has_const_reference)
# undef THRUST_SPECIALIZE_DEPRECATED
template <typename T, typename U>struct has_rebind<std::allocator<T>, U> : false_type{};#endif
template <typename T>struct nested_pointer{ using type = typename T::pointer;};
template <typename T>struct nested_const_pointer{ using type = typename T::const_pointer;};
template <typename T>struct nested_reference{ using type = typename T::reference;};
template <typename T>struct nested_const_reference{ using type = typename T::const_reference;};
template <typename T>struct nested_void_pointer{ using type = typename T::void_pointer;};
template <typename T>struct nested_const_void_pointer{ using type = typename T::const_void_pointer;};
template <typename T>struct nested_difference_type{ using type = typename T::difference_type;};
template <typename T>struct nested_size_type{ using type = typename T::size_type;};
template <typename T>struct nested_propagate_on_container_copy_assignment{ using type = typename T::propagate_on_container_copy_assignment;};
template <typename T>struct nested_propagate_on_container_move_assignment{ using type = typename T::propagate_on_container_move_assignment;};
template <typename T>struct nested_propagate_on_container_swap{ using type = typename T::propagate_on_container_swap;};
template <typename T>struct nested_is_always_equal{ using type = typename T::is_always_equal;};
template <typename T>struct nested_system_type{ using type = typename T::system_type;};
template <typename Alloc>struct has_member_system{ using system_type = typename allocator_system<Alloc>::type;
using type = typename has_member_system_impl<Alloc, system_type&()>::type; static const bool value = type::value;};
_CCCL_SUPPRESS_DEPRECATED_POP
template <class Alloc, class U, bool = has_rebind<Alloc, U>::value>struct rebind_alloc{ using type = typename Alloc::template rebind<U>::other;};
template <template <typename, typename...> class Alloc, typename T, typename... Args, typename U>struct rebind_alloc<Alloc<T, Args...>, U, true>{ using type = typename Alloc<T, Args...>::template rebind<U>::other;};
template <template <typename, typename...> class Alloc, typename T, typename... Args, typename U>struct rebind_alloc<Alloc<T, Args...>, U, false>{ using type = Alloc<U, Args...>;};
} // namespace allocator_traits_detail
template <typename Alloc>struct allocator_traits{ using allocator_type = Alloc;
using value_type = typename allocator_type::value_type;
using pointer = typename eval_if<allocator_traits_detail::has_pointer<allocator_type>::value, allocator_traits_detail::nested_pointer<allocator_type>, identity_<value_type*>>::type;
private: template <typename T> struct rebind_pointer { using type = typename pointer_traits<pointer>::template rebind<T>::other; };
public: using const_pointer = 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;
using void_pointer = typename eval_if<allocator_traits_detail::has_void_pointer<allocator_type>::value, allocator_traits_detail::nested_void_pointer<allocator_type>, rebind_pointer<void>>::type;
using const_void_pointer = 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;
using difference_type = typename eval_if<allocator_traits_detail::has_difference_type<allocator_type>::value, allocator_traits_detail::nested_difference_type<allocator_type>, pointer_difference<pointer>>::type;
using size_type = typename eval_if<allocator_traits_detail::has_size_type<allocator_type>::value, allocator_traits_detail::nested_size_type<allocator_type>, ::cuda::std::make_unsigned<difference_type>>::type;
using propagate_on_container_copy_assignment = 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;
using propagate_on_container_move_assignment = 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;
using propagate_on_container_swap = 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;
using is_always_equal = typename eval_if<allocator_traits_detail::has_is_always_equal<allocator_type>::value, allocator_traits_detail::nested_is_always_equal<allocator_type>, ::cuda::std::is_empty<allocator_type>>::type;
using system_type = 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;
// XXX rebind and rebind_traits are alias templates // and so are omitted while c++11 is unavailable
template <typename U> using rebind_alloc = typename allocator_traits_detail::rebind_alloc<allocator_type, U>::type;
template <typename U> using rebind_traits = allocator_traits<rebind_alloc<U>>;
// We define this nested type alias for compatibility with the C++03-style // rebind_* mechanisms. using other = allocator_traits;
// Deprecated std::allocator aliases that we need: using reference = typename thrust::detail::pointer_traits<pointer>::reference; using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference;
inline _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n);
inline _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
inline _CCCL_HOST_DEVICE static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
// XXX should probably change T* to pointer below and then relax later
template <typename T> inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p);
template <typename T, typename Arg1> inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p, const Arg1& arg1);
template <typename T, typename... Args> inline _CCCL_HOST_DEVICE static void construct(allocator_type& a, T* p, Args&&... args);
template <typename T> inline _CCCL_HOST_DEVICE static void destroy(allocator_type& a, T* p) noexcept;
inline _CCCL_HOST_DEVICE static size_type max_size(const allocator_type& a);}; // end allocator_traits
// we consider a type an allocator if T::value_type exists// it doesn't make much sense (containers, which are not allocators, will fulfill this requirement),// but allocator_traits is specified to work for any type with that nested aliastemplate <typename T>struct is_allocator : allocator_traits_detail::has_value_type<T>{};
// XXX consider moving this non-standard functionality inside allocator_traitstemplate <typename Alloc>struct allocator_system{ // the type of the allocator's system using type = 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;
// the type that get returns using get_result_type = typename eval_if<allocator_traits_detail::has_member_system<Alloc>::value, ::cuda::std::add_lvalue_reference<type>, identity_<type>>::type;
_CCCL_HOST_DEVICE inline static get_result_type get(Alloc& a);};
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/allocator_traits.inl>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370/* * Copyright 2008-2018 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/allocator_traits.h>#include <thrust/detail/integer_traits.h>#include <thrust/detail/memory_wrapper.h>#include <thrust/detail/type_deduction.h>#include <thrust/detail/type_traits/is_call_possible.h>
#include <new>
THRUST_NAMESPACE_BEGINnamespace detail{
// std::allocator's member functions are deprecated in C++17 and removed in// C++20, so we can't just use the generic implementation for allocator_traits// that calls the allocator's member functions.// Instead, specialize allocator_traits for std::allocator and defer to// std::allocator_traits<std::allocator> and let the STL do whatever it needs// to for the current c++ version. Manually forward the calls to suppress// host/device warnings.template <typename T>struct allocator_traits<std::allocator<T>> : public std::allocator_traits<std::allocator<T>>{private: using superclass = std::allocator_traits<std::allocator<T>>;
public: using allocator_type = typename superclass::allocator_type; using value_type = typename superclass::value_type; using pointer = typename superclass::pointer; using const_pointer = typename superclass::const_pointer; using void_pointer = typename superclass::void_pointer; using const_void_pointer = typename superclass::const_void_pointer; using difference_type = typename superclass::difference_type; using size_type = typename superclass::size_type; using propagate_on_container_swap = typename superclass::propagate_on_container_swap; using propagate_on_container_copy_assignment = typename superclass::propagate_on_container_copy_assignment; using propagate_on_container_move_assignment = typename superclass::propagate_on_container_move_assignment;
// std::allocator_traits added this in C++17, but thrust::allocator_traits defines // it unconditionally. using is_always_equal = typename eval_if<allocator_traits_detail::has_is_always_equal<allocator_type>::value, allocator_traits_detail::nested_is_always_equal<allocator_type>, ::cuda::std::is_empty<allocator_type>>::type;
// std::allocator_traits doesn't provide these, but // thrust::detail::allocator_traits does. These used to be part of the // std::allocator API but were deprecated in C++17. using reference = typename thrust::detail::pointer_traits<pointer>::reference; using const_reference = typename thrust::detail::pointer_traits<const_pointer>::reference;
template <typename U> using rebind_alloc = std::allocator<U>; template <typename U> using rebind_traits = allocator_traits<std::allocator<U>>;
_CCCL_EXEC_CHECK_DISABLE _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n) { return superclass::allocate(a, n); }
_CCCL_EXEC_CHECK_DISABLE _CCCL_HOST_DEVICE static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint) { return superclass::allocate(a, n, hint); }
_CCCL_EXEC_CHECK_DISABLE _CCCL_HOST_DEVICE static void deallocate(allocator_type& a, pointer p, size_type n) noexcept { superclass::deallocate(a, p, n); }
_CCCL_EXEC_CHECK_DISABLE template <typename U, typename... Args> _CCCL_HOST_DEVICE static void construct(allocator_type& a, U* p, Args&&... args) { superclass::construct(a, p, THRUST_FWD(args)...); }
_CCCL_EXEC_CHECK_DISABLE template <typename U> _CCCL_HOST_DEVICE static void destroy(allocator_type& a, U* p) noexcept { superclass::destroy(a, p); }
_CCCL_EXEC_CHECK_DISABLE _CCCL_HOST_DEVICE static size_type max_size(const allocator_type& a) { return superclass::max_size(a); }};
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{ using pointer = typename allocator_traits<Alloc>::pointer; using size_type = typename allocator_traits<Alloc>::size_type; using const_void_pointer = typename allocator_traits<Alloc>::const_void_pointer;
public: using type = typename has_member_allocate_with_hint_impl<Alloc, pointer(size_type, const_void_pointer)>::type; static const bool value = type::value;};
template <typename Alloc>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_allocate_with_hint<Alloc>::value, typename allocator_traits<Alloc>::pointer>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>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_allocate_with_hint<Alloc>::value, typename allocator_traits<Alloc>::pointer>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*)>{};
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_construct1<Alloc, T>::value> construct(Alloc& a, T* p){ a.construct(p);}
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_construct1<Alloc, T>::value> construct(Alloc&, 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&)>{};
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T, typename Arg1>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_construct2<Alloc, T, Arg1>::value>construct(Alloc& a, T* p, const Arg1& arg1){ a.construct(p, arg1);}
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T, typename Arg1>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_construct2<Alloc, T, Arg1>::value>construct(Alloc&, T* p, const Arg1& arg1){ ::new (static_cast<void*>(p)) T(arg1);}
__THRUST_DEFINE_IS_CALL_POSSIBLE(has_member_constructN_impl, construct)
template <typename Alloc, typename T, typename... Args>struct has_member_constructN : has_member_constructN_impl<Alloc, void(T*, Args...)>{};
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T, typename... Args>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_constructN<Alloc, T, Args...>::value>construct(Alloc& a, T* p, Args&&... args){ a.construct(p, THRUST_FWD(args)...);}
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T, typename... Args>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_constructN<Alloc, T, Args...>::value>construct(Alloc&, T* p, Args&&... args){ ::new (static_cast<void*>(p)) T(THRUST_FWD(args)...);}
__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*)>{};
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_destroy<Alloc, T>::value> destroy(Alloc& a, T* p){ a.destroy(p);}
_CCCL_EXEC_CHECK_DISABLEtemplate <typename Alloc, typename T>inline _CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_destroy<Alloc, T>::value> 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{ using size_type = typename allocator_traits<Alloc>::size_type;
public: using type = typename has_member_max_size_impl<Alloc, size_type()>::type; static const bool value = type::value;};
template <typename Alloc>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_max_size<Alloc>::value, typename allocator_traits<Alloc>::size_type>max_size(const Alloc& a){ return a.max_size();}
template <typename Alloc>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_max_size<Alloc>::value, typename allocator_traits<Alloc>::size_type>max_size(const Alloc&){ using size_type = typename allocator_traits<Alloc>::size_type; return thrust::detail::integer_traits<size_type>::const_max;}
template <typename Alloc>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<has_member_system<Alloc>::value, typename allocator_system<Alloc>::type&>system(Alloc& a){ // return the allocator's system return a.system();}
template <typename Alloc>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t<!has_member_system<Alloc>::value, typename allocator_system<Alloc>::type>system(Alloc&){ // return a copy of a value-initialized system return typename allocator_system<Alloc>::type();}
} // namespace allocator_traits_detail
template <typename Alloc>_CCCL_HOST_DEVICE typename allocator_traits<Alloc>::pointerallocator_traits<Alloc>::allocate(Alloc& a, typename allocator_traits<Alloc>::size_type n){ struct workaround_warnings { _CCCL_EXEC_CHECK_DISABLE static _CCCL_HOST_DEVICE typename allocator_traits<Alloc>::pointer allocate(Alloc& a, typename allocator_traits<Alloc>::size_type n) { return a.allocate(n); } };
return workaround_warnings::allocate(a, n);}
template <typename Alloc>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE void allocator_traits<Alloc>::deallocate( Alloc& a, typename allocator_traits<Alloc>::pointer p, typename allocator_traits<Alloc>::size_type n) noexcept{ struct workaround_warnings { _CCCL_EXEC_CHECK_DISABLE static _CCCL_HOST_DEVICE void deallocate( Alloc& a, typename allocator_traits<Alloc>::pointer p, typename allocator_traits<Alloc>::size_type n) noexcept { return a.deallocate(p, n); } };
return workaround_warnings::deallocate(a, p, n);}
template <typename Alloc>template <typename T>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE 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, typename... Args>_CCCL_HOST_DEVICE void allocator_traits<Alloc>::construct(allocator_type& a, T* p, Args&&... args){ return allocator_traits_detail::construct(a, p, THRUST_FWD(args)...);}
template <typename Alloc>template <typename T>_CCCL_HOST_DEVICE void allocator_traits<Alloc>::destroy(allocator_type& a, T* p) noexcept{ return allocator_traits_detail::destroy(a, p);}
template <typename Alloc>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE typename allocator_system<Alloc>::get_result_type allocator_system<Alloc>::get(Alloc& a){ return allocator_traits_detail::system(a);}
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/execution_policy.h>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename System, typename Allocator, typename InputIterator, typename Pointer>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE Pointer copy_construct_range_n( thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, Size n, Pointer result);
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/copy_construct_range.inl>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/advance.h>#include <thrust/detail/allocator/allocator_traits.h>#include <thrust/detail/copy.h>#include <thrust/detail/memory_wrapper.h>#include <thrust/detail/type_traits/pointer_traits.h>#include <thrust/distance.h>#include <thrust/for_each.h>#include <thrust/iterator/iterator_traits.h>#include <thrust/iterator/zip_iterator.h>#include <thrust/tuple.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace allocator_traits_detail{
template <typename Allocator, typename InputType, typename OutputType>struct copy_construct_with_allocator{ Allocator& a;
_CCCL_HOST_DEVICE copy_construct_with_allocator(Allocator& a) : a(a) {}
template <typename Tuple> inline _CCCL_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); }};
// we need to use allocator_traits<Allocator>::construct() to// copy construct a T if either:// 1. Allocator has a 2-argument construct() member or// 2. T has a non-trivial copy constructortemplate <typename Allocator, typename T>struct needs_copy_construct_via_allocator : integral_constant<bool, (has_member_construct2<Allocator, T, T>::value || !::cuda::std::is_trivially_copy_constructible<T>::value)>{};
// we know that std::allocator::construct's only effect is to call T's// copy constructor, so we needn't consider or use its construct() member for copy constructiontemplate <typename U, typename T>struct needs_copy_construct_via_allocator<std::allocator<U>, T> : integral_constant<bool, !::cuda::std::is_trivially_copy_constructible<T>::value>{};
// 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 allocatortemplate <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Pointer>_CCCL_HOST_DEVICE enable_if_convertible_t<FromSystem, ToSystem, Pointer> uninitialized_copy_with_allocator( Allocator& a, const thrust::execution_policy<FromSystem>&, const thrust::execution_policy<ToSystem>& to_system, InputIterator first, InputIterator last, Pointer result){ // zip up the iterators using IteratorTuple = thrust::tuple<InputIterator, Pointer>; using ZipIterator = thrust::zip_iterator<IteratorTuple>;
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 using InputType = typename iterator_traits<InputIterator>::value_type; using OutputType = typename iterator_traits<Pointer>::value_type;
// 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 allocatortemplate <typename Allocator, typename FromSystem, typename ToSystem, typename InputIterator, typename Size, typename Pointer>_CCCL_HOST_DEVICE enable_if_convertible_t<FromSystem, ToSystem, Pointer> uninitialized_copy_with_allocator_n( Allocator& a, const thrust::execution_policy<FromSystem>&, const thrust::execution_policy<ToSystem>& to_system, InputIterator first, Size n, Pointer result){ // zip up the iterators using IteratorTuple = thrust::tuple<InputIterator, Pointer>; using ZipIterator = thrust::zip_iterator<IteratorTuple>;
ZipIterator begin = thrust::make_zip_iterator(thrust::make_tuple(first, result));
// create a functor using InputType = typename iterator_traits<InputIterator>::value_type; using OutputType = typename iterator_traits<Pointer>::value_type;
// 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>_CCCL_HOST_DEVICE typename disable_if_convertible<FromSystem, ToSystem, Pointer>::type uninitialized_copy_with_allocator( Allocator&, const thrust::execution_policy<FromSystem>& from_system, const 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>_CCCL_HOST_DEVICE typename disable_if_convertible<FromSystem, ToSystem, Pointer>::typeuninitialized_copy_with_allocator_n( Allocator&, const thrust::execution_policy<FromSystem>& from_system, const 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>_CCCL_HOST_DEVICEtypename disable_if<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer>::typecopy_construct_range(thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result){ // just call two_system_copy return thrust::detail::two_system_copy(from_system, allocator_system<Allocator>::get(a), first, last, result);}
template <typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>_CCCL_HOST_DEVICEtypename disable_if<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer>::typecopy_construct_range_n( thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, Size n, Pointer result){ // just call two_system_copy_n return thrust::detail::two_system_copy_n(from_system, allocator_system<Allocator>::get(a), first, n, result);}
template <typename FromSystem, typename Allocator, typename InputIterator, typename Pointer>_CCCL_HOST_DEVICE ::cuda::std:: enable_if_t<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer> copy_construct_range(thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result){ return uninitialized_copy_with_allocator(a, from_system, allocator_system<Allocator>::get(a), first, last, result);}
template <typename FromSystem, typename Allocator, typename InputIterator, typename Size, typename Pointer>_CCCL_HOST_DEVICE ::cuda::std:: enable_if_t<needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value, Pointer> copy_construct_range_n( thrust::execution_policy<FromSystem>& from_system, Allocator& a, InputIterator first, Size n, Pointer result){ return uninitialized_copy_with_allocator_n(a, from_system, allocator_system<Allocator>::get(a), first, n, result);}
} // namespace allocator_traits_detail
template <typename System, typename Allocator, typename InputIterator, typename Pointer>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE 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);}
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE inline void destroy_range(Allocator& a, Pointer p, Size n) noexcept;
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/destroy_range.inl>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137/* * Copyright 2008-2021 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <thrust/detail/allocator/allocator_traits.h>#include <thrust/detail/allocator/destroy_range.h>#include <thrust/detail/memory_wrapper.h>#include <thrust/detail/type_traits/pointer_traits.h>#include <thrust/for_each.h>
THRUST_NAMESPACE_BEGINnamespace 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 destructortemplate <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 : ::cuda::std::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 destructortemplate <typename Allocator, typename Pointer>struct enable_if_destroy_range_case2 : ::cuda::std::enable_if<!has_effectful_member_destroy<Allocator, typename pointer_element<Pointer>::type>::value && !::cuda::std::is_trivially_destructible<typename pointer_element<Pointer>::type>::value>{};
// case 3: Allocator has no member function "destroy", and T has a trivial destructortemplate <typename Allocator, typename Pointer>struct enable_if_destroy_range_case3 : ::cuda::std::enable_if<!has_effectful_member_destroy<Allocator, typename pointer_element<Pointer>::type>::value && ::cuda::std::is_trivially_destructible<typename pointer_element<Pointer>::type>::value>{};
template <typename Allocator>struct destroy_via_allocator{ Allocator& a;
_CCCL_HOST_DEVICE destroy_via_allocator(Allocator& a) noexcept : a(a) {}
template <typename T> inline _CCCL_HOST_DEVICE void operator()(T& x) noexcept { allocator_traits<Allocator>::destroy(a, &x); }};
// destroy_range case 1: destroy via allocatortemplate <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE typename enable_if_destroy_range_case1<Allocator, Pointer>::typedestroy_range(Allocator& a, Pointer p, Size n) noexcept{ thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, destroy_via_allocator<Allocator>(a));}
// we must prepare for His comingstruct gozer{ _CCCL_EXEC_CHECK_DISABLE template <typename T> inline _CCCL_HOST_DEVICE void operator()(T& x) noexcept { x.~T(); }};
// destroy_range case 2: destroy without the allocatortemplate <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE typename enable_if_destroy_range_case2<Allocator, Pointer>::typedestroy_range(Allocator& a, Pointer p, Size n) noexcept{ thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, gozer());}
// destroy_range case 3: no-optemplate <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE typename enable_if_destroy_range_case3<Allocator, Pointer>::typedestroy_range(Allocator&, Pointer, Size) noexcept{ // no op}
} // namespace allocator_traits_detail
template <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE void destroy_range(Allocator& a, Pointer p, Size n) noexcept{ return allocator_traits_detail::destroy_range(a, p, n);}
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename Allocator, typename Pointer, typename Size, typename T>_CCCL_HOST_DEVICE inline void fill_construct_range(Allocator& a, Pointer p, Size n, const T& value);
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/fill_construct_range.inl>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/allocator_traits.h>#include <thrust/detail/memory_wrapper.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>
THRUST_NAMESPACE_BEGINnamespace 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 newtemplate <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;
_CCCL_HOST_DEVICE construct2_via_allocator(Allocator& a, const Arg1& arg) : a(a) , arg(arg) {}
template <typename T> inline _CCCL_HOST_DEVICE void operator()(T& x) { allocator_traits<Allocator>::construct(a, &x, arg); }};
template <typename Allocator, typename Pointer, typename Size, typename T>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t< has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>::value>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>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t< !has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>::value>fill_construct_range(Allocator& a, Pointer p, Size n, const T& value){ thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, value);}
} // namespace allocator_traits_detail
template <typename Alloc, typename Pointer, typename Size, typename T>_CCCL_HOST_DEVICE void fill_construct_range(Alloc& a, Pointer p, Size n, const T& value){ return allocator_traits_detail::fill_construct_range(a, p, n, value);}
} // namespace detailTHRUST_NAMESPACE_END1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/tagged_allocator.h>#include <thrust/detail/type_traits/pointer_traits.h>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename T, typename System, typename Pointer>class malloc_allocator : public thrust::detail::tagged_allocator<T, System, Pointer>{private: using super_t = thrust::detail::tagged_allocator<T, System, Pointer>;
public: using pointer = typename super_t::pointer; using size_type = typename super_t::size_type;
pointer allocate(size_type cnt);
void deallocate(pointer p, size_type n) noexcept;};
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/malloc_allocator.inl>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/malloc_allocator.h>#include <thrust/detail/malloc_and_free.h>#include <thrust/detail/raw_pointer_cast.h>#include <thrust/system/detail/bad_alloc.h>#include <thrust/system/detail/generic/select_system.h>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename T, typename System, typename Pointer>typename malloc_allocator<T, System, Pointer>::pointermalloc_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) noexcept{ using thrust::system::detail::generic::select_system;
System system; thrust::free(select_system(system), p);} // end malloc_allocator
} // namespace detailTHRUST_NAMESPACE_END12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <nv/target>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename BaseAllocator>struct no_throw_allocator : BaseAllocator{private: using super_t = BaseAllocator;
public: inline _CCCL_HOST_DEVICE no_throw_allocator(const BaseAllocator& other = BaseAllocator()) : super_t(other) {}
template <typename U> struct rebind { using other = no_throw_allocator<typename super_t::template rebind<U>::other>; }; // end rebind
_CCCL_HOST_DEVICE void deallocate(typename super_t::pointer p, typename super_t::size_type n) noexcept { NV_IF_TARGET( NV_IS_HOST, (try { super_t::deallocate(p, n); } // end try catch (...){ // catch anything } // end catch ), (super_t::deallocate(p, n);)); } // end deallocate()
inline _CCCL_HOST_DEVICE bool operator==(no_throw_allocator const& other) { return super_t::operator==(other); }
inline _CCCL_HOST_DEVICE bool operator!=(no_throw_allocator const& other) { return super_t::operator!=(other); }}; // end no_throw_allocator
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/type_traits/pointer_traits.h>#include <thrust/iterator/iterator_traits.h>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename T, typename Tag, typename Pointer>class tagged_allocator;
template <typename Tag, typename Pointer>class tagged_allocator<void, Tag, Pointer>{public: using value_type = void; using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<void>::other; using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<const void>::other; using size_type = std::size_t; using difference_type = typename thrust::detail::pointer_traits<Pointer>::difference_type; using system_type = Tag;
template <typename U> struct rebind { using other = tagged_allocator<U, Tag, Pointer>; }; // end rebind};
template <typename T, typename Tag, typename Pointer>class tagged_allocator{public: using value_type = T; using pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<T>::other; using const_pointer = typename thrust::detail::pointer_traits<Pointer>::template rebind<const T>::other; using reference = typename thrust::iterator_reference<pointer>::type; using const_reference = typename thrust::iterator_reference<const_pointer>::type; using size_type = std::size_t; using difference_type = typename thrust::detail::pointer_traits<pointer>::difference_type; using system_type = Tag;
template <typename U> struct rebind { using other = tagged_allocator<U, Tag, Pointer>; }; // end rebind
_CCCL_HOST_DEVICE inline tagged_allocator();
_CCCL_HOST_DEVICE inline tagged_allocator(const tagged_allocator&);
template <typename U, typename OtherPointer> _CCCL_HOST_DEVICE inline tagged_allocator(const tagged_allocator<U, Tag, OtherPointer>&);
_CCCL_HOST_DEVICE inline ~tagged_allocator();
_CCCL_HOST_DEVICE pointer address(reference x) const;
_CCCL_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>_CCCL_HOST_DEVICE booloperator==(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&);
template <typename T1, typename Pointer1, typename T2, typename Pointer2, typename Tag>_CCCL_HOST_DEVICE booloperator!=(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&);
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/tagged_allocator.inl>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/tagged_allocator.h>
#include <limits>
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename T, typename Tag, typename Pointer>_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::tagged_allocator(){}
template <typename T, typename Tag, typename Pointer>_CCCL_HOST_DEVICE 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>_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::tagged_allocator(const tagged_allocator<U, Tag, OtherPointer>&){}
template <typename T, typename Tag, typename Pointer>_CCCL_HOST_DEVICE tagged_allocator<T, Tag, Pointer>::~tagged_allocator(){}
template <typename T, typename Tag, typename Pointer>_CCCL_HOST_DEVICE typename tagged_allocator<T, Tag, Pointer>::pointertagged_allocator<T, Tag, Pointer>::address(reference x) const{ return &x;}
template <typename T, typename Tag, typename Pointer>_CCCL_HOST_DEVICE typename tagged_allocator<T, Tag, Pointer>::const_pointertagged_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>_CCCL_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>_CCCL_HOST_DEVICE bool operator!=(const tagged_allocator<T1, Pointer1, Tag>&, const tagged_allocator<T2, Pointer2, Tag>&){ return false;}
} // namespace detailTHRUST_NAMESPACE_END12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/allocator_traits.h>#include <thrust/detail/allocator/tagged_allocator.h>#include <thrust/detail/execution_policy.h>#include <thrust/memory.h>#include <thrust/pair.h>
THRUST_NAMESPACE_BEGINnamespace 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: using super_t = thrust::detail::tagged_allocator<T, System, thrust::pointer<T, System>>;
System& m_system;
public: using pointer = typename super_t::pointer; using size_type = typename super_t::size_type;
inline _CCCL_HOST_DEVICE temporary_allocator(const temporary_allocator& other) : super_t() , m_system(other.m_system) {}
inline _CCCL_HOST_DEVICE explicit temporary_allocator(thrust::execution_policy<System>& system) : super_t() , m_system(thrust::detail::derived_cast(system)) {}
_CCCL_HOST_DEVICE pointer allocate(size_type cnt);
_CCCL_HOST_DEVICE void deallocate(pointer p, size_type n) noexcept;
_CCCL_HOST_DEVICE inline System& system() { return m_system; } // end system()
private: using pointer_and_size = thrust::pair<pointer, size_type>;}; // end temporary_allocator
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/temporary_allocator.inl>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#include <thrust/detail/allocator/temporary_allocator.h>#include <thrust/detail/temporary_buffer.h>#include <thrust/system/detail/bad_alloc.h>
#include <cassert>
#include <nv/target>
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA# if (defined(_NVHPC_CUDA) || defined(__CUDA_ARCH__))# include <thrust/system/cuda/detail/terminate.h># endif // NVCC device pass or NVC++#endif // CUDA
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename T, typename System>_CCCL_HOST_DEVICE typename temporary_allocator<T, System>::pointertemporary_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);
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA NV_IF_TARGET(NV_IS_HOST, (throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");), ( // NV_IS_DEVICE thrust::system::cuda::detail::terminate_with_message("temporary_buffer::allocate: " "get_temporary_buffer failed");));#else throw thrust::system::detail::bad_alloc("temporary_buffer::allocate: get_temporary_buffer failed");#endif } // end if
return result.first;} // end temporary_allocator::allocate()
template <typename T, typename System>_CCCL_HOST_DEVICE void temporary_allocator<T, System>::deallocate( typename temporary_allocator<T, System>::pointer p, typename temporary_allocator<T, System>::size_type n) noexcept{ return thrust::return_temporary_buffer(system(), p, n);} // end temporary_allocator
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
THRUST_NAMESPACE_BEGINnamespace detail{
template <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE inline void value_initialize_range(Allocator& a, Pointer p, Size n);
} // namespace detailTHRUST_NAMESPACE_END
#include <thrust/detail/allocator/value_initialize_range.inl>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header#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>
THRUST_NAMESPACE_BEGINnamespace detail{namespace allocator_traits_detail{
template <typename Allocator>struct construct1_via_allocator{ Allocator& a;
_CCCL_HOST_DEVICE construct1_via_allocator(Allocator& a) : a(a) {}
template <typename T> inline _CCCL_HOST_DEVICE void operator()(T& x) { allocator_traits<Allocator>::construct(a, &x); }};
// we need to construct T via the allocator if...template <typename Allocator, typename T>struct needs_default_construct_via_allocator : ::cuda::std::disjunction<has_member_construct1<Allocator, T>, // if the Allocator does something interesting // or if T's default constructor does something // interesting thrust::detail::not_<::cuda::std::is_trivially_default_constructible<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// unless T's constructor does something interestingtemplate <typename U, typename T>struct needs_default_construct_via_allocator<std::allocator<U>, T> : thrust::detail::not_<::cuda::std::is_trivially_default_constructible<T>>{};
template <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE ::cuda::std::enable_if_t< needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value>value_initialize_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>_CCCL_HOST_DEVICEtypename disable_if<needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>::value>::typevalue_initialize_range(Allocator& a, Pointer p, Size n){ thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, typename pointer_element<Pointer>::type());}
} // namespace allocator_traits_detail
template <typename Allocator, typename Pointer, typename Size>_CCCL_HOST_DEVICE void value_initialize_range(Allocator& a, Pointer p, Size n){ return allocator_traits_detail::value_initialize_range(a, p, n);}
} // namespace detailTHRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255/* * Copyright 2008-2021 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex.h>#include <thrust/detail/complex/c99math.h>
#include <cfloat>#include <cmath>
THRUST_NAMESPACE_BEGIN
/* --- Binary Arithmetic Operators --- */
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator+(const complex<T0>& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() + y.real(), x.imag() + y.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator+(const complex<T0>& x, const T1& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() + y, x.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator+(const T0& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x + y.real(), y.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator-(const complex<T0>& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() - y.real(), x.imag() - y.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator-(const complex<T0>& x, const T1& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() - y, x.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator-(const T0& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x - y.real(), -y.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator*(const complex<T0>& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() * y.real() - x.imag() * y.imag(), x.real() * y.imag() + x.imag() * y.real());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator*(const complex<T0>& x, const T1& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() * y, x.imag() * y);}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator*(const T0& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x * y.real(), x * y.imag());}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator/(const complex<T0>& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>;
// Find `abs` by ADL. using std::abs;
T s = abs(y.real()) + abs(y.imag());
T oos = T(1.0) / s;
T ars = x.real() * oos; T ais = x.imag() * oos; T brs = y.real() * oos; T bis = y.imag() * oos;
s = (brs * brs) + (bis * bis);
oos = T(1.0) / s;
complex<T> quot(((ars * brs) + (ais * bis)) * oos, ((ais * brs) - (ars * bis)) * oos); return quot;}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator/(const complex<T0>& x, const T1& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x.real() / y, x.imag() / y);}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> operator/(const T0& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return complex<T>(x) / y;}
/* --- Unary Arithmetic Operators --- */
template <typename T>_CCCL_HOST_DEVICE complex<T> operator+(const complex<T>& y){ return y;}
template <typename T>_CCCL_HOST_DEVICE complex<T> operator-(const complex<T>& y){ return y * -T(1);}
/* --- Other Basic Arithmetic Functions --- */
// As std::hypot is only C++11 we have to use the C interfacetemplate <typename T>_CCCL_HOST_DEVICE T abs(const complex<T>& z){ return hypot(z.real(), z.imag());}
// XXX Why are we specializing here?namespace detail{namespace complex{
_CCCL_HOST_DEVICE inline float abs(const thrust::complex<float>& z){ return hypotf(z.real(), z.imag());}
_CCCL_HOST_DEVICE inline double abs(const thrust::complex<double>& z){ return hypot(z.real(), z.imag());}
} // end namespace complex} // end namespace detail
template <>_CCCL_HOST_DEVICE inline float abs(const complex<float>& z){ return detail::complex::abs(z);}
template <>_CCCL_HOST_DEVICE inline double abs(const complex<double>& z){ return detail::complex::abs(z);}
template <typename T>_CCCL_HOST_DEVICE T arg(const complex<T>& z){ // Find `atan2` by ADL. using std::atan2; return atan2(z.imag(), z.real());}
template <typename T>_CCCL_HOST_DEVICE complex<T> conj(const complex<T>& z){ return complex<T>(z.real(), -z.imag());}
template <typename T>_CCCL_HOST_DEVICE T norm(const complex<T>& z){ return z.real() * z.real() + z.imag() * z.imag();}
// XXX Why specialize these, we could just rely on ADL.template <>_CCCL_HOST_DEVICE inline float norm(const complex<float>& z){ // Find `abs` and `sqrt` by ADL. using std::abs; using std::sqrt;
if (abs(z.real()) < sqrt(FLT_MIN) && abs(z.imag()) < sqrt(FLT_MIN)) { float a = z.real() * 4.0f; float b = z.imag() * 4.0f; return (a * a + b * b) / 16.0f; }
return z.real() * z.real() + z.imag() * z.imag();}
template <>_CCCL_HOST_DEVICE inline double norm(const complex<double>& z){ // Find `abs` and `sqrt` by ADL. using std::abs; using std::sqrt;
if (abs(z.real()) < sqrt(DBL_MIN) && abs(z.imag()) < sqrt(DBL_MIN)) { double a = z.real() * 4.0; double b = z.imag() * 4.0; return (a * a + b * b) / 16.0; }
return z.real() * z.real() + z.imag() * z.imag();}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> polar(const T0& m, const T1& theta){ using T = ::cuda::std::common_type_t<T0, T1>;
// Find `cos` and `sin` by ADL. using std::cos; using std::sin;
return complex<T>(m * cos(theta), m * sin(theta));}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex/math_private.h>
#include <cmath>
#include <math.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
// Define basic arithmetic functions so we can use them without explicit scope// keeping the code as close as possible to FreeBSDs for ease of maintenance.// It also provides an easy way to support compilers with missing C99 functions.// When possible, just use the names in the global scope.// Some platforms define these as macros, others as free functions.// Avoid using the std:: form of these as nvcc may treat std::foo() as __host__ functions.
using ::acos;using ::asin;using ::atan;using ::cos;using ::cosh;using ::exp;using ::log;using ::sin;using ::sinh;using ::sqrt;using ::tan;
template <typename T>inline _CCCL_HOST_DEVICE T infinity();
template <>inline _CCCL_HOST_DEVICE float infinity<float>(){ float res; set_float_word(res, 0x7f800000); return res;}
template <>inline _CCCL_HOST_DEVICE double infinity<double>(){ double res; insert_words(res, 0x7ff00000, 0); return res;}
#if defined _MSC_VER_CCCL_HOST_DEVICE inline int isinf(float x){ return std::abs(x) == infinity<float>();}
_CCCL_HOST_DEVICE inline int isinf(double x){ return std::abs(x) == infinity<double>();}
_CCCL_HOST_DEVICE inline int isnan(float x){ return x != x;}
_CCCL_HOST_DEVICE inline int isnan(double x){ return x != x;}
_CCCL_HOST_DEVICE inline int signbit(float x){ return ((*((uint32_t*) &x)) & 0x80000000) != 0 ? 1 : 0;}
_CCCL_HOST_DEVICE inline int signbit(double x){ return ((*((uint64_t*) &x)) & 0x8000000000000000) != 0ull ? 1 : 0;}
_CCCL_HOST_DEVICE inline int isfinite(float x){ return !isnan(x) && !isinf(x);}
_CCCL_HOST_DEVICE inline int isfinite(double x){ return !isnan(x) && !isinf(x);}
#else
# if defined(__CUDACC__) && !(defined(__CUDA__) && defined(__clang__)) && !defined(_NVHPC_CUDA)// NVCC implements at least some signature of these as functions not macros.using ::isfinite;using ::isinf;using ::isnan;using ::signbit;# else// Some compilers do not provide these in the global scope, because they are// supposed to be macros. The versions in `std` are supposed to be functions.// Since we're not compiling with nvcc, it's safe to use the functions in std::using std::isfinite;using std::isinf;using std::isnan;using std::signbit;# endif // __CUDACC__#endif // _MSC_VER
using ::atanh;
#if defined _MSC_VER
_CCCL_HOST_DEVICE inline double copysign(double x, double y){ uint32_t hx, hy; get_high_word(hx, x); get_high_word(hy, y); set_high_word(x, (hx & 0x7fffffff) | (hy & 0x80000000)); return x;}
_CCCL_HOST_DEVICE inline float copysignf(float x, float y){ uint32_t ix, iy; get_float_word(ix, x); get_float_word(iy, y); set_float_word(x, (ix & 0x7fffffff) | (iy & 0x80000000)); return x;}
# if !defined(__CUDACC__) && !defined(_NVHPC_CUDA)
// Simple approximation to log1p as Visual Studio is lacking oneinline double log1p(double x){ double u = 1.0 + x; if (u == 1.0) { return x; } else { if (u > 2.0) { // Use normal log for large arguments return log(u); } else { return log(u) * (x / (u - 1.0)); } }}
inline float log1pf(float x){ float u = 1.0f + x; if (u == 1.0f) { return x; } else { if (u > 2.0f) { // Use normal log for large arguments return logf(u); } else { return logf(u) * (x / (u - 1.0f)); } }}
# if _MSV_VER <= 1500# include <complex>
inline float hypotf(float x, float y){ return abs(std::complex<float>(x, y));}
inline double hypot(double x, double y){ return _hypot(x, y);}
# endif // _MSC_VER <= 1500
# endif // __CUDACC__
#endif // _MSC_VER
} // namespace complex
} // namespace detail
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* * Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>: * freebsd/lib/msun/src/catrig.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cfloat>#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline void raise_inexact(){ const volatile float tiny = 7.888609052210118054117286e-31; /* 0x1p-100; */ // needs the volatile to prevent compiler from ignoring it volatile float junk = 1 + tiny; (void) junk;}
_CCCL_HOST_DEVICE inline complex<double> clog_for_large_values(complex<double> z);
/* * Testing indicates that all these functions are accurate up to 4 ULP. * The functions casin(h) and cacos(h) are about 2.5 times slower than asinh. * The functions catan(h) are a little under 2 times slower than atanh. * * The code for casinh, casin, cacos, and cacosh comes first. The code is * rather complicated, and the four functions are highly interdependent. * * The code for catanh and catan comes at the end. It is much simpler than * the other functions, and the code for these can be disconnected from the * rest of the code. */
/* * ================================ * | casinh, casin, cacos, cacosh | * ================================ */
/* * The algorithm is very close to that in "Implementing the complex arcsine * and arccosine functions using exception handling" by T. E. Hull, Thomas F. * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335, * http://dl.acm.org/citation.cfm?id=275324. * * Throughout we use the convention z = x + I*y. * * casinh(z) = sign(x)*log(A+sqrt(A*A-1)) + I*asin(B) * where * A = (|z+I| + |z-I|) / 2 * B = (|z+I| - |z-I|) / 2 = y/A * * These formulas become numerically unstable: * (a) for Re(casinh(z)) when z is close to the line segment [-I, I] (that * is, Re(casinh(z)) is close to 0); * (b) for Im(casinh(z)) when z is close to either of the intervals * [I, I*infinity) or (-I*infinity, -I] (that is, |Im(casinh(z))| is * close to PI/2). * * These numerical problems are overcome by defining * f(a, b) = (hypot(a, b) - b) / 2 = a*a / (hypot(a, b) + b) / 2 * Then if A < A_crossover, we use * log(A + sqrt(A*A-1)) = log1p((A-1) + sqrt((A-1)*(A+1))) * A-1 = f(x, 1+y) + f(x, 1-y) * and if B > B_crossover, we use * asin(B) = atan2(y, sqrt(A*A - y*y)) = atan2(y, sqrt((A+y)*(A-y))) * A-y = f(x, y+1) + f(x, y-1) * where without loss of generality we have assumed that x and y are * non-negative. * * Much of the difficulty comes because the intermediate computations may * produce overflows or underflows. This is dealt with in the paper by Hull * et al by using exception handling. We do this by detecting when * computations risk underflow or overflow. The hardest part is handling the * underflows when computing f(a, b). * * Note that the function f(a, b) does not appear explicitly in the paper by * Hull et al, but the idea may be found on pages 308 and 309. Introducing the * function f(a, b) allows us to concentrate many of the clever tricks in this * paper into one function. */
/* * Function f(a, b, hypot_a_b) = (hypot(a, b) - b) / 2. * Pass hypot(a, b) as the third argument. */_CCCL_HOST_DEVICE inline double f(double a, double b, double hypot_a_b){ if (b < 0) { return ((hypot_a_b - b) / 2); } if (b == 0) { return (a / 2); } return (a * a / (hypot_a_b + b) / 2);}
/* * All the hard work is contained in this function. * x and y are assumed positive or zero, and less than RECIP_EPSILON. * Upon return: * rx = Re(casinh(z)) = -Im(cacos(y + I*x)). * B_is_usable is set to 1 if the value of B is usable. * If B_is_usable is set to 0, sqrt_A2my2 = sqrt(A*A - y*y), and new_y = y. * If returning sqrt_A2my2 has potential to result in an underflow, it is * rescaled, and new_y is similarly rescaled. */_CCCL_HOST_DEVICE inline voiddo_hard_work(double x, double y, double* rx, int* B_is_usable, double* B, double* sqrt_A2my2, double* new_y){ double R, S, A; /* A, B, R, and S are as in Hull et al. */ double Am1, Amy; /* A-1, A-y. */ const double A_crossover = 10; /* Hull et al suggest 1.5, but 10 works better */ const double FOUR_SQRT_MIN = 5.966672584960165394632772e-154; /* =0x1p-509; >= 4 * sqrt(DBL_MIN) */ const double B_crossover = 0.6417; /* suggested by Hull et al */
R = hypot(x, y + 1); /* |z+I| */ S = hypot(x, y - 1); /* |z-I| */
/* A = (|z+I| + |z-I|) / 2 */ A = (R + S) / 2; /* * Mathematically A >= 1. There is a small chance that this will not * be so because of rounding errors. So we will make certain it is * so. */ if (A < 1) { A = 1; }
if (A < A_crossover) { /* * Am1 = fp + fm, where fp = f(x, 1+y), and fm = f(x, 1-y). * rx = log1p(Am1 + sqrt(Am1*(A+1))) */ if (y == 1 && x < DBL_EPSILON * DBL_EPSILON / 128) { /* * fp is of order x^2, and fm = x/2. * A = 1 (inexactly). */ *rx = sqrt(x); } else if (x >= DBL_EPSILON * fabs(y - 1)) { /* * Underflow will not occur because * x >= DBL_EPSILON^2/128 >= FOUR_SQRT_MIN */ Am1 = f(x, 1 + y, R) + f(x, 1 - y, S); *rx = log1p(Am1 + sqrt(Am1 * (A + 1))); } else if (y < 1) { /* * fp = x*x/(1+y)/4, fm = x*x/(1-y)/4, and * A = 1 (inexactly). */ *rx = x / sqrt((1 - y) * (1 + y)); } else { /* if (y > 1) */ /* * A-1 = y-1 (inexactly). */ *rx = log1p((y - 1) + sqrt((y - 1) * (y + 1))); } } else { *rx = log(A + sqrt(A * A - 1)); }
*new_y = y;
if (y < FOUR_SQRT_MIN) { /* * Avoid a possible underflow caused by y/A. For casinh this * would be legitimate, but will be picked up by invoking atan2 * later on. For cacos this would not be legitimate. */ *B_is_usable = 0; *sqrt_A2my2 = A * (2 / DBL_EPSILON); *new_y = y * (2 / DBL_EPSILON); return; }
/* B = (|z+I| - |z-I|) / 2 = y/A */ *B = y / A; *B_is_usable = 1;
if (*B > B_crossover) { *B_is_usable = 0; /* * Amy = fp + fm, where fp = f(x, y+1), and fm = f(x, y-1). * sqrt_A2my2 = sqrt(Amy*(A+y)) */ if (y == 1 && x < DBL_EPSILON / 128) { /* * fp is of order x^2, and fm = x/2. * A = 1 (inexactly). */ *sqrt_A2my2 = sqrt(x) * sqrt((A + y) / 2); } else if (x >= DBL_EPSILON * fabs(y - 1)) { /* * Underflow will not occur because * x >= DBL_EPSILON/128 >= FOUR_SQRT_MIN * and * x >= DBL_EPSILON^2 >= FOUR_SQRT_MIN */ Amy = f(x, y + 1, R) + f(x, y - 1, S); *sqrt_A2my2 = sqrt(Amy * (A + y)); } else if (y > 1) { /* * fp = x*x/(y+1)/4, fm = x*x/(y-1)/4, and * A = y (inexactly). * * y < RECIP_EPSILON. So the following * scaling should avoid any underflow problems. */ *sqrt_A2my2 = x * (4 / DBL_EPSILON / DBL_EPSILON) * y / sqrt((y + 1) * (y - 1)); *new_y = y * (4 / DBL_EPSILON / DBL_EPSILON); } else { /* if (y < 1) */ /* * fm = 1-y >= DBL_EPSILON, fp is of order x^2, and * A = 1 (inexactly). */ *sqrt_A2my2 = sqrt((1 - y) * (1 + y)); } }}
/* * casinh(z) = z + O(z^3) as z -> 0 * * casinh(z) = sign(x)*clog(sign(x)*z) + O(1/z^2) as z -> infinity * The above formula works for the imaginary part as well, because * Im(casinh(z)) = sign(x)*atan2(sign(x)*y, fabs(x)) + O(y/z^3) * as z -> infinity, uniformly in y */_CCCL_HOST_DEVICE inline complex<double> casinh(complex<double> z){ double x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y; int B_is_usable; complex<double> w; const double RECIP_EPSILON = 1.0 / DBL_EPSILON; const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */ x = z.real(); y = z.imag(); ax = fabs(x); ay = fabs(y);
if (isnan(x) || isnan(y)) { /* casinh(+-Inf + I*NaN) = +-Inf + I*NaN */ if (isinf(x)) { return (complex<double>(x, y + y)); } /* casinh(NaN + I*+-Inf) = opt(+-)Inf + I*NaN */ if (isinf(y)) { return (complex<double>(y, x + x)); } /* casinh(NaN + I*0) = NaN + I*0 */ if (y == 0) { return (complex<double>(x + x, y)); } /* * All other cases involving NaN return NaN + I*NaN. * C99 leaves it optional whether to raise invalid if one of * the arguments is not NaN, so we opt not to raise it. */ return (complex<double>(x + 0.0 + (y + 0.0), x + 0.0 + (y + 0.0))); }
if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { /* clog...() will raise inexact unless x or y is infinite. */ if (signbit(x) == 0) { w = clog_for_large_values(z) + m_ln2; } else { w = clog_for_large_values(-z) + m_ln2; } return (complex<double>(copysign(w.real(), x), copysign(w.imag(), y))); }
/* Avoid spuriously raising inexact for z = 0. */ if (x == 0 && y == 0) { return (z); }
/* All remaining cases are inexact. */ raise_inexact();
const double SQRT_6_EPSILON = 3.6500241499888571e-8; /* 0x13988e1409212e.0p-77 */ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) { return (z); }
do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y); if (B_is_usable) { ry = asin(B); } else { ry = atan2(new_y, sqrt_A2my2); } return (complex<double>(copysign(rx, x), copysign(ry, y)));}
/* * casin(z) = reverse(casinh(reverse(z))) * where reverse(x + I*y) = y + I*x = I*conj(z). */_CCCL_HOST_DEVICE inline complex<double> casin(complex<double> z){ complex<double> w = casinh(complex<double>(z.imag(), z.real()));
return (complex<double>(w.imag(), w.real()));}
/* * cacos(z) = PI/2 - casin(z) * but do the computation carefully so cacos(z) is accurate when z is * close to 1. * * cacos(z) = PI/2 - z + O(z^3) as z -> 0 * * cacos(z) = -sign(y)*I*clog(z) + O(1/z^2) as z -> infinity * The above formula works for the real part as well, because * Re(cacos(z)) = atan2(fabs(y), x) + O(y/z^3) * as z -> infinity, uniformly in y */_CCCL_HOST_DEVICE inline complex<double> cacos(complex<double> z){ double x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x; int sx, sy; int B_is_usable; complex<double> w; const double pio2_hi = 1.5707963267948966e0; /* 0x1921fb54442d18.0p-52 */ const volatile double pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */ const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */
x = z.real(); y = z.imag(); sx = signbit(x); sy = signbit(y); ax = fabs(x); ay = fabs(y);
if (isnan(x) || isnan(y)) { /* cacos(+-Inf + I*NaN) = NaN + I*opt(-)Inf */ if (isinf(x)) { return (complex<double>(y + y, -infinity<double>())); } /* cacos(NaN + I*+-Inf) = NaN + I*-+Inf */ if (isinf(y)) { return (complex<double>(x + x, -y)); } /* cacos(0 + I*NaN) = PI/2 + I*NaN with inexact */ if (x == 0) { return (complex<double>(pio2_hi + pio2_lo, y + y)); } /* * All other cases involving NaN return NaN + I*NaN. * C99 leaves it optional whether to raise invalid if one of * the arguments is not NaN, so we opt not to raise it. */ return (complex<double>(x + 0.0 + (y + 0), x + 0.0 + (y + 0))); }
const double RECIP_EPSILON = 1.0 / DBL_EPSILON; if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { /* clog...() will raise inexact unless x or y is infinite. */ w = clog_for_large_values(z); rx = fabs(w.imag()); ry = w.real() + m_ln2; if (sy == 0) { ry = -ry; } return (complex<double>(rx, ry)); }
/* Avoid spuriously raising inexact for z = 1. */ if (x == 1.0 && y == 0.0) { return (complex<double>(0, -y)); }
/* All remaining cases are inexact. */ raise_inexact();
const double SQRT_6_EPSILON = 3.6500241499888571e-8; /* 0x13988e1409212e.0p-77 */ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) { return (complex<double>(pio2_hi - (x - pio2_lo), -y)); }
do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x); if (B_is_usable) { if (sx == 0) { rx = acos(B); } else { rx = acos(-B); } } else { if (sx == 0) { rx = atan2(sqrt_A2mx2, new_x); } else { rx = atan2(sqrt_A2mx2, -new_x); } } if (sy == 0) { ry = -ry; } return (complex<double>(rx, ry));}
/* * cacosh(z) = I*cacos(z) or -I*cacos(z) * where the sign is chosen so Re(cacosh(z)) >= 0. */_CCCL_HOST_DEVICE inline complex<double> cacosh(complex<double> z){ complex<double> w; double rx, ry;
w = cacos(z); rx = w.real(); ry = w.imag(); /* cacosh(NaN + I*NaN) = NaN + I*NaN */ if (isnan(rx) && isnan(ry)) { return (complex<double>(ry, rx)); } /* cacosh(NaN + I*+-Inf) = +Inf + I*NaN */ /* cacosh(+-Inf + I*NaN) = +Inf + I*NaN */ if (isnan(rx)) { return (complex<double>(fabs(ry), rx)); } /* cacosh(0 + I*NaN) = NaN + I*NaN */ if (isnan(ry)) { return (complex<double>(ry, ry)); } return (complex<double>(fabs(ry), copysign(rx, z.imag())));}
/* * Optimized version of clog() for |z| finite and larger than ~RECIP_EPSILON. */_CCCL_HOST_DEVICE inline complex<double> clog_for_large_values(complex<double> z){ double x, y; double ax, ay, t; const double m_e = 2.7182818284590452e0; /* 0x15bf0a8b145769.0p-51 */
x = z.real(); y = z.imag(); ax = fabs(x); ay = fabs(y); if (ax < ay) { t = ax; ax = ay; ay = t; }
/* * Avoid overflow in hypot() when x and y are both very large. * Divide x and y by E, and then add 1 to the logarithm. This depends * on E being larger than sqrt(2). * Dividing by E causes an insignificant loss of accuracy; however * this method is still poor since it is unnecessarily slow. */ if (ax > DBL_MAX / 2) { return (complex<double>(log(hypot(x / m_e, y / m_e)) + 1, atan2(y, x))); }
/* * Avoid overflow when x or y is large. Avoid underflow when x or * y is small. */ const double QUARTER_SQRT_MAX = 5.966672584960165394632772e-154; /* = 0x1p509; <= sqrt(DBL_MAX) / 4 */ const double SQRT_MIN = 1.491668146240041348658193e-154; /* = 0x1p-511; >= sqrt(DBL_MIN) */ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN) { return (complex<double>(log(hypot(x, y)), atan2(y, x))); }
return (complex<double>(log(ax * ax + ay * ay) / 2, atan2(y, x)));}
/* * ================= * | catanh, catan | * ================= */
/* * sum_squares(x,y) = x*x + y*y (or just x*x if y*y would underflow). * Assumes x*x and y*y will not overflow. * Assumes x and y are finite. * Assumes y is non-negative. * Assumes fabs(x) >= DBL_EPSILON. */_CCCL_HOST_DEVICE inline double sum_squares(double x, double y){ const double SQRT_MIN = 1.491668146240041348658193e-154; /* = 0x1p-511; >= sqrt(DBL_MIN) */ /* Avoid underflow when y is small. */ if (y < SQRT_MIN) { return (x * x); }
return (x * x + y * y);}
/* * real_part_reciprocal(x, y) = Re(1/(x+I*y)) = x/(x*x + y*y). * Assumes x and y are not NaN, and one of x and y is larger than * RECIP_EPSILON. We avoid unwarranted underflow. It is important to not use * the code creal(1/z), because the imaginary part may produce an unwanted * underflow. * This is only called in a context where inexact is always raised before * the call, so no effort is made to avoid or force inexact. */_CCCL_HOST_DEVICE inline double real_part_reciprocal(double x, double y){ double scale; uint32_t hx, hy; int32_t ix, iy;
/* * This code is inspired by the C99 document n1124.pdf, Section G.5.1, * example 2. */ get_high_word(hx, x); ix = hx & 0x7ff00000; get_high_word(hy, y); iy = hy & 0x7ff00000; // #define BIAS (DBL_MAX_EXP - 1) const int BIAS = DBL_MAX_EXP - 1; /* XXX more guard digits are useful iff there is extra precision. */ // #define CUTOFF (DBL_MANT_DIG / 2 + 1) /* just half or 1 guard digit */ const int CUTOFF = (DBL_MANT_DIG / 2 + 1); if (ix - iy >= CUTOFF << 20 || isinf(x)) { return (1 / x); /* +-Inf -> +-0 is special */ } if (iy - ix >= CUTOFF << 20) { return (x / y / y); /* should avoid double div, but hard */ } if (ix <= (BIAS + DBL_MAX_EXP / 2 - CUTOFF) << 20) { return (x / (x * x + y * y)); } scale = 1; set_high_word(scale, 0x7ff00000 - ix); /* 2**(1-ilogb(x)) */ x *= scale; y *= scale; return (x / (x * x + y * y) * scale);}
/* * catanh(z) = log((1+z)/(1-z)) / 2 * = log1p(4*x / |z-1|^2) / 4 * + I * atan2(2*y, (1-x)*(1+x)-y*y) / 2 * * catanh(z) = z + O(z^3) as z -> 0 * * catanh(z) = 1/z + sign(y)*I*PI/2 + O(1/z^3) as z -> infinity * The above formula works for the real part as well, because * Re(catanh(z)) = x/|z|^2 + O(x/z^4) * as z -> infinity, uniformly in x */_CCCL_HOST_DEVICE inline complex<double> catanh(complex<double> z){ double x, y, ax, ay, rx, ry; const volatile double pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */ const double pio2_hi = 1.5707963267948966e0; /* 0x1921fb54442d18.0p-52 */
x = z.real(); y = z.imag(); ax = fabs(x); ay = fabs(y);
/* This helps handle many cases. */ if (y == 0 && ax <= 1) { return (complex<double>(atanh(x), y)); }
/* To ensure the same accuracy as atan(), and to filter out z = 0. */ if (x == 0) { return (complex<double>(x, atan(y))); }
if (isnan(x) || isnan(y)) { /* catanh(+-Inf + I*NaN) = +-0 + I*NaN */ if (isinf(x)) { return (complex<double>(copysign(0.0, x), y + y)); } /* catanh(NaN + I*+-Inf) = sign(NaN)0 + I*+-PI/2 */ if (isinf(y)) { return (complex<double>(copysign(0.0, x), copysign(pio2_hi + pio2_lo, y))); } /* * All other cases involving NaN return NaN + I*NaN. * C99 leaves it optional whether to raise invalid if one of * the arguments is not NaN, so we opt not to raise it. */ return (complex<double>(x + 0.0 + (y + 0), x + 0.0 + (y + 0))); }
const double RECIP_EPSILON = 1.0 / DBL_EPSILON; if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { return (complex<double>(real_part_reciprocal(x, y), copysign(pio2_hi + pio2_lo, y))); }
const double SQRT_3_EPSILON = 2.5809568279517849e-8; /* 0x1bb67ae8584caa.0p-78 */ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { /* * z = 0 was filtered out above. All other cases must raise * inexact, but this is the only only that needs to do it * explicitly. */ raise_inexact(); return (z); }
const double m_ln2 = 6.9314718055994531e-1; /* 0x162e42fefa39ef.0p-53 */ if (ax == 1 && ay < DBL_EPSILON) { rx = (m_ln2 - log(ay)) / 2; } else { rx = log1p(4 * ax / sum_squares(ax - 1, ay)) / 4; }
if (ax == 1) { ry = atan2(2.0, -ay) / 2; } else if (ay < DBL_EPSILON) { ry = atan2(2 * ay, (1 - ax) * (1 + ax)) / 2; } else { ry = atan2(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2; }
return (complex<double>(copysign(rx, x), copysign(ry, y)));}
/* * catan(z) = reverse(catanh(reverse(z))) * where reverse(x + I*y) = y + I*x = I*conj(z). */_CCCL_HOST_DEVICE inline complex<double> catan(complex<double> z){ complex<double> w = catanh(complex<double>(z.imag(), z.real())); return (complex<double>(w.imag(), w.real()));}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> acos(const complex<ValueType>& z){ const complex<ValueType> ret = thrust::asin(z); const ValueType pi = ValueType(3.14159265358979323846); return complex<ValueType>(pi / 2 - ret.real(), -ret.imag());}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> asin(const complex<ValueType>& z){ const complex<ValueType> i(0, 1); return -i * asinh(i * z);}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> atan(const complex<ValueType>& z){ const complex<ValueType> i(0, 1); return -i * thrust::atanh(i * z);}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> acosh(const complex<ValueType>& z){ thrust::complex<ValueType> ret( (z.real() - z.imag()) * (z.real() + z.imag()) - ValueType(1.0), ValueType(2.0) * z.real() * z.imag()); ret = thrust::sqrt(ret); if (z.real() < ValueType(0.0)) { ret = -ret; } ret += z; ret = thrust::log(ret); if (ret.real() < ValueType(0.0)) { ret = -ret; } return ret;}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> asinh(const complex<ValueType>& z){ return thrust::log(thrust::sqrt(z * z + ValueType(1)) + z);}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> atanh(const complex<ValueType>& z){ ValueType imag2 = z.imag() * z.imag(); ValueType n = ValueType(1.0) + z.real(); n = imag2 + n * n;
ValueType d = ValueType(1.0) - z.real(); d = imag2 + d * d; complex<ValueType> ret(ValueType(0.25) * (std::log(n) - std::log(d)), 0);
d = ValueType(1.0) - z.real() * z.real() - imag2;
ret.imag(ValueType(0.5) * std::atan2(ValueType(2.0) * z.imag(), d)); return ret;}
template <>_CCCL_HOST_DEVICE inline complex<double> acos(const complex<double>& z){ return detail::complex::cacos(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> asin(const complex<double>& z){ return detail::complex::casin(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> atan(const complex<double>& z){ return detail::complex::catan(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> acosh(const complex<double>& z){ return detail::complex::cacosh(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> asinh(const complex<double>& z){ return detail::complex::casinh(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> atanh(const complex<double>& z){ return detail::complex::catanh(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* * Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>: * freebsd/lib/msun/src/catrig.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cfloat>#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<float> clog_for_large_values(complex<float> z);
/* * The algorithm is very close to that in "Implementing the complex arcsine * and arccosine functions using exception handling" by T. E. Hull, Thomas F. * Fairgrieve, and Ping Tak Peter Tang, published in ACM Transactions on * Mathematical Software, Volume 23 Issue 3, 1997, Pages 299-335, * http://dl.acm.org/citation.cfm?id=275324. * * See catrig.c for complete comments. * * XXX comments were removed automatically, and even short ones on the right * of statements were removed (all of them), contrary to normal style. Only * a few comments on the right of declarations remain. */
_CCCL_HOST_DEVICE inline float f(float a, float b, float hypot_a_b){ if (b < 0.0f) { return ((hypot_a_b - b) / 2.0f); } if (b == 0.0f) { return (a / 2.0f); } return (a * a / (hypot_a_b + b) / 2.0f);}
/* * All the hard work is contained in this function. * x and y are assumed positive or zero, and less than RECIP_EPSILON. * Upon return: * rx = Re(casinh(z)) = -Im(cacos(y + I*x)). * B_is_usable is set to 1 if the value of B is usable. * If B_is_usable is set to 0, sqrt_A2my2 = sqrt(A*A - y*y), and new_y = y. * If returning sqrt_A2my2 has potential to result in an underflow, it is * rescaled, and new_y is similarly rescaled. */_CCCL_HOST_DEVICE inline voiddo_hard_work(float x, float y, float* rx, int* B_is_usable, float* B, float* sqrt_A2my2, float* new_y){ float R, S, A; /* A, B, R, and S are as in Hull et al. */ float Am1, Amy; /* A-1, A-y. */ const float A_crossover = 10; /* Hull et al suggest 1.5, but 10 works better */ const float FOUR_SQRT_MIN = 4.336808689942017736029811e-19f; ; /* =0x1p-61; >= 4 * sqrt(FLT_MIN) */ const float B_crossover = 0.6417f; /* suggested by Hull et al */ R = hypotf(x, y + 1); S = hypotf(x, y - 1);
A = (R + S) / 2; if (A < 1) { A = 1; }
if (A < A_crossover) { if (y == 1 && x < FLT_EPSILON * FLT_EPSILON / 128) { *rx = sqrtf(x); } else if (x >= FLT_EPSILON * fabsf(y - 1)) { Am1 = f(x, 1 + y, R) + f(x, 1 - y, S); *rx = log1pf(Am1 + sqrtf(Am1 * (A + 1))); } else if (y < 1) { *rx = x / sqrtf((1 - y) * (1 + y)); } else { *rx = log1pf((y - 1) + sqrtf((y - 1) * (y + 1))); } } else { *rx = logf(A + sqrtf(A * A - 1)); }
*new_y = y;
if (y < FOUR_SQRT_MIN) { *B_is_usable = 0; *sqrt_A2my2 = A * (2 / FLT_EPSILON); *new_y = y * (2 / FLT_EPSILON); return; }
*B = y / A; *B_is_usable = 1;
if (*B > B_crossover) { *B_is_usable = 0; if (y == 1 && x < FLT_EPSILON / 128) { *sqrt_A2my2 = sqrtf(x) * sqrtf((A + y) / 2); } else if (x >= FLT_EPSILON * fabsf(y - 1)) { Amy = f(x, y + 1, R) + f(x, y - 1, S); *sqrt_A2my2 = sqrtf(Amy * (A + y)); } else if (y > 1) { *sqrt_A2my2 = x * (4 / FLT_EPSILON / FLT_EPSILON) * y / sqrtf((y + 1) * (y - 1)); *new_y = y * (4 / FLT_EPSILON / FLT_EPSILON); } else { *sqrt_A2my2 = sqrtf((1 - y) * (1 + y)); } }}
_CCCL_HOST_DEVICE inline complex<float> casinhf(complex<float> z){ float x, y, ax, ay, rx, ry, B, sqrt_A2my2, new_y; int B_is_usable; complex<float> w; const float RECIP_EPSILON = 1.0f / FLT_EPSILON; const float m_ln2 = 6.9314718055994531e-1f; /* 0x162e42fefa39ef.0p-53 */ x = z.real(); y = z.imag(); ax = fabsf(x); ay = fabsf(y);
if (isnan(x) || isnan(y)) { if (isinf(x)) { return (complex<float>(x, y + y)); } if (isinf(y)) { return (complex<float>(y, x + x)); } if (y == 0) { return (complex<float>(x + x, y)); } return (complex<float>(x + 0.0f + (y + 0), x + 0.0f + (y + 0))); }
if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { if (signbit(x) == 0) { w = clog_for_large_values(z) + m_ln2; } else { w = clog_for_large_values(-z) + m_ln2; } return (complex<float>(copysignf(w.real(), x), copysignf(w.imag(), y))); }
if (x == 0 && y == 0) { return (z); }
raise_inexact();
const float SQRT_6_EPSILON = 8.4572793338e-4f; /* 0xddb3d7.0p-34 */ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) { return (z); }
do_hard_work(ax, ay, &rx, &B_is_usable, &B, &sqrt_A2my2, &new_y); if (B_is_usable) { ry = asinf(B); } else { ry = atan2f(new_y, sqrt_A2my2); } return (complex<float>(copysignf(rx, x), copysignf(ry, y)));}
_CCCL_HOST_DEVICE inline complex<float> casinf(complex<float> z){ complex<float> w = casinhf(complex<float>(z.imag(), z.real()));
return (complex<float>(w.imag(), w.real()));}
_CCCL_HOST_DEVICE inline complex<float> cacosf(complex<float> z){ float x, y, ax, ay, rx, ry, B, sqrt_A2mx2, new_x; int sx, sy; int B_is_usable; complex<float> w; const float pio2_hi = 1.5707963267948966e0f; /* 0x1921fb54442d18.0p-52 */ const volatile float pio2_lo = 6.1232339957367659e-17f; /* 0x11a62633145c07.0p-106 */ const float m_ln2 = 6.9314718055994531e-1f; /* 0x162e42fefa39ef.0p-53 */
x = z.real(); y = z.imag(); sx = signbit(x); sy = signbit(y); ax = fabsf(x); ay = fabsf(y);
if (isnan(x) || isnan(y)) { if (isinf(x)) { return (complex<float>(y + y, -infinity<float>())); } if (isinf(y)) { return (complex<float>(x + x, -y)); } if (x == 0) { return (complex<float>(pio2_hi + pio2_lo, y + y)); } return (complex<float>(x + 0.0f + (y + 0), x + 0.0f + (y + 0))); }
const float RECIP_EPSILON = 1.0f / FLT_EPSILON; if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { w = clog_for_large_values(z); rx = fabsf(w.imag()); ry = w.real() + m_ln2; if (sy == 0) { ry = -ry; } return (complex<float>(rx, ry)); }
if (x == 1 && y == 0) { return (complex<float>(0, -y)); }
raise_inexact();
const float SQRT_6_EPSILON = 8.4572793338e-4f; /* 0xddb3d7.0p-34 */ if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) { return (complex<float>(pio2_hi - (x - pio2_lo), -y)); }
do_hard_work(ay, ax, &ry, &B_is_usable, &B, &sqrt_A2mx2, &new_x); if (B_is_usable) { if (sx == 0) { rx = acosf(B); } else { rx = acosf(-B); } } else { if (sx == 0) { rx = atan2f(sqrt_A2mx2, new_x); } else { rx = atan2f(sqrt_A2mx2, -new_x); } } if (sy == 0) { ry = -ry; } return (complex<float>(rx, ry));}
_CCCL_HOST_DEVICE inline complex<float> cacoshf(complex<float> z){ complex<float> w; float rx, ry;
w = cacosf(z); rx = w.real(); ry = w.imag(); /* cacosh(NaN + I*NaN) = NaN + I*NaN */ if (isnan(rx) && isnan(ry)) { return (complex<float>(ry, rx)); } /* cacosh(NaN + I*+-Inf) = +Inf + I*NaN */ /* cacosh(+-Inf + I*NaN) = +Inf + I*NaN */ if (isnan(rx)) { return (complex<float>(fabsf(ry), rx)); } /* cacosh(0 + I*NaN) = NaN + I*NaN */ if (isnan(ry)) { return (complex<float>(ry, ry)); } return (complex<float>(fabsf(ry), copysignf(rx, z.imag())));}
/* * Optimized version of clog() for |z| finite and larger than ~RECIP_EPSILON. */_CCCL_HOST_DEVICE inline complex<float> clog_for_large_values(complex<float> z){ float x, y; float ax, ay, t; const float m_e = 2.7182818284590452e0f; /* 0x15bf0a8b145769.0p-51 */
x = z.real(); y = z.imag(); ax = fabsf(x); ay = fabsf(y); if (ax < ay) { t = ax; ax = ay; ay = t; }
if (ax > FLT_MAX / 2) { return (complex<float>(logf(hypotf(x / m_e, y / m_e)) + 1, atan2f(y, x))); }
const float QUARTER_SQRT_MAX = 2.3058430092136939520000000e+18f; /* = 0x1p61; <= sqrt(FLT_MAX) / 4 */ const float SQRT_MIN = 1.084202172485504434007453e-19f; /* 0x1p-63; >= sqrt(FLT_MIN) */ if (ax > QUARTER_SQRT_MAX || ay < SQRT_MIN) { return (complex<float>(logf(hypotf(x, y)), atan2f(y, x))); }
return (complex<float>(logf(ax * ax + ay * ay) / 2, atan2f(y, x)));}
/* * ================= * | catanh, catan | * ================= */
/* * sum_squares(x,y) = x*x + y*y (or just x*x if y*y would underflow). * Assumes x*x and y*y will not overflow. * Assumes x and y are finite. * Assumes y is non-negative. * Assumes fabsf(x) >= FLT_EPSILON. */_CCCL_HOST_DEVICE inline float sum_squares(float x, float y){ const float SQRT_MIN = 1.084202172485504434007453e-19f; /* 0x1p-63; >= sqrt(FLT_MIN) */ /* Avoid underflow when y is small. */ if (y < SQRT_MIN) { return (x * x); }
return (x * x + y * y);}
_CCCL_HOST_DEVICE inline float real_part_reciprocal(float x, float y){ float scale; uint32_t hx, hy; int32_t ix, iy;
get_float_word(hx, x); ix = hx & 0x7f800000; get_float_word(hy, y); iy = hy & 0x7f800000; // #define BIAS (FLT_MAX_EXP - 1) const int BIAS = FLT_MAX_EXP - 1; // #define CUTOFF (FLT_MANT_DIG / 2 + 1) const int CUTOFF = (FLT_MANT_DIG / 2 + 1); if (ix - iy >= CUTOFF << 23 || isinf(x)) { return (1 / x); } if (iy - ix >= CUTOFF << 23) { return (x / y / y); } if (ix <= (BIAS + FLT_MAX_EXP / 2 - CUTOFF) << 23) { return (x / (x * x + y * y)); } set_float_word(scale, 0x7f800000 - ix); x *= scale; y *= scale; return (x / (x * x + y * y) * scale);}
_CCCL_HOST_DEVICE inline complex<float> catanhf(complex<float> z){ float x, y, ax, ay, rx, ry; const volatile float pio2_lo = 6.1232339957367659e-17f; /* 0x11a62633145c07.0p-106 */ const float pio2_hi = 1.5707963267948966e0f; /* 0x1921fb54442d18.0p-52 */
x = z.real(); y = z.imag(); ax = fabsf(x); ay = fabsf(y);
if (y == 0 && ax <= 1) { return (complex<float>(atanhf(x), y)); }
if (x == 0) { return (complex<float>(x, atanf(y))); }
if (isnan(x) || isnan(y)) { if (isinf(x)) { return (complex<float>(copysignf(0, x), y + y)); } if (isinf(y)) { return (complex<float>(copysignf(0, x), copysignf(pio2_hi + pio2_lo, y))); } return (complex<float>(x + 0.0f + (y + 0.0f), x + 0.0f + (y + 0.0f))); }
const float RECIP_EPSILON = 1.0f / FLT_EPSILON; if (ax > RECIP_EPSILON || ay > RECIP_EPSILON) { return (complex<float>(real_part_reciprocal(x, y), copysignf(pio2_hi + pio2_lo, y))); }
const float SQRT_3_EPSILON = 5.9801995673e-4f; /* 0x9cc471.0p-34 */ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { raise_inexact(); return (z); }
const float m_ln2 = 6.9314718056e-1f; /* 0xb17218.0p-24 */ if (ax == 1 && ay < FLT_EPSILON) { rx = (m_ln2 - logf(ay)) / 2; } else { rx = log1pf(4 * ax / sum_squares(ax - 1, ay)) / 4; }
if (ax == 1) { ry = atan2f(2, -ay) / 2; } else if (ay < FLT_EPSILON) { ry = atan2f(2 * ay, (1 - ax) * (1 + ax)) / 2; } else { ry = atan2f(2 * ay, (1 - ax) * (1 + ax) - ay * ay) / 2; }
return (complex<float>(copysignf(rx, x), copysignf(ry, y)));}
_CCCL_HOST_DEVICE inline complex<float> catanf(complex<float> z){ complex<float> w = catanhf(complex<float>(z.imag(), z.real())); return (complex<float>(w.imag(), w.real()));}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> acos(const complex<float>& z){ return detail::complex::cacosf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> asin(const complex<float>& z){ return detail::complex::casinf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> atan(const complex<float>& z){ return detail::complex::catanf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> acosh(const complex<float>& z){ return detail::complex::cacoshf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> asinh(const complex<float>& z){ return detail::complex::casinhf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> atanh(const complex<float>& z){ return detail::complex::catanhf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* adapted from FreeBSD: * lib/msun/src/s_ccosh.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/cexp.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
/* * Hyperbolic cosine of a complex argument z = x + i y. * * cosh(z) = cosh(x+iy) * = cosh(x) cos(y) + i sinh(x) sin(y). * * Exceptional values are noted in the comments within the source code. * These values and the return value were taken from n1124.pdf. */
_CCCL_HOST_DEVICE inline thrust::complex<double> ccosh(const thrust::complex<double>& z){ const double huge = 8.98846567431157953864652595395e+307; // 0x1p1023 double x, y, h; uint32_t hx, hy, ix, iy, lx, ly;
x = z.real(); y = z.imag();
extract_words(hx, lx, x); extract_words(hy, ly, y);
ix = 0x7fffffff & hx; iy = 0x7fffffff & hy;
/* Handle the nearly-non-exceptional cases where x and y are finite. */ if (ix < 0x7ff00000 && iy < 0x7ff00000) { if ((iy | ly) == 0) { return (thrust::complex<double>(::cosh(x), x * y)); } if (ix < 0x40360000) /* small x: normal case */ { return (thrust::complex<double>(::cosh(x) * ::cos(y), ::sinh(x) * ::sin(y))); }
/* |x| >= 22, so cosh(x) ~= exp(|x|) */ if (ix < 0x40862e42) { /* x < 710: exp(|x|) won't overflow */ h = ::exp(::fabs(x)) * 0.5; return (thrust::complex<double>(h * cos(y), copysign(h, x) * sin(y))); } else if (ix < 0x4096bbaa) { /* x < 1455: scale to avoid overflow */ thrust::complex<double> z_; z_ = ldexp_cexp(thrust::complex<double>(fabs(x), y), -1); return (thrust::complex<double>(z_.real(), z_.imag() * copysign(1.0, x))); } else { /* x >= 1455: the result always overflows */ h = huge * x; return (thrust::complex<double>(h * h * cos(y), h * sin(y))); } }
/* * cosh(+-0 +- I Inf) = dNaN + I sign(d(+-0, dNaN))0. * The sign of 0 in the result is unspecified. Choice = normally * the same as dNaN. Raise the invalid floating-point exception. * * cosh(+-0 +- I NaN) = d(NaN) + I sign(d(+-0, NaN))0. * The sign of 0 in the result is unspecified. Choice = normally * the same as d(NaN). */ if ((ix | lx) == 0 && iy >= 0x7ff00000) { return (thrust::complex<double>(y - y, copysign(0.0, x * (y - y)))); }
/* * cosh(+-Inf +- I 0) = +Inf + I (+-)(+-)0. * * cosh(NaN +- I 0) = d(NaN) + I sign(d(NaN, +-0))0. * The sign of 0 in the result is unspecified. */ if ((iy | ly) == 0 && ix >= 0x7ff00000) { if (((hx & 0xfffff) | lx) == 0) { return (thrust::complex<double>(x * x, copysign(0.0, x) * y)); } return (thrust::complex<double>(x * x, copysign(0.0, (x + x) * y))); }
/* * cosh(x +- I Inf) = dNaN + I dNaN. * Raise the invalid floating-point exception for finite nonzero x. * * cosh(x + I NaN) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception for finite * nonzero x. Choice = don't raise (except for signaling NaNs). */ if (ix < 0x7ff00000 && iy >= 0x7ff00000) { return (thrust::complex<double>(y - y, x * (y - y))); }
/* * cosh(+-Inf + I NaN) = +Inf + I d(NaN). * * cosh(+-Inf +- I Inf) = +Inf + I dNaN. * The sign of Inf in the result is unspecified. Choice = always +. * Raise the invalid floating-point exception. * * cosh(+-Inf + I y) = +Inf cos(y) +- I Inf sin(y) */ if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { if (iy >= 0x7ff00000) { return (thrust::complex<double>(x * x, x * (y - y))); } return (thrust::complex<double>((x * x) * cos(y), x * sin(y))); }
/* * cosh(NaN + I NaN) = d(NaN) + I d(NaN). * * cosh(NaN +- I Inf) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception. * Choice = raise. * * cosh(NaN + I y) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception for finite * nonzero y. Choice = don't raise (except for signaling NaNs). */ return (thrust::complex<double>((x * x) * (y - y), (x + x) * (y - y)));}
_CCCL_HOST_DEVICE inline thrust::complex<double> ccos(const thrust::complex<double>& z){ /* ccos(z) = ccosh(I * z) */ return (ccosh(thrust::complex<double>(-z.imag(), z.real())));}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> cos(const complex<ValueType>& z){ const ValueType re = z.real(); const ValueType im = z.imag(); return complex<ValueType>(std::cos(re) * std::cosh(im), -std::sin(re) * std::sinh(im));}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> cosh(const complex<ValueType>& z){ const ValueType re = z.real(); const ValueType im = z.imag(); return complex<ValueType>(std::cosh(re) * std::cos(im), std::sinh(re) * std::sin(im));}
template <>_CCCL_HOST_DEVICE inline thrust::complex<double> cos(const thrust::complex<double>& z){ return detail::complex::ccos(z);}
template <>_CCCL_HOST_DEVICE inline thrust::complex<double> cosh(const thrust::complex<double>& z){ return detail::complex::ccosh(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* adapted from FreeBSD: * lib/msun/src/s_ccoshf.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/cexp.h>#include <thrust/detail/complex/cexpf.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<float> ccoshf(const complex<float>& z){ float x, y, h; uint32_t hx, hy, ix, iy; const float huge = 1.70141183460469231731687303716e+38; // 0x1p127;
x = z.real(); y = z.imag();
get_float_word(hx, x); get_float_word(hy, y);
ix = 0x7fffffff & hx; iy = 0x7fffffff & hy; if (ix < 0x7f800000 && iy < 0x7f800000) { if (iy == 0) { return (complex<float>(coshf(x), x * y)); } if (ix < 0x41100000) { /* small x: normal case */ return (complex<float>(coshf(x) * cosf(y), sinhf(x) * sinf(y))); } /* |x| >= 9, so cosh(x) ~= exp(|x|) */ if (ix < 0x42b17218) { /* x < 88.7: expf(|x|) won't overflow */ h = expf(fabsf(x)) * 0.5f; return (complex<float>(h * cosf(y), copysignf(h, x) * sinf(y))); } else if (ix < 0x4340b1e7) { /* x < 192.7: scale to avoid overflow */ thrust::complex<float> z_; z_ = ldexp_cexpf(complex<float>(fabsf(x), y), -1); return (complex<float>(z_.real(), z_.imag() * copysignf(1.0f, x))); } else { /* x >= 192.7: the result always overflows */ h = huge * x; return (complex<float>(h * h * cosf(y), h * sinf(y))); } }
if (ix == 0 && iy >= 0x7f800000) { return (complex<float>(y - y, copysignf(0.0f, x * (y - y)))); } if (iy == 0 && ix >= 0x7f800000) { if ((hx & 0x7fffff) == 0) { return (complex<float>(x * x, copysignf(0.0f, x) * y)); } return (complex<float>(x * x, copysignf(0.0f, (x + x) * y))); }
if (ix < 0x7f800000 && iy >= 0x7f800000) { return (complex<float>(y - y, x * (y - y))); }
if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { if (iy >= 0x7f800000) { return (complex<float>(x * x, x * (y - y))); } return (complex<float>((x * x) * cosf(y), x * sinf(y))); } return (complex<float>((x * x) * (y - y), (x + x) * (y - y)));}
_CCCL_HOST_DEVICE inline complex<float> ccosf(const complex<float>& z){ return (ccoshf(complex<float>(-z.imag(), z.real())));}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> cos(const complex<float>& z){ return detail::complex::ccosf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> cosh(const complex<float>& z){ return detail::complex::ccoshf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* adapted from FreeBSD: * lib/msun/src/s_cexp.c * lib/msun/src/k_exp.c * */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{/* * Compute exp(x), scaled to avoid spurious overflow. An exponent is * returned separately in 'expt'. * * Input: ln(DBL_MAX) <= x < ln(2 * DBL_MAX / DBL_MIN_DENORM) ~= 1454.91 * Output: 2**1023 <= y < 2**1024 */_CCCL_HOST_DEVICE inline double frexp_exp(double x, int* expt){ const uint32_t k = 1799; /* constant for reduction */ const double kln2 = 1246.97177782734161156; /* k * ln2 */
double exp_x; uint32_t hx;
/* * We use exp(x) = exp(x - kln2) * 2**k, carefully chosen to * minimize |exp(kln2) - 2**k|. We also scale the exponent of * exp_x to MAX_EXP so that the result can be multiplied by * a tiny number without losing accuracy due to denormalization. */ exp_x = exp(x - kln2); get_high_word(hx, exp_x); *expt = (hx >> 20) - (0x3ff + 1023) + k; set_high_word(exp_x, (hx & 0xfffff) | ((0x3ff + 1023) << 20)); return (exp_x);}
_CCCL_HOST_DEVICE inline complex<double> ldexp_cexp(complex<double> z, int expt){ double x, y, exp_x, scale1, scale2; int ex_expt, half_expt;
x = z.real(); y = z.imag(); exp_x = frexp_exp(x, &ex_expt); expt += ex_expt;
/* * Arrange so that scale1 * scale2 == 2**expt. We use this to * compensate for scalbn being horrendously slow. */ half_expt = expt / 2; insert_words(scale1, (0x3ff + half_expt) << 20, 0); half_expt = expt - half_expt; insert_words(scale2, (0x3ff + half_expt) << 20, 0);
return (complex<double>(cos(y) * exp_x * scale1 * scale2, sin(y) * exp_x * scale1 * scale2));}
_CCCL_HOST_DEVICE inline complex<double> cexp(const complex<double>& z){ double x, y, exp_x; uint32_t hx, hy, lx, ly;
const uint32_t exp_ovfl = 0x40862e42, /* high bits of MAX_EXP * ln2 ~= 710 */ cexp_ovfl = 0x4096b8e4; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
x = z.real(); y = z.imag();
extract_words(hy, ly, y); hy &= 0x7fffffff;
/* cexp(x + I 0) = exp(x) + I 0 */ if ((hy | ly) == 0) { return (complex<double>(exp(x), y)); } extract_words(hx, lx, x); /* cexp(0 + I y) = cos(y) + I sin(y) */ if (((hx & 0x7fffffff) | lx) == 0) { return (complex<double>(cos(y), sin(y))); }
if (hy >= 0x7ff00000) { if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) { /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ return (complex<double>(y - y, y - y)); } else if (hx & 0x80000000) { /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ return (complex<double>(0.0, 0.0)); } else { /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ return (complex<double>(x, y - y)); } }
if (hx >= exp_ovfl && hx <= cexp_ovfl) { /* * x is between 709.7 and 1454.3, so we must scale to avoid * overflow in exp(x). */ return (ldexp_cexp(z, 0)); } else { /* * Cases covered here: * - x < exp_ovfl and exp(x) won't overflow (common case) * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 * - x = +-Inf (generated by exp()) * - x = NaN (spurious inexact exception from y) */ exp_x = std::exp(x); return (complex<double>(exp_x * cos(y), exp_x * sin(y))); }}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> exp(const complex<ValueType>& z){ return polar(std::exp(z.real()), z.imag());}
template <>_CCCL_HOST_DEVICE inline complex<double> exp(const complex<double>& z){ return detail::complex::cexp(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2011 David Schultz <das@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* adapted from FreeBSD: * lib/msun/src/s_cexpf.c * lib/msun/src/k_exp.c * */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
_CCCL_HOST_DEVICE inline float frexp_expf(float x, int* expt){ const uint32_t k = 235; /* constant for reduction */ const float kln2 = 162.88958740F; /* k * ln2 */
// should this be a double instead? float exp_x; uint32_t hx;
exp_x = expf(x - kln2); get_float_word(hx, exp_x); *expt = (hx >> 23) - (0x7f + 127) + k; set_float_word(exp_x, (hx & 0x7fffff) | ((0x7f + 127) << 23)); return (exp_x);}
_CCCL_HOST_DEVICE inline complex<float> ldexp_cexpf(complex<float> z, int expt){ float x, y, exp_x, scale1, scale2; int ex_expt, half_expt;
x = z.real(); y = z.imag(); exp_x = frexp_expf(x, &ex_expt); expt += ex_expt;
half_expt = expt / 2; set_float_word(scale1, (0x7f + half_expt) << 23); half_expt = expt - half_expt; set_float_word(scale2, (0x7f + half_expt) << 23);
return (complex<float>(std::cos(y) * exp_x * scale1 * scale2, std::sin(y) * exp_x * scale1 * scale2));}
_CCCL_HOST_DEVICE inline complex<float> cexpf(const complex<float>& z){ float x, y, exp_x; uint32_t hx, hy;
const uint32_t exp_ovfl = 0x42b17218, /* MAX_EXP * ln2 ~= 88.722839355 */ cexp_ovfl = 0x43400074; /* (MAX_EXP - MIN_DENORM_EXP) * ln2 */
x = z.real(); y = z.imag();
get_float_word(hy, y); hy &= 0x7fffffff;
/* cexp(x + I 0) = exp(x) + I 0 */ if (hy == 0) { return (complex<float>(std::exp(x), y)); } get_float_word(hx, x); /* cexp(0 + I y) = cos(y) + I sin(y) */ if ((hx & 0x7fffffff) == 0) { return (complex<float>(std::cos(y), std::sin(y))); } if (hy >= 0x7f800000) { if ((hx & 0x7fffffff) != 0x7f800000) { /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ return (complex<float>(y - y, y - y)); } else if (hx & 0x80000000) { /* cexp(-Inf +- I Inf|NaN) = 0 + I 0 */ return (complex<float>(0.0, 0.0)); } else { /* cexp(+Inf +- I Inf|NaN) = Inf + I NaN */ return (complex<float>(x, y - y)); } }
if (hx >= exp_ovfl && hx <= cexp_ovfl) { /* * x is between 88.7 and 192, so we must scale to avoid * overflow in expf(x). */ return (ldexp_cexpf(z, 0)); } else { /* * Cases covered here: * - x < exp_ovfl and exp(x) won't overflow (common case) * - x > cexp_ovfl, so exp(x) * s overflows for all s > 0 * - x = +-Inf (generated by exp()) * - x = NaN (spurious inexact exception from y) */ exp_x = std::exp(x); return (complex<float>(exp_x * std::cos(y), exp_x * std::sin(y))); }}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> exp(const complex<float>& z){ return detail::complex::cexpf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223/* * Copyright 2008-2021 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* adapted from FreeBSDs msun:*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
/* round down to 18 = 54/3 bits */_CCCL_HOST_DEVICE inline double trim(double x){ uint32_t hi; get_high_word(hi, x); insert_words(x, hi & 0xfffffff8, 0); return x;}
_CCCL_HOST_DEVICE inline complex<double> clog(const complex<double>& z){ // Adapted from FreeBSDs msun double x, y; double ax, ay; double x0, y0, x1, y1, x2, y2, t, hm1; double val[12]; int i, sorted; const double e = 2.7182818284590452354;
x = z.real(); y = z.imag();
/* Handle NaNs using the general formula to mix them right. */ if (x != x || y != y) { return (complex<double>(std::log(norm(z)), std::atan2(y, x))); }
ax = std::abs(x); ay = std::abs(y); if (ax < ay) { t = ax; ax = ay; ay = t; }
/* * To avoid unnecessary overflow, if x and y are very large, divide x * and y by M_E, and then add 1 to the logarithm. This depends on * M_E being larger than sqrt(2). * There is a potential loss of accuracy caused by dividing by M_E, * but this case should happen extremely rarely. */ // if (ay > 5e307){ // For high values of ay -> hypotf(DBL_MAX,ay) = inf // We expect that for values at or below ay = 5e307 this should not happen if (ay > 5e307) { return (complex<double>(std::log(hypot(x / e, y / e)) + 1.0, std::atan2(y, x))); } if (ax == 1.) { if (ay < 1e-150) { return (complex<double>((ay * 0.5) * ay, std::atan2(y, x))); } return (complex<double>(log1p(ay * ay) * 0.5, std::atan2(y, x))); }
/* * Because atan2 and hypot conform to C99, this also covers all the * edge cases when x or y are 0 or infinite. */ if (ax < 1e-50 || ay < 1e-50 || ax > 1e50 || ay > 1e50) { return (complex<double>(std::log(hypot(x, y)), std::atan2(y, x))); }
/* * From this point on, we don't need to worry about underflow or * overflow in calculating ax*ax or ay*ay. */
/* Some easy cases. */
if (ax >= 1.0) { return (complex<double>(log1p((ax - 1) * (ax + 1) + ay * ay) * 0.5, atan2(y, x))); }
if (ax * ax + ay * ay <= 0.7) { return (complex<double>(std::log(ax * ax + ay * ay) * 0.5, std::atan2(y, x))); }
/* * Take extra care so that ULP of real part is small if hypot(x,y) is * moderately close to 1. */
x0 = trim(ax); ax = ax - x0; x1 = trim(ax); x2 = ax - x1; y0 = trim(ay); ay = ay - y0; y1 = trim(ay); y2 = ay - y1;
val[0] = x0 * x0; val[1] = y0 * y0; val[2] = 2 * x0 * x1; val[3] = 2 * y0 * y1; val[4] = x1 * x1; val[5] = y1 * y1; val[6] = 2 * x0 * x2; val[7] = 2 * y0 * y2; val[8] = 2 * x1 * x2; val[9] = 2 * y1 * y2; val[10] = x2 * x2; val[11] = y2 * y2;
/* Bubble sort. */
do { sorted = 1; for (i = 0; i < 11; i++) { if (val[i] < val[i + 1]) { sorted = 0; t = val[i]; val[i] = val[i + 1]; val[i + 1] = t; } } } while (!sorted);
hm1 = -1; for (i = 0; i < 12; i++) { hm1 += val[i]; } return (complex<double>(0.5 * log1p(hm1), atan2(y, x)));}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> log(const complex<ValueType>& z){ return complex<ValueType>(std::log(thrust::abs(z)), thrust::arg(z));}
template <>_CCCL_HOST_DEVICE inline complex<double> log(const complex<double>& z){ return detail::complex::clog(z);}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> log10(const complex<ValueType>& z){ // Using the explicit literal prevents compile time warnings in // devices that don't support doubles return thrust::log(z) / ValueType(2.30258509299404568402);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210/* * Copyright 2008-2021 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2012 Stephen Montgomery-Smith <stephen@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* adapted from FreeBSDs msun:*/
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
/* round down to 8 = 24/3 bits */_CCCL_HOST_DEVICE inline float trim(float x){ uint32_t hx; get_float_word(hx, x); hx &= 0xffff0000; float ret; set_float_word(ret, hx); return ret;}
_CCCL_HOST_DEVICE inline complex<float> clogf(const complex<float>& z){ // Adapted from FreeBSDs msun float x, y; float ax, ay; float x0, y0, x1, y1, x2, y2, t, hm1; float val[12]; int i, sorted; const float e = 2.7182818284590452354f;
x = z.real(); y = z.imag();
/* Handle NaNs using the general formula to mix them right. */ if (x != x || y != y) { return (complex<float>(std::log(norm(z)), std::atan2(y, x))); }
ax = std::abs(x); ay = std::abs(y); if (ax < ay) { t = ax; ax = ay; ay = t; }
/* * To avoid unnecessary overflow, if x and y are very large, divide x * and y by M_E, and then add 1 to the logarithm. This depends on * M_E being larger than sqrt(2). * There is a potential loss of accuracy caused by dividing by M_E, * but this case should happen extremely rarely. */ // For high values of ay -> hypotf(FLT_MAX,ay) = inf // We expect that for values at or below ay = 1e34f this should not happen if (ay > 1e34f) { return (complex<float>(std::log(hypotf(x / e, y / e)) + 1.0f, std::atan2(y, x))); } if (ax == 1.f) { if (ay < 1e-19f) { return (complex<float>((ay * 0.5f) * ay, std::atan2(y, x))); } return (complex<float>(log1pf(ay * ay) * 0.5f, std::atan2(y, x))); }
/* * Because atan2 and hypot conform to C99, this also covers all the * edge cases when x or y are 0 or infinite. */ if (ax < 1e-6f || ay < 1e-6f || ax > 1e6f || ay > 1e6f) { return (complex<float>(std::log(hypotf(x, y)), std::atan2(y, x))); }
/* * From this point on, we don't need to worry about underflow or * overflow in calculating ax*ax or ay*ay. */
/* Some easy cases. */
if (ax >= 1.0f) { return (complex<float>(log1pf((ax - 1.f) * (ax + 1.f) + ay * ay) * 0.5f, atan2(y, x))); }
if (ax * ax + ay * ay <= 0.7f) { return (complex<float>(std::log(ax * ax + ay * ay) * 0.5f, std::atan2(y, x))); }
/* * Take extra care so that ULP of real part is small if hypot(x,y) is * moderately close to 1. */
x0 = trim(ax); ax = ax - x0; x1 = trim(ax); x2 = ax - x1; y0 = trim(ay); ay = ay - y0; y1 = trim(ay); y2 = ay - y1;
val[0] = x0 * x0; val[1] = y0 * y0; val[2] = 2 * x0 * x1; val[3] = 2 * y0 * y1; val[4] = x1 * x1; val[5] = y1 * y1; val[6] = 2 * x0 * x2; val[7] = 2 * y0 * y2; val[8] = 2 * x1 * x2; val[9] = 2 * y1 * y2; val[10] = x2 * x2; val[11] = y2 * y2;
/* Bubble sort. */
do { sorted = 1; for (i = 0; i < 11; i++) { if (val[i] < val[i + 1]) { sorted = 0; t = val[i]; val[i] = val[i + 1]; val[i + 1] = t; } } } while (!sorted);
hm1 = -1; for (i = 0; i < 12; i++) { hm1 += val[i]; } return (complex<float>(0.5f * log1pf(hm1), atan2(y, x)));}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> log(const complex<float>& z){ return detail::complex::clogf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255/* * Copyright 2008-2024 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex.h>#include <thrust/type_traits/is_trivially_relocatable.h>
THRUST_NAMESPACE_BEGIN
/* --- Constructors --- */
template <typename T>_CCCL_HOST_DEVICE complex<T>::complex(const T& re) // Initialize the storage in the member initializer list using C++ unicorn // initialization. This allows `complex<T const>` to work. : data{re, T()}{}
template <typename T>_CCCL_HOST_DEVICE complex<T>::complex(const T& re, const T& im) // Initialize the storage in the member initializer list using C++ unicorn // initialization. This allows `complex<T const>` to work. : data{re, im}{}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>::complex(const complex<U>& z) // Initialize the storage in the member initializer list using C++ unicorn // initialization. This allows `complex<T const>` to work. // We do a functional-style cast here to suppress conversion warnings. : data{T(z.real()), T(z.imag())}{}
template <typename T>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>::complex(const std::complex<T>& z) // Initialize the storage in the member initializer list using C++ unicorn // initialization. This allows `complex<T const>` to work. : data{THRUST_STD_COMPLEX_REAL(z), THRUST_STD_COMPLEX_IMAG(z)}{}
template <typename T>template <typename U>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>::complex(const std::complex<U>& z) // Initialize the storage in the member initializer list using C++ unicorn // initialization. This allows `complex<T const>` to work. // We do a functional-style cast here to suppress conversion warnings. : data{T(THRUST_STD_COMPLEX_REAL(z)), T(THRUST_STD_COMPLEX_IMAG(z))}{}
/* --- Assignment Operators --- */
template <typename T>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator=(const T& re){ real(re); imag(T()); return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator=(const complex<U>& z){ real(T(z.real())); imag(T(z.imag())); return *this;}
template <typename T>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>& complex<T>::operator=(const std::complex<T>& z){ real(THRUST_STD_COMPLEX_REAL(z)); imag(THRUST_STD_COMPLEX_IMAG(z)); return *this;}
template <typename T>template <typename U>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE complex<T>& complex<T>::operator=(const std::complex<U>& z){ real(T(THRUST_STD_COMPLEX_REAL(z))); imag(T(THRUST_STD_COMPLEX_IMAG(z))); return *this;}
/* --- Compound Assignment Operators --- */
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator+=(const complex<U>& z){ *this = *this + z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator-=(const complex<U>& z){ *this = *this - z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator*=(const complex<U>& z){ *this = *this * z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator/=(const complex<U>& z){ *this = *this / z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator+=(const U& z){ *this = *this + z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator-=(const U& z){ *this = *this - z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator*=(const U& z){ *this = *this * z; return *this;}
template <typename T>template <typename U>_CCCL_HOST_DEVICE complex<T>& complex<T>::operator/=(const U& z){ *this = *this / z; return *this;}
/* --- Equality Operators --- */
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator==(const complex<T0>& x, const complex<T1>& y){ return x.real() == y.real() && x.imag() == y.imag();}
template <typename T0, typename T1>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE bool operator==(const complex<T0>& x, const std::complex<T1>& y){ return x.real() == THRUST_STD_COMPLEX_REAL(y) && x.imag() == THRUST_STD_COMPLEX_IMAG(y);}
template <typename T0, typename T1>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE bool operator==(const std::complex<T0>& x, const complex<T1>& y){ return THRUST_STD_COMPLEX_REAL(x) == y.real() && THRUST_STD_COMPLEX_IMAG(x) == y.imag();}
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator==(const T0& x, const complex<T1>& y){ return x == y.real() && y.imag() == T1();}
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator==(const complex<T0>& x, const T1& y){ return x.real() == y && x.imag() == T1();}
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator!=(const complex<T0>& x, const complex<T1>& y){ return !(x == y);}
template <typename T0, typename T1>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE bool operator!=(const complex<T0>& x, const std::complex<T1>& y){ return !(x == y);}
template <typename T0, typename T1>_CCCL_HOST THRUST_STD_COMPLEX_DEVICE bool operator!=(const std::complex<T0>& x, const complex<T1>& y){ return !(x == y);}
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator!=(const T0& x, const complex<T1>& y){ return !(x == y);}
template <typename T0, typename T1>_CCCL_HOST_DEVICE bool operator!=(const complex<T0>& x, const T1& y){ return !(x == y);}
template <typename T>struct proclaim_trivially_relocatable<complex<T>> : thrust::true_type{};
THRUST_NAMESPACE_END
#include <thrust/detail/complex/arithmetic.h>#include <thrust/detail/complex/catrig.h>#include <thrust/detail/complex/catrigf.h>#include <thrust/detail/complex/ccosh.h>#include <thrust/detail/complex/ccoshf.h>#include <thrust/detail/complex/cexp.h>#include <thrust/detail/complex/cexpf.h>#include <thrust/detail/complex/clog.h>#include <thrust/detail/complex/clogf.h>#include <thrust/detail/complex/cpow.h>#include <thrust/detail/complex/cproj.h>#include <thrust/detail/complex/csinh.h>#include <thrust/detail/complex/csinhf.h>#include <thrust/detail/complex/csqrt.h>#include <thrust/detail/complex/csqrtf.h>#include <thrust/detail/complex/ctanh.h>#include <thrust/detail/complex/ctanhf.h>#include <thrust/detail/complex/stream.h>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex.h>#include <thrust/detail/type_traits.h>
THRUST_NAMESPACE_BEGIN
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> pow(const complex<T0>& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; return exp(log(complex<T>(x)) * complex<T>(y));}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> pow(const complex<T0>& x, const T1& y){ using T = ::cuda::std::common_type_t<T0, T1>; return exp(log(complex<T>(x)) * T(y));}
template <typename T0, typename T1>_CCCL_HOST_DEVICE complex<::cuda::std::common_type_t<T0, T1>> pow(const T0& x, const complex<T1>& y){ using T = ::cuda::std::common_type_t<T0, T1>; // Find `log` by ADL. using std::log; return exp(log(T(x)) * complex<T>(y));}
THRUST_NAMESPACE_END1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{_CCCL_HOST_DEVICE inline complex<float> cprojf(const complex<float>& z){ if (!isinf(z.real()) && !isinf(z.imag())) { return z; } else { // std::numeric_limits<T>::infinity() doesn't run on the GPU return complex<float>(infinity<float>(), copysignf(0.0, z.imag())); }}
_CCCL_HOST_DEVICE inline complex<double> cproj(const complex<double>& z){ if (!isinf(z.real()) && !isinf(z.imag())) { return z; } else { // std::numeric_limits<T>::infinity() doesn't run on the GPU return complex<double>(infinity<double>(), copysign(0.0, z.imag())); }}
} // namespace complex
} // namespace detail
template <typename T>_CCCL_HOST_DEVICE inline thrust::complex<T> proj(const thrust::complex<T>& z){ return detail::complex::cproj(z);}
template <>_CCCL_HOST_DEVICE inline thrust::complex<double> proj(const thrust::complex<double>& z){ return detail::complex::cproj(z);}
template <>_CCCL_HOST_DEVICE inline thrust::complex<float> proj(const thrust::complex<float>& z){ return detail::complex::cprojf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* adapted from FreeBSD: * lib/msun/src/s_csinh.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/cexp.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<double> csinh(const complex<double>& z){ double x, y, h; uint32_t hx, hy, ix, iy, lx, ly; const double huge = 8.98846567431157953864652595395e+307; // 0x1p1023;
x = z.real(); y = z.imag();
extract_words(hx, lx, x); extract_words(hy, ly, y);
ix = 0x7fffffff & hx; iy = 0x7fffffff & hy;
/* Handle the nearly-non-exceptional cases where x and y are finite. */ if (ix < 0x7ff00000 && iy < 0x7ff00000) { if ((iy | ly) == 0) { return (complex<double>(sinh(x), y)); } if (ix < 0x40360000) /* small x: normal case */ { return (complex<double>(sinh(x) * cos(y), cosh(x) * sin(y))); }
/* |x| >= 22, so cosh(x) ~= exp(|x|) */ if (ix < 0x40862e42) { /* x < 710: exp(|x|) won't overflow */ h = exp(fabs(x)) * 0.5; return (complex<double>(copysign(h, x) * cos(y), h * sin(y))); } else if (ix < 0x4096bbaa) { /* x < 1455: scale to avoid overflow */ complex<double> z_ = ldexp_cexp(complex<double>(fabs(x), y), -1); return (complex<double>(z_.real() * copysign(1.0, x), z_.imag())); } else { /* x >= 1455: the result always overflows */ h = huge * x; return (complex<double>(h * cos(y), h * h * sin(y))); } }
/* * sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN. * The sign of 0 in the result is unspecified. Choice = normally * the same as dNaN. Raise the invalid floating-point exception. * * sinh(+-0 +- I NaN) = sign(d(+-0, NaN))0 + I d(NaN). * The sign of 0 in the result is unspecified. Choice = normally * the same as d(NaN). */ if ((ix | lx) == 0 && iy >= 0x7ff00000) { return (complex<double>(copysign(0.0, x * (y - y)), y - y)); }
/* * sinh(+-Inf +- I 0) = +-Inf + I +-0. * * sinh(NaN +- I 0) = d(NaN) + I +-0. */ if ((iy | ly) == 0 && ix >= 0x7ff00000) { if (((hx & 0xfffff) | lx) == 0) { return (complex<double>(x, y)); } return (complex<double>(x, copysign(0.0, y))); }
/* * sinh(x +- I Inf) = dNaN + I dNaN. * Raise the invalid floating-point exception for finite nonzero x. * * sinh(x + I NaN) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception for finite * nonzero x. Choice = don't raise (except for signaling NaNs). */ if (ix < 0x7ff00000 && iy >= 0x7ff00000) { return (complex<double>(y - y, x * (y - y))); }
/* * sinh(+-Inf + I NaN) = +-Inf + I d(NaN). * The sign of Inf in the result is unspecified. Choice = normally * the same as d(NaN). * * sinh(+-Inf +- I Inf) = +Inf + I dNaN. * The sign of Inf in the result is unspecified. Choice = always +. * Raise the invalid floating-point exception. * * sinh(+-Inf + I y) = +-Inf cos(y) + I Inf sin(y) */ if (ix >= 0x7ff00000 && ((hx & 0xfffff) | lx) == 0) { if (iy >= 0x7ff00000) { return (complex<double>(x * x, x * (y - y))); } return (complex<double>(x * cos(y), infinity<double>() * sin(y))); }
/* * sinh(NaN + I NaN) = d(NaN) + I d(NaN). * * sinh(NaN +- I Inf) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception. * Choice = raise. * * sinh(NaN + I y) = d(NaN) + I d(NaN). * Optionally raises the invalid floating-point exception for finite * nonzero y. Choice = don't raise (except for signaling NaNs). */ return (complex<double>((x * x) * (y - y), (x + x) * (y - y)));}
_CCCL_HOST_DEVICE inline complex<double> csin(complex<double> z){ /* csin(z) = -I * csinh(I * z) */ z = csinh(complex<double>(-z.imag(), z.real())); return (complex<double>(z.imag(), -z.real()));}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> sin(const complex<ValueType>& z){ const ValueType re = z.real(); const ValueType im = z.imag(); return complex<ValueType>(std::sin(re) * std::cosh(im), std::cos(re) * std::sinh(im));}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> sinh(const complex<ValueType>& z){ const ValueType re = z.real(); const ValueType im = z.imag(); return complex<ValueType>(std::sinh(re) * std::cos(im), std::cosh(re) * std::sin(im));}
template <>_CCCL_HOST_DEVICE inline complex<double> sin(const complex<double>& z){ return detail::complex::csin(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> sinh(const complex<double>& z){ return detail::complex::csinh(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* adapted from FreeBSD: * lib/msun/src/s_csinhf.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/cexp.h>#include <thrust/detail/complex/cexpf.h>#include <thrust/detail/complex/math_private.h>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<float> csinhf(const complex<float>& z){ float x, y, h; uint32_t hx, hy, ix, iy;
const float huge = 1.70141183460469231731687303716e+38; // 0x1p127;
x = z.real(); y = z.imag();
get_float_word(hx, x); get_float_word(hy, y);
ix = 0x7fffffff & hx; iy = 0x7fffffff & hy;
if (ix < 0x7f800000 && iy < 0x7f800000) { if (iy == 0) { return (complex<float>(sinhf(x), y)); } if (ix < 0x41100000) /* small x: normal case */ { return (complex<float>(sinhf(x) * cosf(y), coshf(x) * sinf(y))); }
/* |x| >= 9, so cosh(x) ~= exp(|x|) */ if (ix < 0x42b17218) { /* x < 88.7: expf(|x|) won't overflow */ h = expf(fabsf(x)) * 0.5f; return (complex<float>(copysignf(h, x) * cosf(y), h * sinf(y))); } else if (ix < 0x4340b1e7) { /* x < 192.7: scale to avoid overflow */ complex<float> z_ = ldexp_cexpf(complex<float>(fabsf(x), y), -1); return (complex<float>(z_.real() * copysignf(1.0f, x), z_.imag())); } else { /* x >= 192.7: the result always overflows */ h = huge * x; return (complex<float>(h * cosf(y), h * h * sinf(y))); } }
if (ix == 0 && iy >= 0x7f800000) { return (complex<float>(copysignf(0, x * (y - y)), y - y)); }
if (iy == 0 && ix >= 0x7f800000) { if ((hx & 0x7fffff) == 0) { return (complex<float>(x, y)); } return (complex<float>(x, copysignf(0.0f, y))); }
if (ix < 0x7f800000 && iy >= 0x7f800000) { return (complex<float>(y - y, x * (y - y))); }
if (ix >= 0x7f800000 && (hx & 0x7fffff) == 0) { if (iy >= 0x7f800000) { return (complex<float>(x * x, x * (y - y))); } return (complex<float>(x * cosf(y), infinity<float>() * sinf(y))); }
return (complex<float>((x * x) * (y - y), (x + x) * (y - y)));}
_CCCL_HOST_DEVICE inline complex<float> csinf(complex<float> z){ z = csinhf(complex<float>(-z.imag(), z.real())); return (complex<float>(z.imag(), -z.real()));}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> sin(const complex<float>& z){ return detail::complex::csinf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> sinh(const complex<float>& z){ return detail::complex::csinhf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* * Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>: * freebsd/lib/msun/src/s_csqrt.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<double> csqrt(const complex<double>& z){ complex<double> result; double a, b; double t; int scale;
/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ const double THRESH = 7.446288774449766337959726e+307;
a = z.real(); b = z.imag();
/* Handle special cases. */ if (z == 0.0) { return (complex<double>(0.0, b)); } if (isinf(b)) { return (complex<double>(infinity<double>(), b)); } if (isnan(a)) { t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ return (complex<double>(a, t)); /* return NaN + NaN i */ } if (isinf(a)) { /* * csqrt(inf + NaN i) = inf + NaN i * csqrt(inf + y i) = inf + 0 i * csqrt(-inf + NaN i) = NaN +- inf i * csqrt(-inf + y i) = 0 + inf i */ if (signbit(a)) { return (complex<double>(fabs(b - b), copysign(a, b))); } else { return (complex<double>(a, copysign(b - b, b))); } } /* * The remaining special case (b is NaN) is handled just fine by * the normal code path below. */
// DBL_MIN*2 const double low_thresh = 4.450147717014402766180465e-308; scale = 0;
if (fabs(a) >= THRESH || fabs(b) >= THRESH) { /* Scale to avoid overflow. */ a *= 0.25; b *= 0.25; scale = 1; } else if (fabs(a) <= low_thresh && fabs(b) <= low_thresh) { /* Scale to avoid underflow. */ a *= 4.0; b *= 4.0; scale = 2; }
/* Algorithm 312, CACM vol 10, Oct 1967. */ if (a >= 0.0) { t = sqrt((a + hypot(a, b)) * 0.5); result = complex<double>(t, b / (2 * t)); } else { t = sqrt((-a + hypot(a, b)) * 0.5); result = complex<double>(fabs(b) / (2 * t), copysign(t, b)); }
/* Rescale. */ if (scale == 1) { return (result * 2.0); } else if (scale == 2) { return (result * 0.5); } else { return (result); }}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> sqrt(const complex<ValueType>& z){ return thrust::polar(std::sqrt(thrust::abs(z)), thrust::arg(z) / ValueType(2));}
template <>_CCCL_HOST_DEVICE inline complex<double> sqrt(const complex<double>& z){ return detail::complex::csqrt(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2007 David Schultz <das@FreeBSD.ORG> * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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. */
/* * Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>: * freebsd/lib/msun/src/s_csqrt.c */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<float> csqrtf(const complex<float>& z){ float a = z.real(), b = z.imag(); float t; int scale; complex<float> result;
/* We risk spurious overflow for components >= FLT_MAX / (1 + sqrt(2)). */ const float THRESH = 1.40949553037932e+38f;
/* Handle special cases. */ if (z == 0.0f) { return (complex<float>(0, b)); } if (isinf(b)) { return (complex<float>(infinity<float>(), b)); } if (isnan(a)) { t = (b - b) / (b - b); /* raise invalid if b is not a NaN */ return (complex<float>(a, t)); /* return NaN + NaN i */ } if (isinf(a)) { /* * csqrtf(inf + NaN i) = inf + NaN i * csqrtf(inf + y i) = inf + 0 i * csqrtf(-inf + NaN i) = NaN +- inf i * csqrtf(-inf + y i) = 0 + inf i */ if (signbit(a)) { return (complex<float>(fabsf(b - b), copysignf(a, b))); } else { return (complex<float>(a, copysignf(b - b, b))); } } /* * The remaining special case (b is NaN) is handled just fine by * the normal code path below. */
/* * Unlike in the FreeBSD code we'll avoid using double precision as * not all hardware supports it. */
// FLT_MIN*2 const float low_thresh = 2.35098870164458e-38f; scale = 0;
if (fabsf(a) >= THRESH || fabsf(b) >= THRESH) { /* Scale to avoid overflow. */ a *= 0.25f; b *= 0.25f; scale = 1; } else if (fabsf(a) <= low_thresh && fabsf(b) <= low_thresh) { /* Scale to avoid underflow. */ a *= 4.f; b *= 4.f; scale = 2; }
/* Algorithm 312, CACM vol 10, Oct 1967. */ if (a >= 0.0f) { t = sqrtf((a + hypotf(a, b)) * 0.5f); result = complex<float>(t, b / (2.0f * t)); } else { t = sqrtf((-a + hypotf(a, b)) * 0.5f); result = complex<float>(fabsf(b) / (2.0f * t), copysignf(t, b)); }
/* Rescale. */ if (scale == 1) { return (result * 2.0f); } else if (scale == 2) { return (result * 0.5f); } else { return (result); }}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> sqrt(const complex<float>& z){ return detail::complex::csqrtf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2011 David Schultz * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* * Adapted from FreeBSD by Filipe Maia <filipe.c.maia@gmail.com>: * freebsd/lib/msun/src/s_ctanh.c */
/* * Hyperbolic tangent of a complex argument z = x + i y. * * The algorithm is from: * * W. Kahan. Branch Cuts for Complex Elementary Functions or Much * Ado About Nothing's Sign Bit. In The State of the Art in * Numerical Analysis, pp. 165 ff. Iserles and Powell, eds., 1987. * * Method: * * Let t = tan(x) * beta = 1/cos^2(y) * s = sinh(x) * rho = cosh(x) * * We have: * * tanh(z) = sinh(z) / cosh(z) * * sinh(x) cos(y) + i cosh(x) sin(y) * = --------------------------------- * cosh(x) cos(y) + i sinh(x) sin(y) * * cosh(x) sinh(x) / cos^2(y) + i tan(y) * = ------------------------------------- * 1 + sinh^2(x) / cos^2(y) * * beta rho s + i t * = ---------------- * 1 + beta s^2 * * Modifications: * * I omitted the original algorithm's handling of overflow in tan(x) after * verifying with nearpi.c that this can't happen in IEEE single or double * precision. I also handle large x differently. */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<double> ctanh(const complex<double>& z){ double x, y; double t, beta, s, rho, denom; uint32_t hx, ix, lx;
x = z.real(); y = z.imag();
extract_words(hx, lx, x); ix = hx & 0x7fffffff;
/* * ctanh(NaN + i 0) = NaN + i 0 * * ctanh(NaN + i y) = NaN + i NaN for y != 0 * * The imaginary part has the sign of x*sin(2*y), but there's no * special effort to get this right. * * ctanh(+-Inf +- i Inf) = +-1 +- 0 * * ctanh(+-Inf + i y) = +-1 + 0 sin(2y) for y finite * * The imaginary part of the sign is unspecified. This special * case is only needed to avoid a spurious invalid exception when * y is infinite. */ if (ix >= 0x7ff00000) { if ((ix & 0xfffff) | lx) /* x is NaN */ { return (complex<double>(x, (y == 0 ? y : x * y))); } set_high_word(x, hx - 0x40000000); /* x = copysign(1, x) */ return (complex<double>(x, copysign(0.0, isinf(y) ? y : sin(y) * cos(y)))); }
/* * ctanh(x + i NAN) = NaN + i NaN * ctanh(x +- i Inf) = NaN + i NaN */ if (!isfinite(y)) { return (complex<double>(y - y, y - y)); }
/* * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the * approximation sinh^2(huge) ~= exp(2*huge) / 4. * We use a modified formula to avoid spurious overflow. */ if (ix >= 0x40360000) { /* x >= 22 */ double exp_mx = exp(-fabs(x)); return (complex<double>(copysign(1.0, x), 4.0 * sin(y) * cos(y) * exp_mx * exp_mx)); }
/* Kahan's algorithm */ t = tan(y); beta = 1.0 + t * t; /* = 1 / cos^2(y) */ s = sinh(x); rho = sqrt(1.0 + s * s); /* = cosh(x) */ denom = 1.0 + beta * s * s; return (complex<double>((beta * rho * s) / denom, t / denom));}
_CCCL_HOST_DEVICE inline complex<double> ctan(complex<double> z){ /* ctan(z) = -I * ctanh(I * z) */ z = ctanh(complex<double>(-z.imag(), z.real())); return (complex<double>(z.imag(), -z.real()));}
} // namespace complex
} // namespace detail
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> tan(const complex<ValueType>& z){ return sin(z) / cos(z);}
template <typename ValueType>_CCCL_HOST_DEVICE inline complex<ValueType> tanh(const complex<ValueType>& z){ // This implementation seems better than the simple sin/cos return (thrust::exp(ValueType(2) * z) - ValueType(1)) / (thrust::exp(ValueType(2) * z) + ValueType(1));}
template <>_CCCL_HOST_DEVICE inline complex<double> tan(const complex<double>& z){ return detail::complex::ctan(z);}
template <>_CCCL_HOST_DEVICE inline complex<double> tanh(const complex<double>& z){ return detail::complex::ctanh(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/*- * Copyright (c) 2011 David Schultz * 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 unmodified, 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. */
/* * Adapted from FreeBSD by Filipe Maia, filipe.c.maia@gmail.com: * freebsd/lib/msun/src/s_ctanhf.c */
/* * Hyperbolic tangent of a complex argument z. See ctanh.c for details. */
#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>#include <thrust/detail/complex/math_private.h>
#include <cmath>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
_CCCL_HOST_DEVICE inline complex<float> ctanhf(const complex<float>& z){ float x, y; float t, beta, s, rho, denom; uint32_t hx, ix;
x = z.real(); y = z.imag();
get_float_word(hx, x); ix = hx & 0x7fffffff;
if (ix >= 0x7f800000) { if (ix & 0x7fffff) { return (complex<float>(x, (y == 0.0f ? y : x * y))); } set_float_word(x, hx - 0x40000000); return (complex<float>(x, copysignf(0, isinf(y) ? y : sinf(y) * cosf(y)))); }
if (!isfinite(y)) { return (complex<float>(y - y, y - y)); }
if (ix >= 0x41300000) { /* x >= 11 */ float exp_mx = expf(-fabsf(x)); return (complex<float>(copysignf(1.0f, x), 4.0f * sinf(y) * cosf(y) * exp_mx * exp_mx)); }
t = tanf(y); beta = 1.0f + t * t; s = sinhf(x); rho = sqrtf(1.0f + s * s); denom = 1.0f + beta * s * s; return (complex<float>((beta * rho * s) / denom, t / denom));}
_CCCL_HOST_DEVICE inline complex<float> ctanf(complex<float> z){ z = ctanhf(complex<float>(-z.imag(), z.real())); return (complex<float>(z.imag(), -z.real()));}
} // namespace complex
} // namespace detail
template <>_CCCL_HOST_DEVICE inline complex<float> tan(const complex<float>& z){ return detail::complex::ctanf(z);}
template <>_CCCL_HOST_DEVICE inline complex<float> tanh(const complex<float>& z){ return detail::complex::ctanhf(z);}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138/* * Copyright 2008-2013 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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. */
/* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */
/* adapted from FreeBSD: * lib/msun/src/math_private.h */#pragma once
#include <thrust/detail/config.h>
#include <thrust/complex.h>
#include <cstdint>
THRUST_NAMESPACE_BEGINnamespace detail{namespace complex{
using thrust::complex;
using ieee_float_shape_type = union{ float value; uint32_t word;};
_CCCL_HOST_DEVICE inline void get_float_word(uint32_t& i, float d){ ieee_float_shape_type gf_u; gf_u.value = (d); (i) = gf_u.word;}
_CCCL_HOST_DEVICE inline void get_float_word(int32_t& i, float d){ ieee_float_shape_type gf_u; gf_u.value = (d); (i) = gf_u.word;}
_CCCL_HOST_DEVICE inline void set_float_word(float& d, uint32_t i){ ieee_float_shape_type sf_u; sf_u.word = (i); (d) = sf_u.value;}
// Assumes little endian orderingusing ieee_double_shape_type = union{ double value; struct { uint32_t lsw; uint32_t msw; } parts; struct { uint64_t w; } xparts;};
_CCCL_HOST_DEVICE inline void get_high_word(uint32_t& i, double d){ ieee_double_shape_type gh_u; gh_u.value = (d); (i) = gh_u.parts.msw;}
/* Set the more significant 32 bits of a double from an int. */_CCCL_HOST_DEVICE inline void set_high_word(double& d, uint32_t v){ ieee_double_shape_type sh_u; sh_u.value = (d); sh_u.parts.msw = (v); (d) = sh_u.value;}
_CCCL_HOST_DEVICE inline void insert_words(double& d, uint32_t ix0, uint32_t ix1){ ieee_double_shape_type iw_u; iw_u.parts.msw = (ix0); iw_u.parts.lsw = (ix1); (d) = iw_u.value;}
/* Get two 32 bit ints from a double. */_CCCL_HOST_DEVICE inline void extract_words(uint32_t& ix0, uint32_t& ix1, double d){ ieee_double_shape_type ew_u; ew_u.value = (d); (ix0) = ew_u.parts.msw; (ix1) = ew_u.parts.lsw;}
/* Get two 32 bit ints from a double. */_CCCL_HOST_DEVICE inline void extract_words(int32_t& ix0, int32_t& ix1, double d){ ieee_double_shape_type ew_u; ew_u.value = (d); (ix0) = ew_u.parts.msw; (ix1) = ew_u.parts.lsw;}
} // namespace complex
} // namespace detail
THRUST_NAMESPACE_END
#include <thrust/detail/complex/c99math.h>12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273/* * Copyright 2008-2021 NVIDIA Corporation * Copyright 2013 Filipe RNC Maia * * 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/complex.h>
THRUST_NAMESPACE_BEGINtemplate <typename ValueType, class charT, class traits>std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const complex<ValueType>& z){ os << '(' << z.real() << ',' << z.imag() << ')'; return os;}
template <typename ValueType, typename charT, class traits>std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is, complex<ValueType>& z){ ValueType re, im;
charT ch; is >> ch;
if (ch == '(') { is >> re >> ch; if (ch == ',') { is >> im >> ch; if (ch == ')') { z = complex<ValueType>(re, im); } else { is.setstate(std::ios_base::failbit); } } else if (ch == ')') { z = re; } else { is.setstate(std::ios_base::failbit); } } else { is.putback(ch); is >> re; z = re; } return is;}
THRUST_NAMESPACE_END123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119/* * Copyright 2008-2013 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 compiler.h * \brief Compiler-specific configuration */
#pragma once
// Internal config header that is only included through thrust/detail/config/config.h
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
// enumerate host compilers we know about//! deprecated [Since 2.7]#define THRUST_HOST_COMPILER_UNKNOWN 0//! deprecated [Since 2.7]#define THRUST_HOST_COMPILER_MSVC 1//! deprecated [Since 2.7]#define THRUST_HOST_COMPILER_GCC 2//! deprecated [Since 2.7]#define THRUST_HOST_COMPILER_CLANG 3//! deprecated [Since 2.7]#define THRUST_HOST_COMPILER_INTEL 4
// enumerate device compilers we know about//! deprecated [Since 2.7]#define THRUST_DEVICE_COMPILER_UNKNOWN 0//! deprecated [Since 2.7]#define THRUST_DEVICE_COMPILER_MSVC 1//! deprecated [Since 2.7]#define THRUST_DEVICE_COMPILER_GCC 2//! deprecated [Since 2.7]#define THRUST_DEVICE_COMPILER_CLANG 3//! deprecated [Since 2.7]#define THRUST_DEVICE_COMPILER_NVCC 4
// figure out which host compiler we're using#if _CCCL_COMPILER(MSVC)//! deprecated [Since 2.7]# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC//! deprecated [Since 2.7]# define THRUST_MSVC_VERSION _MSC_VER//! deprecated [Since 2.7]# define THRUST_MSVC_VERSION_FULL _MSC_FULL_VER#elif _CCCL_COMPILER(ICC)//! deprecated [Since 2.7]# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_INTEL#elif _CCCL_COMPILER(CLANG)//! deprecated [Since 2.7]# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_CLANG//! deprecated [Since 2.7]# define THRUST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)#elif _CCCL_COMPILER(GCC)//! deprecated [Since 2.7]# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_GCC//! deprecated [Since 2.7]# define THRUST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)# if _CCCL_COMPILER(GCC, >=, 5)//! deprecated [Since 2.7]# define THRUST_MODERN_GCC# else//! deprecated [Since 2.7]# define THRUST_LEGACY_GCC# endif#else//! deprecated [Since 2.7]# define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_UNKNOWN#endif // TRUST_HOST_COMPILER
// figure out which device compiler we're using#if defined(__CUDACC__) || defined(_NVHPC_CUDA)//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC#elif _CCCL_COMPILER(MSVC)//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_MSVC#elif _CCCL_COMPILER(GCC)//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_GCC#elif _CCCL_COMPILER(CLANG)// CUDA-capable clang should behave similar to NVCC.# if defined(__CUDA__)//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_NVCC# else//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_CLANG# endif#else//! deprecated [Since 2.7]# define THRUST_DEVICE_COMPILER THRUST_DEVICE_COMPILER_UNKNOWN#endif
// is the device compiler capable of compiling omp?#if defined(_OPENMP) || defined(_NVHPC_STDPAR_OPENMP)# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_TRUE#else# define THRUST_DEVICE_COMPILER_IS_OMP_CAPABLE THRUST_FALSE#endif // _OPENMP12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879/* * Copyright 2008-2013 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>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <thrust/detail/preprocessor.h>
#if _CCCL_COMPILER(MSVC)# pragma message( \ "warning: The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 atomics instead.")#else#warning The functionality in this header is unsafe, deprecated, and will soon be removed. Use C++11 or C11 atomics instead.#endif
// msvc case#if _CCCL_COMPILER(MSVC)
# ifndef _DEBUG
# include <intrin.h># pragma intrinsic(_ReadWriteBarrier)# define __thrust_compiler_fence() _ReadWriteBarrier()# else
# define __thrust_compiler_fence() \ do \ { \ } while (0)
# endif // _DEBUG
// gcc case#elif _CCCL_COMPILER(GCC)
# if _CCCL_COMPILER(GCC, >=, 4, 2) // atomic built-ins were introduced ~4.2# define __thrust_compiler_fence() __sync_synchronize()# else// allow the code to compile without any guarantees# define __thrust_compiler_fence() \ do \ { \ } while (0)# endif // _CCCL_COMPILER(GCC, >=, 4, 2)
// unknown case#elif _CCCL_COMPILER(CLANG)# define __thrust_compiler_fence() __sync_synchronize()#else
// allow the code to compile without any guarantees# define __thrust_compiler_fence() \ do \ { \ } while (0)
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445/* * Copyright 2008-2013 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 config.h * \brief Defines platform configuration. */
#pragma once
// For _CCCL_IMPLICIT_SYSTEM_HEADER#include <cuda/__cccl_config> // IWYU pragma: export
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
// NOTE: The order of these #includes matters.
#include <thrust/detail/config/compiler.h> // IWYU pragma: export#include <thrust/detail/config/cpp_compatibility.h> // IWYU pragma: export#include <thrust/detail/config/cpp_dialect.h> // IWYU pragma: export#include <thrust/detail/config/simple_defines.h> // IWYU pragma: export// host_system.h & device_system.h must be #included as early as possible because other config headers depend on it#include <thrust/detail/config/host_system.h> // IWYU pragma: export
#include <thrust/detail/config/device_system.h> // IWYU pragma: export#include <thrust/detail/config/global_workarounds.h> // IWYU pragma: export#include <thrust/detail/config/namespace.h> // IWYU pragma: export12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061/* * Copyright 2008-2018 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
// Internal config header that is only included through thrust/detail/config/config.h
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
// deprecated [Since 2.8.0]#define THRUST_NODISCARD _CCCL_NODISCARD// deprecated [Since 2.8.0]#define THRUST_INLINE_CONSTANT _CCCL_GLOBAL_CONSTANT// deprecated [Since 2.8.0]#define THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT static constexpr
// These definitions were intended for internal use only and are now obsolete.// If you relied on them, consider porting your code to use the functionality// in libcu++'s <nv/target> header.// For a temporary workaround, define THRUST_PROVIDE_LEGACY_ARCH_MACROS to make// them available again. These should be considered deprecated and will be// fully removed in a future version.#ifdef THRUST_PROVIDE_LEGACY_ARCH_MACROS# ifndef THRUST_IS_DEVICE_CODE# if defined(_NVHPC_CUDA)# define THRUST_IS_DEVICE_CODE __builtin_is_device_code()# define THRUST_IS_HOST_CODE (!__builtin_is_device_code())# define THRUST_INCLUDE_DEVICE_CODE 1# define THRUST_INCLUDE_HOST_CODE 1# elif defined(__CUDA_ARCH__)# define THRUST_IS_DEVICE_CODE 1# define THRUST_IS_HOST_CODE 0# define THRUST_INCLUDE_DEVICE_CODE 1# define THRUST_INCLUDE_HOST_CODE 0# else# define THRUST_IS_DEVICE_CODE 0# define THRUST_IS_HOST_CODE 1# define THRUST_INCLUDE_DEVICE_CODE 0# define THRUST_INCLUDE_HOST_CODE 1# endif# endif#endif // THRUST_PROVIDE_LEGACY_ARCH_MACROS123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100/* * Copyright 2020 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 cpp_dialect.h * \brief Detect the version of the C++ standard used by the compiler. */
#pragma once
#include <thrust/detail/config/config.h>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <thrust/detail/config/compiler.h> // IWYU pragma: export
// Deprecation warnings may be silenced by defining the following macros. These// may be combined.// - CCCL_IGNORE_DEPRECATED_CPP_DIALECT:// Ignore all deprecated C++ dialects and outdated compilers.// - CCCL_IGNORE_DEPRECATED_CPP_11:// Ignore deprecation warnings when compiling with C++11. C++03 and outdated// compilers will still issue warnings.// - CCCL_IGNORE_DEPRECATED_CPP_14:// Ignore deprecation warnings when compiling with C++14. C++03 and outdated// compilers will still issue warnings.// - CCCL_IGNORE_DEPRECATED_COMPILER// Ignore deprecation warnings when using deprecated compilers. Compiling// with C++03, C++11 and C++14 will still issue warnings.
#define THRUST_CPP_DIALECT _CCCL_STD_VER
// Define THRUST_COMPILER_DEPRECATION macro:#if _CCCL_COMPILER(MSVC) || _CCCL_COMPILER(NVRTC)# define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(message(__FILE__ ":" _CCCL_TO_STRING(__LINE__) ": warning: " #msg))#else // clang / gcc:# define THRUST_COMP_DEPR_IMPL(msg) _CCCL_PRAGMA(GCC warning #msg)#endif
// clang-format off#define THRUST_COMPILER_DEPRECATION(REQ) \ THRUST_COMP_DEPR_IMPL(Thrust requires at least REQ. Define CCCL_IGNORE_DEPRECATED_COMPILER to suppress this message.)
#define THRUST_COMPILER_DEPRECATION_SOFT(REQ, CUR) \ THRUST_COMP_DEPR_IMPL( \ Thrust requires at least REQ. CUR is deprecated but still supported. CUR support will be removed in a \ future release. Define CCCL_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.)// clang-format on
#ifndef CCCL_IGNORE_DEPRECATED_COMPILER
// Compiler checks:# if _CCCL_COMPILER(GCC, <, 5)THRUST_COMPILER_DEPRECATION(GCC 5.0);# elif _CCCL_COMPILER(CLANG, <, 7)THRUST_COMPILER_DEPRECATION(Clang 7.0);# elif _CCCL_COMPILER(MSVC, <, 19, 10)// <2017. Hard upgrade message:THRUST_COMPILER_DEPRECATION(MSVC 2019(19.20 / 16.0 / 14.20));# elif _CCCL_COMPILER(MSVC2017)// >=2017, <2019. Soft deprecation message:THRUST_COMPILER_DEPRECATION_SOFT(MSVC 2019(19.20 / 16.0 / 14.20), MSVC 2017);# endif
#endif // CCCL_IGNORE_DEPRECATED_COMPILER
#if _CCCL_STD_VER < 2011// <C++11. Hard upgrade message:THRUST_COMPILER_DEPRECATION(C++ 17);#elif _CCCL_STD_VER == 2011 && !defined(CCCL_IGNORE_DEPRECATED_CPP_11)// =C++11. Soft upgrade message:THRUST_COMPILER_DEPRECATION_SOFT(C++ 17, C++ 11);#elif _CCCL_STD_VER == 2014 && !defined(CCCL_IGNORE_DEPRECATED_CPP_14)// =C++14. Soft upgrade message:THRUST_COMPILER_DEPRECATION_SOFT(C++ 17, C++ 14);#endif // _CCCL_STD_VER >= 2017
#undef THRUST_COMPILER_DEPRECATION_SOFT#undef THRUST_COMPILER_DEPRECATION#undef THRUST_COMP_DEPR_IMPL#undef THRUST_COMP_DEPR_IMPL0#undef THRUST_COMP_DEPR_IMPL112345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455/* * Copyright 2008-2013 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
// Internal config header that is only included through thrust/detail/config/config.h
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
// reserve 0 for undefined#define THRUST_DEVICE_SYSTEM_CUDA 1#define THRUST_DEVICE_SYSTEM_OMP 2#define THRUST_DEVICE_SYSTEM_TBB 3#define THRUST_DEVICE_SYSTEM_CPP 4
#ifndef THRUST_DEVICE_SYSTEM# define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_CUDA#endif // THRUST_DEVICE_SYSTEM
#ifdef THRUST_DEVICE_BACKEND# error THRUST_DEVICE_BACKEND is no longer supported; use THRUST_DEVICE_SYSTEM instead.#endif // THRUST_DEVICE_BACKEND
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA# define __THRUST_DEVICE_SYSTEM_NAMESPACE cuda#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_OMP# define __THRUST_DEVICE_SYSTEM_NAMESPACE omp#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_TBB# define __THRUST_DEVICE_SYSTEM_NAMESPACE tbb#elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CPP# define __THRUST_DEVICE_SYSTEM_NAMESPACE cpp#endif
// clang-format off#define __THRUST_DEVICE_SYSTEM_ROOT thrust/system/__THRUST_DEVICE_SYSTEM_NAMESPACE// clang-format on123456789101112131415161718192021222324252627282930313233343536/* * Copyright 2008-2013 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
// Internal config header that is only included through thrust/detail/config/config.h
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
#include <thrust/detail/config/compiler.h>
// XXX workaround gcc 4.8+'s complaints about unused local aliases by silencing them globally#if _CCCL_COMPILER(GCC, >=, 4, 8)# if defined(__NVCC__) && (CUDART_VERSION >= 6000)# pragma GCC diagnostic ignored "-Wunused-local-typedefs"# endif // nvcc & cuda 6+#endif // gcc 4.812345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152/* * Copyright 2008-2013 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
// Internal config header that is only included through thrust/detail/config/config.h
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)# pragma GCC system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)# pragma clang system_header#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)# pragma system_header#endif // no system header
// reserve 0 for undefined#define THRUST_HOST_SYSTEM_CPP 1#define THRUST_HOST_SYSTEM_OMP 2#define THRUST_HOST_SYSTEM_TBB 3
#ifndef THRUST_HOST_SYSTEM# define THRUST_HOST_SYSTEM THRUST_HOST_SYSTEM_CPP#endif // THRUST_HOST_SYSTEM
#ifdef THRUST_HOST_BACKEND# error THRUST_HOST_BACKEND is no longer supported; use THRUST_HOST_SYSTEM instead.#endif // THRUST_HOST_BACKEND
#if THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_CPP# define __THRUST_HOST_SYSTEM_NAMESPACE cpp#elif THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_OMP# define __THRUST_HOST_SYSTEM_NAMESPACE omp#elif THRUST_HOST_SYSTEM == THRUST_HOST_SYSTEM_TBB# define __THRUST_HOST_SYSTEM_NAMESPACE tbb#endif
// clang-format off#define __THRUST_HOST_SYSTEM_ROOT thrust/system/__THRUST_HOST_SYSTEM_NAMESPACE// clang-format ondata/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/info/licenses/LICENSEAdded+1632
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/info/test/run_test.shAdded+9
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/nv/detail/__preprocessorAdded+176
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/nv/detail/__target_macrosAdded+610
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/allocator_traits.hAdded+350
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/allocator_traits.inlAdded+370
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/copy_construct_range.hAdded+45
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/copy_construct_range.inlAdded+242
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/destroy_range.hAdded+39
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/destroy_range.inlAdded+137
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/fill_construct_range.hAdded+39
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/fill_construct_range.inlAdded+99
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/malloc_allocator.hAdded+53
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/malloc_allocator.inlAdded+68
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/no_throw_allocator.hAdded+76
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/tagged_allocator.hAdded+102
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/tagged_allocator.inlAdded+86
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/temporary_allocator.hAdded+79
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/temporary_allocator.inlAdded+81
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/value_initialize_range.hAdded+39
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/allocator/value_initialize_range.inlAdded+98
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/arithmetic.hAdded+255
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/c99math.hAdded+221
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/catrig.hAdded+875
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/catrigf.hAdded+588
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ccosh.hAdded+233
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ccoshf.hAdded+161
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cexp.hAdded+195
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cexpf.hAdded+173
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/clog.hAdded+223
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/clogf.hAdded+210
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/complex.inlAdded+255
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cpow.hAdded+50
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/cproj.hAdded+80
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csinh.hAdded+226
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csinhf.hAdded+166
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csqrt.hAdded+177
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/csqrtf.hAdded+173
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ctanh.hAdded+208
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/ctanhf.hAdded+133
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/math_private.hAdded+138
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/complex/stream.hAdded+73
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/compiler.hAdded+119
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/compiler_fence.hAdded+79
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/config.hAdded+45
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/cpp_compatibility.hAdded+61
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/cpp_dialect.hAdded+100
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/device_system.hAdded+55
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/global_workarounds.hAdded+36
data/miniconda3/pkgs/cuda-cccl_linux-64-12.9.27-0/targets/x86_64-linux/include/thrust/detail/config/host_system.hAdded+52