├── .clang-format ├── .codecov.yml ├── .gitignore ├── .travis.yml ├── CCS-memo-2020-11-18.pdf ├── LICENSE.md ├── README.md ├── inputs ├── 3D_hohlraum_multi_node.xml ├── 3D_hohlraum_single_node.xml ├── big_cube.xml ├── block_it.py ├── cubanova.py ├── cube_decomp_test.xml ├── hot_zone_input.xml ├── marshak_wave_dd.xml └── marshak_wave_replicated.xml ├── scripts ├── Dockerfile ├── check_style.sh ├── plot_scaling.py ├── run_scaling.py └── travis-run-tests.sh └── src ├── CMakeLists.txt ├── RNG.h ├── buffer.h ├── cell.h ├── cell_tally.h ├── census_functions.h ├── config.h.in ├── config ├── FindMETIS.cmake ├── FindSilo.cmake ├── find_tpls.cmake └── lanl-setup.cmake ├── constants.h ├── decompose_mesh.h ├── doxygen.config ├── event_based_transport.h ├── gpu_setup.h ├── history_based_transport.h ├── imc_parameters.h ├── imc_state.h ├── info.h ├── input.h ├── main.cc ├── mesh.h ├── message_counter.h ├── mpi_types.h ├── particle_pass_driver.h ├── particle_pass_transport.h ├── photon.h ├── photon_array.h ├── post_process_functions.h ├── proto_cell.h ├── proto_mesh.h ├── pugixml ├── .codecov.yml ├── .gitattributes ├── .github │ └── workflows │ │ └── build.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE.md ├── Makefile ├── README.md ├── SECURITY.md ├── appveyor.yml ├── docs │ ├── config.adoc │ ├── images │ │ ├── dom_tree.png │ │ ├── vs2005_link1.png │ │ ├── vs2005_link2.png │ │ ├── vs2005_pch1.png │ │ ├── vs2005_pch2.png │ │ ├── vs2005_pch3.png │ │ ├── vs2005_pch4.png │ │ ├── vs2010_link1.png │ │ └── vs2010_link2.png │ ├── manual.adoc │ ├── manual.html │ ├── quickstart.adoc │ ├── quickstart.html │ └── samples │ │ ├── character.xml │ │ ├── custom_memory_management.cpp │ │ ├── include.cpp │ │ ├── load_error_handling.cpp │ │ ├── load_file.cpp │ │ ├── load_memory.cpp │ │ ├── load_options.cpp │ │ ├── load_stream.cpp │ │ ├── modify_add.cpp │ │ ├── modify_base.cpp │ │ ├── modify_remove.cpp │ │ ├── save_custom_writer.cpp │ │ ├── save_declaration.cpp │ │ ├── save_file.cpp │ │ ├── save_options.cpp │ │ ├── save_stream.cpp │ │ ├── save_subtree.cpp │ │ ├── text.cpp │ │ ├── transitions.xml │ │ ├── traverse_base.cpp │ │ ├── traverse_iter.cpp │ │ ├── traverse_predicate.cpp │ │ ├── traverse_rangefor.cpp │ │ ├── traverse_walker.cpp │ │ ├── tree.xml │ │ ├── weekly-shift_jis.xml │ │ ├── weekly-utf-16.xml │ │ ├── weekly-utf-8.xml │ │ ├── xgconsole.xml │ │ ├── xpath_error.cpp │ │ ├── xpath_query.cpp │ │ ├── xpath_select.cpp │ │ └── xpath_variables.cpp ├── readme.txt ├── scripts │ ├── archive.py │ ├── cocoapods_push.sh │ ├── natvis │ │ ├── pugixml.natvis │ │ └── pugixml_compact.natvis │ ├── nuget │ │ ├── build │ │ │ └── native │ │ │ │ ├── pugixml-propertiesui.xml │ │ │ │ └── pugixml.targets │ │ └── pugixml.nuspec │ ├── nuget_build.ps1 │ ├── premake4.lua │ ├── pugixml-config.cmake.in │ ├── pugixml.pc.in │ ├── pugixml.podspec │ ├── pugixml.xcodeproj │ │ └── project.pbxproj │ ├── pugixml_airplay.mkf │ ├── pugixml_codeblocks.cbp │ ├── pugixml_codelite.project │ ├── pugixml_dll.rc │ ├── pugixml_vs2005.vcproj │ ├── pugixml_vs2005_static.vcproj │ ├── pugixml_vs2008.vcproj │ ├── pugixml_vs2008_static.vcproj │ ├── pugixml_vs2010.vcxproj │ ├── pugixml_vs2010_static.vcxproj │ ├── pugixml_vs2013.vcxproj │ ├── pugixml_vs2013_static.vcxproj │ ├── pugixml_vs2015.vcxproj │ ├── pugixml_vs2015_static.vcxproj │ ├── pugixml_vs2017.vcxproj │ ├── pugixml_vs2017_static.vcxproj │ ├── pugixml_vs2019.vcxproj │ ├── pugixml_vs2019_static.vcxproj │ ├── pugixml_vs2022.vcxproj │ └── pugixml_vs2022_static.vcxproj ├── src │ ├── pugiconfig.hpp │ ├── pugixml.cpp │ └── pugixml.hpp └── tests │ ├── allocator.cpp │ ├── allocator.hpp │ ├── autotest-appveyor.ps1 │ ├── data │ ├── empty.xml │ ├── large.xml │ ├── latintest_latin1.xml │ ├── latintest_utf8.xml │ ├── multiline.xml │ ├── small.xml │ ├── truncation.xml │ ├── utftest_utf16_be.xml │ ├── utftest_utf16_be_bom.xml │ ├── utftest_utf16_be_clean.xml │ ├── utftest_utf16_be_nodecl.xml │ ├── utftest_utf16_le.xml │ ├── utftest_utf16_le_bom.xml │ ├── utftest_utf16_le_clean.xml │ ├── utftest_utf16_le_nodecl.xml │ ├── utftest_utf32_be.xml │ ├── utftest_utf32_be_bom.xml │ ├── utftest_utf32_be_clean.xml │ ├── utftest_utf32_be_nodecl.xml │ ├── utftest_utf32_le.xml │ ├── utftest_utf32_le_bom.xml │ ├── utftest_utf32_le_clean.xml │ ├── utftest_utf32_le_nodecl.xml │ ├── utftest_utf8.xml │ ├── utftest_utf8_bom.xml │ ├── utftest_utf8_clean.xml │ ├── utftest_utf8_nodecl.xml │ └── тест.xml │ ├── data_fuzz_parse │ ├── basic.xml │ ├── doctype.xml │ ├── refs.xml │ ├── types.xml │ ├── utf16.xml │ └── utf32.xml │ ├── data_fuzz_xpath │ ├── basic.xpath │ ├── functions.xpath │ ├── math.xpath │ ├── path.xpath │ └── predicate.xpath │ ├── fuzz_parse.cpp │ ├── fuzz_parse.dict │ ├── fuzz_setup.sh │ ├── fuzz_xpath.cpp │ ├── fuzz_xpath.dict │ ├── helpers.hpp │ ├── main.cpp │ ├── test.cpp │ ├── test.hpp │ ├── test_compact.cpp │ ├── test_deprecated.cpp │ ├── test_document.cpp │ ├── test_dom_modify.cpp │ ├── test_dom_text.cpp │ ├── test_dom_traverse.cpp │ ├── test_header_guard.cpp │ ├── test_header_iosfwd_1.cpp │ ├── test_header_iosfwd_2.cpp │ ├── test_header_iostream_1.cpp │ ├── test_header_iostream_2.cpp │ ├── test_header_only_1.cpp │ ├── test_header_only_2.cpp │ ├── test_header_string_1.cpp │ ├── test_header_string_2.cpp │ ├── test_header_string_iostream.cpp │ ├── test_memory.cpp │ ├── test_parse.cpp │ ├── test_parse_doctype.cpp │ ├── test_unicode.cpp │ ├── test_version.cpp │ ├── test_write.cpp │ ├── test_xpath.cpp │ ├── test_xpath_api.cpp │ ├── test_xpath_functions.cpp │ ├── test_xpath_operators.cpp │ ├── test_xpath_parse.cpp │ ├── test_xpath_paths.cpp │ ├── test_xpath_paths_abbrev_w3c.cpp │ ├── test_xpath_paths_w3c.cpp │ ├── test_xpath_variables.cpp │ ├── test_xpath_xalan_1.cpp │ ├── test_xpath_xalan_2.cpp │ ├── test_xpath_xalan_3.cpp │ ├── test_xpath_xalan_4.cpp │ ├── test_xpath_xalan_5.cpp │ ├── writer_string.cpp │ └── writer_string.hpp ├── random123 ├── LICENSE ├── MicroURNG.hpp ├── README.md ├── ReinterpretCtr.hpp ├── aes.h ├── array.h ├── ars.h ├── boxmuller.hpp ├── conventional │ ├── Engine.hpp │ └── gsl_cbrng.h ├── features │ ├── clangfeatures.h │ ├── compilerfeatures.h │ ├── fujitsufeatures.h │ ├── gccfeatures.h │ ├── hipfeatures.h │ ├── iccfeatures.h │ ├── metalfeatures.h │ ├── msvcfeatures.h │ ├── nvccfeatures.h │ ├── open64features.h │ ├── openclfeatures.h │ ├── pgccfeatures.h │ ├── sse.h │ ├── sunprofeatures.h │ └── xlcfeatures.h ├── gsl_microrng.h ├── philox.h ├── threefry.h ├── u01fixedpt.h └── uniform.hpp ├── region.h ├── replicated_driver.h ├── replicated_transport.h ├── sampling_functions.h ├── source.h ├── test ├── CMakeLists.txt ├── large_particle_input.xml ├── simple_input.xml ├── test_buffer.cc ├── test_cell.cc ├── test_counter_rng.cc ├── test_imc_parameters.cc ├── test_imc_state.cc ├── test_input.cc ├── test_mesh.cc ├── test_mpi_types.cc ├── test_photon.cc ├── test_proto_cell.cc ├── test_sampling_functions.cc ├── test_write_silo.cc ├── testing_functions.h └── three_region_mesh_input.xml ├── timer.h └── write_silo.h /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | token: 25f392e6-778f-4e54-90c4-50b8594f60f6 3 | notify: 4 | require_ci_to_pass: yes 5 | 6 | coverage: 7 | precision: 1 8 | round: down 9 | range: "70...100" 10 | 11 | status: 12 | project: yes 13 | patch: yes 14 | changes: no 15 | 16 | parsers: 17 | gcov: 18 | branch_detection: 19 | conditional: yes 20 | loop: yes 21 | method: no 22 | macro: no 23 | 24 | ignore: 25 | - "src/old/.*" 26 | - "src/random123/.*" 27 | - "src/test/.*" 28 | - "src/test/sample.f90" 29 | 30 | comment: 31 | layout: "header, diff" 32 | behavior: default 33 | require_changes: no 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.elc 3 | *~ 4 | TAGS 5 | GPATH 6 | GTAGS 7 | GRTAGS 8 | .nfs* 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------# 2 | # File: .travis.yml 3 | # Author: Kelly Thompson 4 | # Date: Friday, Jul 13, 2018, 07:41 am 5 | # Purpose: Instructions for Travis continuous integration testing on GitHub. 6 | # This script wil be run to test pull requests 7 | # Note: Copyright (C) 2018 Los Alamos National Security, LLC. 8 | # All rights reserved. 9 | #------------------------------------------------------------------------------# 10 | 11 | language: cpp 12 | sudo: required 13 | services: 14 | - docker 15 | 16 | #------------------------------------------------------------------------------# 17 | # Notes: Build docker container before running this script: 18 | # 19 | # 1. cd to directory contataining Dockerfile. 20 | # 2. Build the docker container. This can take an hour or more. If you are 21 | # starting from scratch, you will need to change the first line of the 22 | # Dockerfile so that it starts from 'ubuntu' instead of 'draco-travis-ci' 23 | # 24 | # docker build --rm --pull --tag draco-travis-ci:latest . 25 | # 26 | # 3. Commit and upload the updated container: 27 | # 28 | # docker ps -a # find new container name 29 | # docker commit -m "updated cmake version" -a \ 30 | # kinetictheory/draco-travis-ci:latest 31 | # docker login -u kinetictheory # must provide password to upload 32 | # docker push 33 | # 34 | # 4. Optional: test the container with an interactive run (the -l is important!) 35 | # 36 | # docker run -it kinetictheory/draco-travis-ci /bin/bash -l 37 | # 38 | # or possibly 39 | # 40 | # docker run -it -v /path/to/draco:/home/travis/draco -w /home/travis/draco kinetictheory/draco-travis-ci /bin/bash -l -c "./.travis-run-tests.sh" 41 | # 42 | #------------------------------------------------------------------------------# 43 | 44 | #------------------------------------------------------------------------------# 45 | # Travis Environment: 46 | # 47 | # HOME=/home/travis 48 | # PWD=/home/travis/build/lanl/branson 49 | # (starting directory for Travis, sources are here) 50 | # 51 | # Docker Environment: 52 | # 53 | # - The docker image mounts the PR sources (/home/travis/build/lanl/branson) as 54 | # /home/travis/branson 55 | # - The vendors are at /vendors/spack 56 | # - Spack is already in the environment 57 | #------------------------------------------------------------------------------# 58 | 59 | env: 60 | global: 61 | - BUILD_DIR=/home/travis/branson/build 62 | - SOURCE_DIR=/home/travis/branson 63 | - T_SOURCE_DIR=/home/travis/build/lanl/branson 64 | - VENDOR_DIR=/vendors 65 | matrix: 66 | - STYLE=ON 67 | - WERROR=ON COVERAGE=ON DEBUG=ON 68 | - DEBUG=OFF 69 | 70 | # Coverage with Docker - https://docs.codecov.io/docs/testing-with-docker 71 | 72 | install: 73 | - travis_retry timeout 540 docker pull kinetictheory/draco-travis-ci 74 | 75 | script: 76 | - if [[ $COVERAGE ]]; then ci_env=`/bin/bash <(curl -s https://codecov.io/env)`; fi 77 | - docker run ${ci_env} -v ${T_SOURCE_DIR}:${SOURCE_DIR} -e VENDOR_DIR=${VENDOR_DIR} -e BUILD_DIR=${BUILD_DIR} -e SOURCE_DIR=${SOURCE_DIR} -e STYLE=${STYLE} -e TRAVIS=${TRAVIS} -e COVERAGE=${COVERAGE} -e WERROR=${WERROR} -e DEBUG=${DEBUG} kinetictheory/draco-travis-ci /bin/bash -l -c "${SOURCE_DIR}/scripts/travis-run-tests.sh" 78 | 79 | #------------------------------------------------------------------------------# 80 | # See also: 81 | # - Advanced used: https://github.com/laristra/flecsi/blob/master/.travis.yml 82 | #------------------------------------------------------------------------------# 83 | -------------------------------------------------------------------------------- /CCS-memo-2020-11-18.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/CCS-memo-2020-11-18.pdf -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License (BSD) 2 | 3 | Copyright (c) 2017, Triad National Security, LLC. All rights reserved. 4 | 5 | This program was produced under U.S. Government contract 89233218CNA000001 for 6 | Los Alamos National Laboratory (LANL), which is operated by Triad National 7 | Security, LLC for the U.S. Department of Energy/National Nuclear Security 8 | Administration. 9 | 10 | All rights in the program are reserved by Triad National Security, LLC, and the 11 | U.S. Department of Energy/National Nuclear Security Administration. The 12 | Government is granted for itself and others acting on its behalf a nonexclusive, 13 | paid-up, irrevocable worldwide license in this material to reproduce, prepare 14 | derivative works, distribute copies to the public, perform publicly and display 15 | publicly, and to permit others to do so. 16 | 17 | This is open source software; you can redistribute it and/or modify it under the 18 | terms of the BSD-3 Clause License. If software is modified to produce derivative 19 | works, such modified software should be clearly marked, so as not to confuse it 20 | with the version available from LANL. Full text of the BSD-3 License can be 21 | found in the License file in the main development branch of the repository. 22 | 23 | Additionally, redistribution and use in source and binary forms, with 24 | or without modification, are permitted provided that the following 25 | conditions are met: 26 | 27 | - Redistributions of source code must retain the above copyright 28 | notice, this list of conditions and the following disclaimer. 29 | 30 | - Redistributions in binary form must reproduce the above copyright 31 | notice, this list of conditions and the following disclaimer in the 32 | documentation and/or other materials provided with the distribution. 33 | 34 | - Neither the name of Triad National Security, LLC, Los Alamos 35 | National Laboratory, LANL, the U.S. Government, nor the names of its 36 | contributors may be used to endorse or promote products derived from 37 | this software without specific prior written permission. 38 | 39 | THIS SOFTWARE IS PROVIDED BY TRIAD NATIONAL SECURITY, LLC AND CONTRIBUTORS 40 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 41 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 42 | ARE DISCLAIMED. IN NO EVENT SHALL TRIAD NATIONAL SECURITY, LLC OR CONTRIBUTORS 43 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 44 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 45 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 47 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 48 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 49 | -------------------------------------------------------------------------------- /inputs/big_cube.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.01 6 | 0.001 7 | 1.0 8 | 1.0 9 | 5000000 10 | 14706 11 | FALSE 12 | FALSE 13 | CELL_PASS 14 | 1 15 | CUBE 16 | 5000 17 | 1 18 | FALSE 19 | 20 | 21 | 22 | FALSE 23 | FALSE 24 | 25 | 26 | 27 | 28 | 0.0 29 | 4.0 30 | 800 31 | 32 | 33 | 34 | 0.0 35 | 4.0 36 | 800 37 | 38 | 39 | 40 | 0.0 41 | 4.0 42 | 800 43 | 44 | 45 | 46 | 0 47 | 0 48 | 0 49 | 6 50 | 51 | 52 | 53 | 54 | REFLECT 55 | REFLECT 56 | 57 | REFLECT 58 | REFLECT 59 | 60 | REFLECT 61 | REFLECT 62 | 63 | 64 | 65 | 66 | 6 67 | 1.0 68 | 1.0 69 | 100.0 70 | 0.0 71 | 0.0 72 | 0.0 73 | 1.0 74 | 1.0 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /inputs/cubanova.py: -------------------------------------------------------------------------------- 1 | # This is a script to write an XML geometry for our "cubanova" calculation 2 | 3 | import sys 4 | import numpy 5 | from BlockIt import block 6 | from BlockIt import branson_run_param 7 | from BlockIt import generate_input 8 | 9 | # generate branson run_param 10 | 11 | run_param = branson_run_param(t_stop=1.0e-2, dt_start=1.0e-3, photons=5000, seed=14706) 12 | 13 | # build a symmetric cubanova 14 | scale_size = 10**16 15 | scale_cv = 1.0e12 16 | smear_shock = 1.1 17 | domain_size = 4.0*10**16/scale_size 18 | CSM_size = 2.0*10**16/scale_size 19 | CSM_shock_size = 2.0*10**15.831/scale_size*smear_shock 20 | cubanova_size = 2.0*10**15.829/scale_size 21 | 22 | block_list = [] 23 | # build up materials 24 | void = {} 25 | void["id"] = 1 26 | void["density"] = 1e-6 27 | void["cv"] = 1e16 28 | void["opacA"] = 1e-6 29 | void["opacB"] = 0.0 30 | void["opacC"] = 0.0 31 | void["opacS"] = 0.0 32 | void["initial_T_e"] = 8.6e-4 33 | void["initial_T_r"] = 8.6e-4 34 | 35 | unit_cube = block([domain_size]*3, [0.0]*3, void, 1) 36 | block_list.append(unit_cube) 37 | 38 | CSM_material= {} 39 | CSM_material["id"] = 2 40 | CSM_material["density"] = 1.0e-14 41 | CSM_material["cv"] = 1.0e-3*scale_cv 42 | CSM_material["opacA"] = 1.0e-4*CSM_material["density"]*scale_size 43 | CSM_material["opacB"] = 0.0 44 | CSM_material["opacC"] = 0.0 45 | CSM_material["opacS"] = 0.0 46 | CSM_material["initial_T_e"] = 8.6e-4 47 | CSM_material["initial_T_r"] = 8.6e-4 48 | 49 | CSM_dim=[CSM_size]*3 50 | 51 | CSM = block(CSM_dim, [0.0]*3, CSM_material, 4) 52 | block_list.append(CSM) 53 | 54 | CSM_Shock_material= {} 55 | CSM_Shock_material["id"] = 3 56 | CSM_Shock_material["density"] = 1.0e-12 57 | CSM_Shock_material["cv"] = 1.0e-3*scale_cv 58 | CSM_Shock_material["opacA"] = 0.3*CSM_Shock_material["density"]*scale_size/smear_shock 59 | CSM_Shock_material["opacB"] = 0.0 60 | CSM_Shock_material["opacC"] = 0.0 61 | CSM_Shock_material["opacS"] = 0.0 62 | CSM_Shock_material["initial_T_e"] = 8.6e-2 63 | CSM_Shock_material["initial_T_r"] = 8.6e-2 64 | 65 | CSM_Shock_dim=[CSM_shock_size]*3 66 | 67 | CSM_Shock = block(CSM_Shock_dim, [0.0]*3, CSM_Shock_material, 10) 68 | block_list.append(CSM_Shock) 69 | 70 | 71 | cubanova_material= {} 72 | cubanova_material["id"] = 4 73 | cubanova_material["density"] = 1.0e-14 74 | cubanova_material["cv"] = 1.0e-3*scale_cv 75 | cubanova_material["opacA"] = 0.3*cubanova_material["density"]*scale_size 76 | cubanova_material["opacB"] = 0.0 77 | cubanova_material["opacC"] = 0.0 78 | cubanova_material["opacS"] = 0.0 79 | cubanova_material["initial_T_e"] = 8.6e-4 80 | cubanova_material["initial_T_r"] = 8.6e-4 81 | 82 | cubanova_dim = [cubanova_size]*3 83 | 84 | cubanova = block(cubanova_dim, [0.0]*3, cubanova_material, 8) 85 | block_list.append(cubanova) 86 | 87 | generate_input(block_list, run_param) 88 | 89 | -------------------------------------------------------------------------------- /inputs/cube_decomp_test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.5 6 | 0.01 7 | 1.0 8 | 1.0 9 | 500000 10 | 14706 11 | FALSE 12 | FALSE 13 | 1 14 | CELL_PASS 15 | 1 16 | CUBE 17 | 10000 18 | 20000 19 | TRUE 20 | 21 | 22 | 23 | FALSE 24 | FALSE 25 | 26 | 27 | 28 | 29 | 0.0 30 | 1.0 31 | 8 32 | 33 | 34 | 35 | 0.0 36 | 4.0 37 | 8 38 | 39 | 40 | 41 | 0.0 42 | 4.0 43 | 8 44 | 45 | 46 | 47 | 0 48 | 0 49 | 0 50 | 6 51 | 52 | 53 | 54 | 55 | REFLECT 56 | REFLECT 57 | 58 | REFLECT 59 | REFLECT 60 | 61 | REFLECT 62 | REFLECT 63 | 64 | 65 | 66 | 67 | 6 68 | 1.0 69 | 1.0 70 | 100.0 71 | 0.0 72 | 0.0 73 | 0.0 74 | 1.0 75 | 1.0 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /inputs/hot_zone_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.2 6 | 0.01 7 | 1.0 8 | 1.0 9 | 1000000 10 | 14706 11 | FALSE 12 | FALSE 13 | CELL_PASS 14 | 1 15 | 500 16 | 1000 17 | 1 18 | TRUE 19 | 20 | 21 | 22 | FALSE 23 | FALSE 24 | 25 | 26 | 27 | 28 | 0.0 29 | 0.05 30 | 5 31 | 32 | 33 | 34 | 0.05 35 | 2.0 36 | 195 37 | 38 | 39 | 40 | 0.0 41 | 0.05 42 | 5 43 | 44 | 45 | 46 | 0.05 47 | 2.0 48 | 195 49 | 50 | 51 | 52 | 0.0 53 | 1.0 54 | 1 55 | 56 | 57 | 58 | 0 59 | 0 60 | 0 61 | 100 62 | 63 | 64 | 65 | 1 66 | 0 67 | 0 68 | 5 69 | 70 | 71 | 72 | 0 73 | 1 74 | 0 75 | 5 76 | 77 | 78 | 79 | 1 80 | 1 81 | 0 82 | 5 83 | 84 | 85 | 86 | 87 | 88 | REFLECT 89 | REFLECT 90 | 91 | REFLECT 92 | REFLECT 93 | 94 | REFLECT 95 | REFLECT 96 | 97 | 98 | 99 | 100 | 100 101 | 1.0 102 | 0.1 103 | 50.0 104 | 0.0 105 | 0.0 106 | 0.0 107 | 1.0 108 | 1.0 109 | 110 | 111 | 5 112 | 1.0 113 | 0.1 114 | 50.0 115 | 0.0 116 | 0.0 117 | 0.0 118 | 0.01 119 | 0.01 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /inputs/marshak_wave_dd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.001 6 | 0.0001 7 | 1.0 8 | 1.0 9 | 100 10 | 14706 11 | TRUE 12 | TRUE 13 | PARTICLE_PASS 14 | 1 15 | 1 16 | 17 | 18 | 19 | TRUE 20 | TRUE 21 | 22 | 23 | 24 | 25 | 0.0 26 | 0.1 27 | 100 28 | 29 | 30 | 31 | 0.0 32 | 1.0 33 | 1 34 | 35 | 36 | 37 | 0.0 38 | 1.0 39 | 1 40 | 41 | 42 | 43 | 0 44 | 0 45 | 0 46 | 1 47 | 48 | 49 | 50 | 51 | 52 | SOURCE 53 | VACUUM 54 | 55 | REFLECT 56 | REFLECT 57 | 58 | REFLECT 59 | REFLECT 60 | 61 | 1.00 62 | 63 | 64 | 65 | 66 | 1 67 | 1.0 68 | 1.0 69 | 0.0 70 | 100.0 71 | -3.0 72 | 0.0 73 | 0.01 74 | 0.01 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /inputs/marshak_wave_replicated.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 1.0 6 | 0.01 7 | 1.0 8 | 1.0 9 | 1000000 10 | 14706 11 | TRUE 12 | FALSE 13 | REPLICATED 14 | 1 15 | 1 16 | 17 | 18 | 19 | TRUE 20 | TRUE 21 | 22 | 23 | 24 | 25 | 0.0 26 | 0.25 27 | 25 28 | 29 | 30 | 31 | 0.0 32 | 0.1 33 | 1 34 | 35 | 36 | 37 | 0.0 38 | 0.1 39 | 1 40 | 41 | 42 | 43 | 0 44 | 0 45 | 0 46 | 1 47 | 48 | 49 | 50 | 51 | 52 | SOURCE 53 | VACUUM 54 | 55 | REFLECT 56 | REFLECT 57 | 58 | REFLECT 59 | REFLECT 60 | 61 | 1.00 62 | 63 | 64 | 65 | 66 | 1 67 | 1.0 68 | 1.0 69 | 0.0 70 | 100.0 71 | -3.0 72 | 0.0 73 | 0.01 74 | 0.01 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /scripts/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Ref: https://github.com/lanl/Draco/regression/Dockerfile 2 | 3 | FROM kinetictheory/draco-travis-ci 4 | 5 | # Use ubuntu if building from scratch 6 | #FROM ubuntu:latest 7 | 8 | MAINTAINER KineticTheory "https://github.com/KineticTheory" 9 | 10 | # See draco/.travis-run-tests.sh for some instructions. 11 | 12 | ## Environment needed by 'docker build' ---------------------------------------- 13 | 14 | ## for apt to be noninteractive 15 | ## https://stackoverflow.com/questions/8671308/non-interactive-method-for-dpkg-reconfigure-tzdata 16 | ## https://spack.readthedocs.io/en/latest/workflows.html?highlight=docker 17 | ENV DEBIAN_FRONTEND noninteractive 18 | ENV DEBCONF_NONINTERACTIVE_SEEN true 19 | ENV SPACK_ROOT=/vendors/spack 20 | ENV DRACO_TPL="cmake@3.11.4 random123@1.09 openmpi@3.1.1 netlib-lapack@3.8.0 metis@5.1.0" 21 | ENV FORCE_UNSAFE_CONFIGURE=1 22 | ENV DISTRO=bionic 23 | ENV CLANG_FORMAT_VER=6.0 24 | ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 25 | 26 | ## Update packages on the raw Ubuntu image ------------------------------------------- 27 | 28 | RUN sed -i '/DISTRO/d' /etc/apt/sources.list 29 | # try to eliminate warning about "mesg: ttyname failed: Inappropriate ioctl for device" 30 | RUN sed -i 's/mesg/tty -s \&\& mesg/' /root/.profile 31 | RUN cat /root/.profile 32 | 33 | ## preesed tzdata, update package index, upgrade packages and install needed software 34 | RUN echo "tzdata tzdata/Areas select US" > /tmp/preseed.txt; \ 35 | echo "tzdata tzdata/Zones/US select Mountain" >> /tmp/preseed.txt; \ 36 | debconf-set-selections /tmp/preseed.txt && \ 37 | apt-get update && \ 38 | apt-get install -y tzdata 39 | 40 | ## Basic admin tools 41 | RUN apt-get -y install apt-utils autoconf python software-properties-common 42 | 43 | ## Basic developer tools 44 | RUN apt-get -y install build-essential ca-certificates coreutils ccache curl doxygen environment-modules gcc-7 g++-7 gfortran-7 git grace graphviz python-pip tar tcl tk unzip vim wget 45 | # RUN apg-get upgrade 46 | RUN if ! test -f /etc/profile.d/modules.sh; then \ 47 | echo "source /usr/share/modules/init/bash" > /etc/profile.d/modules.sh; \ 48 | fi 49 | 50 | ## LLVM tools like clang-format 51 | ## Note: we can't use variables in the add-apt-repository commmand as this 52 | ## creates an invalid entry in /etc/apt/sources.list 53 | RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - ; \ 54 | add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main' ; \ 55 | apt-get update; \ 56 | apt-get install -y clang-format-${CLANG_FORMAT_VER}; \ 57 | export PATH=$PATH:/usr/bin 58 | 59 | ## code cov plugin... 60 | RUN python -m pip install --upgrade pip 61 | RUN python -m pip install codecov 62 | 63 | ## SPACK ----------------------------------------------------------------------------- 64 | 65 | # install/setup spack 66 | RUN mkdir -p $SPACK_ROOT 67 | RUN curl -s -L https://api.github.com/repos/spack/spack/tarball | tar xzC $SPACK_ROOT --strip 1 68 | # note: if you wish to change default settings, add files alongside 69 | # the Dockerfile with your desired settings. Then uncomment this line 70 | #COPY packages.yaml modules.yaml $SPACK_ROOT/etc/spack/ 71 | RUN if ! test -f /etc/profile.d/spack.sh; then \ 72 | echo "source $SPACK_ROOT/share/spack/setup-env.sh" > /etc/profile.d/spack.sh; \ 73 | fi 74 | 75 | ## Provide some TPLs 76 | RUN export PATH=$SPACK_ROOT/bin:$PATH && spack install ${DRACO_TPL} && spack clean -a 77 | 78 | # image run hook: the -l will make sure /etc/profile.d/*.sh environments are loaded 79 | CMD /bin/bash -l 80 | -------------------------------------------------------------------------------- /scripts/plot_scaling.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import matplotlib 3 | import numpy as np 4 | 5 | 6 | ############################################################################### 7 | def method_to_num(method_str): 8 | if (method_str=="CELL_PASS"): return 0 9 | if (method_str=="PARTICLE_PASS"): return 1 10 | ############################################################################### 11 | def get_scaling_from_file(filename): 12 | data = np.loadtxt(filename, converters={3:method_to_num}) 13 | map_particles = data[:,2] 14 | map_algorithms = data[:,3] 15 | unique_particles = set(map_particles) 16 | unique_schemes = set(map_algorithms) 17 | 18 | results = [] 19 | results_map = {} 20 | count = 0 21 | for i,n_p in enumerate(unique_particles): 22 | for j, dd_type in enumerate(unique_schemes): 23 | results.append([]) 24 | results_map["{0}_{1}".format(int(n_p),int(dd_type))] =count 25 | count=count+1 26 | 27 | for run in data: 28 | # use the key to get the index into the results vector 29 | key = "{0}_{1}".format(int(run[2]), int(run[3])) 30 | r_index = results_map[key] 31 | results[r_index].append(run) 32 | 33 | return results 34 | ############################################################################### 35 | 36 | scale_1_filename = "results/scale_1_results.txt" 37 | scale_2_filename = "results/scale_2_results.txt" 38 | 39 | plot_scale_1 = True 40 | plot_scale_2 = True 41 | 42 | #different symbol types: 'o', '+', 'x', '*' 43 | #use 'markersize' option to set size of symbols 44 | #set font size 45 | matplotlib.rcParams.update({'font.size': 20}) 46 | 47 | 48 | ############################################################################### 49 | if plot_scale_2: 50 | # weak scaling data and plot 51 | fig = plt.figure(1) 52 | ax = fig.add_subplot(111) 53 | 54 | results = get_scaling_from_file(scale_2_filename) 55 | 56 | d_label = {"1024001_0":"Cell Pass--1.0e6", "1024001_1":"Particle Pass--1.0e6", \ 57 | "10240001_0":"Cell Pass--1.0e7", "10240001_1":"Particle Pass--1.0e7",\ 58 | "102400001_0":"Cell Pass--1.0e8", "102400001_1":"Particle Pass--1.0e8"} 59 | d_format = {"1024001_0":"mo-", "1024001_1":"mo--", \ 60 | "10240001_0":"bo-", "10240001_1":"bo--",\ 61 | "102400001_0":"go-", "102400001_1":"go--"} 62 | 63 | max_cores = 0 64 | max_scale = 0.0 65 | for result in results: 66 | time = [] 67 | p = [] 68 | for run in result: 69 | p.append(run[0]) 70 | time.append(run[4]) 71 | t_1 = time[0] 72 | strong_scale = np.divide(t_1, time) 73 | max_scale = np.max([max_scale, np.max(strong_scale)]) 74 | max_cores = np.max([max_cores, np.max(p)]) 75 | key = "{0}_{1}".format(int(result[0][2]), int(result[0][3])) 76 | ax.plot(p, strong_scale, d_format[key], label=d_label[key] ) 77 | 78 | ideal_x = np.linspace(0,max_cores,100) 79 | ideal_y = np.linspace(0,max_cores,100) 80 | ax.plot(ideal_x, ideal_y, 'k-', label="Ideal Strong") 81 | 82 | #ax.set_xscale('log') 83 | #ax.set_yscale('log') 84 | plt.xlabel("cores") 85 | plt.ylabel("strong scaling") 86 | 87 | plt.axis([0.9, 1.001*max_cores, 0.0, max_scale]) 88 | ax.legend(loc = 'best') 89 | #save figure 90 | fig.set_size_inches(12.0,10.0) 91 | plt.savefig('dd_scaling_weak.pdf',dpi=100, bbox_inches='tight') 92 | ############################################################################### 93 | -------------------------------------------------------------------------------- /scripts/run_scaling.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import subprocess 4 | import re 5 | import lxml.etree as ET 6 | import numpy as np 7 | 8 | ################################################################################ 9 | def make_input_file(base_file, dd_type, buffer_size, n_photons, n_cells): 10 | r_tree = ET.parse(base_file) 11 | r_root = r_tree.getroot() 12 | # set photons 13 | r_common = r_root.find("common") 14 | e_photons = r_common.find("photons") 15 | e_photons.text = "{0}".format(n_photons) 16 | # set buffer size 17 | r_common.find("particle_message_size").text = "{0}".format(buffer_size) 18 | # set dd algorithm 19 | r_common.find("dd_transport_type").text = "{0}".format(dd_type) 20 | # set cells per dimension 21 | e_spatial = r_root.find("spatial") 22 | e_spatial.find("n_x_cells").text = "{0}".format(n_cells) 23 | e_spatial.find("n_y_cells").text = "{0}".format(n_cells) 24 | e_spatial.find("n_z_cells").text = "{0}".format(n_cells) 25 | # set spacing in each dimension 26 | side_length = 1.0 27 | #mesh_spacing = side_length/n_cells 28 | mesh_spacing = 1.0 29 | e_spatial.find("dx").text = "{0}".format(mesh_spacing) 30 | e_spatial.find("dy").text = "{0}".format(mesh_spacing) 31 | e_spatial.find("dz").text = "{0}".format(mesh_spacing) 32 | 33 | new_filename = "temp_input_n_{0}_cell_{1}.xml".format(n_photons, n_cells) 34 | r_tree.write(new_filename, pretty_print=True ) 35 | return new_filename 36 | ################################################################################ 37 | 38 | if (len(sys.argv) != 2): 39 | print("usage: {0} ".format(sys.argv[0])) 40 | sys.exit(); 41 | 42 | base_filename = sys.argv[1] 43 | 44 | path_to_exe = "/net/scratch1/along/branson/build" 45 | exe_name = "BRANSON" 46 | 47 | time_r = re.compile('runtime: (.*?) $') 48 | 49 | buffer_size = 2000 50 | c_per_dim = [40] 51 | base_photons = 1024000 52 | np_list = [base_photons+1, 10*base_photons+1, 100*base_photons+1] 53 | proc_list = [128, 256, 512] 54 | dd_methods = ["CELL_PASS", "PARTICLE_PASS" ] 55 | samples = 4 56 | 57 | #temp_input_file = make_input_file(base_filename, "CELL_PASS", 2000, 1000000, 40) 58 | # make output file for results 59 | results_filename = "scaling_results.txt" 60 | f_results = open(results_filename,'w') 61 | 62 | for dd_method in dd_methods: 63 | for n_particles in np_list: 64 | for n_cells in c_per_dim: 65 | for p in proc_list: 66 | times = [] 67 | temp_input_file = make_input_file(base_filename, dd_method,\ 68 | buffer_size, n_particles, n_cells) 69 | for s in range(samples): 70 | time = 0.0 71 | output_file = "temp_output.txt" 72 | subprocess.call(["mpirun -np {0} {1}/{2} {3} >> {4}".format( \ 73 | p, path_to_exe, exe_name, temp_input_file, output_file) ], shell=True) 74 | f_out = open(output_file,'r') 75 | for line in f_out: 76 | if (time_r.search(line)): 77 | time = float(time_r.findall(line)[0]) 78 | times.append(time) 79 | os.remove("{0}".format(output_file)) 80 | print("{0} {1} {2} {3} {4}".format( \ 81 | p, n_cells, n_particles, dd_method, time)) 82 | os.remove("{0}".format(temp_input_file)) 83 | # calculate average runtime and standard deviation 84 | runtime = np.average(times) 85 | stdev_runtime = np.std(times) 86 | f_results.write("{0} {1} {2} {3} {4} {5}\n".format(\ 87 | p, n_cells, n_particles, dd_method, runtime, stdev_runtime)) 88 | f_results.close() 89 | -------------------------------------------------------------------------------- /src/cell_tally.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file cell_tally.h 4 | * \author Alex Long 5 | * \date March 3 2015 6 | * \brief Holds cells data and provides basic sampling functions 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #ifndef cell_tally_h_ 13 | #define cell_tally_h_ 14 | 15 | #include 16 | #include 17 | 18 | #include "config.h" 19 | 20 | //============================================================================== 21 | /*! 22 | * \class Cell_Tally 23 | * \brief Simple class that holds tally data needed in each cell on the mesh 24 | * 25 | * This cell is mostly to abstract away GPU atomics 26 | */ 27 | //============================================================================== 28 | 29 | class Cell_Tally { 30 | 31 | public: 32 | Cell_Tally() 33 | :abs_E{0.0}, track_E{0.0} 34 | {} 35 | 36 | GPU_HOST_DEVICE 37 | inline void accumulate_absorbed_E(const double delta_abs_E) { 38 | accumulate(abs_E, delta_abs_E); 39 | } 40 | 41 | GPU_HOST_DEVICE 42 | inline void accumulate_track_E(const double delta_track_E) { 43 | accumulate(track_E, delta_track_E); 44 | } 45 | 46 | GPU_HOST_DEVICE 47 | double get_abs_E() const {return abs_E;} 48 | 49 | double get_track_E() const {return track_E;} 50 | 51 | double abs_E; //!< Absorbed energy in jerks 52 | double track_E; //!< Track energy used for estimate of radiation temperature 53 | 54 | void merge_in_tally(const Cell_Tally &other_cell_tally) { 55 | abs_E+= other_cell_tally.get_abs_E(); 56 | track_E+= other_cell_tally.get_track_E(); 57 | } 58 | }; 59 | 60 | #endif // cell_tally_h_ 61 | //---------------------------------------------------------------------------// 62 | // end of cell_tally.h 63 | //---------------------------------------------------------------------------// 64 | -------------------------------------------------------------------------------- /src/census_functions.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file census_functions.h 4 | * \author Alex Long 5 | * \date June 21 2018 6 | * \brief Comb census routine, yes, I'm finally putting it in 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #ifndef census_functions_h_ 13 | #define census_functions_h_ 14 | 15 | #include "photon_array.h" 16 | #include "photon.h" 17 | #include 18 | 19 | 20 | template 21 | void join_photon_arrays(Census_T &original, Census_T &to_append) { 22 | 23 | if constexpr(std::is_same_v>) { 24 | original.insert(original.end(), to_append.begin(), to_append.end()); 25 | } 26 | else { 27 | original.insert(to_append); 28 | } 29 | } 30 | 31 | double get_photon_list_E(const PhotonArray &photon_array) { 32 | double total_E = 0.0; 33 | for (size_t i = 0; i < photon_array.E.size(); ++i) 34 | { 35 | total_E += photon_array.E[i]; 36 | } 37 | return total_E; 38 | } 39 | 40 | double get_photon_list_E(const std::vector &photons) { 41 | double total_E = 0.0; 42 | for (auto const &iphtn : photons) { 43 | total_E += iphtn.get_E(); 44 | } 45 | return total_E; 46 | } 47 | 48 | void comb_photons(std::vector &census_photons, 49 | int64_t max_census_photons, RNG *rng) { 50 | std::unordered_map cell_census_count; 51 | std::unordered_map cell_census_E; 52 | std::unordered_map cell_corrected_E; 53 | 54 | std::vector post_comb_photons; 55 | 56 | double census_total_E = get_photon_list_E(census_photons); 57 | double global_census_E = census_total_E; 58 | MPI_Allreduce(MPI_IN_PLACE, &global_census_E, 1, MPI_DOUBLE, MPI_SUM, 59 | MPI_COMM_WORLD); 60 | double comb_photon_E = global_census_E / double(max_census_photons); 61 | 62 | for (auto &p : census_photons) { 63 | cell_census_count[p.get_cell()]++; 64 | cell_census_E[p.get_cell()] += p.get_E(); 65 | } 66 | 67 | for (auto ip = census_photons.begin(); ip != census_photons.end(); ++ip) { 68 | uint32_t cell = ip->get_cell(); 69 | double p_kill = 1.0 - ip->get_E() / comb_photon_E; 70 | double rand_check = rng->generate_random_number(); 71 | // save the photon probabilistically or if there is only one photon 72 | // remaining in the cell 73 | if (rand_check > p_kill || cell_census_count[cell] == 1) { 74 | ip->set_E(comb_photon_E); 75 | cell_corrected_E[cell] += comb_photon_E; 76 | post_comb_photons.push_back(*ip); 77 | } else { 78 | cell_census_count[cell]--; 79 | } 80 | } 81 | 82 | // correct energy for conservation 83 | double new_E; 84 | uint32_t cell; 85 | for (auto &p : post_comb_photons) { 86 | cell = p.get_cell(); 87 | new_E = p.get_E() + (cell_census_E[cell] - cell_corrected_E[cell]) / 88 | double(cell_census_count[cell]); 89 | p.set_E(new_E); 90 | } 91 | 92 | census_photons = post_comb_photons; 93 | } 94 | 95 | #endif // census_functions_h_ 96 | -------------------------------------------------------------------------------- /src/config/lanl-setup.cmake: -------------------------------------------------------------------------------- 1 | #-----------------------------*-cmake-*----------------------------------------# 2 | # file src/config/lanl-setup.cmake 3 | # author Kelly Thompson 4 | # date Tuesday, Aug 14, 2018, 15:24 pm 5 | # brief Setup targeting LANL HPC 6 | # note Copyright (C) 2018 Los Alamos National Security, LLC. 7 | # All rights reserved. 8 | #------------------------------------------------------------------------------# 9 | 10 | if( ${SITENAME} MATCHES "sn" OR ${SITENAME} MATCHES "ic" OR ${SITENAME} MATCHES "fi") 11 | set( SITENAME "Snow") 12 | set(SNOW_NODE TRUE) 13 | elseif( ${SITENAME} MATCHES "ba") 14 | set( SITENAME "Badger") 15 | set(BADGER_NODE TRUE) 16 | elseif( ${SITENAME} MATCHES "tt") 17 | set( SITENAME "Trinitite") 18 | set(TRINITITE_NODE TRUE) 19 | elseif( ${SITENAME} MATCHES "tr") 20 | set( SITENAME "Trinity") 21 | set(TRINITY_NODE TRUE) 22 | elseif( ${SITENAME} MATCHES "ccscs[0-9]+" ) 23 | # do nothing (keep the fullname) 24 | set(TRINITY_NODE TRUE) 25 | elseif( ${SITENAME} MATCHES "nid[0-9]+" ) 26 | set( SITENAME "Trinitite") 27 | set(TRINITITE_NODE TRUE) 28 | endif() 29 | 30 | #------------------------------------------------------------------------------# 31 | function(report_lanl_hpc_features) 32 | 33 | if( SNOW_NODE ) 34 | message( STATUS "LANL option : '-DSNOW_NODE'" ) 35 | elseif( BADGER_NODE ) 36 | message( STATUS "LANL option : '-DBADGER_NODE'" ) 37 | elseif( TRINITITE_NODE ) 38 | message( STATUS "LANL option : '-DTRINITITE_NODE'" ) 39 | elseif( TRINITY_NODE ) 40 | message( STATUS "LANL option : '-DTRINITY_NODE'" ) 41 | endif() 42 | 43 | endfunction() 44 | 45 | #------------------------------------------------------------------------------# 46 | # End lanl-setup.cmake 47 | #------------------------------------------------------------------------------# 48 | -------------------------------------------------------------------------------- /src/constants.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file constants.h 4 | * \author Alex Long 5 | * \date July 18 2014 6 | * \brief Physical constants, custom enumerations and MPI tags 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #ifndef constants_h_ 13 | #define constants_h_ 14 | 15 | namespace Constants { 16 | constexpr double pi(3.1415926535897932384626433832795); //!< Pi 17 | constexpr double c(299.792458); //!< speed of light in cm/shake 18 | constexpr double c_SO(1.0); //!< speed of light for Su-Olson problem 19 | constexpr double h(6.62606957e-34 * 1.0e-9 / 20 | 1.0e-8); //!< Planck's constant in GJ/sh 21 | constexpr double k(1.60219e-31); //!< energy conversion constant GJ/keV 22 | constexpr double a(0.01372); //!< Boltzmann constant in GJ/cm^3/keV^4 23 | constexpr double a_SO(1.0); //!< Boltzmann constant for SO problems 24 | constexpr double cutoff_fraction = 0.01; // note: get this from IMC_state in the future 25 | 26 | enum bc_type { REFLECT, VACUUM, ELEMENT, SOURCE, PROCESSOR }; //!< Boundary conditions 27 | enum dir_type { X_NEG, X_POS, Y_NEG, Y_POS, Z_NEG, Z_POS }; //!< Directions 28 | enum event_type : unsigned char { EXIT, PASS, CENSUS, SCATTER, KILLED, BOUND }; //!< Events 29 | enum { 30 | PARTICLE_PASS, 31 | REPLICATED 32 | }; //!< Parallel types 33 | enum {AOS, SOA}; //!< Particle array types 34 | enum {HISTORY, EVENT}; //!< Transport algorithm 35 | enum { NO_DECOMP, METIS, CUBE }; //!< Mesh decomposition method 36 | constexpr int grip_id_tag(1); //!< MPI tag for grip ID messages 37 | constexpr int cell_id_tag(2); //!< MPI tag for requested cell ID messages 38 | constexpr int count_tag(3); //!< MPI tag for completion count messages 39 | constexpr int photon_tag(4); //!< MPI tag for photon messages 40 | constexpr int n_photon_tag(5); //!< MPI tag for work packet messages 41 | constexpr int work_tag(6); //!< MPI tag for work packet messages 42 | constexpr int n_work_tag(7); //!< MPI tag for work packet messages 43 | constexpr int tally_tag(8); //!< MPI tag for tally messages 44 | constexpr int n_tally_tag(9); //!< MPI tag for number of tally messages 45 | 46 | //! MPI tag for cell messages NOTE: the number of grips in the message will 47 | // added to the end of this number 48 | constexpr int cell_tag(10); 49 | 50 | constexpr int n_threads_per_block = 128; 51 | }; // namespace Constants 52 | 53 | #endif // constants_h_ 54 | //---------------------------------------------------------------------------// 55 | // end of constants.h 56 | //---------------------------------------------------------------------------// 57 | -------------------------------------------------------------------------------- /src/gpu_setup.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------*-C++-*---------------------------------------------// 2 | /*! 3 | * \file gpu_setup.h 4 | * \author Alex Long 5 | * \date Oct 20 2022 6 | * \brief Struct that holds device pointers to particles, mesh and tallies 7 | * \note Copyright (C) 2022 Triad National Security, LLC., All rights reserved. 8 | */ 9 | //------------------------------------------------------------------------------------------------// 10 | 11 | #ifndef gpu_setup_h_ 12 | #define gpu_setup_h_ 13 | 14 | #include 15 | 16 | #include "cell.h" 17 | #include "config.h" 18 | 19 | class GPU_Setup { 20 | 21 | public: 22 | //! Constructor 23 | GPU_Setup(const int rank, const int n_ranks, const bool use_gpu_transporter, const std::vector &cpu_cells) 24 | : m_use_gpu_transporter(use_gpu_transporter), device_cells_ptr(nullptr) 25 | { 26 | #ifdef HAS_GPU 27 | if(m_use_gpu_transporter) { 28 | // MPI rank to GPU mapping 29 | set_device_ID(rank, n_ranks); 30 | 31 | std::cout<<"Allocating and transferring "< error in allocating cells data"); 35 | err = cudaMemcpy(device_cells_ptr, cpu_cells.data(), sizeof(Cell) * cpu_cells.size(), 36 | cudaMemcpyHostToDevice); 37 | Insist(!err, " error in copying cells data"); 38 | } 39 | #endif 40 | } 41 | 42 | 43 | 44 | //! Destructor 45 | ~GPU_Setup() { 46 | #ifdef HAS_GPU 47 | if(m_use_gpu_transporter) { 48 | auto err = cudaFree(device_cells_ptr); 49 | Insist(!err, " error in freeing device cell data"); 50 | } 51 | #endif 52 | } 53 | 54 | Cell *get_device_cells_ptr() const {return device_cells_ptr;} 55 | bool use_gpu_transporter() const {return m_use_gpu_transporter;} 56 | 57 | private: 58 | 59 | //------------------------------------------------------------------------------------------------// 60 | /*! 61 | * \brief Assign GPUs to MPI ranks 62 | * 63 | * If there are more ranks on a node than GPUs available on a node, multiple ranks will be allowed 64 | * to use the same GPU. 65 | * 66 | * \param[in] rank MPI rank of calling processor 67 | * \param[in] n_ranks total number of MPI ranks 68 | */ 69 | void set_device_ID(const int rank, const int n_ranks) { 70 | #ifdef USE_CUDA 71 | // device set 72 | int n_devices; 73 | cudaGetDeviceCount(&n_devices); 74 | int my_device = 0; 75 | if (n_ranks <= n_devices) 76 | my_device = rank; 77 | else 78 | my_device = rank % n_devices; 79 | cudaSetDevice(my_device); 80 | int my_bus_id = 0; 81 | cudaDeviceGetAttribute(&my_bus_id, cudaDevAttrPciBusId, my_device); 82 | std::cout << "N devices: " << n_devices << std::endl; 83 | std::cout << "rank: " << rank << ", device: " << my_device << " bus id: "; 84 | std::cout << my_bus_id << std::endl; 85 | #endif 86 | } 87 | 88 | 89 | bool m_use_gpu_transporter; 90 | Cell *device_cells_ptr; 91 | }; 92 | 93 | #endif // gpu_setup_h_ 94 | //----------------------------------------------------------------------------// 95 | // end of gpu_setup.h 96 | //----------------------------------------------------------------------------// 97 | 98 | -------------------------------------------------------------------------------- /src/message_counter.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*-----------------------------------// 2 | /*! 3 | * \file message_counter.h 4 | * \author Alex Long 5 | * \date July 20 2016 6 | * \brief Struct that holds all network message counters 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //----------------------------------------------------------------------------// 11 | 12 | #ifndef message_counter_h_ 13 | #define message_counter_h_ 14 | 15 | #include 16 | 17 | struct Message_Counter { 18 | 19 | public: 20 | //! Constructor 21 | Message_Counter() 22 | : n_cell_messages(0), n_cells_sent(0), n_particle_messages(0), 23 | n_particles_sent(0), n_sends_posted(0), n_sends_completed(0), 24 | n_receives_posted(0), n_receives_completed(0) {} 25 | 26 | //! Destructor 27 | ~Message_Counter() {} 28 | 29 | //! Reset the counter data to zero 30 | void reset_counters(void) { 31 | n_cell_messages = 0; 32 | n_cells_sent = 0; 33 | n_particle_messages = 0; 34 | n_particles_sent = 0; 35 | n_sends_posted = 0; 36 | n_sends_completed = 0; 37 | n_receives_posted = 0; 38 | n_receives_completed = 0; 39 | } 40 | 41 | uint32_t n_cell_messages; //!< Number of cell messages 42 | uint32_t n_cells_sent; //!< Number of cells passed 43 | uint32_t n_particle_messages; //!< Number of particle messages 44 | uint64_t n_particles_sent; //!< Number of particles sent (64 bit) 45 | uint32_t n_sends_posted; //!< Number of sent messages posted 46 | uint32_t n_sends_completed; //!< Number of sent messages completed 47 | uint32_t n_receives_posted; //!< Number of received messages completed 48 | uint32_t n_receives_completed; //!< Number of received messages completed 49 | }; 50 | 51 | #endif // message_counter_h_ 52 | //----------------------------------------------------------------------------// 53 | // end of message_counter.h 54 | //----------------------------------------------------------------------------// 55 | -------------------------------------------------------------------------------- /src/pugixml/.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | coverage: 3 | status: 4 | project: 5 | default: 6 | informational: true 7 | patch: off 8 | -------------------------------------------------------------------------------- /src/pugixml/.gitattributes: -------------------------------------------------------------------------------- 1 | tests/data/* -text 2 | -------------------------------------------------------------------------------- /src/pugixml/.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'master' 7 | pull_request: 8 | 9 | jobs: 10 | unix: 11 | strategy: 12 | matrix: 13 | os: [ubuntu, macos] 14 | compiler: [g++, clang++] 15 | defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS] 16 | exclude: 17 | - os: macos 18 | compiler: g++ 19 | name: ${{matrix.os}} (${{matrix.compiler}}, ${{matrix.defines}}) 20 | runs-on: ${{matrix.os}}-latest 21 | steps: 22 | - uses: actions/checkout@v1 23 | - name: make test 24 | run: | 25 | export CXX=${{matrix.compiler}} 26 | make test cxxstd=c++11 defines=${{matrix.defines}} config=release -j2 27 | make test cxxstd=c++98 defines=${{matrix.defines}} config=debug -j2 28 | make test defines=${{matrix.defines}} config=sanitize -j2 29 | - name: make coverage 30 | if: ${{!(matrix.os == 'ubuntu' && matrix.compiler == 'clang++')}} # linux/clang produces coverage info gcov can't parse 31 | run: | 32 | export CXX=${{matrix.compiler}} 33 | make test defines=${{matrix.defines}} config=coverage -j2 34 | bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov -X search -t ${{secrets.CODECOV_TOKEN}} -B ${{github.ref}} 35 | 36 | windows: 37 | runs-on: windows-latest 38 | strategy: 39 | matrix: 40 | arch: [Win32, x64] 41 | defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS] 42 | steps: 43 | - uses: actions/checkout@v1 44 | - name: cmake configure 45 | run: cmake . -DPUGIXML_BUILD_TESTS=ON -D${{matrix.defines}}=ON -A ${{matrix.arch}} 46 | - name: cmake test 47 | shell: bash # necessary for fail-fast 48 | run: | 49 | cmake --build . -- -property:Configuration=Debug -verbosity:minimal 50 | Debug/pugixml-check.exe 51 | cmake --build . -- -property:Configuration=Release -verbosity:minimal 52 | Release/pugixml-check.exe 53 | -------------------------------------------------------------------------------- /src/pugixml/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /.vscode/ 3 | -------------------------------------------------------------------------------- /src/pugixml/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2006-2024 Arseny Kapoulkine 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /src/pugixml/Makefile: -------------------------------------------------------------------------------- 1 | .SUFFIXES: 2 | MAKEFLAGS+=-r 3 | 4 | config=debug 5 | defines=standard 6 | cxxstd=c++11 7 | # set cxxstd=any to disable use of -std=... 8 | 9 | BUILD=build/make-$(firstword $(CXX))-$(config)-$(defines)-$(cxxstd) 10 | 11 | SOURCES=src/pugixml.cpp $(filter-out tests/fuzz_%,$(wildcard tests/*.cpp)) 12 | EXECUTABLE=$(BUILD)/test 13 | 14 | VERSION=$(shell sed -n 's/.*version \(.*\).*/\1/p' src/pugiconfig.hpp) 15 | RELEASE=$(filter-out scripts/archive.py docs/%.adoc,$(shell git ls-files docs scripts src CMakeLists.txt LICENSE.md readme.txt)) 16 | 17 | CXXFLAGS=-g -Wall -Wextra -Werror -pedantic -Wundef -Wshadow -Wcast-align -Wcast-qual -Wold-style-cast -Wdouble-promotion 18 | LDFLAGS= 19 | 20 | ifeq ($(config),release) 21 | CXXFLAGS+=-O3 -DNDEBUG 22 | endif 23 | 24 | ifeq ($(config),coverage) 25 | CXXFLAGS+=-coverage 26 | LDFLAGS+=-coverage 27 | endif 28 | 29 | ifeq ($(config),sanitize) 30 | CXXFLAGS+=-fsanitize=address,undefined -fno-sanitize-recover=all 31 | LDFLAGS+=-fsanitize=address,undefined 32 | endif 33 | 34 | ifeq ($(config),analyze) 35 | CXXFLAGS+=--analyze 36 | endif 37 | 38 | ifneq ($(defines),standard) 39 | COMMA=, 40 | CXXFLAGS+=-D $(subst $(COMMA), -D ,$(defines)) 41 | endif 42 | 43 | ifneq ($(findstring PUGIXML_NO_EXCEPTIONS,$(defines)),) 44 | CXXFLAGS+=-fno-exceptions 45 | endif 46 | 47 | ifneq ($(cxxstd),any) 48 | CXXFLAGS+=-std=$(cxxstd) 49 | endif 50 | 51 | OBJECTS=$(SOURCES:%=$(BUILD)/%.o) 52 | 53 | all: $(EXECUTABLE) 54 | 55 | ifeq ($(config),coverage) 56 | test: $(EXECUTABLE) 57 | -@find $(BUILD) -name '*.gcda' -exec rm {} + 58 | ./$(EXECUTABLE) 59 | @gcov -b -o $(BUILD)/src/ pugixml.cpp.gcda | sed -e '/./{H;$!d;}' -e 'x;/pugixml.cpp/!d;' 60 | @find . -name '*.gcov' -and -not -name 'pugixml.cpp.gcov' -exec rm {} + 61 | @sed -i -e "s/#####\(.*\)\(\/\/ unreachable.*\)/ 1\1\2/" pugixml.cpp.gcov 62 | else 63 | test: $(EXECUTABLE) 64 | ./$(EXECUTABLE) 65 | endif 66 | 67 | fuzz_%: $(BUILD)/fuzz_% 68 | @mkdir -p build/$@ 69 | $< build/$@ tests/data_fuzz_$* -max_len=1024 -dict=tests/fuzz_$*.dict -fork=16 70 | 71 | clean: 72 | rm -rf $(BUILD) 73 | 74 | release: build/pugixml-$(VERSION).tar.gz build/pugixml-$(VERSION).zip 75 | 76 | docs: docs/quickstart.html docs/manual.html 77 | 78 | build/pugixml-%: .FORCE | $(RELEASE) 79 | @mkdir -p $(BUILD) 80 | TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python3 scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $| 81 | 82 | $(EXECUTABLE): $(OBJECTS) 83 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@ 84 | 85 | $(BUILD)/fuzz_%: tests/fuzz_%.cpp src/pugixml.cpp 86 | @mkdir -p $(BUILD) 87 | $(CXX) $(CXXFLAGS) -fsanitize=address,fuzzer $^ -o $@ 88 | 89 | $(BUILD)/%.o: % 90 | @mkdir -p $(dir $@) 91 | $(CXX) $< $(CXXFLAGS) -c -MMD -MP -o $@ 92 | 93 | -include $(OBJECTS:.o=.d) 94 | 95 | .SECONDEXPANSION: 96 | docs/%.html: docs/%.adoc $$(shell sed -n 's/include\:\:\(.*\)\[.*/docs\/\1/p' docs/%.adoc) 97 | asciidoctor -b html5 -a version=$(VERSION) $< -o $@ 98 | 99 | .PHONY: all test clean release .FORCE 100 | -------------------------------------------------------------------------------- /src/pugixml/README.md: -------------------------------------------------------------------------------- 1 | pugixml [![Actions Status](https://github.com/zeux/pugixml/workflows/build/badge.svg)](https://github.com/zeux/pugixml/actions) [![Build status](https://ci.appveyor.com/api/projects/status/9hdks1doqvq8pwe7/branch/master?svg=true)](https://ci.appveyor.com/project/zeux/pugixml) [![codecov.io](https://codecov.io/github/zeux/pugixml/coverage.svg?branch=master)](https://codecov.io/github/zeux/pugixml?branch=master) ![MIT](https://img.shields.io/badge/license-MIT-blue.svg) 2 | ======= 3 | 4 | pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification 5 | capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 6 | implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface 7 | variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). 8 | 9 | pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface. 10 | 11 | ## Documentation 12 | 13 | Documentation for the current release of pugixml is available on-line as two separate documents: 14 | 15 | * [Quick-start guide](https://pugixml.org/docs/quickstart.html), that aims to provide enough information to start using the library; 16 | * [Complete reference manual](https://pugixml.org/docs/manual.html), that describes all features of the library in detail. 17 | 18 | You’re advised to start with the quick-start guide; however, many important library features are either not described in it at all or only mentioned briefly; if you require more information you should read the complete manual. 19 | 20 | ## Example 21 | 22 | Here's an example of how code using pugixml looks; it opens an XML file, goes over all Tool nodes and prints tools that have a Timeout attribute greater than 0: 23 | 24 | ```c++ 25 | #include "pugixml.hpp" 26 | #include 27 | 28 | int main() 29 | { 30 | pugi::xml_document doc; 31 | pugi::xml_parse_result result = doc.load_file("xgconsole.xml"); 32 | if (!result) 33 | return -1; 34 | 35 | for (pugi::xml_node tool: doc.child("Profile").child("Tools").children("Tool")) 36 | { 37 | int timeout = tool.attribute("Timeout").as_int(); 38 | 39 | if (timeout > 0) 40 | std::cout << "Tool " << tool.attribute("Filename").value() << " has timeout " << timeout << "\n"; 41 | } 42 | } 43 | ``` 44 | 45 | And the same example using XPath: 46 | 47 | ```c++ 48 | #include "pugixml.hpp" 49 | #include 50 | 51 | int main() 52 | { 53 | pugi::xml_document doc; 54 | pugi::xml_parse_result result = doc.load_file("xgconsole.xml"); 55 | if (!result) 56 | return -1; 57 | 58 | pugi::xpath_node_set tools_with_timeout = doc.select_nodes("/Profile/Tools/Tool[@Timeout > 0]"); 59 | 60 | for (pugi::xpath_node node: tools_with_timeout) 61 | { 62 | pugi::xml_node tool = node.node(); 63 | std::cout << "Tool " << tool.attribute("Filename").value() << 64 | " has timeout " << tool.attribute("Timeout").as_int() << "\n"; 65 | } 66 | } 67 | ``` 68 | 69 | 70 | ## License 71 | 72 | This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md). 73 | -------------------------------------------------------------------------------- /src/pugixml/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Please verify that the vulnerabilities reported can be reproduced on the [latest released version](https://github.com/zeux/pugixml/releases). 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Vulnerabilities can be reported via e-mail to the [project maintainer](https://github.com/zeux). 10 | -------------------------------------------------------------------------------- /src/pugixml/appveyor.yml: -------------------------------------------------------------------------------- 1 | branches: 2 | only: 3 | - master 4 | 5 | image: 6 | - Visual Studio 2022 7 | - Visual Studio 2019 8 | - Visual Studio 2017 9 | - Visual Studio 2015 10 | 11 | version: "{branch}-{build}" 12 | 13 | build_script: 14 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2013") { .\scripts\nuget_build.ps1 2013} 15 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\scripts\nuget_build.ps1 2015} 16 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\scripts\nuget_build.ps1 2017} 17 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\scripts\nuget_build.ps1 2019} 18 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\scripts\nuget_build.ps1 2022} 19 | 20 | test_script: 21 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\autotest-appveyor.ps1 9 10 11 12 14 } 22 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\tests\autotest-appveyor.ps1 15 } 23 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\tests\autotest-appveyor.ps1 19 } 24 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\tests\autotest-appveyor.ps1 22 } 25 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make -j2 config=coverage test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" } 26 | - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make -j2 config=coverage defines=PUGIXML_WCHAR_MODE test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" } 27 | 28 | artifacts: 29 | - path: .\scripts\*.nupkg 30 | -------------------------------------------------------------------------------- /src/pugixml/docs/config.adoc: -------------------------------------------------------------------------------- 1 | website ; repository 2 | :toc: right 3 | :source-highlighter: pygments 4 | :source-language: c++ 5 | :sectanchors: 6 | :sectlinks: 7 | :imagesdir: images 8 | -------------------------------------------------------------------------------- /src/pugixml/docs/images/dom_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/dom_tree.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_link1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_link1.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_link2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_link2.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_pch1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_pch1.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_pch2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_pch2.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_pch3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_pch3.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2005_pch4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2005_pch4.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2010_link1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2010_link1.png -------------------------------------------------------------------------------- /src/pugixml/docs/images/vs2010_link2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/images/vs2010_link2.png -------------------------------------------------------------------------------- /src/pugixml/docs/samples/character.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/custom_memory_management.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | // tag::decl[] 6 | void* custom_allocate(size_t size) 7 | { 8 | return new (std::nothrow) char[size]; 9 | } 10 | 11 | void custom_deallocate(void* ptr) 12 | { 13 | delete[] static_cast(ptr); 14 | } 15 | // end::decl[] 16 | 17 | int main() 18 | { 19 | // tag::call[] 20 | pugi::set_memory_management_functions(custom_allocate, custom_deallocate); 21 | // end::call[] 22 | 23 | pugi::xml_document doc; 24 | doc.load_string(""); 25 | } 26 | 27 | // vim:et 28 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/include.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | // tag::code[] 7 | bool load_preprocess(pugi::xml_document& doc, const char* path); 8 | 9 | bool preprocess(pugi::xml_node node) 10 | { 11 | for (pugi::xml_node child = node.first_child(); child; ) 12 | { 13 | if (child.type() == pugi::node_pi && strcmp(child.name(), "include") == 0) 14 | { 15 | pugi::xml_node include = child; 16 | 17 | // load new preprocessed document (note: ideally this should handle relative paths) 18 | const char* path = include.value(); 19 | 20 | pugi::xml_document doc; 21 | if (!load_preprocess(doc, path)) return false; 22 | 23 | // insert the comment marker above include directive 24 | node.insert_child_before(pugi::node_comment, include).set_value(path); 25 | 26 | // copy the document above the include directive (this retains the original order!) 27 | for (pugi::xml_node ic = doc.first_child(); ic; ic = ic.next_sibling()) 28 | { 29 | node.insert_copy_before(ic, include); 30 | } 31 | 32 | // remove the include node and move to the next child 33 | child = child.next_sibling(); 34 | 35 | node.remove_child(include); 36 | } 37 | else 38 | { 39 | if (!preprocess(child)) return false; 40 | 41 | child = child.next_sibling(); 42 | } 43 | } 44 | 45 | return true; 46 | } 47 | 48 | bool load_preprocess(pugi::xml_document& doc, const char* path) 49 | { 50 | pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for 51 | 52 | return result ? preprocess(doc) : false; 53 | } 54 | // end::code[] 55 | 56 | int main() 57 | { 58 | pugi::xml_document doc; 59 | if (!load_preprocess(doc, "character.xml")) return -1; 60 | 61 | doc.print(std::cout); 62 | } 63 | 64 | // vim:et 65 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/load_error_handling.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | void check_xml(const char* source) 6 | { 7 | // tag::code[] 8 | pugi::xml_document doc; 9 | pugi::xml_parse_result result = doc.load_string(source); 10 | 11 | if (result) 12 | { 13 | std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n"; 14 | } 15 | else 16 | { 17 | std::cout << "XML [" << source << "] parsed with errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n"; 18 | std::cout << "Error description: " << result.description() << "\n"; 19 | std::cout << "Error offset: " << result.offset << " (error at [..." << (source + result.offset) << "]\n\n"; 20 | } 21 | // end::code[] 22 | } 23 | 24 | int main() 25 | { 26 | check_xml("text"); 27 | check_xml("text"); 28 | check_xml("text"); 29 | check_xml("<#tag />"); 31 | } 32 | 33 | // vim:et 34 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/load_file.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // tag::code[] 8 | pugi::xml_document doc; 9 | 10 | pugi::xml_parse_result result = doc.load_file("tree.xml"); 11 | 12 | std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; 13 | // end::code[] 14 | } 15 | 16 | // vim:et 17 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/load_memory.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | // tag::decl[] 9 | const char source[] = "0 0 1 1"; 10 | size_t size = sizeof(source); 11 | // end::decl[] 12 | 13 | pugi::xml_document doc; 14 | 15 | { 16 | // tag::load_buffer[] 17 | // You can use load_buffer to load document from immutable memory block: 18 | pugi::xml_parse_result result = doc.load_buffer(source, size); 19 | // end::load_buffer[] 20 | 21 | std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; 22 | } 23 | 24 | { 25 | // tag::load_buffer_inplace_begin[] 26 | // You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document 27 | char* buffer = new char[size]; 28 | memcpy(buffer, source, size); 29 | 30 | // The block can be allocated by any method; the block is modified during parsing 31 | pugi::xml_parse_result result = doc.load_buffer_inplace(buffer, size); 32 | // end::load_buffer_inplace_begin[] 33 | 34 | std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; 35 | 36 | // tag::load_buffer_inplace_end[] 37 | // You have to destroy the block yourself after the document is no longer used 38 | delete[] buffer; 39 | // end::load_buffer_inplace_end[] 40 | } 41 | 42 | { 43 | // tag::load_buffer_inplace_own[] 44 | // You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block 45 | // The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect 46 | char* buffer = static_cast(pugi::get_memory_allocation_function()(size)); 47 | memcpy(buffer, source, size); 48 | 49 | // The block will be deleted by the document 50 | pugi::xml_parse_result result = doc.load_buffer_inplace_own(buffer, size); 51 | // end::load_buffer_inplace_own[] 52 | 53 | std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; 54 | } 55 | 56 | { 57 | // tag::load_string[] 58 | // You can use load to load document from null-terminated strings, for example literals: 59 | pugi::xml_parse_result result = doc.load_string("0 0 1 1"); 60 | // end::load_string[] 61 | 62 | std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; 63 | } 64 | } 65 | 66 | // vim:et 67 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/load_options.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | 9 | // tag::code[] 10 | const char* source = "<"; 11 | 12 | // Parsing with default options; note that comment node is not added to the tree, and entity reference < is expanded 13 | doc.load_string(source); 14 | std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; 15 | 16 | // Parsing with additional parse_comments option; comment node is now added to the tree 17 | doc.load_string(source, pugi::parse_default | pugi::parse_comments); 18 | std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; 19 | 20 | // Parsing with additional parse_comments option and without the (default) parse_escapes option; < is not expanded 21 | doc.load_string(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes); 22 | std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; 23 | 24 | // Parsing with minimal option mask; comment node is not added to the tree, and < is not expanded 25 | doc.load_string(source, pugi::parse_minimal); 26 | std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; 27 | // end::code[] 28 | } 29 | 30 | // vim:et 31 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/load_stream.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void print_doc(const char* message, const pugi::xml_document& doc, const pugi::xml_parse_result& result) 8 | { 9 | std::cout 10 | << message 11 | << "\t: load result '" << result.description() << "'" 12 | << ", first character of root name: U+" << std::hex << std::uppercase << std::setw(4) << std::setfill('0') << pugi::as_wide(doc.first_child().name())[0] 13 | << ", year: " << doc.first_child().first_child().first_child().child_value() 14 | << std::endl; 15 | } 16 | 17 | bool try_imbue(std::wistream& stream, const char* name) 18 | { 19 | try 20 | { 21 | stream.imbue(std::locale(name)); 22 | 23 | return true; 24 | } 25 | catch (const std::exception&) 26 | { 27 | return false; 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | pugi::xml_document doc; 34 | 35 | { 36 | // tag::code[] 37 | std::ifstream stream("weekly-utf-8.xml"); 38 | pugi::xml_parse_result result = doc.load(stream); 39 | // end::code[] 40 | 41 | // first character of root name: U+9031, year: 1997 42 | print_doc("UTF8 file from narrow stream", doc, result); 43 | } 44 | 45 | { 46 | std::ifstream stream("weekly-utf-16.xml"); 47 | pugi::xml_parse_result result = doc.load(stream); 48 | 49 | // first character of root name: U+9031, year: 1997 50 | print_doc("UTF16 file from narrow stream", doc, result); 51 | } 52 | 53 | { 54 | // Since wide streams are treated as UTF-16/32 ones, you can't load the UTF-8 file from a wide stream 55 | // directly if you have localized characters; you'll have to provide a UTF8 locale (there is no 56 | // standard one; you can use utf8_codecvt_facet from Boost or codecvt_utf8 from C++0x) 57 | std::wifstream stream("weekly-utf-8.xml"); 58 | 59 | if (try_imbue(stream, "en_US.UTF-8")) // try Linux encoding 60 | { 61 | pugi::xml_parse_result result = doc.load(stream); 62 | 63 | // first character of root name: U+00E9, year: 1997 64 | print_doc("UTF8 file from wide stream", doc, result); 65 | } 66 | else 67 | { 68 | std::cout << "UTF-8 locale is not available\n"; 69 | } 70 | } 71 | 72 | { 73 | // Since wide streams are treated as UTF-16/32 ones, you can't load the UTF-16 file from a wide stream without 74 | // using custom codecvt; you can use codecvt_utf16 from C++0x 75 | } 76 | 77 | { 78 | // Since encoding names are non-standard, you can't load the Shift-JIS (or any other non-ASCII) file 79 | // from a wide stream portably 80 | std::wifstream stream("weekly-shift_jis.xml"); 81 | 82 | if (try_imbue(stream, ".932") || // try Microsoft encoding 83 | try_imbue(stream, "ja_JP.SJIS")) // try Linux encoding; run "localedef -i ja_JP -c -f SHIFT_JIS /usr/lib/locale/ja_JP.SJIS" to get it 84 | { 85 | pugi::xml_parse_result result = doc.load(stream); 86 | 87 | // first character of root name: U+9031, year: 1997 88 | print_doc("Shift-JIS file from wide stream", doc, result); 89 | } 90 | else 91 | { 92 | std::cout << "Shift-JIS locale is not available\n"; 93 | } 94 | } 95 | } 96 | 97 | // vim:et 98 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/modify_add.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | 9 | // tag::code[] 10 | // add node with some name 11 | pugi::xml_node node = doc.append_child("node"); 12 | 13 | // add description node with text child 14 | pugi::xml_node descr = node.append_child("description"); 15 | descr.append_child(pugi::node_pcdata).set_value("Simple node"); 16 | 17 | // add param node before the description 18 | pugi::xml_node param = node.insert_child_before("param", descr); 19 | 20 | // add attributes to param node 21 | param.append_attribute("name") = "version"; 22 | param.append_attribute("value") = 1.1; 23 | param.insert_attribute_after("type", param.attribute("name")) = "float"; 24 | // end::code[] 25 | 26 | doc.print(std::cout); 27 | } 28 | 29 | // vim:et 30 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/modify_base.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | pugi::xml_document doc; 9 | if (!doc.load_string("text", pugi::parse_default | pugi::parse_comments)) return -1; 10 | 11 | // tag::node[] 12 | pugi::xml_node node = doc.child("node"); 13 | 14 | // change node name 15 | std::cout << node.set_name("notnode"); 16 | std::cout << ", new node name: " << node.name() << std::endl; 17 | 18 | // change comment text 19 | std::cout << doc.last_child().set_value("useless comment"); 20 | std::cout << ", new comment text: " << doc.last_child().value() << std::endl; 21 | 22 | // we can't change value of the element or name of the comment 23 | std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl; 24 | // end::node[] 25 | 26 | // tag::attr[] 27 | pugi::xml_attribute attr = node.attribute("id"); 28 | 29 | // change attribute name/value 30 | std::cout << attr.set_name("key") << ", " << attr.set_value("345"); 31 | std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl; 32 | 33 | // we can use numbers or booleans 34 | attr.set_value(1.234); 35 | std::cout << "new attribute value: " << attr.value() << std::endl; 36 | 37 | // we can also use assignment operators for more concise code 38 | attr = true; 39 | std::cout << "final attribute value: " << attr.value() << std::endl; 40 | // end::attr[] 41 | } 42 | 43 | // vim:et 44 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/modify_remove.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | if (!doc.load_string("Simple node")) return -1; 9 | 10 | // tag::code[] 11 | // remove description node with the whole subtree 12 | pugi::xml_node node = doc.child("node"); 13 | node.remove_child("description"); 14 | 15 | // remove id attribute 16 | pugi::xml_node param = node.child("param"); 17 | param.remove_attribute("value"); 18 | 19 | // we can also remove nodes/attributes by handles 20 | pugi::xml_attribute id = param.attribute("name"); 21 | param.remove_attribute(id); 22 | // end::code[] 23 | 24 | doc.print(std::cout); 25 | } 26 | 27 | // vim:et 28 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_custom_writer.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // tag::code[] 8 | struct xml_string_writer: pugi::xml_writer 9 | { 10 | std::string result; 11 | 12 | virtual void write(const void* data, size_t size) 13 | { 14 | result.append(static_cast(data), size); 15 | } 16 | }; 17 | // end::code[] 18 | 19 | struct xml_memory_writer: pugi::xml_writer 20 | { 21 | char* buffer; 22 | size_t capacity; 23 | 24 | size_t result; 25 | 26 | xml_memory_writer(): buffer(0), capacity(0), result(0) 27 | { 28 | } 29 | 30 | xml_memory_writer(char* buffer, size_t capacity): buffer(buffer), capacity(capacity), result(0) 31 | { 32 | } 33 | 34 | size_t written_size() const 35 | { 36 | return result < capacity ? result : capacity; 37 | } 38 | 39 | virtual void write(const void* data, size_t size) 40 | { 41 | if (result < capacity) 42 | { 43 | size_t chunk = (capacity - result < size) ? capacity - result : size; 44 | 45 | memcpy(buffer + result, data, chunk); 46 | } 47 | 48 | result += size; 49 | } 50 | }; 51 | 52 | std::string node_to_string(pugi::xml_node node) 53 | { 54 | xml_string_writer writer; 55 | node.print(writer); 56 | 57 | return writer.result; 58 | } 59 | 60 | char* node_to_buffer(pugi::xml_node node, char* buffer, size_t size) 61 | { 62 | if (size == 0) return buffer; 63 | 64 | // leave one character for null terminator 65 | xml_memory_writer writer(buffer, size - 1); 66 | node.print(writer); 67 | 68 | // null terminate 69 | buffer[writer.written_size()] = 0; 70 | 71 | return buffer; 72 | } 73 | 74 | char* node_to_buffer_heap(pugi::xml_node node) 75 | { 76 | // first pass: get required memory size 77 | xml_memory_writer counter; 78 | node.print(counter); 79 | 80 | // allocate necessary size (+1 for null termination) 81 | char* buffer = new char[counter.result + 1]; 82 | 83 | // second pass: actual printing 84 | xml_memory_writer writer(buffer, counter.result); 85 | node.print(writer); 86 | 87 | // null terminate 88 | buffer[writer.written_size()] = 0; 89 | 90 | return buffer; 91 | } 92 | 93 | int main() 94 | { 95 | // get a test document 96 | pugi::xml_document doc; 97 | doc.load_string("hey"); 98 | 99 | // get contents as std::string (single pass) 100 | std::cout << "contents: [" << node_to_string(doc) << "]\n"; 101 | 102 | // get contents into fixed-size buffer (single pass) 103 | char large_buf[128]; 104 | std::cout << "contents: [" << node_to_buffer(doc, large_buf, sizeof(large_buf)) << "]\n"; 105 | 106 | // get contents into fixed-size buffer (single pass, shows truncating behavior) 107 | char small_buf[22]; 108 | std::cout << "contents: [" << node_to_buffer(doc, small_buf, sizeof(small_buf)) << "]\n"; 109 | 110 | // get contents into heap-allocated buffer (two passes) 111 | char* heap_buf = node_to_buffer_heap(doc); 112 | std::cout << "contents: [" << heap_buf << "]\n"; 113 | delete[] heap_buf; 114 | } 115 | 116 | // vim:et 117 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_declaration.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // tag::code[] 8 | // get a test document 9 | pugi::xml_document doc; 10 | doc.load_string("hey"); 11 | 12 | // add a custom declaration node 13 | pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); 14 | decl.append_attribute("version") = "1.0"; 15 | decl.append_attribute("encoding") = "UTF-8"; 16 | decl.append_attribute("standalone") = "no"; 17 | 18 | // 19 | // 20 | // hey 21 | // 22 | doc.save(std::cout); 23 | std::cout << std::endl; 24 | // end::code[] 25 | } 26 | 27 | // vim:et 28 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_file.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // get a test document 8 | pugi::xml_document doc; 9 | doc.load_string("hey"); 10 | 11 | // tag::code[] 12 | // save document to file 13 | std::cout << "Saving result: " << doc.save_file("save_file_output.xml") << std::endl; 14 | // end::code[] 15 | } 16 | 17 | // vim:et 18 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_options.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // tag::code[] 8 | // get a test document 9 | pugi::xml_document doc; 10 | doc.load_string("hey"); 11 | 12 | // default options; prints 13 | // 14 | // 15 | // hey 16 | // 17 | doc.save(std::cout); 18 | std::cout << std::endl; 19 | 20 | // default options with custom indentation string; prints 21 | // 22 | // 23 | // --hey 24 | // 25 | doc.save(std::cout, "--"); 26 | std::cout << std::endl; 27 | 28 | // default options without indentation; prints 29 | // 30 | // 31 | // hey 32 | // 33 | doc.save(std::cout, "\t", pugi::format_default & ~pugi::format_indent); // can also pass "" instead of indentation string for the same effect 34 | std::cout << std::endl; 35 | 36 | // raw output; prints 37 | // hey 38 | doc.save(std::cout, "\t", pugi::format_raw); 39 | std::cout << std::endl << std::endl; 40 | 41 | // raw output without declaration; prints 42 | // hey 43 | doc.save(std::cout, "\t", pugi::format_raw | pugi::format_no_declaration); 44 | std::cout << std::endl; 45 | // end::code[] 46 | } 47 | 48 | // vim:et 49 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_stream.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // get a test document 8 | pugi::xml_document doc; 9 | doc.load_string("hey"); 10 | 11 | // tag::code[] 12 | // save document to standard output 13 | std::cout << "Document:\n"; 14 | doc.save(std::cout); 15 | // end::code[] 16 | } 17 | 18 | // vim:et 19 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/save_subtree.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | // tag::code[] 8 | // get a test document 9 | pugi::xml_document doc; 10 | doc.load_string("hey"); 11 | 12 | // print document to standard output (prints hey) 13 | doc.save(std::cout, "", pugi::format_raw); 14 | std::cout << std::endl; 15 | 16 | // print document to standard output as a regular node (prints hey) 17 | doc.print(std::cout, "", pugi::format_raw); 18 | std::cout << std::endl; 19 | 20 | // print a subtree to standard output (prints hey) 21 | doc.child("foo").child("call").print(std::cout, "", pugi::format_raw); 22 | std::cout << std::endl; 23 | // end::code[] 24 | } 25 | 26 | // vim:et 27 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/text.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | 9 | // get a test document 10 | doc.load_string("test1.1yes"); 11 | 12 | pugi::xml_node project = doc.child("project"); 13 | 14 | // tag::access[] 15 | std::cout << "Project name: " << project.child("name").text().get() << std::endl; 16 | std::cout << "Project version: " << project.child("version").text().as_double() << std::endl; 17 | std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl; 18 | std::cout << "Project description: " << project.child("description").text().get() << std::endl; 19 | // end::access[] 20 | 21 | std::cout << std::endl; 22 | 23 | // tag::modify[] 24 | // change project version 25 | project.child("version").text() = 1.2; 26 | 27 | // add description element and set the contents 28 | // note that we do not have to explicitly add the node_pcdata child 29 | project.append_child("description").text().set("a test project"); 30 | // end::modify[] 31 | 32 | doc.save(std::cout); 33 | } 34 | 35 | // vim:et 36 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/transitions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/traverse_base.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | pugi::xml_document doc; 9 | if (!doc.load_file("xgconsole.xml")) return -1; 10 | 11 | pugi::xml_node tools = doc.child("Profile").child("Tools"); 12 | 13 | // tag::basic[] 14 | for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling()) 15 | { 16 | std::cout << "Tool:"; 17 | 18 | for (pugi::xml_attribute attr = tool.first_attribute(); attr; attr = attr.next_attribute()) 19 | { 20 | std::cout << " " << attr.name() << "=" << attr.value(); 21 | } 22 | 23 | std::cout << std::endl; 24 | } 25 | // end::basic[] 26 | 27 | std::cout << std::endl; 28 | 29 | // tag::data[] 30 | for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) 31 | { 32 | std::cout << "Tool " << tool.attribute("Filename").value(); 33 | std::cout << ": AllowRemote " << tool.attribute("AllowRemote").as_bool(); 34 | std::cout << ", Timeout " << tool.attribute("Timeout").as_int(); 35 | std::cout << ", Description '" << tool.child_value("Description") << "'\n"; 36 | } 37 | // end::data[] 38 | 39 | std::cout << std::endl; 40 | 41 | // tag::contents[] 42 | std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n"; 43 | 44 | for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) 45 | { 46 | std::cout << "Tool " << tool.attribute("Filename").value() << "\n"; 47 | } 48 | // end::contents[] 49 | } 50 | 51 | // vim:et 52 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/traverse_iter.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | if (!doc.load_file("xgconsole.xml")) return -1; 9 | 10 | pugi::xml_node tools = doc.child("Profile").child("Tools"); 11 | 12 | // tag::code[] 13 | for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it) 14 | { 15 | std::cout << "Tool:"; 16 | 17 | for (pugi::xml_attribute_iterator ait = it->attributes_begin(); ait != it->attributes_end(); ++ait) 18 | { 19 | std::cout << " " << ait->name() << "=" << ait->value(); 20 | } 21 | 22 | std::cout << std::endl; 23 | } 24 | // end::code[] 25 | } 26 | 27 | // vim:et 28 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/traverse_predicate.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | // tag::decl[] 7 | bool small_timeout(pugi::xml_node node) 8 | { 9 | return node.attribute("Timeout").as_int() < 20; 10 | } 11 | 12 | struct allow_remote_predicate 13 | { 14 | bool operator()(pugi::xml_attribute attr) const 15 | { 16 | return strcmp(attr.name(), "AllowRemote") == 0; 17 | } 18 | 19 | bool operator()(pugi::xml_node node) const 20 | { 21 | return node.attribute("AllowRemote").as_bool(); 22 | } 23 | }; 24 | // end::decl[] 25 | 26 | int main() 27 | { 28 | pugi::xml_document doc; 29 | if (!doc.load_file("xgconsole.xml")) return -1; 30 | 31 | pugi::xml_node tools = doc.child("Profile").child("Tools"); 32 | 33 | // tag::find[] 34 | // Find child via predicate (looks for direct children only) 35 | std::cout << tools.find_child(allow_remote_predicate()).attribute("Filename").value() << std::endl; 36 | 37 | // Find node via predicate (looks for all descendants in depth-first order) 38 | std::cout << doc.find_node(allow_remote_predicate()).attribute("Filename").value() << std::endl; 39 | 40 | // Find attribute via predicate 41 | std::cout << tools.last_child().find_attribute(allow_remote_predicate()).value() << std::endl; 42 | 43 | // We can use simple functions instead of function objects 44 | std::cout << tools.find_child(small_timeout).attribute("Filename").value() << std::endl; 45 | // end::find[] 46 | } 47 | 48 | // vim:et 49 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/traverse_rangefor.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | if (!doc.load_file("xgconsole.xml")) return -1; 9 | 10 | pugi::xml_node tools = doc.child("Profile").child("Tools"); 11 | 12 | // tag::code[] 13 | for (pugi::xml_node tool: tools.children("Tool")) 14 | { 15 | std::cout << "Tool:"; 16 | 17 | for (pugi::xml_attribute attr: tool.attributes()) 18 | { 19 | std::cout << " " << attr.name() << "=" << attr.value(); 20 | } 21 | 22 | for (pugi::xml_node child: tool.children()) 23 | { 24 | std::cout << ", child " << child.name(); 25 | } 26 | 27 | std::cout << std::endl; 28 | } 29 | // end::code[] 30 | } 31 | 32 | // vim:et 33 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/traverse_walker.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | const char* node_types[] = 6 | { 7 | "null", "document", "element", "pcdata", "cdata", "comment", "pi", "declaration" 8 | }; 9 | 10 | // tag::impl[] 11 | struct simple_walker: pugi::xml_tree_walker 12 | { 13 | virtual bool for_each(pugi::xml_node& node) 14 | { 15 | for (int i = 0; i < depth(); ++i) std::cout << " "; // indentation 16 | 17 | std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n"; 18 | 19 | return true; // continue traversal 20 | } 21 | }; 22 | // end::impl[] 23 | 24 | int main() 25 | { 26 | pugi::xml_document doc; 27 | if (!doc.load_file("tree.xml")) return -1; 28 | 29 | // tag::traverse[] 30 | simple_walker walker; 31 | doc.traverse(walker); 32 | // end::traverse[] 33 | } 34 | 35 | // vim:et 36 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/tree.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | some text 5 | 6 | some more text 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/weekly-shift_jis.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/samples/weekly-shift_jis.xml -------------------------------------------------------------------------------- /src/pugixml/docs/samples/weekly-utf-16.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/docs/samples/weekly-utf-16.xml -------------------------------------------------------------------------------- /src/pugixml/docs/samples/weekly-utf-8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <週報> 5 | <年月週> 6 | <年度>1997 7 | <月度>1 8 | <週>1 9 | 10 | 11 | <氏名> 12 | <氏>山田 13 | <名>太郎 14 | 15 | 16 | <業務報告リスト> 17 | <業務報告> 18 | <業務名>XMLエディターの作成 19 | <業務コード>X3355-23 20 | <工数管理> 21 | <見積もり工数>1600 22 | <実績工数>320 23 | <当月見積もり工数>160 24 | <当月実績工数>24 25 | 26 | <予定項目リスト> 27 | <予定項目> 28 |

XMLエディターの基本仕様の作成

29 | 30 | 31 | <実施事項リスト> 32 | <実施事項> 33 |

XMLエディターの基本仕様の作成

34 | 35 | <実施事項> 36 |

競合他社製品の機能調査

37 | 38 | 39 | <上長への要請事項リスト> 40 | <上長への要請事項> 41 |

特になし

42 | 43 | 44 | <問題点対策> 45 |

XMLとは何かわからない。

46 | 47 | 48 | 49 | <業務報告> 50 | <業務名>検索エンジンの開発 51 | <業務コード>S8821-76 52 | <工数管理> 53 | <見積もり工数>120 54 | <実績工数>6 55 | <当月見積もり工数>32 56 | <当月実績工数>2 57 | 58 | <予定項目リスト> 59 | <予定項目> 60 |

gooの機能を調べてみる

61 | 62 | 63 | <実施事項リスト> 64 | <実施事項> 65 |

更に、どういう検索エンジンがあるか調査する

66 | 67 | 68 | <上長への要請事項リスト> 69 | <上長への要請事項> 70 |

開発をするのはめんどうなので、Yahoo!を買収して下さい。

71 | 72 | 73 | <問題点対策> 74 |

検索エンジンで車を走らせることができない。(要調査)

75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/xgconsole.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jamplus build system 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/xpath_error.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | if (!doc.load_file("xgconsole.xml")) return -1; 9 | 10 | // tag::code[] 11 | // Exception is thrown for incorrect query syntax 12 | try 13 | { 14 | doc.select_nodes("//nodes[#true()]"); 15 | } 16 | catch (const pugi::xpath_exception& e) 17 | { 18 | std::cout << "Select failed: " << e.what() << std::endl; 19 | } 20 | 21 | // Exception is thrown for incorrect query semantics 22 | try 23 | { 24 | doc.select_nodes("(123)/next"); 25 | } 26 | catch (const pugi::xpath_exception& e) 27 | { 28 | std::cout << "Select failed: " << e.what() << std::endl; 29 | } 30 | 31 | // Exception is thrown for query with incorrect return type 32 | try 33 | { 34 | doc.select_nodes("123"); 35 | } 36 | catch (const pugi::xpath_exception& e) 37 | { 38 | std::cout << "Select failed: " << e.what() << std::endl; 39 | } 40 | // end::code[] 41 | } 42 | 43 | // vim:et 44 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/xpath_query.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | pugi::xml_document doc; 9 | if (!doc.load_file("xgconsole.xml")) return -1; 10 | 11 | // tag::code[] 12 | // Select nodes via compiled query 13 | pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote='true']"); 14 | 15 | pugi::xpath_node_set tools = query_remote_tools.evaluate_node_set(doc); 16 | std::cout << "Remote tool: "; 17 | tools[2].node().print(std::cout); 18 | 19 | // Evaluate numbers via compiled query 20 | pugi::xpath_query query_timeouts("sum(//Tool/@Timeout)"); 21 | std::cout << query_timeouts.evaluate_number(doc) << std::endl; 22 | 23 | // Evaluate strings via compiled query for different context nodes 24 | pugi::xpath_query query_name_valid("string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks"); 25 | pugi::xpath_query query_name("concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)"); 26 | 27 | for (pugi::xml_node tool = doc.first_element_by_path("Profile/Tools/Tool"); tool; tool = tool.next_sibling()) 28 | { 29 | std::string s = query_name.evaluate_string(tool); 30 | 31 | if (query_name_valid.evaluate_boolean(tool)) std::cout << s << std::endl; 32 | } 33 | // end::code[] 34 | } 35 | 36 | // vim:et 37 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/xpath_select.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | 5 | int main() 6 | { 7 | pugi::xml_document doc; 8 | if (!doc.load_file("xgconsole.xml")) return -1; 9 | 10 | // tag::code[] 11 | pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"); 12 | 13 | std::cout << "Tools:\n"; 14 | 15 | for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it) 16 | { 17 | pugi::xpath_node node = *it; 18 | std::cout << node.node().attribute("Filename").value() << "\n"; 19 | } 20 | 21 | pugi::xpath_node build_tool = doc.select_node("//Tool[contains(Description, 'build system')]"); 22 | 23 | if (build_tool) 24 | std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n"; 25 | // end::code[] 26 | } 27 | 28 | // vim:et 29 | -------------------------------------------------------------------------------- /src/pugixml/docs/samples/xpath_variables.cpp: -------------------------------------------------------------------------------- 1 | #include "pugixml.hpp" 2 | 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | pugi::xml_document doc; 9 | if (!doc.load_file("xgconsole.xml")) return -1; 10 | 11 | // tag::code[] 12 | // Select nodes via compiled query 13 | pugi::xpath_variable_set vars; 14 | vars.add("remote", pugi::xpath_type_boolean); 15 | 16 | pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars); 17 | 18 | vars.set("remote", true); 19 | pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc); 20 | 21 | vars.set("remote", false); 22 | pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc); 23 | 24 | std::cout << "Remote tool: "; 25 | tools_remote[2].node().print(std::cout); 26 | 27 | std::cout << "Local tool: "; 28 | tools_local[0].node().print(std::cout); 29 | 30 | // You can pass the context directly to select_nodes/select_node 31 | pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars); 32 | 33 | std::cout << "Local tool imm: "; 34 | tools_local_imm[0].node().print(std::cout); 35 | // end::code[] 36 | } 37 | 38 | // vim:et 39 | -------------------------------------------------------------------------------- /src/pugixml/readme.txt: -------------------------------------------------------------------------------- 1 | pugixml 1.14 - an XML processing library 2 | 3 | Copyright (C) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 4 | Report bugs and download new versions at https://pugixml.org/ 5 | 6 | This is the distribution of pugixml, which is a C++ XML processing library, 7 | which consists of a DOM-like interface with rich traversal/modification 8 | capabilities, an extremely fast XML parser which constructs the DOM tree from 9 | an XML file/buffer, and an XPath 1.0 implementation for complex data-driven 10 | tree queries. Full Unicode support is also available, with Unicode interface 11 | variants and conversions between different Unicode encodings (which happen 12 | automatically during parsing/saving). 13 | 14 | The distribution contains the following folders: 15 | 16 | docs/ - documentation 17 | docs/samples - pugixml usage examples 18 | docs/quickstart.html - quick start guide 19 | docs/manual.html - complete manual 20 | 21 | scripts/ - project files for IDE/build systems 22 | 23 | src/ - header and source files 24 | 25 | readme.txt - this file. 26 | 27 | This library is distributed under the MIT License: 28 | 29 | Copyright (c) 2006-2024 Arseny Kapoulkine 30 | 31 | Permission is hereby granted, free of charge, to any person 32 | obtaining a copy of this software and associated documentation 33 | files (the "Software"), to deal in the Software without 34 | restriction, including without limitation the rights to use, 35 | copy, modify, merge, publish, distribute, sublicense, and/or sell 36 | copies of the Software, and to permit persons to whom the 37 | Software is furnished to do so, subject to the following 38 | conditions: 39 | 40 | The above copyright notice and this permission notice shall be 41 | included in all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 44 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 45 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 46 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 47 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 48 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 49 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 50 | OTHER DEALINGS IN THE SOFTWARE. 51 | -------------------------------------------------------------------------------- /src/pugixml/scripts/archive.py: -------------------------------------------------------------------------------- 1 | import io 2 | import os.path 3 | import sys 4 | import tarfile 5 | import time 6 | import zipfile 7 | 8 | def read_file(path, use_crlf): 9 | with open(path, 'rb') as file: 10 | data = file.read() 11 | 12 | if b'\0' not in data: 13 | data = data.replace(b'\r', b'') 14 | if use_crlf: 15 | data = data.replace(b'\n', b'\r\n') 16 | 17 | return data 18 | 19 | def write_zip(target, arcprefix, timestamp, sources): 20 | with zipfile.ZipFile(target, 'w') as archive: 21 | for source in sorted(sources): 22 | data = read_file(source, use_crlf = True) 23 | path = os.path.join(arcprefix, source) 24 | info = zipfile.ZipInfo(path) 25 | info.date_time = time.localtime(timestamp) 26 | info.compress_type = zipfile.ZIP_DEFLATED 27 | info.external_attr = 0o644 << 16 28 | archive.writestr(info, data) 29 | 30 | def write_tar(target, arcprefix, timestamp, sources, compression): 31 | with tarfile.open(target, 'w:' + compression) as archive: 32 | for source in sorted(sources): 33 | data = read_file(source, use_crlf = False) 34 | path = os.path.join(arcprefix, source) 35 | info = tarfile.TarInfo(path) 36 | info.size = len(data) 37 | info.mtime = timestamp 38 | archive.addfile(info, io.BytesIO(data)) 39 | 40 | if len(sys.argv) < 5: 41 | raise RuntimeError('Usage: python archive.py ') 42 | 43 | target, arcprefix, timestamp = sys.argv[1:4] 44 | sources = sys.argv[4:] 45 | 46 | # tarfile._Stream._init_write_gz always writes current time to gzip header 47 | time.time = lambda: timestamp 48 | 49 | if target.endswith('.zip'): 50 | write_zip(target, arcprefix, int(timestamp), sources) 51 | elif target.endswith('.tar.gz') or target.endswith('.tar.bz2'): 52 | write_tar(target, arcprefix, int(timestamp), sources, compression = os.path.splitext(target)[1][1:]) 53 | else: 54 | raise NotImplementedError('File type not supported: ' + target) 55 | -------------------------------------------------------------------------------- /src/pugixml/scripts/cocoapods_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Push to igagis repo for now 4 | pod repo push igagis pugixml.podspec --use-libraries --verbose 5 | -------------------------------------------------------------------------------- /src/pugixml/scripts/natvis/pugixml.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {_root} 5 | none 6 | 7 | _root 8 | 9 | 10 | 11 | 12 | {(pugi::xml_node_type)(header & 0xf),en} name={name,na} value={value,na} 13 | {(pugi::xml_node_type)(header & 0xf),en} name={name,na} 14 | {(pugi::xml_node_type)(header & 0xf),en} value={value,na} 15 | {(pugi::xml_node_type)(header & 0xf),en} 16 | 17 | value,na 18 | 19 | 20 | 21 | 22 | 23 | 24 | curr,view(child)na 25 | curr = curr->next_attribute 26 | 27 | 28 | 29 | 30 | 31 | first_child 32 | next_sibling 33 | this,na 34 | 35 | 36 | 37 | 38 | 39 | {_attr} 40 | none 41 | 42 | _attr 43 | 44 | 45 | 46 | 47 | {name,na} = {value,na} 48 | {value,na} 49 | 50 | name,na 51 | value,na 52 | 53 | 54 | 55 | 56 | {_node,na} "{_attribute._attr->name,na}"="{_attribute._attr->value,na}" 57 | {_node,na} 58 | {_attribute} 59 | empty 60 | 61 | _node 62 | _attribute 63 | _node,na 64 | _attribute,na 65 | 66 | 67 | 68 | 69 | 70 | _type 71 | 72 | _end - _begin 73 | _begin 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/pugixml/scripts/nuget/build/native/pugixml.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | dynamic 5 | Debug 6 | Release 7 | 8 | 9 | 10 | 11 | 12 | 13 | PUGIXML_HEADER_ONLY;%(PreprocessorDefinitions) 14 | $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) 15 | 16 | 17 | $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | $(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\$(Configuration-pugixml)\pugixml.lib;%(AdditionalDependencies) 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/pugixml/scripts/nuget/pugixml.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | pugixml 5 | 1.14.0-appveyor 6 | pugixml 7 | Arseny Kapoulkine 8 | Arseny Kapoulkine 9 | false 10 | MIT 11 | https://pugixml.org/ 12 | pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). 13 | pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface. 14 | This package contains builds for VS2013, VS2015, VS2017, VS2019 and VS2022, for both statically linked and DLL CRT; you can switch the CRT linkage in Project -> Properties -> Referenced Packages -> pugixml. 15 | Light-weight, simple and fast XML parser for C++ with XPath support 16 | https://pugixml.org/docs/manual.html#changes 17 | Copyright (c) 2006-2024 Arseny Kapoulkine 18 | native nativepackage 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/pugixml/scripts/nuget_build.ps1: -------------------------------------------------------------------------------- 1 | function Run-Command([string]$cmd) 2 | { 3 | Invoke-Expression $cmd 4 | if ($LastExitCode) { exit $LastExitCode } 5 | } 6 | 7 | function Force-Copy([string]$from, [string]$to) 8 | { 9 | Write-Host $from "->" $to 10 | New-Item -Force $to | Out-Null 11 | Copy-Item -Force $from $to 12 | if (! $?) { exit 1 } 13 | } 14 | 15 | function Build-Version([string]$vs, [string]$toolset, [string]$linkage) 16 | { 17 | $prjsuffix = if ($linkage -eq "static") { "_static" } else { "" } 18 | $cfgsuffix = if ($linkage -eq "static") { "Static" } else { "" } 19 | 20 | foreach ($configuration in "Debug","Release") 21 | { 22 | Run-Command "msbuild pugixml_$vs$prjsuffix.vcxproj /t:Rebuild /p:Configuration=$configuration /p:Platform=x86 /v:minimal /nologo" 23 | Run-Command "msbuild pugixml_$vs$prjsuffix.vcxproj /t:Rebuild /p:Configuration=$configuration /p:Platform=x64 /v:minimal /nologo" 24 | 25 | Force-Copy "$vs/Win32_$configuration$cfgsuffix/pugixml.lib" "nuget/build/native/lib/Win32/$toolset/$linkage/$configuration/pugixml.lib" 26 | Force-Copy "$vs/x64_$configuration$cfgsuffix/pugixml.lib" "nuget/build/native/lib/x64/$toolset/$linkage/$configuration/pugixml.lib" 27 | } 28 | } 29 | 30 | Push-Location 31 | $scriptdir = Split-Path $MyInvocation.MyCommand.Path 32 | cd $scriptdir 33 | 34 | Force-Copy "../src/pugiconfig.hpp" "nuget/build/native/include/pugiconfig.hpp" 35 | Force-Copy "../src/pugixml.hpp" "nuget/build/native/include/pugixml.hpp" 36 | Force-Copy "../src/pugixml.cpp" "nuget/build/native/include/pugixml.cpp" 37 | 38 | if ($args[0] -eq 2022){ 39 | Build-Version "vs2022" "v143" "dynamic" 40 | Build-Version "vs2022" "v143" "static" 41 | 42 | } elseif ($args[0] -eq 2019){ 43 | Build-Version "vs2019" "v142" "dynamic" 44 | Build-Version "vs2019" "v142" "static" 45 | 46 | } elseif ($args[0] -eq 2017){ 47 | Build-Version "vs2017" "v141" "dynamic" 48 | Build-Version "vs2017" "v141" "static" 49 | 50 | Build-Version "vs2015" "v140" "dynamic" 51 | Build-Version "vs2015" "v140" "static" 52 | 53 | Build-Version "vs2013" "v120" "dynamic" 54 | Build-Version "vs2013" "v120" "static" 55 | 56 | } elseif($args[0] -eq 2015){ 57 | Build-Version "vs2015" "v140" "dynamic" 58 | Build-Version "vs2015" "v140" "static" 59 | 60 | Build-Version "vs2013" "v120" "dynamic" 61 | Build-Version "vs2013" "v120" "static" 62 | 63 | } elseif($args[0] -eq 2013){ 64 | Build-Version "vs2013" "v120" "dynamic" 65 | Build-Version "vs2013" "v120" "static" 66 | } 67 | 68 | Run-Command "nuget pack nuget" 69 | 70 | Pop-Location 71 | -------------------------------------------------------------------------------- /src/pugixml/scripts/premake4.lua: -------------------------------------------------------------------------------- 1 | -- Reset RNG seed to get consistent results across runs (i.e. XCode) 2 | math.randomseed(12345) 3 | 4 | local static = _ARGS[1] == 'static' 5 | local action = premake.action.current() 6 | 7 | if string.startswith(_ACTION, "vs") then 8 | if action then 9 | -- Disable solution generation 10 | function action.onsolution(sln) 11 | sln.vstudio_configs = premake.vstudio_buildconfigs(sln) 12 | end 13 | 14 | -- Rename output file 15 | function action.onproject(prj) 16 | local name = "%%_" .. _ACTION .. (static and "_static" or "") 17 | 18 | if static then 19 | for k, v in pairs(prj.project.__configs) do 20 | v.objectsdir = v.objectsdir .. "Static" 21 | end 22 | end 23 | 24 | if _ACTION == "vs2010" then 25 | premake.generate(prj, name .. ".vcxproj", premake.vs2010_vcxproj) 26 | else 27 | premake.generate(prj, name .. ".vcproj", premake.vs200x_vcproj) 28 | end 29 | end 30 | end 31 | elseif _ACTION == "codeblocks" then 32 | action.onsolution = nil 33 | 34 | function action.onproject(prj) 35 | premake.generate(prj, "%%_" .. _ACTION .. ".cbp", premake.codeblocks_cbp) 36 | end 37 | elseif _ACTION == "codelite" then 38 | action.onsolution = nil 39 | 40 | function action.onproject(prj) 41 | premake.generate(prj, "%%_" .. _ACTION .. ".project", premake.codelite_project) 42 | end 43 | end 44 | 45 | solution "pugixml" 46 | objdir(_ACTION) 47 | targetdir(_ACTION) 48 | 49 | if string.startswith(_ACTION, "vs") then 50 | if _ACTION ~= "vs2002" and _ACTION ~= "vs2003" then 51 | platforms { "x32", "x64" } 52 | 53 | configuration "x32" targetdir(_ACTION .. "/x32") 54 | configuration "x64" targetdir(_ACTION .. "/x64") 55 | end 56 | 57 | configurations { "Debug", "Release" } 58 | 59 | if static then 60 | configuration "Debug" targetsuffix "sd" 61 | configuration "Release" targetsuffix "s" 62 | else 63 | configuration "Debug" targetsuffix "d" 64 | end 65 | else 66 | if _ACTION == "xcode3" then 67 | platforms "universal" 68 | end 69 | 70 | configurations { "Debug", "Release" } 71 | 72 | configuration "Debug" targetsuffix "d" 73 | end 74 | 75 | project "pugixml" 76 | kind "StaticLib" 77 | language "C++" 78 | files { "../src/pugixml.hpp", "../src/pugiconfig.hpp", "../src/pugixml.cpp" } 79 | flags { "NoPCH", "NoMinimalRebuild", "NoEditAndContinue", "Symbols" } 80 | uuid "89A1E353-E2DC-495C-B403-742BE206ACED" 81 | 82 | configuration "Debug" 83 | defines { "_DEBUG" } 84 | 85 | configuration "Release" 86 | defines { "NDEBUG" } 87 | flags { "Optimize" } 88 | 89 | if static then 90 | configuration "*" 91 | flags { "StaticRuntime" } 92 | end 93 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/pugixml-targets.cmake") 4 | 5 | # If the user is not requiring 1.11 (either by explicitly requesting an older 6 | # version or not requesting one at all), provide the old imported target name 7 | # for compatibility. 8 | if (NOT TARGET pugixml AND (NOT DEFINED PACKAGE_FIND_VERSION OR PACKAGE_FIND_VERSION VERSION_LESS "1.11")) 9 | add_library(pugixml INTERFACE IMPORTED) 10 | # Equivalent to target_link_libraries INTERFACE, but compatible with CMake 3.10 11 | set_target_properties(pugixml PROPERTIES INTERFACE_LINK_LIBRARIES pugixml::pugixml) 12 | endif () 13 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@PUGIXML_PC_INCLUDEDIR@ 4 | libdir=@PUGIXML_PC_LIBDIR@ 5 | 6 | Name: pugixml 7 | Description: Light-weight, simple and fast XML parser for C++ with XPath support. 8 | URL: https://pugixml.org/ 9 | Version: @pugixml_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs: -L${libdir} -lpugixml@LIB_POSTFIX@ 12 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "pugixml" 3 | s.version = "1.14" 4 | s.summary = "C++ XML parser library." 5 | s.homepage = "https://pugixml.org" 6 | s.license = "MIT" 7 | s.author = { "Arseny Kapoulkine" => "arseny.kapoulkine@gmail.com" } 8 | s.platform = :ios, "7.0" 9 | 10 | s.source = { :git => "https://github.com/zeux/pugixml.git", :tag => "v" + s.version.to_s } 11 | 12 | s.source_files = "src/**/*.{hpp,cpp}" 13 | s.header_mappings_dir = "src" 14 | end 15 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml_airplay.mkf: -------------------------------------------------------------------------------- 1 | includepaths 2 | { 3 | "../src" 4 | } 5 | 6 | files 7 | { 8 | ("../src") 9 | pugiconfig.hpp 10 | pugixml.cpp 11 | pugixml.hpp 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml_codeblocks.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml_codelite.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | None 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | None 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/pugixml/scripts/pugixml_dll.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PUGIXML_VERSION_MAJOR 1 4 | #define PUGIXML_VERSION_MINOR 14 5 | #define PUGIXML_VERSION_PATCH 0 6 | #define PUGIXML_VERSION_NUMBER "1.14.0\0" 7 | 8 | #if defined(GCC_WINDRES) || defined(__MINGW32__) || defined(__CYGWIN__) 9 | VS_VERSION_INFO VERSIONINFO 10 | #else 11 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 12 | #endif 13 | FILEVERSION PUGIXML_VERSION_MAJOR,PUGIXML_VERSION_MINOR,PUGIXML_VERSION_PATCH,0 14 | PRODUCTVERSION PUGIXML_VERSION_MAJOR,PUGIXML_VERSION_MINOR,PUGIXML_VERSION_PATCH,0 15 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 16 | #ifdef _DEBUG 17 | FILEFLAGS 1 18 | #else 19 | FILEFLAGS 0 20 | #endif 21 | FILEOS VOS__WINDOWS32 22 | FILETYPE VFT_DLL 23 | FILESUBTYPE 0 // not used 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "040904E4" 28 | //language ID = U.S. English, char set = Windows, Multilingual 29 | BEGIN 30 | VALUE "CompanyName", "zeux/pugixml\0" 31 | VALUE "FileDescription", "pugixml library\0" 32 | VALUE "FileVersion", PUGIXML_VERSION_NUMBER 33 | VALUE "InternalName", "pugixml.dll\0" 34 | VALUE "LegalCopyright", "Copyright (C) 2006-2024, by Arseny Kapoulkine\0" 35 | VALUE "OriginalFilename", "pugixml.dll\0" 36 | VALUE "ProductName", "pugixml\0" 37 | VALUE "ProductVersion", PUGIXML_VERSION_NUMBER 38 | VALUE "Comments", "For more information visit https://github.com/zeux/pugixml/\0" 39 | END 40 | END 41 | BLOCK "VarFileInfo" 42 | BEGIN 43 | VALUE "Translation", 0x0409, 1252 44 | END 45 | END 46 | -------------------------------------------------------------------------------- /src/pugixml/src/pugiconfig.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * pugixml parser - version 1.14 3 | * -------------------------------------------------------- 4 | * Copyright (C) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | * Report bugs and download new versions at https://pugixml.org/ 6 | * 7 | * This library is distributed under the MIT License. See notice at the end 8 | * of this file. 9 | * 10 | * This work is based on the pugxml parser, which is: 11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) 12 | */ 13 | 14 | #ifndef HEADER_PUGICONFIG_HPP 15 | #define HEADER_PUGICONFIG_HPP 16 | 17 | // Uncomment this to enable wchar_t mode 18 | // #define PUGIXML_WCHAR_MODE 19 | 20 | // Uncomment this to enable compact mode 21 | // #define PUGIXML_COMPACT 22 | 23 | // Uncomment this to disable XPath 24 | // #define PUGIXML_NO_XPATH 25 | 26 | // Uncomment this to disable STL 27 | // #define PUGIXML_NO_STL 28 | 29 | // Uncomment this to disable exceptions 30 | // #define PUGIXML_NO_EXCEPTIONS 31 | 32 | // Set this to control attributes for public classes/functions, i.e.: 33 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL 34 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL 35 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall 36 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead 37 | 38 | // Tune these constants to adjust memory-related behavior 39 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768 40 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 41 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 42 | 43 | // Tune this constant to adjust max nesting for XPath queries 44 | // #define PUGIXML_XPATH_DEPTH_LIMIT 1024 45 | 46 | // Uncomment this to switch to header-only version 47 | // #define PUGIXML_HEADER_ONLY 48 | 49 | // Uncomment this to enable long long support 50 | // #define PUGIXML_HAS_LONG_LONG 51 | 52 | #endif 53 | 54 | /** 55 | * Copyright (c) 2006-2024 Arseny Kapoulkine 56 | * 57 | * Permission is hereby granted, free of charge, to any person 58 | * obtaining a copy of this software and associated documentation 59 | * files (the "Software"), to deal in the Software without 60 | * restriction, including without limitation the rights to use, 61 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 62 | * copies of the Software, and to permit persons to whom the 63 | * Software is furnished to do so, subject to the following 64 | * conditions: 65 | * 66 | * The above copyright notice and this permission notice shall be 67 | * included in all copies or substantial portions of the Software. 68 | * 69 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 70 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 71 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 72 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 73 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 74 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 75 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 76 | * OTHER DEALINGS IN THE SOFTWARE. 77 | */ 78 | -------------------------------------------------------------------------------- /src/pugixml/tests/allocator.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_TEST_ALLOCATOR_HPP 2 | #define HEADER_TEST_ALLOCATOR_HPP 3 | 4 | #include 5 | 6 | void* memory_allocate(size_t size); 7 | size_t memory_size(void* ptr); 8 | void memory_deallocate(void* ptr); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/pugixml/tests/autotest-appveyor.ps1: -------------------------------------------------------------------------------- 1 | function Invoke-CmdScript($scriptName) 2 | { 3 | $cmdLine = """$scriptName"" $args & set" 4 | & $Env:SystemRoot\system32\cmd.exe /c $cmdLine | 5 | select-string '^([^=]*)=(.*)$' | foreach-object { 6 | $varName = $_.Matches[0].Groups[1].Value 7 | $varValue = $_.Matches[0].Groups[2].Value 8 | set-item Env:$varName $varValue 9 | } 10 | } 11 | 12 | $sources = @("src/pugixml.cpp") + (Get-ChildItem -Path "tests/*.cpp" -Exclude "fuzz_*.cpp") 13 | $failed = $FALSE 14 | 15 | foreach ($vs in $args) 16 | { 17 | foreach ($arch in "x86","x64") 18 | { 19 | Write-Output "# Setting up VS$vs $arch" 20 | 21 | if ($vs -eq 15) { 22 | $vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } 23 | Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch" 24 | } 25 | elseif ($vs -eq 19) { 26 | $vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } 27 | Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch" 28 | } 29 | elseif ($vs -eq 22) { 30 | $vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } 31 | Invoke-CmdScript "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch" 32 | } 33 | else 34 | { 35 | Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio $vs.0\VC\vcvarsall.bat" $arch 36 | } 37 | 38 | if (! $?) { throw "Error setting up VS$vs $arch" } 39 | 40 | foreach ($defines in "standard", "PUGIXML_WCHAR_MODE", "PUGIXML_COMPACT") 41 | { 42 | $target = "tests_vs${vs}_${arch}_${defines}" 43 | $deflist = if ($defines -eq "standard") { "" } else { "/D$defines" } 44 | 45 | Add-AppveyorTest $target -Outcome Running 46 | 47 | Write-Output "# Building $target.exe" 48 | & cmd /c "cl.exe /MP /Fe$target.exe /EHsc /W4 /WX $deflist $sources 2>&1" | Tee-Object -Variable buildOutput 49 | 50 | if ($?) 51 | { 52 | Write-Output "# Running $target.exe" 53 | 54 | $sw = [Diagnostics.Stopwatch]::StartNew() 55 | 56 | & .\$target | Tee-Object -Variable testOutput 57 | 58 | if ($?) 59 | { 60 | Write-Output "# Passed" 61 | 62 | Update-AppveyorTest $target -Outcome Passed -StdOut ($testOutput | out-string) -Duration $sw.ElapsedMilliseconds 63 | } 64 | else 65 | { 66 | Write-Output "# Failed" 67 | 68 | Update-AppveyorTest $target -Outcome Failed -StdOut ($testOutput | out-string) -ErrorMessage "Running failed" 69 | 70 | $failed = $TRUE 71 | } 72 | } 73 | else 74 | { 75 | Write-Output "# Failed to build" 76 | 77 | Update-AppveyorTest $target -Outcome Failed -StdOut ($buildOutput | out-string) -ErrorMessage "Compilation failed" 78 | 79 | $failed = $TRUE 80 | } 81 | } 82 | } 83 | } 84 | 85 | if ($failed) { throw "One or more build steps failed" } 86 | 87 | Write-Output "# End" 88 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/empty.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/empty.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/latintest_latin1.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/latintest_latin1.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/latintest_utf8.xml: -------------------------------------------------------------------------------- 1 | 
00000535351010MüllerJörg
<Test>
10
<Test 2>
20
This is a text.
-------------------------------------------------------------------------------- /src/pugixml/tests/data/multiline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/small.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/truncation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | some text 7 | 8 | some more text 9 | 10 | 11 | <汉语 名字="name" 价值="value">世界有很多语言𤭢 12 | 13 | 14 | <氏名> 15 | <氏>山田 16 | <名>太郎 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_be.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_be.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_be_bom.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_be_bom.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_be_clean.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_be_clean.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_be_nodecl.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_be_nodecl.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_le.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_le.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_le_bom.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_le_bom.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_le_clean.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_le_clean.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf16_le_nodecl.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf16_le_nodecl.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_be.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_be.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_be_bom.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_be_bom.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_be_clean.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_be_clean.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_be_nodecl.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_be_nodecl.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_le.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_le.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_le_bom.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_le_bom.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_le_clean.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_le_clean.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf32_le_nodecl.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data/utftest_utf32_le_nodecl.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf8.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <週報> 5 | The world has many languages 6 | Мир имеет много языков 7 | el mundo tiene muchos idiomas 8 | 世界有很多语言 9 | <Русский название="name" ценность="value"><имеет> 10 | <汉语 名字="name" 价值="value">世界有很多语言𤭢 11 | "Mëtæl!" 12 | <ä>Umlaut Element 13 | 14 | <年月週> 15 | <年度>1997 16 | <月度>1 17 | <週>1 18 | 19 | 20 | <氏名> 21 | <氏>山田 22 | <名>太郎 23 | 24 | 25 | <業務報告リスト> 26 | <業務報告> 27 | <業務名>XMLエディターの作成 28 | <業務コード>X3355-23 29 | <工数管理> 30 | <見積もり工数>1600 31 | <実績工数>320 32 | <当月見積もり工数>160 33 | <当月実績工数>24 34 | 35 | <予定項目リスト> 36 | <予定項目> 37 |

XMLエディターの基本仕様の作成

38 | 39 | 40 | <実施事項リスト> 41 | <実施事項> 42 |

XMLエディターの基本仕様の作成

43 | 44 | <実施事項> 45 |

競合他社製品の機能調査

46 | 47 | 48 | <上長への要請事項リスト> 49 | <上長への要請事項> 50 |

特になし

51 | 52 | 53 | <問題点対策> 54 |

XMLとは何かわからない。

55 | 56 | 57 | 58 | <業務報告> 59 | <業務名>検索エンジンの開発 60 | <業務コード>S8821-76 61 | <工数管理> 62 | <見積もり工数>120 63 | <実績工数>6 64 | <当月見積もり工数>32 65 | <当月実績工数>2 66 | 67 | <予定項目リスト> 68 | <予定項目> 69 |

gooの機能を調べてみる

70 | 71 | 72 | <実施事項リスト> 73 | <実施事項> 74 |

更に、どういう検索エンジンがあるか調査する

75 | 76 | 77 | <上長への要請事項リスト> 78 | <上長への要請事項> 79 |

開発をするのはめんどうなので、Yahoo!を買収して下さい。

80 | 81 | 82 | <問題点対策> 83 |

検索エンジンで車を走らせることができない。(要調査)

84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf8_bom.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <週報> 5 | The world has many languages 6 | Мир имеет много языков 7 | el mundo tiene muchos idiomas 8 | 世界有很多语言 9 | <Русский название="name" ценность="value"><имеет> 10 | <汉语 名字="name" 价值="value">世界有很多语言𤭢 11 | "Mëtæl!" 12 | <ä>Umlaut Element 13 | 14 | <年月週> 15 | <年度>1997 16 | <月度>1 17 | <週>1 18 | 19 | 20 | <氏名> 21 | <氏>山田 22 | <名>太郎 23 | 24 | 25 | <業務報告リスト> 26 | <業務報告> 27 | <業務名>XMLエディターの作成 28 | <業務コード>X3355-23 29 | <工数管理> 30 | <見積もり工数>1600 31 | <実績工数>320 32 | <当月見積もり工数>160 33 | <当月実績工数>24 34 | 35 | <予定項目リスト> 36 | <予定項目> 37 |

XMLエディターの基本仕様の作成

38 | 39 | 40 | <実施事項リスト> 41 | <実施事項> 42 |

XMLエディターの基本仕様の作成

43 | 44 | <実施事項> 45 |

競合他社製品の機能調査

46 | 47 | 48 | <上長への要請事項リスト> 49 | <上長への要請事項> 50 |

特になし

51 | 52 | 53 | <問題点対策> 54 |

XMLとは何かわからない。

55 | 56 | 57 | 58 | <業務報告> 59 | <業務名>検索エンジンの開発 60 | <業務コード>S8821-76 61 | <工数管理> 62 | <見積もり工数>120 63 | <実績工数>6 64 | <当月見積もり工数>32 65 | <当月実績工数>2 66 | 67 | <予定項目リスト> 68 | <予定項目> 69 |

gooの機能を調べてみる

70 | 71 | 72 | <実施事項リスト> 73 | <実施事項> 74 |

更に、どういう検索エンジンがあるか調査する

75 | 76 | 77 | <上長への要請事項リスト> 78 | <上長への要請事項> 79 |

開発をするのはめんどうなので、Yahoo!を買収して下さい。

80 | 81 | 82 | <問題点対策> 83 |

検索エンジンで車を走らせることができない。(要調査)

84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf8_clean.xml: -------------------------------------------------------------------------------- 1 | <週報> 2 | The world has many languages 3 | Мир имеет много языков 4 | el mundo tiene muchos idiomas 5 | 世界有很多语言 6 | <Русский название="name" ценность="value"><имеет> 7 | <汉语 名字="name" 价值="value">世界有很多语言𤭢 8 | quot;Mëtæl!quot; 9 | <ä>Umlaut Element 10 | 11 | <年月週> 12 | <年度>1997 13 | <月度>1 14 | <週>1 15 | 16 | 17 | <氏名> 18 | <氏>山田 19 | <名>太郎 20 | 21 | 22 | <業務報告リスト> 23 | <業務報告> 24 | <業務名>XMLエディターの作成 25 | <業務コード>X3355-23 26 | <工数管理> 27 | <見積もり工数>1600 28 | <実績工数>320 29 | <当月見積もり工数>160 30 | <当月実績工数>24 31 | 32 | <予定項目リスト> 33 | <予定項目> 34 |

XMLエディターの基本仕様の作成

35 | 36 | 37 | <実施事項リスト> 38 | <実施事項> 39 |

XMLエディターの基本仕様の作成

40 | 41 | <実施事項> 42 |

競合他社製品の機能調査

43 | 44 | 45 | <上長への要請事項リスト> 46 | <上長への要請事項> 47 |

特になし

48 | 49 | 50 | <問題点対策> 51 |

XMLとは何かわからない。

52 | 53 | 54 | 55 | <業務報告> 56 | <業務名>検索エンジンの開発 57 | <業務コード>S8821-76 58 | <工数管理> 59 | <見積もり工数>120 60 | <実績工数>6 61 | <当月見積もり工数>32 62 | <当月実績工数>2 63 | 64 | <予定項目リスト> 65 | <予定項目> 66 |

gooの機能を調べてみる

67 | 68 | 69 | <実施事項リスト> 70 | <実施事項> 71 |

更に、どういう検索エンジンがあるか調査する

72 | 73 | 74 | <上長への要請事項リスト> 75 | <上長への要請事項> 76 |

開発をするのはめんどうなので、Yahoo!を買収して下さい。

77 | 78 | 79 | <問題点対策> 80 |

検索エンジンで車を走らせることができない。(要調査)

81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/utftest_utf8_nodecl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | <週報> 4 | The world has many languages 5 | Мир имеет много языков 6 | el mundo tiene muchos idiomas 7 | 世界有很多语言 8 | <Русский название="name" ценность="value"><имеет> 9 | <汉语 名字="name" 价值="value">世界有很多语言𤭢 10 | "Mëtæl!" 11 | <ä>Umlaut Element 12 | 13 | <年月週> 14 | <年度>1997 15 | <月度>1 16 | <週>1 17 | 18 | 19 | <氏名> 20 | <氏>山田 21 | <名>太郎 22 | 23 | 24 | <業務報告リスト> 25 | <業務報告> 26 | <業務名>XMLエディターの作成 27 | <業務コード>X3355-23 28 | <工数管理> 29 | <見積もり工数>1600 30 | <実績工数>320 31 | <当月見積もり工数>160 32 | <当月実績工数>24 33 | 34 | <予定項目リスト> 35 | <予定項目> 36 |

XMLエディターの基本仕様の作成

37 | 38 | 39 | <実施事項リスト> 40 | <実施事項> 41 |

XMLエディターの基本仕様の作成

42 | 43 | <実施事項> 44 |

競合他社製品の機能調査

45 | 46 | 47 | <上長への要請事項リスト> 48 | <上長への要請事項> 49 |

特になし

50 | 51 | 52 | <問題点対策> 53 |

XMLとは何かわからない。

54 | 55 | 56 | 57 | <業務報告> 58 | <業務名>検索エンジンの開発 59 | <業務コード>S8821-76 60 | <工数管理> 61 | <見積もり工数>120 62 | <実績工数>6 63 | <当月見積もり工数>32 64 | <当月実績工数>2 65 | 66 | <予定項目リスト> 67 | <予定項目> 68 |

gooの機能を調べてみる

69 | 70 | 71 | <実施事項リスト> 72 | <実施事項> 73 |

更に、どういう検索エンジンがあるか調査する

74 | 75 | 76 | <上長への要請事項リスト> 77 | <上長への要請事項> 78 |

開発をするのはめんどうなので、Yahoo!を買収して下さい。

79 | 80 | 81 | <問題点対策> 82 |

検索エンジンで車を走らせることができない。(要調査)

83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/pugixml/tests/data/тест.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/basic.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/doctype.xml: -------------------------------------------------------------------------------- 1 | ]> ]]> ]> ]> -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/refs.xml: -------------------------------------------------------------------------------- 1 | pcdata < > & " ' « &unknown; %entity; -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/types.xml: -------------------------------------------------------------------------------- 1 | pcdata -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/utf16.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data_fuzz_parse/utf16.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_parse/utf32.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lanl/branson/68d27b59c46b2d80d390923f5b9adcc9b25003ca/src/pugixml/tests/data_fuzz_parse/utf32.xml -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_xpath/basic.xpath: -------------------------------------------------------------------------------- 1 | a/b/c -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_xpath/functions.xpath: -------------------------------------------------------------------------------- 1 | sum(nodes) + round(concat(//a[translate(@id, 'abc', '012')])) 2 | -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_xpath/math.xpath: -------------------------------------------------------------------------------- 1 | 1+2*3 div 4 mod 5-6 -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_xpath/path.xpath: -------------------------------------------------------------------------------- 1 | @*/ancestor::*/near-north/*[4]/@*/preceding::text() -------------------------------------------------------------------------------- /src/pugixml/tests/data_fuzz_xpath/predicate.xpath: -------------------------------------------------------------------------------- 1 | library/nodes[@id=12]/element[@type='translate'][1] -------------------------------------------------------------------------------- /src/pugixml/tests/fuzz_parse.cpp: -------------------------------------------------------------------------------- 1 | #include "../src/pugixml.hpp" 2 | 3 | #include 4 | 5 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) 6 | { 7 | pugi::xml_document doc; 8 | 9 | doc.load_buffer(Data, Size); 10 | doc.load_buffer(Data, Size, pugi::parse_minimal); 11 | doc.load_buffer(Data, Size, pugi::parse_full); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/pugixml/tests/fuzz_parse.dict: -------------------------------------------------------------------------------- 1 | # 2 | # AFL dictionary for XML 3 | # ---------------------- 4 | # 5 | # Several basic syntax elements and attributes, modeled on libxml2. 6 | # 7 | # Created by Michal Zalewski 8 | # 9 | 10 | attr_encoding=" encoding=\"1\"" 11 | attr_generic=" a=\"1\"" 12 | attr_href=" href=\"1\"" 13 | attr_standalone=" standalone=\"no\"" 14 | attr_version=" version=\"1\"" 15 | attr_xml_base=" xml:base=\"1\"" 16 | attr_xml_id=" xml:id=\"1\"" 17 | attr_xml_lang=" xml:lang=\"1\"" 18 | attr_xml_space=" xml:space=\"1\"" 19 | attr_xmlns=" xmlns=\"1\"" 20 | 21 | entity_builtin="<" 22 | entity_decimal="" 23 | entity_external="&a;" 24 | entity_hex="" 25 | 26 | string_any="ANY" 27 | string_brackets="[]" 28 | string_cdata="CDATA" 29 | string_col_fallback=":fallback" 30 | string_col_generic=":a" 31 | string_col_include=":include" 32 | string_dashes="--" 33 | string_empty="EMPTY" 34 | string_empty_dblquotes="\"\"" 35 | string_empty_quotes="''" 36 | string_entities="ENTITIES" 37 | string_entity="ENTITY" 38 | string_fixed="#FIXED" 39 | string_id="ID" 40 | string_idref="IDREF" 41 | string_idrefs="IDREFS" 42 | string_implied="#IMPLIED" 43 | string_nmtoken="NMTOKEN" 44 | string_nmtokens="NMTOKENS" 45 | string_notation="NOTATION" 46 | string_parentheses="()" 47 | string_pcdata="#PCDATA" 48 | string_percent="%a" 49 | string_public="PUBLIC" 50 | string_required="#REQUIRED" 51 | string_schema=":schema" 52 | string_system="SYSTEM" 53 | string_ucs4="UCS-4" 54 | string_utf16="UTF-16" 55 | string_utf8="UTF-8" 56 | string_xmlns="xmlns:" 57 | 58 | tag_attlist="" 61 | tag_doctype="" 68 | tag_open_close="" 69 | tag_open_exclamation="" 72 | tag_xml_q="" 73 | -------------------------------------------------------------------------------- /src/pugixml/tests/fuzz_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get --yes install subversion screen gcc g++ cmake ninja-build golang autoconf libtool apache2 python-dev pkg-config zlib1g-dev libgcrypt11-dev 4 | 5 | mkdir -p clang 6 | cd clang 7 | git clone https://chromium.googlesource.com/chromium/src/tools/clang 8 | cd .. 9 | clang/clang/scripts/update.py 10 | sudo cp -rf third_party/llvm-build/Release+Asserts/lib/* /usr/local/lib/ 11 | sudo cp -rf third_party/llvm-build/Release+Asserts/bin/* /usr/local/bin 12 | -------------------------------------------------------------------------------- /src/pugixml/tests/fuzz_xpath.cpp: -------------------------------------------------------------------------------- 1 | #include "../src/pugixml.hpp" 2 | #include "fuzzer/FuzzedDataProvider.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) 9 | { 10 | FuzzedDataProvider fdp(Data, Size); 11 | std::string text = fdp.ConsumeRandomLengthString(1024); 12 | 13 | #ifndef PUGIXML_NO_EXCEPTIONS 14 | try 15 | #endif 16 | { 17 | pugi::xpath_variable_set vars; 18 | size_t var_count = fdp.ConsumeIntegralInRange(0, 50); 19 | std::vector var_name_storage; 20 | for (size_t i = 0; i < var_count; ++i) 21 | { 22 | var_name_storage.push_back(fdp.ConsumeRandomLengthString(128)); 23 | 24 | const int xpath_value_type_count = pugi::xpath_type_boolean + 1; 25 | pugi::xpath_value_type value_type = static_cast(fdp.ConsumeIntegralInRange(0, xpath_value_type_count)); 26 | vars.add(var_name_storage.back().c_str(), value_type); 27 | } 28 | pugi::xpath_query q(text.c_str(), &vars); 29 | 30 | std::vector xml_buffer = fdp.ConsumeBytes(fdp.ConsumeIntegralInRange(0, 1024)); 31 | pugi::xml_document doc; 32 | doc.load_buffer(xml_buffer.data(), xml_buffer.size(), pugi::parse_full); 33 | 34 | q.evaluate_boolean(doc); 35 | q.evaluate_number(doc); 36 | q.evaluate_string(doc); 37 | q.evaluate_node(doc); 38 | q.evaluate_node_set(doc); 39 | } 40 | #ifndef PUGIXML_NO_EXCEPTIONS 41 | catch (pugi::xpath_exception&) 42 | { 43 | } 44 | #endif 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /src/pugixml/tests/fuzz_xpath.dict: -------------------------------------------------------------------------------- 1 | "boolean" 2 | "count" 3 | "contains" 4 | "concat" 5 | "ceiling" 6 | "false" 7 | "floor" 8 | "id" 9 | "last" 10 | "lang" 11 | "local-name" 12 | "name" 13 | "namespace-uri" 14 | "normalize-space" 15 | "not" 16 | "number" 17 | "position" 18 | "round" 19 | "string" 20 | "string-length" 21 | "starts-with" 22 | "substring-before" 23 | "substring-after" 24 | "substring" 25 | "sum" 26 | "translate" 27 | "true" 28 | "ancestor" 29 | "ancestor-or-self" 30 | "attribute" 31 | "child" 32 | "descendant" 33 | "descendant-or-self" 34 | "following" 35 | "following-sibling" 36 | "namespace" 37 | "parent" 38 | "preceding" 39 | "preceding-sibling" 40 | "self" 41 | "comment" 42 | "node" 43 | "processing-instruction" 44 | "text" 45 | "or" 46 | "and" 47 | "div" 48 | "mod" 49 | ">" 50 | ">=" 51 | "<" 52 | "<=" 53 | "!" 54 | "!=" 55 | "=" 56 | "+" 57 | "-" 58 | "*" 59 | "|" 60 | "$" 61 | "(" 62 | ")" 63 | "[" 64 | "]" 65 | "," 66 | "//" 67 | "/" 68 | ".." 69 | "." 70 | "@" 71 | "::" 72 | ":" 73 | -------------------------------------------------------------------------------- /src/pugixml/tests/helpers.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_TEST_HELPERS_HPP 2 | #define HEADER_TEST_HELPERS_HPP 3 | 4 | #include "test.hpp" 5 | 6 | #include 7 | 8 | template static void generic_bool_ops_test(const T& obj) 9 | { 10 | T null; 11 | 12 | CHECK(!null); 13 | CHECK(obj); 14 | CHECK(!!obj); 15 | 16 | #ifdef _MSC_VER 17 | # pragma warning(push) 18 | # pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning) - we really want to just cast to bool instead of !! 19 | #endif 20 | 21 | bool b1 = null, b2 = obj; 22 | 23 | #ifdef _MSC_VER 24 | # pragma warning(pop) 25 | #endif 26 | 27 | CHECK(!b1); 28 | CHECK(b2); 29 | 30 | CHECK(obj && b2); 31 | CHECK(obj || b2); 32 | CHECK(obj && obj); 33 | CHECK(obj || obj); 34 | } 35 | 36 | template static void generic_eq_ops_test(const T& obj1, const T& obj2) 37 | { 38 | T null = T(); 39 | 40 | // operator== 41 | CHECK(null == null); 42 | CHECK(obj1 == obj1); 43 | CHECK(!(null == obj1)); 44 | CHECK(!(null == obj2)); 45 | CHECK(T(null) == null); 46 | CHECK(T(obj1) == obj1); 47 | 48 | // operator!= 49 | CHECK(!(null != null)); 50 | CHECK(!(obj1 != obj1)); 51 | CHECK(null != obj1); 52 | CHECK(null != obj2); 53 | CHECK(!(T(null) != null)); 54 | CHECK(!(T(obj1) != obj1)); 55 | } 56 | 57 | template static void generic_rel_ops_test(T obj1, T obj2) 58 | { 59 | T null = T(); 60 | 61 | // obj1 < obj2 (we use operator<, but there is no other choice 62 | if (obj1 > obj2) 63 | { 64 | T temp = obj1; 65 | obj1 = obj2; 66 | obj2 = temp; 67 | } 68 | 69 | // operator< 70 | CHECK(null < obj1); 71 | CHECK(null < obj2); 72 | CHECK(obj1 < obj2); 73 | CHECK(!(null < null)); 74 | CHECK(!(obj1 < obj1)); 75 | CHECK(!(obj1 < null)); 76 | CHECK(!(obj2 < obj1)); 77 | 78 | // operator<= 79 | CHECK(null <= obj1); 80 | CHECK(null <= obj2); 81 | CHECK(obj1 <= obj2); 82 | CHECK(null <= null); 83 | CHECK(obj1 <= obj1); 84 | CHECK(!(obj1 <= null)); 85 | CHECK(!(obj2 <= obj1)); 86 | 87 | // operator> 88 | CHECK(obj1 > null); 89 | CHECK(obj2 > null); 90 | CHECK(obj2 > obj1); 91 | CHECK(!(null > null)); 92 | CHECK(!(obj1 > obj1)); 93 | CHECK(!(null > obj1)); 94 | CHECK(!(obj1 > obj2)); 95 | 96 | // operator>= 97 | CHECK(obj1 >= null); 98 | CHECK(obj2 >= null); 99 | CHECK(obj2 >= obj1); 100 | CHECK(null >= null); 101 | CHECK(obj1 >= obj1); 102 | CHECK(!(null >= obj1)); 103 | CHECK(!(obj1 >= obj2)); 104 | } 105 | 106 | template static void generic_empty_test(const T& obj) 107 | { 108 | T null; 109 | 110 | CHECK(null.empty()); 111 | CHECK(!obj.empty()); 112 | } 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_deprecated.cpp: -------------------------------------------------------------------------------- 1 | #define PUGIXML_DEPRECATED // Suppress deprecated declarations to avoid warnings 2 | 3 | #include "test.hpp" 4 | 5 | using namespace pugi; 6 | 7 | TEST(document_deprecated_load) 8 | { 9 | xml_document doc; 10 | CHECK(doc.load(STR(""))); 11 | CHECK_NODE(doc, STR("")); 12 | } 13 | 14 | #ifndef PUGIXML_NO_XPATH 15 | TEST_XML(xpath_api_deprecated_select_single_node, "") 16 | { 17 | xpath_node n1 = doc.select_single_node(STR("node/foo")); 18 | 19 | xpath_query q(STR("node/foo")); 20 | xpath_node n2 = doc.select_single_node(q); 21 | 22 | CHECK(n1.node().attribute(STR("id")).as_int() == 1); 23 | CHECK(n2.node().attribute(STR("id")).as_int() == 1); 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_guard.cpp: -------------------------------------------------------------------------------- 1 | // Tests header guards 2 | #include "../src/pugixml.hpp" 3 | #include "../src/pugixml.hpp" 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_iosfwd_1.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with iosfwd 2 | #include "../src/pugixml.hpp" 3 | #include 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_iosfwd_2.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with iosfwd 2 | #include 3 | #include "../src/pugixml.hpp" 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_iostream_1.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with iostream 2 | #include "../src/pugixml.hpp" 3 | #include 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_iostream_2.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with iostream 2 | #include 3 | #include "../src/pugixml.hpp" 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_only_1.cpp: -------------------------------------------------------------------------------- 1 | #define PUGIXML_HEADER_ONLY 2 | #define pugi pugih 3 | 4 | #include "test.hpp" 5 | 6 | // Check header guards 7 | #include "../src/pugixml.hpp" 8 | #include "../src/pugixml.hpp" 9 | 10 | using namespace pugi; 11 | 12 | TEST(header_only_1) 13 | { 14 | xml_document doc; 15 | CHECK(doc.load_string(STR(""))); 16 | CHECK_STRING(doc.first_child().name(), STR("node")); 17 | 18 | #ifndef PUGIXML_NO_XPATH 19 | CHECK(doc.first_child() == doc.select_node(STR("//*")).node()); 20 | #endif 21 | } 22 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_only_2.cpp: -------------------------------------------------------------------------------- 1 | #define PUGIXML_HEADER_ONLY 2 | #define pugi pugih 3 | 4 | #include "test.hpp" 5 | 6 | // Check header guards 7 | #include "../src/pugixml.hpp" 8 | #include "../src/pugixml.hpp" 9 | 10 | using namespace pugi; 11 | 12 | TEST(header_only_2) 13 | { 14 | xml_document doc; 15 | CHECK(doc.load_string(STR(""))); 16 | CHECK_STRING(doc.first_child().name(), STR("node")); 17 | 18 | #ifndef PUGIXML_NO_XPATH 19 | CHECK(doc.first_child() == doc.select_node(STR("//*")).node()); 20 | #endif 21 | } 22 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_string_1.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with string 2 | #include "../src/pugixml.hpp" 3 | #include 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_string_2.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with string 2 | #include 3 | #include "../src/pugixml.hpp" 4 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_header_string_iostream.cpp: -------------------------------------------------------------------------------- 1 | // Tests compatibility with string/iostream 2 | #include 3 | #include "../src/pugixml.hpp" 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /src/pugixml/tests/test_version.cpp: -------------------------------------------------------------------------------- 1 | #include "../src/pugixml.hpp" 2 | 3 | #if PUGIXML_VERSION != 1140 // 1.14 4 | #error Unexpected pugixml version 5 | #endif 6 | -------------------------------------------------------------------------------- /src/pugixml/tests/writer_string.cpp: -------------------------------------------------------------------------------- 1 | #include "writer_string.hpp" 2 | 3 | #include "test.hpp" 4 | 5 | static bool test_narrow(const std::string& result, const char* expected, size_t length) 6 | { 7 | // check result 8 | if (result != std::string(expected, expected + length)) return false; 9 | 10 | // check comparison operator (incorrect implementation can theoretically early-out on zero terminators...) 11 | if (length > 0 && result == std::string(expected, expected + length - 1) + "?") return false; 12 | 13 | return true; 14 | } 15 | 16 | void xml_writer_string::write(const void* data, size_t size) 17 | { 18 | contents.append(static_cast(data), size); 19 | } 20 | 21 | std::string xml_writer_string::as_narrow() const 22 | { 23 | return contents; 24 | } 25 | 26 | std::basic_string xml_writer_string::as_wide() const 27 | { 28 | CHECK(contents.size() % sizeof(wchar_t) == 0); 29 | 30 | // round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast 31 | return std::basic_string(static_cast(static_cast(contents.data())), contents.size() / sizeof(wchar_t)); 32 | } 33 | 34 | std::basic_string xml_writer_string::as_string() const 35 | { 36 | #ifdef PUGIXML_WCHAR_MODE // to avoid "condition is always true" warning in BCC 37 | CHECK(contents.size() % sizeof(pugi::char_t) == 0); 38 | #endif 39 | 40 | // round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast 41 | return std::basic_string(static_cast(static_cast(contents.data())), contents.size() / sizeof(pugi::char_t)); 42 | } 43 | 44 | std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding) 45 | { 46 | xml_writer_string writer; 47 | 48 | doc.save(writer, STR("\t"), flags, encoding); 49 | 50 | return writer.as_narrow(); 51 | } 52 | 53 | bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length) 54 | { 55 | return test_narrow(save_narrow(doc, flags, encoding), expected, length); 56 | } 57 | 58 | std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding) 59 | { 60 | xml_writer_string writer; 61 | 62 | node.print(writer, STR("\t"), flags, encoding); 63 | 64 | return writer.as_narrow(); 65 | } 66 | 67 | bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length) 68 | { 69 | return test_narrow(write_narrow(node, flags, encoding), expected, length); 70 | } 71 | 72 | std::basic_string write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding) 73 | { 74 | xml_writer_string writer; 75 | 76 | node.print(writer, STR("\t"), flags, encoding); 77 | 78 | return writer.as_wide(); 79 | } 80 | -------------------------------------------------------------------------------- /src/pugixml/tests/writer_string.hpp: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_TEST_WRITER_STRING_HPP 2 | #define HEADER_TEST_WRITER_STRING_HPP 3 | 4 | #include "../src/pugixml.hpp" 5 | 6 | #include 7 | 8 | struct xml_writer_string: public pugi::xml_writer 9 | { 10 | std::string contents; 11 | 12 | virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; 13 | 14 | std::string as_narrow() const; 15 | std::basic_string as_wide() const; 16 | std::basic_string as_string() const; 17 | }; 18 | 19 | std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding); 20 | bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length); 21 | 22 | std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding); 23 | bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length); 24 | 25 | std::basic_string write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/random123/LICENSE: -------------------------------------------------------------------------------- 1 | /** @page LICENSE 2 | Copyright 2010-2012, D. E. Shaw Research. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions, and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions, and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of D. E. Shaw Research nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | -------------------------------------------------------------------------------- /src/random123/features/clangfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010-2016, D. E. Shaw Research. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions, and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions, and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of D. E. Shaw Research nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | #ifndef __clangfeatures_dot_hpp 33 | #define __clangfeatures_dot_hpp 34 | 35 | #ifndef R123_USE_X86INTRIN_H 36 | #define R123_USE_X86INTRIN_H ((defined(__x86_64__)||defined(__i386__))) 37 | #endif 38 | 39 | #ifndef R123_USE_CXX11_UNRESTRICTED_UNIONS 40 | #define R123_USE_CXX11_UNRESTRICTED_UNIONS __has_feature(cxx_unrestricted_unions) 41 | #endif 42 | 43 | #ifndef R123_USE_CXX11_STATIC_ASSERT 44 | #define R123_USE_CXX11_STATIC_ASSERT __has_feature(cxx_static_assert) 45 | #endif 46 | 47 | // With clang-3.6, -Wall warns about unused-local-typedefs. 48 | // The "obvious" thing to do is to ignore -Wunused-local-typedefs, 49 | // but that doesn't work because earlier versions of clang blow 50 | // up on an 'unknown warning group'. So we briefly ignore -Wall... 51 | // It's tempting to just give up on static assertions in pre-c++11 code. 52 | #if !R123_USE_CXX11_STATIC_ASSERT && !defined(R123_STATIC_ASSERT) 53 | #define R123_STATIC_ASSERT(expr, msg) \ 54 | _Pragma("clang diagnostic push") \ 55 | _Pragma("clang diagnostic ignored \"-Wall\"") \ 56 | typedef char static_assertion[(!!(expr))*2-1] \ 57 | _Pragma("clang diagnostic pop") 58 | #endif 59 | 60 | #ifndef R123_USE_CXX11_CONSTEXPR 61 | #define R123_USE_CXX11_CONSTEXPR __has_feature(cxx_constexpr) 62 | #endif 63 | 64 | #ifndef R123_USE_CXX11_EXPLICIT_CONVERSIONS 65 | #define R123_USE_CXX11_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions) 66 | #endif 67 | 68 | // With clang-3.0, the apparently simpler: 69 | // #define R123_USE_CXX11_RANDOM __has_include() 70 | // dumps core. 71 | #ifndef R123_USE_CXX11_RANDOM 72 | #if __cplusplus>=201103L && __has_include() 73 | #define R123_USE_CXX11_RANDOM 1 74 | #else 75 | #define R123_USE_CXX11_RANDOM 0 76 | #endif 77 | #endif 78 | 79 | #ifndef R123_USE_CXX11_TYPE_TRAITS 80 | #if __cplusplus>=201103L && __has_include() 81 | #define R123_USE_CXX11_TYPE_TRAITS 1 82 | #else 83 | #define R123_USE_CXX11_TYPE_TRAITS 0 84 | #endif 85 | #endif 86 | 87 | #include "gccfeatures.h" 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/random123/features/fujitsufeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | Note: Minimum/Initial version derived from openclfeatures.h to work 3 | with fujitsu compiler (_FCC). 4 | */ 5 | 6 | #ifndef __fujitsufeatures_dot_hpp 7 | #define __fujitsufeatures_dot_hpp 8 | 9 | #ifndef R123_STATIC_INLINE 10 | #define R123_STATIC_INLINE static __inline 11 | #endif 12 | 13 | #ifndef R123_FORCE_INLINE 14 | #define R123_FORCE_INLINE(decl) decl 15 | #endif 16 | 17 | #ifndef R123_CUDA_DEVICE 18 | #define R123_CUDA_DEVICE 19 | #endif 20 | 21 | #ifndef R123_ASSERT 22 | #include 23 | #define R123_ASSERT(x) assert(x) 24 | #endif 25 | 26 | #ifndef R123_BUILTIN_EXPECT 27 | #define R123_BUILTIN_EXPECT(expr,likely) expr 28 | #endif 29 | 30 | #ifndef R123_USE_WMMINTRIN_H 31 | #define R123_USE_WMMINTRIN_H 0 32 | #endif 33 | 34 | #ifndef R123_USE_INTRIN_H 35 | #define R123_USE_INTRIN_H 0 36 | #endif 37 | 38 | #ifndef R123_USE_MULHILO32_ASM 39 | #define R123_USE_MULHILO32_ASM 0 40 | #endif 41 | 42 | #ifndef R123_USE_MULHILO64_ASM 43 | #define R123_USE_MULHILO64_ASM 0 44 | #endif 45 | 46 | #ifndef R123_USE_MULHILO64_MSVC_INTRIN 47 | #define R123_USE_MULHILO64_MSVC_INTRIN 0 48 | #endif 49 | 50 | #ifndef R123_USE_MULHILO64_CUDA_INTRIN 51 | #define R123_USE_MULHILO64_CUDA_INTRIN 0 52 | #endif 53 | 54 | #ifndef R123_USE_MULHILO64_OPENCL_INTRIN 55 | #define R123_USE_MULHILO64_OPENCL_INTRIN 0 56 | #endif 57 | 58 | #ifndef R123_USE_MULHILO64_MULHI_INTRIN 59 | #if (defined(__powerpc64__)) 60 | #define R123_USE_MULHILO64_MULHI_INTRIN 1 61 | #else 62 | #define R123_USE_MULHILO64_MULHI_INTRIN 0 63 | #endif 64 | #endif 65 | 66 | #ifndef R123_MULHILO64_MULHI_INTRIN 67 | #define R123_MULHILO64_MULHI_INTRIN __mulhdu 68 | #endif 69 | 70 | #ifndef R123_USE_MULHILO32_MULHI_INTRIN 71 | #define R123_USE_MULHILO32_MULHI_INTRIN 0 72 | #endif 73 | 74 | #ifndef R123_MULHILO32_MULHI_INTRIN 75 | #define R123_MULHILO32_MULHI_INTRIN __mulhwu 76 | #endif 77 | 78 | #ifndef __STDC_CONSTANT_MACROS 79 | #define __STDC_CONSTANT_MACROS 80 | #endif 81 | #include 82 | #ifndef UINT64_C 83 | #error UINT64_C not defined. You must define __STDC_CONSTANT_MACROS before you #include 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/random123/features/metalfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010-2011, D. E. Shaw Research. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions, and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions, and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of D. E. Shaw Research nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * Written by Tom Schoonjans 35 | */ 36 | 37 | #ifndef __metalfeatures_dot_hpp 38 | #define __metalfeatures_dot_hpp 39 | 40 | #ifndef R123_STATIC_INLINE 41 | #define R123_STATIC_INLINE inline 42 | #endif 43 | 44 | #ifndef R123_FORCE_INLINE 45 | #define R123_FORCE_INLINE(decl) decl __attribute__((always_inline)) 46 | #endif 47 | 48 | #ifndef R123_CUDA_DEVICE 49 | #define R123_CUDA_DEVICE 50 | #endif 51 | 52 | #ifndef R123_METAL_THREAD_ADDRESS_SPACE 53 | #define R123_METAL_THREAD_ADDRESS_SPACE thread 54 | #endif 55 | 56 | #ifndef R123_METAL_CONSTANT_ADDRESS_SPACE 57 | #define R123_METAL_CONSTANT_ADDRESS_SPACE constant 58 | #endif 59 | 60 | #ifndef R123_ASSERT 61 | #define R123_ASSERT(x) 62 | #endif 63 | 64 | #ifndef R123_BUILTIN_EXPECT 65 | #define R123_BUILTIN_EXPECT(expr,likely) expr 66 | #endif 67 | 68 | #ifndef R123_USE_GNU_UINT128 69 | #define R123_USE_GNU_UINT128 0 70 | #endif 71 | 72 | #ifndef R123_USE_MULHILO64_ASM 73 | #define R123_USE_MULHILO64_ASM 0 74 | #endif 75 | 76 | #ifndef R123_USE_MULHILO64_MSVC_INTRIN 77 | #define R123_USE_MULHILO64_MSVC_INTRIN 0 78 | #endif 79 | 80 | #ifndef R123_USE_MULHILO64_CUDA_INTRIN 81 | #define R123_USE_MULHILO64_CUDA_INTRIN 0 82 | #endif 83 | 84 | #ifndef R123_USE_MULHILO64_OPENCL_INTRIN 85 | #define R123_USE_MULHILO64_OPENCL_INTRIN 0 86 | #endif 87 | 88 | #ifndef R123_USE_MULHILO32_MULHI_INTRIN 89 | #define R123_USE_MULHILO32_MULHI_INTRIN 1 90 | #endif 91 | 92 | #if R123_USE_MULHILO32_MULHI_INTRIN 93 | #include 94 | #define R123_MULHILO32_MULHI_INTRIN metal::mulhi 95 | #endif 96 | 97 | #ifndef R123_USE_AES_NI 98 | #define R123_USE_AES_NI 0 99 | #endif 100 | 101 | #ifndef R123_USE_64BIT 102 | #define R123_USE_64BIT 0 /* Metal currently (Feb 2019, Specification-2) does not support 64-bit variable types */ 103 | #endif 104 | 105 | #ifndef R123_ULONG_LONG 106 | /* the longest integer type in Metal (Feb 2019, Specification-2) is a 107 | * 32-bit unsigned int. Let's hope for the best... */ 108 | #define R123_ULONG_LONG unsigned int 109 | #endif 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /src/random123/features/open64features.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010-2011, D. E. Shaw Research. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions, and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions, and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of D. E. Shaw Research nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | #ifndef __open64features_dot_hpp 33 | #define __open64features_dot_hpp 34 | 35 | /* The gcc features are mostly right. We just override a few and then include gccfeatures.h */ 36 | 37 | /* Open64 4.2.3 and 4.2.4 accept the __uint128_t code without complaint 38 | but produce incorrect code for 64-bit philox. The MULHILO64_ASM 39 | seems to work fine */ 40 | #ifndef R123_USE_GNU_UINT128 41 | #define R123_USE_GNU_UINT128 0 42 | #endif 43 | 44 | #ifndef R123_USE_MULHILO64_ASM 45 | #define R123_USE_MULHILO64_ASM 1 46 | #endif 47 | 48 | #include "gccfeatures.h" 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/random123/features/openclfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2010-2011, D. E. Shaw Research. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions, and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions, and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of D. E. Shaw Research nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | #ifndef __openclfeatures_dot_hpp 33 | #define __openclfeatures_dot_hpp 34 | 35 | #ifndef R123_STATIC_INLINE 36 | #define R123_STATIC_INLINE inline 37 | #endif 38 | 39 | #ifndef R123_FORCE_INLINE 40 | #define R123_FORCE_INLINE(decl) decl __attribute__((always_inline)) 41 | #endif 42 | 43 | #ifndef R123_CUDA_DEVICE 44 | #define R123_CUDA_DEVICE 45 | #endif 46 | 47 | #ifndef R123_ASSERT 48 | #define R123_ASSERT(x) 49 | #endif 50 | 51 | #ifndef R123_BUILTIN_EXPECT 52 | #define R123_BUILTIN_EXPECT(expr,likely) expr 53 | #endif 54 | 55 | #ifndef R123_USE_GNU_UINT128 56 | #define R123_USE_GNU_UINT128 0 57 | #endif 58 | 59 | #ifndef R123_USE_MULHILO64_ASM 60 | #define R123_USE_MULHILO64_ASM 0 61 | #endif 62 | 63 | #ifndef R123_USE_MULHILO64_MSVC_INTRIN 64 | #define R123_USE_MULHILO64_MSVC_INTRIN 0 65 | #endif 66 | 67 | #ifndef R123_USE_MULHILO64_CUDA_INTRIN 68 | #define R123_USE_MULHILO64_CUDA_INTRIN 0 69 | #endif 70 | 71 | #ifndef R123_USE_MULHILO64_OPENCL_INTRIN 72 | #define R123_USE_MULHILO64_OPENCL_INTRIN 1 73 | #endif 74 | 75 | #ifndef R123_USE_AES_NI 76 | #define R123_USE_AES_NI 0 77 | #endif 78 | 79 | // XXX ATI APP SDK 2.4 clBuildProgram SEGVs if one uses uint64_t instead of 80 | // ulong to mul_hi. And gets lots of complaints from stdint.h 81 | // on some machines. 82 | // But these typedefs mean we cannot include stdint.h with 83 | // these headers? Do we need R123_64T, R123_32T, R123_8T? 84 | typedef ulong uint64_t; 85 | typedef uint uint32_t; 86 | typedef uchar uint8_t; 87 | #define UINT64_C(x) ((ulong)(x##UL)) 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /src/region.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file region.h 4 | * \author Alex Long 5 | * \date April 4 2016 6 | * \brief Describes a mesh region with independent physical properties 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #ifndef region_h_ 13 | #define region_h_ 14 | 15 | #include 16 | 17 | //============================================================================== 18 | /*! 19 | * \class Region 20 | * \brief Contains data necessary to physically define a region of the problem 21 | * 22 | * This class holds heat capcaity, density, opacity and initial temperature 23 | * conditions. All of these are necessary to initialize cells created in 24 | * this spatial region. 25 | */ 26 | //============================================================================== 27 | class Region { 28 | public: 29 | Region(void) { T_s = 0.0; } 30 | ~Region(void) {} 31 | 32 | //----------------------------------------------------------------------------// 33 | // const functions // 34 | //----------------------------------------------------------------------------// 35 | uint32_t get_ID(void) const { return ID; } 36 | double get_cV(void) const { return cv; } 37 | double get_rho(void) const { return rho; } 38 | double get_opac_A(void) const { return opacA; } 39 | double get_opac_B(void) const { return opacB; } 40 | double get_opac_C(void) const { return opacC; } 41 | double get_T_e(void) const { return T_e; } 42 | double get_T_r(void) const { return T_r; } 43 | double get_T_s(void) const { return T_s; } 44 | double get_absorption_opacity(double T) const { 45 | return opacA + opacB * std::pow(T, opacC); 46 | } 47 | double get_scattering_opacity(void) const { return opacS; } 48 | //----------------------------------------------------------------------------// 49 | // non-const functions // 50 | //----------------------------------------------------------------------------// 51 | void set_ID(const uint32_t &_ID) { ID = _ID; } 52 | void set_cV(const double &_cv) { cv = _cv; } 53 | void set_rho(const double &_rho) { rho = _rho; } 54 | void set_opac_A(const double &_opacA) { opacA = _opacA; } 55 | void set_opac_B(const double &_opacB) { opacB = _opacB; } 56 | void set_opac_C(const double &_opacC) { opacC = _opacC; } 57 | void set_opac_S(const double &_opacS) { opacS = _opacS; } 58 | void set_T_e(const double &_T_e) { T_e = _T_e; } 59 | void set_T_r(const double &_T_r) { T_r = _T_r; } 60 | void set_T_s(const double &_T_s) { T_s = _T_s; } 61 | 62 | //----------------------------------------------------------------------------// 63 | // member variables and private functions // 64 | //----------------------------------------------------------------------------// 65 | private: 66 | uint32_t ID; //!< User defined ID of this region 67 | double cv; //!< Heat capacity in this region 68 | double rho; //!< Density in this region (g/cc) 69 | double opacA; //!< A in A + B * T ^ C 70 | double opacB; //!< B in A + B * T ^ C 71 | double opacC; //!< C in A + B * T ^ C 72 | double opacS; //!< Physical scattering constant coefficient 73 | double T_e; //!< Initial electron temperature in region 74 | double T_r; //!< Initial radiation temperature in region 75 | double T_s; //!< Temperature of source in region 76 | }; 77 | 78 | #endif 79 | //----------------------------------------------------------------------------// 80 | // end of region.h 81 | //----------------------------------------------------------------------------// 82 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Unit tests 2 | cmake_minimum_required (VERSION 3.11) 3 | 4 | # 5 | # force mpiexec to be srun in cray environments 6 | # can't run as root on a cray so don't try to match 7 | # mpirun's allow-run-as-root and oversubscribe 8 | # 9 | message( STATUS "Looking to see if we are building in a Cray Environment...") 10 | if( DEFINED ENV{CRAYPE_VERSION} ) 11 | set(MPIEXEC_EXECUTABLE srun) 12 | set( MPIEXEC_POSTFLAGS "--cpu-bind=none" CACHE STRING 13 | "extra mpirun flags (list)." FORCE) 14 | message("In Cray Environment, MPI executable is: ${MPIEXEC_EXECUTABLE}") 15 | else() 16 | # allow run as root 17 | if( "$ENV{GITLAB_CI}" STREQUAL "true" OR "$ENV{TRAVIS}" STREQUAL "true") 18 | message("In CI mode, allow running mpiexec as root") 19 | set(runasroot "--allow-run-as-root --oversubscribe") 20 | endif() 21 | # set extra flags for mpiexec in testing 22 | set( MPIEXEC_POSTFLAGS "-bind-to none ${runasroot}" CACHE STRING 23 | "extra mpirun flags (list)." FORCE) 24 | endif() 25 | 26 | 27 | 28 | string( REPLACE " " ";" mpiexec_postflags_list "${MPIEXEC_POSTFLAGS}" ) 29 | 30 | #------------------------------------------------------------------------------# 31 | # Helper for building and registering tests. 32 | # 33 | # add_branson_test( 34 | # SOURCE "foo.cc" 35 | # PE_LIST "1;4" ) 36 | 37 | function( add_branson_test ) 38 | cmake_parse_arguments( 39 | abt 40 | "" 41 | "SOURCE" 42 | "PE_LIST" 43 | ${ARGV} ) 44 | string( REPLACE ".cc" "_exe" build_target ${abt_SOURCE} ) 45 | string( REPLACE ".cc" "" ctest_name ${abt_SOURCE} ) 46 | 47 | # Build the test 48 | add_executable( ${build_target} ${abt_SOURCE} ) 49 | target_include_directories( ${build_target} PRIVATE 50 | $ ) 51 | target_link_libraries( ${build_target} PUBLIC ${branson_deps} ) 52 | 53 | # Register the test command with ctest. 54 | foreach( np ${abt_PE_LIST} ) 55 | add_test( 56 | NAME ${ctest_name}_${np}pe 57 | COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${np} 58 | ${mpiexec_postflags_list} 59 | $ ) 60 | set_tests_properties( ${ctest_name}_${np}pe PROPERTIES PROCESSORS ${np} ) 61 | endforeach() 62 | endfunction() 63 | 64 | #------------------------------------------------------------------------------# 65 | # 1 PE tests 66 | 67 | set(branson_test_sources_1pe 68 | test_buffer.cc 69 | test_cell.cc 70 | test_proto_cell.cc 71 | test_counter_rng.cc 72 | test_input.cc 73 | test_mesh.cc 74 | test_mpi_types.cc 75 | test_sampling_functions.cc 76 | test_imc_parameters.cc 77 | ) 78 | foreach( btest ${branson_test_sources_1pe} ) 79 | add_branson_test( SOURCE ${btest} PE_LIST "1" ) 80 | endforeach() 81 | 82 | #------------------------------------------------------------------------------# 83 | # Other tests 84 | 85 | add_branson_test( SOURCE test_imc_state.cc PE_LIST "2" ) 86 | add_branson_test( SOURCE test_photon.cc PE_LIST "2" ) 87 | 88 | #------------------------------------------------------------------------------# 89 | # copy these input files for Input, IMC_State, Mesh and write_silo tests 90 | 91 | set( inputfiles 92 | simple_input.xml 93 | large_particle_input.xml 94 | three_region_mesh_input.xml ) 95 | foreach( ifile ${inputfiles} ) 96 | configure_file(${ifile} ${CMAKE_CURRENT_BINARY_DIR}/${ifile} COPYONLY) 97 | endforeach() 98 | 99 | #------------------------------------------------------------------------------# 100 | # write_silo function test 101 | if (VIZ_LIBRARIES_FOUND) 102 | add_branson_test( SOURCE test_write_silo.cc PE_LIST "2") 103 | endif() 104 | 105 | #------------------------------------------------------------------------------# 106 | # End test/CMakeLists.txt 107 | #------------------------------------------------------------------------------# 108 | -------------------------------------------------------------------------------- /src/test/large_particle_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 100.0 6 | 0.2 7 | 1.5 8 | 2.0 9 | 6000000000 10 | 14706 11 | 1 12 | FALSE 13 | PARTICLE_PASS 14 | 50000 15 | 10000 16 | 1000 17 | 18 | 19 | 20 | FALSE 21 | FALSE 22 | 23 | 24 | 25 | 26 | 0.0 27 | 1.0 28 | 10 29 | 30 | 31 | 32 | 0.0 33 | 1.0 34 | 10 35 | 36 | 37 | 38 | 0.0 39 | 1.0 40 | 10 41 | 42 | 43 | 44 | 0 45 | 0 46 | 0 47 | 12 48 | 49 | 50 | 51 | 52 | REFLECT 53 | REFLECT 54 | 55 | REFLECT 56 | REFLECT 57 | 58 | REFLECT 59 | REFLECT 60 | 61 | 62 | 63 | 0 64 | 0.0 65 | 66 | 67 | 68 | 69 | 12 70 | 1.0 71 | 1.0 72 | 1.0 73 | 0.0 74 | 0.0 75 | 0.0 76 | 1.0 77 | 1.0 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/test/simple_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.1 6 | 0.01 7 | 1.0 8 | 1.0 9 | 10000 10 | 14706 11 | 1 12 | FALSE 13 | PARTICLE_PASS 14 | 50000 15 | 10000 16 | 1000 17 | FALSE 18 | FALSE 19 | 20 | 21 | 22 | TRUE 23 | TRUE 24 | 25 | 26 | 27 | 28 | 0.0 29 | 10.0 30 | 10 31 | 32 | 33 | 34 | 0.0 35 | 40.0 36 | 20 37 | 38 | 39 | 40 | 0.0 41 | 90.0 42 | 30 43 | 44 | 45 | 46 | 0 47 | 0 48 | 0 49 | 6 50 | 51 | 52 | 53 | 54 | REFLECT 55 | REFLECT 56 | 57 | VACUUM 58 | VACUUM 59 | 60 | REFLECT 61 | VACUUM 62 | 63 | 64 | 65 | 66 | 6 67 | 1.0 68 | 2.0 69 | 3.0 70 | 1.5 71 | 0.1 72 | 5.0 73 | 1.0 74 | 1.1 75 | 76 | 77 | 78 | 79 | 0 80 | 0.0 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/test/test_imc_parameters.cc: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file test_imc_parameters.cc 4 | * \author Alex Long 5 | * \date February 11 2016 6 | * \brief Test Input class for correct reading of XML imc_parameters files 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../constants.h" 17 | #include "../input.h" 18 | #include "../imc_parameters.h" 19 | #include "../region.h" 20 | #include "testing_functions.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | 24 | MPI_Init(&argc, &argv); 25 | 26 | using std::cout; 27 | using std::endl; 28 | using std::string; 29 | 30 | int nfail = 0; 31 | 32 | // scope for MPI_Types 33 | { 34 | MPI_Types mpi_types; 35 | 36 | // test the get functions to make sure correct values are set from the imc_parameters class, 37 | // right now the imc_parameters are just a subset of the input file se we construct an input 38 | // file first 39 | { 40 | using Constants::REPLICATED; 41 | // test simple imc_parameters file (one division in each dimension and one region) 42 | string filename("simple_input.xml"); 43 | Input input(filename, mpi_types); 44 | IMC_Parameters imc_parameters(input); 45 | bool simple_imc_parameters_pass = true; 46 | 47 | if (imc_parameters.get_use_comb_flag() != false) 48 | simple_imc_parameters_pass = false; 49 | if (imc_parameters.get_output_frequency() != 1) 50 | simple_imc_parameters_pass = false; 51 | if (imc_parameters.get_rng_seed() != 14706) 52 | simple_imc_parameters_pass = false; 53 | if (imc_parameters.get_n_user_photons() != 10000) 54 | simple_imc_parameters_pass = false; 55 | // Even though input file says 10k, this defaults to the replicated 56 | // value of 100M when you're running 1 MPI rank. 57 | if (imc_parameters.get_batch_size() != 100000000) 58 | simple_imc_parameters_pass = false; 59 | if (imc_parameters.get_particle_message_size() != 1000) 60 | simple_imc_parameters_pass = false; 61 | // Even though imc_parameters says PARTICLE_PASS, this defaults back to replicated 62 | // when you're only running 1 MPI rank. 63 | if (imc_parameters.get_dd_mode() != REPLICATED) 64 | simple_imc_parameters_pass = false; 65 | if(imc_parameters.get_use_gpu_transporter_flag() != false) 66 | simple_imc_parameters_pass = false; 67 | 68 | if (simple_imc_parameters_pass) 69 | cout << "TEST PASSED: simple IMC_Parameters get functions" << endl; 70 | else { 71 | cout << "TEST FAILED: simple IMC_Parameters get functions" << endl; 72 | nfail++; 73 | } 74 | } 75 | 76 | } // end scope of MPI Types 77 | 78 | MPI_Finalize(); 79 | 80 | return nfail; 81 | } 82 | //---------------------------------------------------------------------------// 83 | // end of test_imc_parameters.cc 84 | //---------------------------------------------------------------------------// 85 | 86 | -------------------------------------------------------------------------------- /src/test/test_mpi_types.cc: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file test_mpi_types.cc 4 | * \author Alex Long 5 | * \date May 12 2016 6 | * \brief Test custom MPI types for consistency with their datatypes 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #include "../cell.h" 13 | #include "../mpi_types.h" 14 | #include "../photon.h" 15 | #include "../proto_cell.h" 16 | #include 17 | #include 18 | 19 | using std::cout; 20 | using std::endl; 21 | using std::string; 22 | 23 | int main(int argc, char *argv[]) { 24 | 25 | MPI_Init(&argc, &argv); 26 | 27 | int rank, n_rank; 28 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 29 | MPI_Comm_size(MPI_COMM_WORLD, &n_rank); 30 | 31 | int nfail = 0; 32 | 33 | // test get and size functions 34 | { 35 | MPI_Types mpi_types; 36 | 37 | bool size_functions_pass = true; 38 | 39 | // test particle size 40 | MPI_Datatype MPI_Particle = mpi_types.get_particle_type(); 41 | 42 | int particle_size; 43 | MPI_Type_size(MPI_Particle, &particle_size); 44 | 45 | // copy should be the same size as size recorded in class 46 | if (particle_size != mpi_types.get_particle_size()) 47 | size_functions_pass = false; 48 | 49 | // copy should be the same size as actual Photon class 50 | if (particle_size != sizeof(Photon)) 51 | size_functions_pass = false; 52 | 53 | cout << "Particle object size :" << sizeof(Photon) << endl; 54 | cout << "MPI Particle object size :" << particle_size << endl; 55 | 56 | // test proto_cell size 57 | MPI_Datatype MPI_Proto_Cell = mpi_types.get_proto_cell_type(); 58 | 59 | int proto_cell_size; 60 | MPI_Type_size(MPI_Proto_Cell, &proto_cell_size); 61 | 62 | // copy should be the same size as size recorded in class 63 | if (proto_cell_size != mpi_types.get_proto_cell_size()) 64 | size_functions_pass = false; 65 | 66 | // copy should be the same size as actual Proto_Cell class 67 | if (proto_cell_size != sizeof(Proto_Cell)) 68 | size_functions_pass = false; 69 | 70 | cout << "Proto_Cell object size :" << sizeof(Proto_Cell) << endl; 71 | cout << "MPI Proto_Cell object size :" << proto_cell_size << endl; 72 | 73 | if (size_functions_pass) 74 | cout << "TEST PASSED: MPI_Types size functions " << endl; 75 | else { 76 | cout << "TEST FAILED: MPI_Types size functions" << endl; 77 | nfail++; 78 | } 79 | } 80 | 81 | MPI_Finalize(); 82 | 83 | return nfail; 84 | } 85 | //---------------------------------------------------------------------------// 86 | // end of test_mpi_types.cc 87 | //---------------------------------------------------------------------------// 88 | -------------------------------------------------------------------------------- /src/test/test_proto_cell.cc: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file test_proto_cell.cc 4 | * \author Alex Long 5 | * \date October 29 2018 6 | * \brief Test proto cell construction, get and set functions 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #include "../constants.h" 13 | #include "../proto_cell.h" 14 | #include "testing_functions.h" 15 | #include 16 | #include 17 | 18 | int main(void) { 19 | 20 | using Constants::bc_type; 21 | using Constants::dir_type; 22 | using std::cout; 23 | using std::endl; 24 | using std::vector; 25 | int nfail = 0; 26 | 27 | // get/set functions 28 | { 29 | bool get_set_functions_pass = true; 30 | 31 | const vector dirs{Constants::X_NEG, Constants::X_POS, 32 | Constants::Y_NEG, Constants::Y_POS, 33 | Constants::Z_NEG, Constants::Z_POS}; 34 | 35 | //setup cell 36 | Proto_Cell proto_cell; 37 | 38 | uint32_t global_index = 3271733928; // 64-bit cell global_index 39 | uint32_t region_ID = 12; 40 | uint32_t silo_index = 1231; 41 | 42 | vector bcs{Constants::REFLECT, Constants::VACUUM, 43 | Constants::ELEMENT, Constants::PROCESSOR, 44 | Constants::ELEMENT, Constants::VACUUM}; 45 | vector neighbors{3500000000, 3500000001, 3500000002, 46 | 3500000003, 3500000004, 3500000005}; 47 | 48 | // simple cube of size 1.0 49 | double x_low = 0.0; 50 | double x_high = 1.0; 51 | double y_low = 0.0; 52 | double y_high = 1.0; 53 | double z_low = 0.0; 54 | double z_high = 1.0; 55 | vector coords = {x_low, x_high, y_low, y_high, z_low, z_high}; 56 | 57 | // set values 58 | proto_cell.set_coor(x_low, x_high, y_low, y_high, z_low, z_high); 59 | proto_cell.set_global_index(global_index); 60 | proto_cell.set_region_ID(region_ID); 61 | proto_cell.set_silo_index(silo_index); 62 | for (auto i : dirs) { 63 | proto_cell.set_bc(i, bcs[i]); 64 | proto_cell.set_neighbor(i, neighbors[i]); 65 | } 66 | 67 | // test the get methods 68 | const double *cell_coords = proto_cell.get_node_array(); 69 | if (proto_cell.get_global_index() != global_index) 70 | get_set_functions_pass = false; 71 | if (proto_cell.get_region_ID() != region_ID) 72 | get_set_functions_pass = false; 73 | if (proto_cell.get_silo_index() != silo_index) 74 | get_set_functions_pass = false; 75 | for (int i = 0; i < 6; ++i) { 76 | if (proto_cell.get_next_cell(i) != neighbors[i]) 77 | get_set_functions_pass = false; 78 | if (proto_cell.get_bc(i) != bcs[i]) 79 | get_set_functions_pass = false; 80 | if (cell_coords[i] != coords[i]) 81 | get_set_functions_pass = false; 82 | } 83 | 84 | if (get_set_functions_pass) 85 | cout << "TEST PASSED: Proto_Cell get/set functions" << endl; 86 | else { 87 | cout << "TEST FAILED: Proto_Cell get/set functions" << endl; 88 | nfail++; 89 | } 90 | } 91 | 92 | return nfail; 93 | } 94 | //---------------------------------------------------------------------------// 95 | // end of test_proto_cell.cc 96 | //---------------------------------------------------------------------------// 97 | -------------------------------------------------------------------------------- /src/test/test_write_silo.cc: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file test_write_silo.cc 4 | * \author Alex Long 5 | * \date April 15 2016 6 | * \brief Test ability to write SILO files 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "../decompose_mesh.h" 17 | #include "../mesh.h" 18 | #include "../mpi_types.h" 19 | #include "../write_silo.h" 20 | #include "testing_functions.h" 21 | 22 | int main(int argc, char *argv[]) { 23 | 24 | MPI_Init(&argc, &argv); 25 | 26 | int rank, n_rank; 27 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 28 | MPI_Comm_size(MPI_COMM_WORLD, &n_rank); 29 | 30 | const Info mpi_info; 31 | 32 | using std::cout; 33 | using std::endl; 34 | using std::string; 35 | 36 | int nfail = 0; 37 | 38 | // Test that a simple mesh (one division in each dimension) is constructed 39 | // correctly from the input file (simple_input.xml) and that the write 40 | // silo function exits without error 41 | { 42 | // put MPI_Types in scope so it's destructor is called before MPI_Finalize 43 | MPI_Types mpi_types; 44 | string filename("simple_input.xml"); 45 | Input input(filename, mpi_types); 46 | IMC_Parameters imc_p(input); 47 | 48 | Mesh mesh(input, mpi_types, mpi_info, imc_p); 49 | 50 | bool silo_write_pass = true; 51 | 52 | // get fake vector of mesh requests 53 | std::vector n_requests(mesh.get_n_global_cells(), 0); 54 | 55 | double time = 0.0; 56 | int step = 0; 57 | double transport_runtime = 10.0; 58 | double mpi_time = 5.0; 59 | write_silo(mesh, time, step, transport_runtime, mpi_time, rank, n_rank, false); 60 | 61 | if (silo_write_pass) 62 | cout << "TEST PASSED: writing simple mesh silo file" << endl; 63 | else { 64 | cout << "TEST FAILED: writing silo file" << endl; 65 | nfail++; 66 | } 67 | } 68 | 69 | // Test that a simple mesh (one division in each dimension) is constructed 70 | // correctly from the input file (simple_input.xml) and that each cell 71 | // is assigned the correct region 72 | { 73 | // put MPI_Types in scope so it's destructor is called before MPI_Finalize 74 | MPI_Types mpi_types; 75 | string filename("three_region_mesh_input.xml"); 76 | Input input(filename, mpi_types); 77 | IMC_Parameters imc_p(input); 78 | 79 | Mesh mesh(input, mpi_types, mpi_info, imc_p); 80 | 81 | bool three_reg_silo_write_pass = true; 82 | 83 | double time = 2.0; 84 | int step = 1; 85 | double transport_runtime = 7.0; 86 | double mpi_time = 2.0; 87 | write_silo(mesh, time, step, transport_runtime, mpi_time, rank, n_rank, false); 88 | 89 | if (three_reg_silo_write_pass) { 90 | cout << "TEST PASSED: writing three region mesh silo file" << endl; 91 | } else { 92 | cout << "TEST FAILED: writing silo file" << endl; 93 | nfail++; 94 | } 95 | } 96 | 97 | MPI_Finalize(); 98 | 99 | return nfail; 100 | } 101 | //---------------------------------------------------------------------------// 102 | // end of test_write_silo.cc 103 | //---------------------------------------------------------------------------// 104 | -------------------------------------------------------------------------------- /src/test/testing_functions.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file testing_functions.h 4 | * \author Alex Long 5 | * \date December 10 2015 6 | * \brief Provide soft equivalence functions for testing 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | #include 12 | 13 | #ifndef testing_functions_h_ 14 | #define testing_functions_h_ 15 | 16 | bool soft_equiv(const double& a, const double& b, double tolerance=1.0e-8 ) { 17 | double diff = a-b; 18 | return std::fabs(diff) < tolerance; 19 | } 20 | 21 | #endif // testing_functions_h_ 22 | //---------------------------------------------------------------------------// 23 | // end of testing_functions.h 24 | //---------------------------------------------------------------------------// 25 | 26 | -------------------------------------------------------------------------------- /src/test/three_region_mesh_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IMC 4 | 0.0 5 | 0.1 6 | 0.01 7 | 1.0 8 | 1.0 9 | 10000 10 | 14706 11 | 1 12 | FALSE 13 | PARTICLE_PASS 14 | 50000 15 | 10000 16 | 1000 17 | 18 | 19 | 20 | FALSE 21 | FALSE 22 | 23 | 24 | 25 | 26 | 0.0 27 | 4.0 28 | 4 29 | 30 | 31 | 32 | 4.0 33 | 8.0 34 | 2 35 | 36 | 37 | 38 | 8.0 39 | 10.0 40 | 15 41 | 42 | 43 | 44 | 0.0 45 | 30.0 46 | 10 47 | 48 | 49 | 50 | 0.0 51 | 1.0 52 | 1 53 | 54 | 55 | 56 | 0 57 | 0 58 | 0 59 | 230 60 | 61 | 62 | 63 | 1 64 | 0 65 | 0 66 | 177 67 | 68 | 69 | 70 | 2 71 | 0 72 | 0 73 | 11 74 | 75 | 76 | 77 | 78 | 79 | REFLECT 80 | REFLECT 81 | 82 | VACUUM 83 | VACUUM 84 | 85 | REFLECT 86 | VACUUM 87 | 88 | 89 | 90 | 91 | 230 92 | 1.0 93 | 2.0 94 | 3.0 95 | 1.5 96 | 0.1 97 | 5.0 98 | 1.0 99 | 1.1 100 | 101 | 102 | 177 103 | 5.0 104 | 0.99 105 | 101.0 106 | 10.5 107 | 0.3 108 | 0.01 109 | 0.01 110 | 0.1 111 | 112 | 113 | 11 114 | 100.0 115 | 5.0 116 | 0.001 117 | 0.01 118 | 4.8 119 | 100.0 120 | 1.2 121 | 0.0 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/timer.h: -------------------------------------------------------------------------------- 1 | //----------------------------------*-C++-*----------------------------------// 2 | /*! 3 | * \file timer.h 4 | * \author Alex Long 5 | * \date August 4 2016 6 | * \brief Class for tracking multiple timers 7 | * \note Copyright (C) 2017 Los Alamos National Security, LLC. 8 | * All rights reserved 9 | */ 10 | //---------------------------------------------------------------------------// 11 | 12 | #ifndef timer_h_ 13 | #define timer_h_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | class Timer { 21 | public: 22 | Timer(void) {} 23 | ~Timer(void) {} 24 | 25 | //! Start or continute timer with name 26 | void start_timer(std::string name) { 27 | // start timer if new 28 | if (times.find(name) == times.end()) 29 | times[name] = 0.0; 30 | temp_start = std::chrono::high_resolution_clock::now(); 31 | } 32 | 33 | //! Stop timer with name (must be the last active timer) 34 | void stop_timer(std::string name) { 35 | double time_seconds = 36 | std::chrono::duration_cast( 37 | std::chrono::high_resolution_clock::now() - temp_start) 38 | .count() / 39 | 1.0e6; 40 | times[name] += time_seconds; 41 | } 42 | 43 | //! Print all timers that have been measured with this clsas 44 | void print_timers(void) const { 45 | for (auto const &i_time : times) { 46 | std::cout << i_time.first << ": " << i_time.second << std::endl; 47 | } 48 | } 49 | 50 | //! Get the current elapsed time for a timer 51 | double get_time(std::string name) { return times[name]; } 52 | 53 | private: 54 | //! Starting time for the latest timing instance 55 | std::chrono::high_resolution_clock::time_point temp_start; 56 | 57 | //! Map of timer names to times 58 | std::unordered_map times; 59 | }; 60 | 61 | #endif // timer_h_ 62 | --------------------------------------------------------------------------------