├── .gitignore ├── docs ├── sphinx │ ├── requirements.in │ └── _toc.yml.in ├── license.md ├── .gitignore ├── README.md ├── api │ ├── memory_management.rst │ ├── memory_ordering.rst │ └── ctx.rst ├── conf.py ├── index.rst └── introduction.rst ├── .github └── CODEOWNERS ├── scripts ├── functional_tests │ ├── GDB_README │ ├── gdbscript │ └── gdbrun └── build_configs │ ├── gda_bnxt │ ├── gda_ionic │ ├── gda_mlx5 │ ├── ro_net_debug │ ├── gda │ ├── ro_ipc │ ├── ro_net │ ├── ipc_single │ ├── all_backends │ └── ipc_tests_only ├── .readthedocs.yaml ├── AUTHORS.md ├── LICENSE.md ├── tests ├── CMakeLists.txt ├── unit_tests │ ├── mpi_instance_gtest.cpp │ ├── remote_heap_info_gtest.cpp │ ├── bin_gtest.hpp │ ├── heap_memory_gtest.cpp │ ├── single_heap_gtest.hpp │ ├── wavefront_size_gtest.hpp │ ├── hipmalloc_gtest.hpp │ ├── heap_memory_gtest.hpp │ ├── hipmalloc_gtest.cpp │ ├── shmem_gtest.cpp │ ├── mpi_instance_gtest.hpp │ ├── wf_size.hpp │ ├── address_record_gtest.hpp │ ├── symmetric_heap_gtest.hpp │ ├── bin_gtest.cpp │ ├── dlmalloc_gtest.hpp │ ├── wavefront_size_gtest.cpp │ ├── symmetric_heap_gtest.cpp │ ├── pow2_bins_gtest.hpp │ ├── remote_heap_info_gtest.hpp │ ├── free_list_gtest.hpp │ └── binner_gtest.hpp └── functional_tests │ ├── verify_results_kernels.hpp │ ├── primitive_tester.hpp │ ├── shmem_ptr_tester.hpp │ ├── primitive_mr_tester.hpp │ ├── empty_tester.hpp │ ├── workgroup_primitives.hpp │ ├── wavefront_primitives.hpp │ ├── default_ctx_primitive_tester.hpp │ ├── team_ctx_primitive_tester.hpp │ ├── sync_all_tester.hpp │ ├── barrier_all_tester.hpp │ ├── signaling_operations_tester.hpp │ ├── ping_all_tester.hpp │ ├── team_ctx_infra_tester.hpp │ ├── ping_pong_tester.hpp │ ├── team_sync_tester.hpp │ ├── team_barrier_tester.hpp │ ├── amo_bitwise_tester.hpp │ ├── amo_standard_tester.hpp │ └── barrier_all_on_stream_tester.hpp ├── src ├── gda │ ├── bnxt │ │ └── CMakeLists.txt │ ├── ionic │ │ ├── CMakeLists.txt │ │ └── provider_gda_ionic.hpp │ ├── mlx5 │ │ ├── CMakeLists.txt │ │ ├── provider_gda_mlx5.hpp │ │ └── segment_builder.hpp │ ├── CMakeLists.txt │ ├── gda_team.hpp │ ├── endian.hpp │ └── gda_team.cpp ├── host │ └── CMakeLists.txt ├── sync │ ├── CMakeLists.txt │ └── abql_block_mutex.cpp ├── containers │ ├── CMakeLists.txt │ ├── strategies.cpp │ ├── helper_macros.hpp │ └── strategies.hpp ├── bootstrap │ └── CMakeLists.txt ├── memory │ ├── CMakeLists.txt │ └── single_heap.cpp ├── ipc │ ├── CMakeLists.txt │ ├── ipc_team.hpp │ └── ipc_team.cpp ├── reverse_offload │ ├── CMakeLists.txt │ ├── ro_net_team.hpp │ ├── ro_net_team.cpp │ └── commands_types.hpp ├── team_tracker.cpp ├── context_incl.hpp ├── atomic_return.hpp ├── tools │ └── CMakeLists.txt ├── hdp_proxy.hpp ├── wf_coal_policy.hpp └── constants.hpp ├── include └── rocshmem │ └── rocshmem_debug.hpp ├── README.md ├── cmake ├── rocshmem_config.h.in └── rocm_local_targets.cmake └── examples └── util.h /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /docs/sphinx/requirements.in: -------------------------------------------------------------------------------- 1 | rocm-docs-core==1.18.4 2 | 3 | -------------------------------------------------------------------------------- /docs/license.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | ```{include} ../LICENSE.md 4 | ``` 5 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | _doxygen/ 3 | doxygen/html/ 4 | doxygen/xml/ 5 | sphinx/_toc.yml 6 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @avinashkethineedi @akolliasAMD @Yiltan @BKP @abouteiller @edgargabriel @gaoikawa @omor1 2 | -------------------------------------------------------------------------------- /scripts/functional_tests/GDB_README: -------------------------------------------------------------------------------- 1 | gdb scripts allow launching rocshmem tests repeatedly with gdb 2 | and dump backtrace on error 3 | - gdbscript - consists of commands which are executed on gdb launch 4 | - gdbrun - run script, launches test in loop with gdb enabled 5 | e.g ./gdbrun 14 10 launches pingPong 10 times 6 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | version: 2 5 | 6 | sphinx: 7 | configuration: docs/conf.py 8 | 9 | formats: [] 10 | 11 | python: 12 | install: 13 | - requirements: docs/sphinx/requirements.txt 14 | 15 | build: 16 | os: ubuntu-22.04 17 | tools: 18 | python: "3.10" 19 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | ## This is the list of rocSHMEM's significant contributors. 2 | 3 | #### This does not necessarily list everyone who has contributed code, especially since many employees of one corporation may be contributing. To see the full list of contributors, see the revision history in source control. 4 | 5 | - Khaled Hamidouche 6 | - Brandon Potter 7 | - Michael LeBeane 8 | - Rohit Zambre 9 | - Kishore Punniyamurthy 10 | - Ruchi Shah 11 | - Muhammad A. Awad 12 | - Edgar Gabriel 13 | - Avinash Kethineedi 14 | - Yiltan Temucin 15 | - Aurelien Bouteiller 16 | - Omri Mor 17 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Building the rocSHMEM documentation 2 | 3 | ## macOS 4 | 5 | To build html documentation locally: 6 | 7 | ``` 8 | brew install doxygen sphinx-doc 9 | pip3.10 install -r ./sphinx/requirements.txt 10 | python3.10 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html 11 | open _build/html/index.html 12 | ``` 13 | 14 | To build pdf documentation we require a LaTeX installation on your machine. 15 | Once LaTeX is installed, you may run the following: 16 | 17 | ``` 18 | pip3.10 install -r ./sphinx/requirements.txt 19 | sphinx-build -M latexpdf . _build 20 | open _build/latex/rocshmem.pdf 21 | ``` 22 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | 5 | SPDX-License-Identifier: MIT 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /docs/api/memory_management.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocSHMEM intra-kernel networking runtime for AMD dGPUs on the ROCm platform. 3 | :keywords: rocSHMEM, API, ROCm, documentation, HIP, Networking, Communication 4 | 5 | .. _rocshmem-api-memory-management: 6 | 7 | 8 | --------------------------- 9 | Memory management routines 10 | --------------------------- 11 | 12 | ROCSHMEM_MALLOC 13 | --------------- 14 | 15 | .. cpp:function:: __host__ void *rocshmem_malloc(size_t size) 16 | 17 | :param size: Memory allocation size in bytes. 18 | :returns: A pointer to the allocated memory on the symmetric heap. 19 | If a valid allocation cannot be made, it returns ``NULL``. 20 | 21 | **Description:** 22 | This routine allocates memory of ``size`` bytes from the symmetric heap. 23 | This is a collective operation and must be called by all PEs. 24 | 25 | ROCSHMEM_FREE 26 | ------------- 27 | 28 | .. cpp:function:: __host__ void rocshmem_free(void *ptr) 29 | 30 | :param ptr: A pointer to previously allocated memory on the symmetric heap. 31 | :returns: None. 32 | 33 | **Description:** 34 | This routine frees a memory allocation from the symmetric heap. 35 | It is a collective operation and must be called by all PEs. 36 | -------------------------------------------------------------------------------- /docs/sphinx/_toc.yml.in: -------------------------------------------------------------------------------- 1 | defaults: 2 | numbered: False 3 | root: index 4 | subtrees: 5 | 6 | - entries: 7 | - file: introduction.rst 8 | title: What is rocSHMEM? 9 | 10 | - caption: Install 11 | entries: 12 | - file: install.rst 13 | title: Install rocSHMEM 14 | 15 | 16 | - caption: How to 17 | entries: 18 | - file: compile_and_run.rst 19 | title: Compile and run applications 20 | 21 | - caption: API reference 22 | entries: 23 | - file: api/init.rst 24 | title: Library setup, exit, and query routines 25 | - file: api/memory_management.rst 26 | title: Memory management routines 27 | - file: api/teams.rst 28 | title: Team management routines 29 | - file: api/ctx.rst 30 | title: Context management routines 31 | - file: api/env_variables.rst 32 | title: Environment variables 33 | - file: api/rma.rst 34 | title: Remote memory access routines 35 | - file: api/amo.rst 36 | title: Atomic memory operations 37 | - file: api/sigops.rst 38 | title: Signaling operations 39 | - file: api/coll.rst 40 | title: Collective routines 41 | - file: api/pt2pt_sync.rst 42 | title: Point-to-point synchronization routines 43 | - file: api/memory_ordering.rst 44 | title: Memory ordering routines 45 | 46 | - caption: About 47 | entries: 48 | - file: license.rst 49 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | import re 8 | 9 | from rocm_docs import ROCmDocs 10 | 11 | with open('../include/rocshmem/rocshmem.hpp', encoding='utf-8') as f: 12 | match = re.search(r'constexpr char VERSION\[\] = "([0-9.]+)[^0-9.]+', f.read()) 13 | if not match: 14 | raise ValueError("VERSION not found!") 15 | version_number = match[1] 16 | left_nav_title = f"rocSHMEM {version_number} documentation" 17 | 18 | # for PDF output on Read the Docs 19 | project = "rocSHMEM" 20 | author = "Advanced Micro Devices, Inc." 21 | copyright = "Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved." 22 | version = version_number 23 | release = version_number 24 | 25 | external_toc_path = "./sphinx/_toc.yml" 26 | 27 | docs_core = ROCmDocs(left_nav_title) 28 | docs_core.run_doxygen(doxygen_root="doxygen", doxygen_path="doxygen/xml") 29 | docs_core.setup() 30 | 31 | external_projects_current_project = "rocshmem" 32 | cpp_id_attributes = ["__host__", "__global__", "__device__"] 33 | exclude_patterns = ["README.md"] 34 | 35 | for sphinx_var in ROCmDocs.SPHINX_VARS: 36 | globals()[sphinx_var] = getattr(docs_core, sphinx_var) 37 | -------------------------------------------------------------------------------- /scripts/build_configs/gda_bnxt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | script_path=$(dirname "$(realpath $0)") 29 | 30 | source $script_path/gda -DGDA_BNXT=ON $* 31 | -------------------------------------------------------------------------------- /scripts/build_configs/gda_ionic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | script_path=$(dirname "$(realpath $0)") 29 | 30 | source $script_path/gda -DGDA_IONIC=ON $* 31 | -------------------------------------------------------------------------------- /scripts/build_configs/gda_mlx5: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | script_path=$(dirname "$(realpath $0)") 29 | 30 | source $script_path/gda -DGDA_MLX5=ON $* 31 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_net_debug: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | script_path=$(dirname "$(realpath $0)") 29 | 30 | BUILD_TYPE=Debug source $script_path/ro_net $* 31 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | IF (BUILD_FUNCTIONAL_TESTS) 26 | add_subdirectory(functional_tests) 27 | ENDIF() 28 | 29 | IF (BUILD_UNIT_TESTS) 30 | add_subdirectory(unit_tests) 31 | ENDIF() 32 | -------------------------------------------------------------------------------- /src/gda/bnxt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | target_sources( 25 | ${PROJECT_NAME} 26 | PRIVATE 27 | backend_gda_bnxt.cpp 28 | ) 29 | 30 | if(GDA_BNXT) 31 | target_sources( 32 | ${PROJECT_NAME} 33 | PRIVATE 34 | queue_pair_bnxt.cpp 35 | ) 36 | endif() 37 | -------------------------------------------------------------------------------- /src/gda/ionic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | target_sources( 25 | ${PROJECT_NAME} 26 | PRIVATE 27 | backend_gda_ionic.cpp 28 | ) 29 | 30 | if(GDA_IONIC) 31 | target_sources( 32 | ${PROJECT_NAME} 33 | PRIVATE 34 | queue_pair_ionic.cpp 35 | ) 36 | endif() 37 | -------------------------------------------------------------------------------- /src/gda/mlx5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | target_sources( 25 | ${PROJECT_NAME} 26 | PRIVATE 27 | backend_gda_mlx5.cpp 28 | ) 29 | 30 | if(GDA_MLX5) 31 | target_sources( 32 | ${PROJECT_NAME} 33 | PRIVATE 34 | queue_pair_mlx5.cpp 35 | segment_builder.cpp 36 | ) 37 | endif() 38 | -------------------------------------------------------------------------------- /src/host/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | host.cpp 32 | ) 33 | -------------------------------------------------------------------------------- /src/sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | abql_block_mutex.cpp 32 | ) 33 | -------------------------------------------------------------------------------- /scripts/functional_tests/gdbscript: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | set pagination off 26 | set print frame-arguments all 27 | set logging file log.dat 28 | set logging on 29 | 30 | set $_exitcode = -1 31 | run 32 | 33 | if $_exitcode != -1 34 | quit 35 | else 36 | #backtrace 37 | # backtrace for all threads 38 | thread apply all bt full 39 | quit 40 | end 41 | -------------------------------------------------------------------------------- /scripts/functional_tests/gdbrun: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | # argument1 - operation to run 26 | # argument2 - loop count 27 | # e.g ./gdbrun 14 10 (launches pingpong for 10 times) 28 | 29 | set -e 30 | for i in {1..$2}; 31 | do 32 | mpirun -np 2 xterm -e gdb -x gdbscript --args build/rocshmem_functional_tests -t 1 -w 1 -s 32768 -a $1 -x 8 33 | test $? -eq 0 || exit 1 34 | done 35 | -------------------------------------------------------------------------------- /src/containers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | share_strategy.cpp 32 | strategies.cpp 33 | ) 34 | -------------------------------------------------------------------------------- /src/bootstrap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | socket.cpp 32 | bootstrap.cpp 33 | utils.cpp 34 | ) 35 | -------------------------------------------------------------------------------- /include/rocshmem/rocshmem_debug.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_INCLUDE_DEBUG_HPP 26 | #define LIBRARY_INCLUDE_DEBUG_HPP 27 | 28 | namespace rocshmem { 29 | 30 | void debug_print_cq(int dest_pe, int src_wg, int cqe_index); 31 | 32 | void debug_print_sq(int dest_pe, int src_wg, int index_wqe); 33 | 34 | } // namespace rocshmem 35 | 36 | #endif // LIBRARY_INCLUDE_DEBUG_HPP 37 | -------------------------------------------------------------------------------- /src/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | single_heap.cpp 32 | memory_allocator.cpp 33 | dlmalloc.cpp 34 | ) 35 | -------------------------------------------------------------------------------- /tests/unit_tests/mpi_instance_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "mpi_instance_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(MPIInstanceTestFixture, library_initialize_destroy) {} 30 | 31 | TEST_F(MPIInstanceTestFixture, rank) { 32 | ASSERT_NO_FATAL_FAILURE(s_ptr_->get_rank()); 33 | } 34 | 35 | TEST_F(MPIInstanceTestFixture, nprocs) { 36 | ASSERT_EQ(s_ptr_->get_nprocs(), 4); 37 | } 38 | -------------------------------------------------------------------------------- /src/containers/strategies.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "strategies.hpp" 26 | 27 | namespace rocshmem { 28 | 29 | DefaultObjectStrategy* DefaultObjectStrategy::_instance = nullptr; 30 | 31 | DefaultObjectStrategy* DefaultObjectStrategy::instance() { 32 | if (!_instance) { 33 | _instance = new DefaultObjectStrategy(); 34 | return _instance; 35 | } 36 | return _instance; 37 | } 38 | 39 | } // namespace rocshmem 40 | -------------------------------------------------------------------------------- /src/ipc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | context_ipc_device.cpp 32 | context_ipc_host.cpp 33 | backend_ipc.cpp 34 | ipc_team.cpp 35 | context_ipc_device_coll.cpp 36 | ) 37 | -------------------------------------------------------------------------------- /src/reverse_offload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | backend_ro.cpp 32 | context_ro_device.cpp 33 | context_ro_host.cpp 34 | mpi_transport.cpp 35 | queue.cpp 36 | ro_net_team.cpp 37 | ) 38 | -------------------------------------------------------------------------------- /src/gda/mlx5/provider_gda_mlx5.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_GDA_MLX5_GDA_PROVIDER_HPP_ 26 | #define LIBRARY_SRC_GDA_MLX5_GDA_PROVIDER_HPP_ 27 | 28 | extern "C" { 29 | #include "gda/mlx5/mlx5dv.h" 30 | } 31 | 32 | typedef union db_reg { 33 | uint64_t *ptr; 34 | uintptr_t uint; 35 | } db_reg_t; 36 | 37 | struct mlx5dv_funcs_t { 38 | int (*init_obj)(struct mlx5dv_obj *obj, uint64_t obj_type); 39 | }; 40 | 41 | #endif //LIBRARY_SRC_GDA_MLX5_GDA_PROVIDER_HPP_ 42 | -------------------------------------------------------------------------------- /tests/unit_tests/remote_heap_info_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "remote_heap_info_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(RemoteHeapInfoTestFixture, MPI_num_pes) { ASSERT_EQ(mpi_.num_pes(), 4); } 30 | 31 | TEST_F(RemoteHeapInfoTestFixture, MPI_barrier) { 32 | ASSERT_NO_FATAL_FAILURE(mpi_.barrier()); 33 | } 34 | 35 | TEST_F(RemoteHeapInfoTestFixture, MPI_bases) { 36 | for (auto base : mpi_.get_heap_bases()) { 37 | ASSERT_NE(base, nullptr); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/unit_tests/bin_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_BIN_GTEST_HPP 26 | #define ROCSHMEM_BIN_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/bin.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class BinTestFixture : public ::testing::Test 35 | { 36 | protected: 37 | /** 38 | * @brief A bin object containing pointers 39 | */ 40 | Bin bin_ {}; 41 | }; 42 | 43 | } // namespace rocshmem 44 | 45 | #endif // ROCSHMEM_BIN_GTEST_HPP 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ROCm OpenSHMEM (rocSHMEM) 2 | 3 | The ROCm OpenSHMEM (rocSHMEM) runtime is part of an AMD and AMD Research 4 | initiative to provide GPU-centric networking through an OpenSHMEM-like interface. 5 | This intra-kernel networking library simplifies application 6 | code complexity and enables more fine-grained communication/computation 7 | overlap than traditional host-driven networking. 8 | rocSHMEM uses a single symmetric heap that is allocated on GPU memories. 9 | 10 | There are currently three backends for rocSHMEM; 11 | IPC, Reverse Offload (RO), and GDA. 12 | The backends primarily differ in their implementations of intra-kernel networking. 13 | 14 | The IPC backend implements communication primitives using load/store operations issued from the GPU. 15 | 16 | The Reverse Offload (RO) backend has the GPU runtime forward rocSHMEM networking operations 17 | to the host-side runtime, which calls into a traditional MPI or OpenSHMEM 18 | implementation. This forwarding of requests is transparent to the 19 | programmer, who only sees the GPU-side interface. 20 | 21 | The GPU Direct Async (GDA) backend allows for rocSHMEM to issue communication operations to the NIC directly from the device-side code, without involving a CPU proxy. 22 | within the GPU. 23 | During initialization we prepare network resources for each NIC vendor using the vendor-appropriate 24 | Direct Verbs APIs. 25 | When calling the device-side rocSHMEM API, the device threads are used to construct Work Queue Entries (WQEs) and post the communication to the send queues of the NIC directly. 26 | Completion Queues (CQs) are polled from the device-side code as well. 27 | 28 | The RO and GDA backend is provided as-is with limited support from AMD or AMD Research. 29 | 30 | ## Installation and using rocSHMEM 31 | 32 | For information on how to install and use rocSHMEM, 33 | [please see our documentation](https://rocm.docs.amd.com/projects/rocSHMEM/en/latest/). 34 | -------------------------------------------------------------------------------- /tests/unit_tests/heap_memory_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "heap_memory_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST(HeapMemoryTest, size_constructor) { 30 | HeapMemory heap_mem{2048}; 31 | ASSERT_EQ(heap_mem.get_size(), 2048); 32 | ASSERT_NE(heap_mem.get_ptr(), nullptr); 33 | } 34 | 35 | TEST_F(HeapMemoryTestFixture, size_check) { 36 | ASSERT_EQ(heap_mem_.get_size(), 1 << 30); 37 | } 38 | 39 | TEST_F(HeapMemoryTestFixture, ptr_check) { 40 | ASSERT_NE(heap_mem_.get_ptr(), nullptr); 41 | } 42 | -------------------------------------------------------------------------------- /tests/unit_tests/single_heap_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_SINGLE_HEAP_GTEST_HPP 26 | #define ROCSHMEM_SINGLE_HEAP_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/single_heap.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class SingleHeapTestFixture : public ::testing::Test 35 | { 36 | protected: 37 | /** 38 | * @brief Single heap object 39 | */ 40 | SingleHeap single_heap_ {}; 41 | }; 42 | 43 | } // namespace rocshmem 44 | 45 | #endif // ROCSHMEM_SINGLE_HEAP_GTEST_HPP 46 | -------------------------------------------------------------------------------- /tests/unit_tests/wavefront_size_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_WAVEFRONT_SIZE_GTEST_HPP 26 | #define ROCSHMEM_WAVEFRONT_SIZE_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | #include "wf_size.hpp" 30 | 31 | namespace rocshmem { 32 | 33 | class WavefrontSizeTestFixture : public ::testing::Test { 34 | public: 35 | void SetUp() override { 36 | wf_size = get_wf_size(); 37 | } 38 | 39 | protected: 40 | int wf_size; 41 | }; 42 | 43 | } // namespace rocshmem 44 | 45 | #endif // ROCSHMEM_WAVEFRONT_SIZE_GTEST_HPP 46 | -------------------------------------------------------------------------------- /docs/api/memory_ordering.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocSHMEM intra-kernel networking runtime for AMD dGPUs on the ROCm platform. 3 | :keywords: rocSHMEM, API, ROCm, documentation, HIP, Networking, Communication 4 | 5 | .. _rocshmem-api-memory-ordering: 6 | 7 | --------------------------- 8 | Memory ordering routines 9 | --------------------------- 10 | 11 | ROCSHMEM_FENCE 12 | -------------- 13 | 14 | .. cpp:function:: __device__ void rocshmem_fence() 15 | .. cpp:function:: __device__ void rocshmem_fence(int pe) 16 | .. cpp:function:: __device__ void rocshmem_ctx_fence(rocshmem_ctx_t ctx) 17 | .. cpp:function:: __device__ void rocshmem_ctx_fence(rocshmem_ctx_t ctx, int pe) 18 | 19 | :param ctx: Context with which to perform this operation. 20 | :param pe: Destination ``pe``. 21 | :returns: None. 22 | 23 | **Description:** 24 | This routine ensures order between messages in this context to follow OpenSHMEM semantics. 25 | 26 | ROCSHMEM_QUIET 27 | -------------- 28 | 29 | .. cpp:function:: __device__ void rocshmem_ctx_quiet(rocshmem_ctx_t ctx) 30 | .. cpp:function:: __device__ void rocshmem_quiet() 31 | 32 | :param ctx: Context with which to perform this operation. 33 | :returns: None. 34 | 35 | **Description:** 36 | This routine completes all previous operations posted to this context. 37 | 38 | ROCSHMEM_PE_QUIET 39 | ----------------- 40 | 41 | .. cpp:function:: __device__ void rocshmem_ctx_pe_quiet(shmem_ctx_t ctx, const int *target_pes, size_t npes) 42 | .. cpp:function:: __device__ void rocshmem_pe_quiet(const int *target_pes, size_t npes) 43 | 44 | :param ctx: Context with which to perform this operation. 45 | :param target_pes: Address of target PE array where the operations need to be completed 46 | :param npes: The number of PEs in the target PE array 47 | :returns: None. 48 | 49 | **Description:** 50 | This routine completes all previous operations posted to this context 51 | for the PEs in the `target_pes` array. 52 | -------------------------------------------------------------------------------- /tests/unit_tests/hipmalloc_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_HIPMALLOC_GTEST_HPP 26 | #define ROCSHMEM_HIPMALLOC_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/symmetric_heap.hpp" 31 | #include "../src/util.hpp" 32 | 33 | namespace rocshmem { 34 | 35 | class HipMallocTestFixture : public ::testing::Test { 36 | public: 37 | HIPAllocator hip_allocator_ {}; 38 | HIPAllocatorFinegrained hip_allocator_fg_ {}; 39 | }; 40 | 41 | } // namespace rocshmem 42 | 43 | #endif // ROCSHMEM_HIPMALLOC_GTEST_HPP 44 | -------------------------------------------------------------------------------- /src/team_tracker.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "team_tracker.hpp" 26 | 27 | #include 28 | #include 29 | 30 | namespace rocshmem { 31 | 32 | TeamTracker::TeamTracker() { } 33 | 34 | void TeamTracker::track(rocshmem_team_t team) { 35 | if (team == ROCSHMEM_TEAM_INVALID) { 36 | return; 37 | } 38 | teams_.push_back(team); 39 | } 40 | 41 | void TeamTracker::untrack(rocshmem_team_t team) { 42 | auto it{std::find(teams_.begin(), teams_.end(), team)}; 43 | assert(it != teams_.end()); 44 | teams_.erase(it); 45 | } 46 | 47 | } // namespace rocshmem 48 | -------------------------------------------------------------------------------- /tests/functional_tests/verify_results_kernels.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _VERIFY_RESULTS_KERNELS_HPP_ 26 | #define _VERIFY_RESULTS_KERNELS_HPP_ 27 | 28 | namespace rocshmem { 29 | 30 | static __global__ void verify_results_kernel_char(char *source, char *dest, size_t buf_size, 31 | bool *verification_error) { 32 | 33 | int idx = get_flat_id(); 34 | 35 | if (idx >= buf_size) { 36 | return; 37 | } 38 | 39 | if (dest[idx] != source[idx]) { 40 | *verification_error = true; 41 | } 42 | } 43 | 44 | } 45 | 46 | #endif /* _VERIFY_RESULTS_KERNELS_HPP_ */ 47 | -------------------------------------------------------------------------------- /src/reverse_offload/ro_net_team.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_REVERSE_OFFLOAD_RO_NET_TEAM_HPP_ 26 | #define LIBRARY_SRC_REVERSE_OFFLOAD_RO_NET_TEAM_HPP_ 27 | 28 | #include "team.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | class Backend; 33 | 34 | class ROTeam : public Team { 35 | public: 36 | ROTeam(Backend* handle, TeamInfo* team_info_wrt_parent, 37 | TeamInfo* team_info_wrt_world, int num_pes, int my_pe, 38 | MPI_Comm team_comm); 39 | 40 | virtual ~ROTeam(); 41 | 42 | void* ata_buffer; 43 | }; 44 | 45 | } // namespace rocshmem 46 | 47 | #endif // LIBRARY_SRC_REVERSE_OFFLOAD_RO_NET_TEAM_HPP_ 48 | -------------------------------------------------------------------------------- /tests/unit_tests/heap_memory_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_HEAP_MEMORY_GTEST_HPP 26 | #define ROCSHMEM_HEAP_MEMORY_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include 31 | 32 | #include "../src/memory/hip_allocator.hpp" 33 | #include "../src/memory/heap_memory.hpp" 34 | 35 | namespace rocshmem { 36 | 37 | class HeapMemoryTestFixture : public ::testing::Test 38 | { 39 | protected: 40 | /** 41 | * @brief a heap memory object 42 | */ 43 | HeapMemory heap_mem_ {}; 44 | }; 45 | 46 | } // namespace rocshmem 47 | 48 | #endif // ROCSHMEM_HEAP_MEMORY_GTEST_HPP 49 | -------------------------------------------------------------------------------- /src/gda/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | ############################################################################### 26 | # ADD ROCSHMEM TARGET FOR FILES IN CURRENT DIRECTORY 27 | ############################################################################### 28 | target_sources( 29 | ${PROJECT_NAME} 30 | PRIVATE 31 | context_gda_device.cpp 32 | context_gda_device_coll.cpp 33 | context_gda_host.cpp 34 | backend_gda.cpp 35 | ibv_wrapper.cpp 36 | gda_team.cpp 37 | queue_pair.cpp 38 | numa_wrapper.cpp 39 | endian.cpp 40 | topology.cpp 41 | ) 42 | 43 | add_subdirectory(mlx5) 44 | add_subdirectory(bnxt) 45 | add_subdirectory(ionic) 46 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocSHMEM is a runtime that provides GPU-centric networking through an OpenSHMEM-like interface. 3 | :keywords: rocSHMEM, ROCm, OpenSHMEM, library, API, IPC, RO 4 | 5 | **************************** 6 | rocSHMEM documentation 7 | **************************** 8 | 9 | The ROCm OpenSHMEM (rocSHMEM) is an intra-kernel networking library that provides GPU-centric networking through an OpenSHMEM-like interface. It simplifies application code complexity and enables finer communication and computation overlap than traditional host-driven networking. rocSHMEM uses a single symmetric heap allocated to GPU memories. For more information, see :doc:`introduction`. 10 | 11 | The rocSHMEM public repository is located at ``_. 12 | 13 | .. grid:: 2 14 | :gutter: 3 15 | 16 | .. grid-item-card:: Install 17 | 18 | * :doc:`Install rocSHMEM <./install>` 19 | 20 | .. grid-item-card:: How to 21 | 22 | * :doc:`Compile and run applications <./compile_and_run>` 23 | 24 | .. grid-item-card:: API reference 25 | 26 | * :doc:`Library setup, exit, and query routines <./api/init>` 27 | * :doc:`Memory management routines <./api/memory_management>` 28 | * :doc:`Team management routines <./api/teams>` 29 | * :doc:`Context management routines <./api/ctx>` 30 | * :doc:`Environment variables <./api/env_variables>` 31 | * :doc:`Remote memory access routines <./api/rma>` 32 | * :doc:`Atomic memory operations <./api/amo>` 33 | * :doc:`Signaling operations <./api/sigops>` 34 | * :doc:`Collective routines <./api/coll>` 35 | * :doc:`Point-to-point synchronization routines <./api/pt2pt_sync>` 36 | * :doc:`Memory ordering routines <./api/memory_ordering>` 37 | 38 | To contribute to the documentation, refer to 39 | `Contributing to ROCm `_. 40 | 41 | You can find licensing information on the 42 | `Licensing `_ page. 43 | -------------------------------------------------------------------------------- /src/context_incl.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_CONTEXT_INCL_HPP_ 26 | #define LIBRARY_SRC_CONTEXT_INCL_HPP_ 27 | 28 | #include "context.hpp" 29 | #include "context_tmpl_device.hpp" 30 | #include "context_tmpl_host.hpp" 31 | #if defined(USE_GDA) 32 | #include "gda/context_gda_device.hpp" 33 | #include "gda/context_gda_host.hpp" 34 | #endif 35 | #if defined(USE_RO) 36 | #include "reverse_offload/context_ro_device.hpp" 37 | #include "reverse_offload/context_ro_host.hpp" 38 | #endif 39 | #if defined(USE_IPC) 40 | #include "ipc/context_ipc_device.hpp" 41 | #include "ipc/context_ipc_host.hpp" 42 | #endif 43 | 44 | #endif // LIBRARY_SRC_CONTEXT_INCL_HPP_ 45 | -------------------------------------------------------------------------------- /tests/unit_tests/hipmalloc_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "hipmalloc_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(HipMallocTestFixture, normal_1GBx256) { 30 | void* ptr{nullptr}; 31 | size_t gb {1073741824}; 32 | for (int i{0}; i < 256; i++) { 33 | hip_allocator_.allocate(&ptr, gb); 34 | hip_allocator_.deallocate(ptr); 35 | } 36 | } 37 | 38 | TEST_F(HipMallocTestFixture, fine_1GBx256) { 39 | void* ptr{nullptr}; 40 | size_t gb {1073741824}; 41 | for (int i{0}; i < 256; i++) { 42 | hip_allocator_fg_.allocate(&ptr, gb); 43 | hip_allocator_fg_.deallocate(ptr); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/unit_tests/shmem_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "gtest/gtest.h" 26 | #include 27 | 28 | int main(int argc, char **argv) { 29 | ::testing::InitGoogleTest(&argc, argv); 30 | 31 | int initialized; 32 | MPI_Initialized(&initialized); 33 | if (!initialized) { 34 | int provided; 35 | MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); 36 | if (provided != MPI_THREAD_MULTIPLE) { 37 | std::cerr << "MPI_THREAD_MULTIPLE support disabled.\n"; 38 | } 39 | } 40 | 41 | int ret_val = RUN_ALL_TESTS(); 42 | 43 | int finalized{0}; 44 | MPI_Finalized(&finalized); 45 | if (!finalized) { 46 | MPI_Finalize(); 47 | } 48 | return ret_val; 49 | } 50 | -------------------------------------------------------------------------------- /src/atomic_return.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_ATOMIC_RETURN_HPP_ 26 | #define LIBRARY_SRC_ATOMIC_RETURN_HPP_ 27 | 28 | #include 29 | 30 | #include "memory/symmetric_heap.hpp" 31 | #include "util.hpp" 32 | 33 | namespace rocshmem { 34 | 35 | const int max_nb_atomic = 4096; 36 | 37 | struct atomic_ret_t { 38 | uint64_t* atomic_base_ptr; 39 | uint32_t atomic_lkey; 40 | uint64_t atomic_counter; 41 | }; 42 | 43 | void allocate_atomic_region(atomic_ret_t** atomic_ret, int num_wg); 44 | 45 | void init_g_ret(SymmetricHeap* heap_handle, MPI_Comm thread_comm, int num_wg, 46 | char** g_ret); 47 | 48 | } // namespace rocshmem 49 | 50 | #endif // LIBRARY_SRC_ATOMIC_RETURN_HPP_ 51 | -------------------------------------------------------------------------------- /scripts/build_configs/gda: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_UNIT_TESTS=ON \ 38 | -DDEBUG=OFF \ 39 | -DPROFILE=OFF \ 40 | -DUSE_GDA=ON \ 41 | -DUSE_RO=OFF \ 42 | -DUSE_IPC=OFF \ 43 | -DUSE_THREADS=OFF \ 44 | -DUSE_WF_COAL=OFF \ 45 | -DUSE_HDP_FLUSH=OFF \ 46 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 47 | $* $src_path 48 | cmake --build . --parallel 8 49 | cmake --install . 50 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_ipc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_UNIT_TESTS=ON \ 38 | -DDEBUG=OFF \ 39 | -DPROFILE=OFF \ 40 | -DUSE_GDA=OFF \ 41 | -DUSE_RO=ON \ 42 | -DUSE_IPC=ON \ 43 | -DUSE_THREADS=OFF \ 44 | -DUSE_WF_COAL=OFF \ 45 | -DUSE_HDP_FLUSH=OFF \ 46 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 47 | $* $src_path 48 | cmake --build . --parallel 8 49 | cmake --install . 50 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_net: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_UNIT_TESTS=ON \ 38 | -DDEBUG=OFF \ 39 | -DPROFILE=OFF \ 40 | -DUSE_GDA=OFF \ 41 | -DUSE_RO=ON \ 42 | -DUSE_IPC=OFF \ 43 | -DUSE_THREADS=OFF \ 44 | -DUSE_WF_COAL=OFF \ 45 | -DUSE_HDP_FLUSH=OFF \ 46 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 47 | $* $src_path 48 | cmake --build . --parallel 8 49 | cmake --install . 50 | -------------------------------------------------------------------------------- /tests/unit_tests/mpi_instance_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_MPI_INSTANCE_GTEST_HPP 26 | #define ROCSHMEM_MPI_INSTANCE_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/mpi_instance.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class MPIInstanceTestFixture : public ::testing::Test 35 | { 36 | public: 37 | MPIInstanceTestFixture() { 38 | s_ptr_ = new MPIInstance(MPI_COMM_WORLD); 39 | } 40 | 41 | ~MPIInstanceTestFixture() { 42 | delete s_ptr_; 43 | } 44 | 45 | protected: 46 | /** 47 | * @brief A MPI instance object used to initialize MPI 48 | */ 49 | MPIInstance* s_ptr_ {nullptr}; 50 | }; 51 | 52 | } // namespace rocshmem 53 | 54 | #endif // ROCSHMEM_MPI_INSTANCE_GTEST_HPP 55 | -------------------------------------------------------------------------------- /src/ipc/ipc_team.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_IPC_TEAM_HPP_ 26 | #define LIBRARY_SRC_IPC_TEAM_HPP_ 27 | 28 | #include "team.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | class IPCTeam : public Team { 33 | public: 34 | IPCTeam(Backend* handle, TeamInfo* team_info_wrt_parent, 35 | TeamInfo* team_info_wrt_world, int num_pes, int my_pe, 36 | MPI_Comm team_comm, int pool_index); 37 | 38 | virtual ~IPCTeam(); 39 | 40 | long* barrier_pSync{nullptr}; 41 | long* reduce_pSync{nullptr}; 42 | long* bcast_pSync{nullptr}; 43 | long* alltoall_pSync{nullptr}; 44 | void* pWrk{nullptr}; 45 | void* pAta{nullptr}; 46 | 47 | int pool_index_{-1}; 48 | }; 49 | 50 | } // namespace rocshmem 51 | 52 | #endif // LIBRARY_SRC_IPC_TEAM_HPP_ 53 | -------------------------------------------------------------------------------- /tests/unit_tests/wf_size.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_WF_SIZE_HPP 26 | #define ROCSHMEM_WF_SIZE_HPP 27 | 28 | #include 29 | #include "mpi.h" 30 | 31 | #define CHECK_HIP_MPI(cond) { \ 32 | if(cond != hipSuccess){ \ 33 | fprintf(stderr,"HIP error: %d line: %d\n", cond, __LINE__); \ 34 | MPI_Abort(MPI_COMM_WORLD, 1); \ 35 | } \ 36 | } 37 | 38 | static int get_wf_size() { 39 | int deviceId; 40 | hipDeviceProp_t prop; 41 | CHECK_HIP_MPI(hipGetDevice(&deviceId)); 42 | CHECK_HIP_MPI(hipGetDeviceProperties(&prop, deviceId)); 43 | return prop.warpSize; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tests/unit_tests/address_record_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_ADDRESS_RECORD_GTEST_HPP 26 | #define ROCSHMEM_ADDRESS_RECORD_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/address_record.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class AddressRecordTestFixture : public ::testing::Test 35 | { 36 | protected: 37 | AddressRecord split_ {reinterpret_cast(0x200), 0x80}; 38 | AddressRecord combine_1_ {reinterpret_cast(0x120), 0x20}; 39 | AddressRecord combine_2_ {reinterpret_cast(0x140), 0x20}; 40 | AddressRecord bad_addr_ {nullptr, 0x20}; 41 | AddressRecord bad_size_ {reinterpret_cast(0x800), 0x0}; 42 | }; 43 | 44 | } // namespace rocshmem 45 | 46 | #endif // ROCSHMEM_ADDRESS_RECORD_GTEST_HPP 47 | -------------------------------------------------------------------------------- /scripts/build_configs/ipc_single: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_UNIT_TESTS=ON \ 38 | -DDEBUG=OFF \ 39 | -DPROFILE=OFF \ 40 | -DUSE_GDA=OFF \ 41 | -DUSE_RO=OFF \ 42 | -DUSE_IPC=ON \ 43 | -DUSE_THREADS=OFF \ 44 | -DUSE_WF_COAL=OFF \ 45 | -DUSE_HDP_FLUSH=OFF \ 46 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 47 | -DUSE_SINGLE_NODE=ON \ 48 | $* $src_path 49 | cmake --build . --parallel 8 50 | cmake --install . 51 | -------------------------------------------------------------------------------- /cmake/rocshmem_config.h.in: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #cmakedefine DEBUG 26 | #cmakedefine PROFILE 27 | #cmakedefine USE_RO 28 | #cmakedefine USE_IPC 29 | #cmakedefine USE_GDA 30 | #cmakedefine USE_THREADS 31 | #cmakedefine USE_SHARED_CTX 32 | #cmakedefine USE_WF_COAL 33 | #cmakedefine USE_HEAP_DEVICE_FINEGRAIN 34 | #cmakedefine USE_HEAP_DEVICE_UNCACHED 35 | #cmakedefine USE_HEAP_DEVICE_COARSEGRAIN 36 | #cmakedefine USE_HEAP_MANAGED 37 | #cmakedefine USE_HEAP_HOST_HIP 38 | #cmakedefine USE_HEAP_HOST 39 | #cmakedefine USE_ALLOC_DLMALLOC 40 | #cmakedefine USE_ALLOC_POW2BINS 41 | #cmakedefine USE_FUNC_CALL 42 | #cmakedefine USE_SINGLE_NODE 43 | #cmakedefine USE_HDP_FLUSH 44 | #cmakedefine USE_HDP_FLUSH_HOST_SIDE 45 | #cmakedefine GDA_IONIC 46 | #cmakedefine GDA_BNXT 47 | #cmakedefine GDA_MLX5 48 | #cmakedefine HAVE_EXTERNAL_MPI 49 | -------------------------------------------------------------------------------- /src/gda/gda_team.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_GDA_TEAM_HPP_ 26 | #define LIBRARY_SRC_GDA_TEAM_HPP_ 27 | 28 | #include "team.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | class GDATeam : public Team { 33 | public: 34 | GDATeam(Backend* handle, TeamInfo* team_info_wrt_parent, 35 | TeamInfo* team_info_wrt_world, int num_pes, int my_pe, 36 | MPI_Comm team_comm, int pool_index); 37 | 38 | virtual ~GDATeam(); 39 | 40 | long* barrier_pSync{nullptr}; 41 | long* reduce_pSync{nullptr}; 42 | long* bcast_pSync{nullptr}; 43 | long* alltoall_pSync{nullptr}; 44 | void* pWrk{nullptr}; 45 | void* pAta{nullptr}; 46 | 47 | int pool_index_{-1}; 48 | uint64_t alltoall_sequence_number = 0; 49 | }; 50 | 51 | } // namespace rocshmem 52 | 53 | #endif // LIBRARY_SRC_GDA_TEAM_HPP_ 54 | -------------------------------------------------------------------------------- /tests/unit_tests/symmetric_heap_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP 26 | #define ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP 27 | 28 | #include 29 | 30 | #include "gtest/gtest.h" 31 | 32 | #include "../src/memory/symmetric_heap.hpp" 33 | 34 | namespace rocshmem { 35 | 36 | class SymmetricHeapTestFixture : public ::testing::Test 37 | { 38 | protected: 39 | /** 40 | * @brief Symmetric heap object 41 | */ 42 | SymmetricHeap *symmetric_heap_; 43 | 44 | void SetUp() override { 45 | MPIInstance::mpilib_dl_init(); 46 | symmetric_heap_ = new SymmetricHeap(MPI_COMM_WORLD); 47 | } 48 | 49 | void TearDown() override { 50 | MPIInstance::mpilib_dl_close(); 51 | } 52 | }; 53 | 54 | } // namespace rocshmem 55 | 56 | #endif // ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP 57 | -------------------------------------------------------------------------------- /tests/unit_tests/bin_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "bin_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(BinTestFixture, is_empty_check) { ASSERT_TRUE(bin_.empty()); } 30 | 31 | TEST_F(BinTestFixture, is_not_empty_check) { 32 | bin_.put(nullptr); 33 | 34 | ASSERT_FALSE(bin_.empty()); 35 | } 36 | 37 | TEST_F(BinTestFixture, size_check) { 38 | ASSERT_EQ(bin_.size(), 0); 39 | bin_.put(nullptr); 40 | ASSERT_EQ(bin_.size(), 1); 41 | bin_.put(nullptr); 42 | ASSERT_EQ(bin_.size(), 2); 43 | } 44 | 45 | TEST_F(BinTestFixture, retrieval_check) { 46 | char* p_xa{reinterpret_cast(0xa)}; 47 | char* p_xb{reinterpret_cast(0xb)}; 48 | bin_.put(p_xa); 49 | bin_.put(p_xb); 50 | auto g_xb = bin_.get(); 51 | auto g_xa = bin_.get(); 52 | ASSERT_EQ(p_xa, g_xa); 53 | ASSERT_EQ(p_xb, g_xb); 54 | } 55 | -------------------------------------------------------------------------------- /scripts/build_configs/all_backends: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_UNIT_TESTS=ON \ 38 | -DDEBUG=OFF \ 39 | -DPROFILE=OFF \ 40 | -DUSE_GDA=ON \ 41 | -DGDA_MLX5=ON \ 42 | -DGDA_BNXT=ON \ 43 | -DGDA_IONIC=ON \ 44 | -DUSE_RO=ON \ 45 | -DUSE_IPC=ON \ 46 | -DUSE_THREADS=OFF \ 47 | -DUSE_WF_COAL=OFF \ 48 | -DUSE_HDP_FLUSH=OFF \ 49 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 50 | $* $src_path 51 | cmake --build . --parallel 8 52 | cmake --install . 53 | -------------------------------------------------------------------------------- /scripts/build_configs/ipc_tests_only: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 4 | # 5 | # SPDX-License-Identifier: MIT 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to 9 | # deal in the Software without restriction, including without limitation the 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | # sell copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in 15 | # all copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | # IN THE SOFTWARE. 24 | ############################################################################### 25 | 26 | set -e 27 | 28 | src_path=$(dirname "$(realpath $0)")/../../ 29 | 30 | cmake \ 31 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 32 | -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release} \ 33 | -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX:-~/rocshmem} \ 34 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 35 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 36 | -DBUILD_FUNCTIONAL_TESTS=ON \ 37 | -DBUILD_EXAMPLES=ON \ 38 | -DBUILD_UNIT_TESTS=OFF \ 39 | -DDEBUG=OFF \ 40 | -DPROFILE=OFF \ 41 | -DUSE_GDA=OFF \ 42 | -DUSE_RO=OFF \ 43 | -DUSE_IPC=ON \ 44 | -DUSE_THREADS=OFF \ 45 | -DUSE_WF_COAL=OFF \ 46 | -DUSE_SINGLE_NODE=ON \ 47 | -DUSE_HDP_FLUSH=OFF \ 48 | -DUSE_HDP_FLUSH_HOST_SIDE=OFF \ 49 | -DBUILD_TESTS_ONLY=ON \ 50 | $* $src_path 51 | cmake --build . --parallel 8 52 | -------------------------------------------------------------------------------- /src/reverse_offload/ro_net_team.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "ro_net_team.hpp" 26 | 27 | #include "backend_type.hpp" 28 | #include "backend_ro.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | ROTeam::ROTeam(Backend* backend, TeamInfo* team_info_wrt_parent, 33 | TeamInfo* team_info_wrt_world, int num_pes, int my_pe, 34 | MPI_Comm mpi_comm) 35 | : Team(backend, team_info_wrt_parent, team_info_wrt_world, num_pes, my_pe, 36 | mpi_comm) { 37 | type = BackendType::RO_BACKEND; 38 | 39 | // Disable allocating ata_buffer for now. It is not 40 | // used at the moment, but might come back in future versions. 41 | ata_buffer = nullptr; 42 | } 43 | 44 | ROTeam::~ROTeam() { 45 | if (ata_buffer != nullptr) { 46 | free(ata_buffer); 47 | ata_buffer = nullptr; 48 | } 49 | } 50 | 51 | } // namespace rocshmem 52 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | # SOURCES 25 | ############################################################################### 26 | 27 | execute_process ( 28 | COMMAND bash -c "git -C ${PROJECT_SOURCE_DIR} rev-parse HEAD;" 29 | OUTPUT_VARIABLE GIT_HASH 30 | ) 31 | 32 | string(STRIP "${GIT_HASH}" GIT_HASH) 33 | string(REPLACE ";" " " ROCSHMEM_OFFLOAD_TARGETS "${COMPILING_TARGETS}") 34 | 35 | add_executable(rocshmem_info rocshmem_info.cpp) 36 | 37 | target_compile_definitions( 38 | rocshmem_info 39 | PRIVATE 40 | ROCSHMEM_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" 41 | ROCSHMEM_GIT_HASH="${GIT_HASH}" 42 | ROCSHMEM_OFFLOAD_TARGETS="${ROCSHMEM_OFFLOAD_TARGETS}" 43 | ) 44 | 45 | target_include_directories( 46 | rocshmem_info 47 | PRIVATE 48 | roc::rocshmem 49 | ) 50 | 51 | target_link_libraries( 52 | rocshmem_info 53 | PRIVATE 54 | roc::rocshmem 55 | ) 56 | -------------------------------------------------------------------------------- /tests/functional_tests/primitive_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _PRIMITIVE_TESTER_HPP_ 26 | #define _PRIMITIVE_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class PrimitiveTester : public Tester { 34 | public: 35 | explicit PrimitiveTester(TesterArguments args); 36 | virtual ~PrimitiveTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/functional_tests/shmem_ptr_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _SHMEM_PTR_TESTER_HPP_ 26 | #define _SHMEM_PTR_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class ShmemPtrTester : public Tester { 34 | public: 35 | explicit ShmemPtrTester(TesterArguments args); 36 | virtual ~ShmemPtrTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *dest = nullptr; 47 | int *_available = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/containers/helper_macros.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_CONTAINERS_HELPER_MACROS_HPP_ 26 | #define LIBRARY_SRC_CONTAINERS_HELPER_MACROS_HPP_ 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "rocshmem/rocshmem.hpp" 36 | 37 | #define BARRIER() rocshmem::rocshmem_wg_barrier_all() 38 | #define RANK rocshmem::rocshmem_my_pe() 39 | #define NPES rocshmem::rocshmem_n_pes() 40 | 41 | #define PE_BITS ((uint64_t)ceil(log(NPES) / log(2))) 42 | #define PE_OF(X) ((X) >> (64 - PE_BITS)) 43 | 44 | #define _printf \ 45 | if (RANK == 0) printf 46 | #define _cout \ 47 | if (RANK == 0) std::cout 48 | #define _cerr \ 49 | if (RANK == 0) std::cerr 50 | 51 | #define GIBI 1073741824L 52 | #define MEBI 1048576 53 | 54 | #endif // LIBRARY_SRC_CONTAINERS_HELPER_MACROS_HPP_ 55 | -------------------------------------------------------------------------------- /tests/functional_tests/primitive_mr_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _PRIMITIVE_MR_TESTER_HPP_ 26 | #define _PRIMITIVE_MR_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class PrimitiveMRTester : public Tester { 34 | public: 35 | explicit PrimitiveMRTester(TesterArguments args); 36 | virtual ~PrimitiveMRTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *s_buf = nullptr; 47 | char *r_buf = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/gda/ionic/provider_gda_ionic.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_GDA_IONIC_GDA_PROVIDER_HPP_ 26 | #define LIBRARY_SRC_GDA_IONIC_GDA_PROVIDER_HPP_ 27 | 28 | extern "C" { 29 | #include "gda/ionic/ionic_dv.h" 30 | #include "gda/ionic/ionic_fw.h" 31 | } 32 | 33 | struct ionicdv_funcs_t { 34 | int (*get_ctx)(struct ionic_dv_ctx *dvctx, struct ibv_context *ibctx); 35 | uint8_t (*qp_get_udma_idx)(struct ibv_qp *ibqp); 36 | int (*get_cq)(struct ionic_dv_cq *dvcq, struct ibv_cq *ibcq, uint8_t udma_idx); 37 | int (*get_qp)(struct ionic_dv_qp *dvqp, struct ibv_qp *ibqp); 38 | int (*pd_set_sqcmb)(struct ibv_pd *ibpd, bool enable, bool expdb, bool require); 39 | int (*pd_set_rqcmb)(struct ibv_pd *ibpd, bool enable, bool expdb, bool require); 40 | int (*pd_set_udma_mask)(struct ibv_pd *ibpd, uint8_t udma_mask); 41 | }; 42 | 43 | #endif //LIBRARY_SRC_GDA_IONIC_GDA_PROVIDER_HPP_ 44 | -------------------------------------------------------------------------------- /tests/functional_tests/empty_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_CLIENTS_FUNCTIONAL_TESTS_EMPTY_TESTER_HPP 26 | #define ROCSHMEM_CLIENTS_FUNCTIONAL_TESTS_EMPTY_TESTER_HPP 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class EmptyTester : public Tester { 34 | public: 35 | explicit EmptyTester(TesterArguments args); 36 | virtual ~EmptyTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | }; 46 | 47 | #endif // ROCSHMEM_CLIENTS_FUNCTIONAL_TESTS_EMPTY_TESTER_HPP 48 | -------------------------------------------------------------------------------- /tests/functional_tests/workgroup_primitives.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _EXTENDED_PRIMITIVES_HPP_ 26 | #define _EXTENDED_PRIMITIVES_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class WorkGroupPrimitiveTester : public Tester { 34 | public: 35 | explicit WorkGroupPrimitiveTester(TesterArguments args); 36 | virtual ~WorkGroupPrimitiveTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/functional_tests/wavefront_primitives.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _WAVE_LEVEL_PRIMITIVE_TEST_HPP_ 26 | #define _WAVE_LEVEL_PRIMITIVE_TEST_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class WaveFrontPrimitiveTester : public Tester { 34 | public: 35 | explicit WaveFrontPrimitiveTester(TesterArguments args); 36 | virtual ~WaveFrontPrimitiveTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/functional_tests/default_ctx_primitive_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _DEFAULT_CTX_PRIMITIVE_TESTER_HPP_ 26 | #define _DEFAULT_CTX_PRIMITIVE_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class DefaultCTXPrimitiveTester : public Tester { 34 | public: 35 | explicit DefaultCTXPrimitiveTester(TesterArguments args); 36 | virtual ~DefaultCTXPrimitiveTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | size_t size) override; 43 | 44 | virtual void verifyResults(size_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/unit_tests/dlmalloc_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_DLMALLOC_GTEST_HPP 26 | #define ROCSHMEM_DLMALLOC_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/heap_memory.hpp" 31 | #include "../src/memory/hip_allocator.hpp" 32 | #include "../src/memory/dlmalloc.hpp" 33 | 34 | namespace rocshmem { 35 | 36 | class DLMallocTestFixture : public ::testing::Test 37 | { 38 | /** 39 | * @brief Helper type for heap memory 40 | */ 41 | using HEAP_T = HeapMemory; 42 | 43 | /** 44 | * @brief Helper type for allocation strategy 45 | */ 46 | using STRAT_T = DLAllocatorStrategy; 47 | 48 | protected: 49 | /** 50 | * @brief Heap memory object 51 | */ 52 | HEAP_T heap_mem_ {}; 53 | 54 | /** 55 | * @brief Allocation strategy object 56 | */ 57 | STRAT_T strat_ {&heap_mem_}; 58 | }; 59 | 60 | } // namespace rocshmem 61 | 62 | #endif // ROCSHMEM_DLMALLOC_GTEST_HPP 63 | -------------------------------------------------------------------------------- /tests/unit_tests/wavefront_size_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "wavefront_size_gtest.hpp" 26 | 27 | #include "../src/util.hpp" 28 | 29 | using namespace rocshmem; 30 | 31 | __global__ void check_wf_size(int wf_size_prop, int *ret) { 32 | if (wf_size_prop == WF_SIZE) { 33 | *ret = 0; 34 | } else { 35 | *ret = 1; 36 | } 37 | } 38 | 39 | 40 | TEST_F(WavefrontSizeTestFixture, constant_matches_runtime) { 41 | int device_count = 0; 42 | hipDeviceProp_t prop; 43 | int *ret; 44 | 45 | CHECK_HIP(hipGetDeviceCount(&device_count)); 46 | ASSERT_GT(device_count, 0); 47 | CHECK_HIP(hipHostMalloc(&ret, sizeof(int), 0)); 48 | 49 | for (int i = 0; i < device_count; i++) { 50 | *ret = -1; 51 | CHECK_HIP(hipSetDevice(i)); 52 | CHECK_HIP(hipGetDeviceProperties(&prop, i)); 53 | 54 | check_wf_size<<<1, 1>>>(prop.warpSize, ret); 55 | CHECK_HIP(hipDeviceSynchronize()); 56 | 57 | ASSERT_EQ(*ret, 0); 58 | } 59 | CHECK_HIP(hipHostFree(ret)); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/reverse_offload/commands_types.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_REVERSE_OFFLOAD_COMMANDS_TYPES_HPP_ 26 | #define LIBRARY_SRC_REVERSE_OFFLOAD_COMMANDS_TYPES_HPP_ 27 | 28 | 29 | namespace rocshmem { 30 | 31 | enum ro_net_cmds { 32 | RO_NET_PUT, 33 | RO_NET_P, 34 | RO_NET_GET, 35 | RO_NET_PUT_NBI, 36 | RO_NET_GET_NBI, 37 | RO_NET_AMO_FOP, 38 | RO_NET_AMO_FCAS, 39 | RO_NET_FENCE, 40 | RO_NET_QUIET, 41 | RO_NET_FINALIZE, 42 | RO_NET_TEAM_REDUCE, 43 | RO_NET_SYNC, 44 | RO_NET_BARRIER, 45 | RO_NET_TEAM_BROADCAST, 46 | RO_NET_ALLTOALL, 47 | RO_NET_FCOLLECT, 48 | }; 49 | 50 | enum ro_net_types { 51 | RO_NET_FLOAT, 52 | RO_NET_CHAR, 53 | RO_NET_SIGNED_CHAR, 54 | RO_NET_UNSIGNED_CHAR, 55 | RO_NET_DOUBLE, 56 | RO_NET_INT, 57 | RO_NET_LONG, 58 | RO_NET_UNSIGNED_LONG, 59 | RO_NET_LONG_LONG, 60 | RO_NET_SHORT, 61 | RO_NET_LONG_DOUBLE 62 | }; 63 | 64 | } // namespace rocshmem 65 | 66 | #endif // LIBRARY_SRC_REVERSE_OFFLOAD_COMMANDS_TYPES_HPP_ 67 | -------------------------------------------------------------------------------- /tests/functional_tests/team_ctx_primitive_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _TEAM_CTX_PRIMITIVE_TESTER_HPP_ 26 | #define _TEAM_CTX_PRIMITIVE_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class TeamCtxPrimitiveTester : public Tester { 34 | public: 35 | explicit TeamCtxPrimitiveTester(TesterArguments args); 36 | virtual ~TeamCtxPrimitiveTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void preLaunchKernel() override; 42 | 43 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 44 | size_t size) override; 45 | 46 | virtual void postLaunchKernel() override; 47 | 48 | virtual void verifyResults(size_t size) override; 49 | 50 | char *source = nullptr; 51 | char *dest = nullptr; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /tests/functional_tests/sync_all_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _SYNC_ALL_TESTER_HPP_ 26 | #define _SYNC_ALL_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * DEVICE TEST KERNEL 32 | *****************************************************************************/ 33 | __global__ void SyncAllTest(TestType type); 34 | 35 | /****************************************************************************** 36 | * HOST TESTER CLASS 37 | *****************************************************************************/ 38 | class SyncAllTester : public Tester { 39 | public: 40 | explicit SyncAllTester(TesterArguments args); 41 | virtual ~SyncAllTester(); 42 | 43 | protected: 44 | virtual void resetBuffers(size_t size) override; 45 | 46 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 47 | size_t size) override; 48 | 49 | virtual void verifyResults(size_t size) override; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /examples/util.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef __ROCSHMEM_EXAMPLES_UTIL_H__ 26 | #define __ROCSHMEM_EXAMPLES_UTIL_H__ 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #define CHECK_HIP(condition) { \ 34 | hipError_t error = condition; \ 35 | if(error != hipSuccess){ \ 36 | fprintf(stderr,"HIP error: %d line: %d\n", error, __LINE__); \ 37 | exit(error); \ 38 | } \ 39 | } 40 | 41 | static int get_launcher_local_rank() { 42 | char *local_rank_str = nullptr; 43 | 44 | local_rank_str = getenv("OMPI_COMM_WORLD_LOCAL_RANK"); 45 | if (nullptr != local_rank_str) { 46 | return atoi(local_rank_str); 47 | } 48 | 49 | return -1; 50 | } 51 | 52 | #endif /* __ROCSHMEM_EXAMPLES_UTIL_H__ */ 53 | -------------------------------------------------------------------------------- /tests/functional_tests/barrier_all_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _BARRIER_ALL_TESTER_HPP_ 26 | #define _BARRIER_ALL_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * DEVICE TEST KERNEL 32 | *****************************************************************************/ 33 | __global__ void BarrierAllTest(TestType type); 34 | 35 | /****************************************************************************** 36 | * HOST TESTER CLASS 37 | *****************************************************************************/ 38 | class BarrierAllTester : public Tester { 39 | public: 40 | explicit BarrierAllTester(TesterArguments args); 41 | virtual ~BarrierAllTester(); 42 | 43 | protected: 44 | virtual void resetBuffers(size_t size) override; 45 | 46 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 47 | size_t size) override; 48 | 49 | virtual void verifyResults(size_t size) override; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /tests/functional_tests/signaling_operations_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _SIGNALING_OPERATIONS_ 26 | #define _SIGNALING_OPERATIONS_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class SignalingOperationsTester : public Tester { 34 | public: 35 | explicit SignalingOperationsTester(TesterArguments args); 36 | explicit SignalingOperationsTester(TesterArguments args, int signal_op); 37 | virtual ~SignalingOperationsTester(); 38 | 39 | protected: 40 | virtual void resetBuffers(size_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | size_t size) override; 44 | 45 | virtual void verifyResults(size_t size) override; 46 | 47 | int sig_op; 48 | char *s_buf = nullptr; 49 | char *r_buf = nullptr; 50 | uint64_t *sig_addr; 51 | uint64_t *fetched_value; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/memory/single_heap.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "single_heap.hpp" 26 | 27 | #include 28 | 29 | namespace rocshmem { 30 | 31 | SingleHeap::SingleHeap() { } 32 | 33 | void SingleHeap::malloc(void** ptr, size_t size) { 34 | strat_.alloc(reinterpret_cast(ptr), size); 35 | } 36 | 37 | __device__ void SingleHeap::malloc(void** ptr, size_t size) {} 38 | 39 | void SingleHeap::free(void* ptr) { 40 | if (!ptr) { 41 | return; 42 | } 43 | strat_.free(reinterpret_cast(ptr)); 44 | } 45 | 46 | __device__ void SingleHeap::free(void* ptr) {} 47 | 48 | void* SingleHeap::realloc(void* ptr, size_t size) { return nullptr; } 49 | 50 | void* SingleHeap::malign(size_t alignment, size_t size) { return nullptr; } 51 | 52 | char* SingleHeap::get_base_ptr() { return heap_mem_.get_ptr(); } 53 | 54 | size_t SingleHeap::get_size() { return heap_mem_.get_size(); } 55 | 56 | size_t SingleHeap::get_used() { return strat_.get_used(); } 57 | 58 | size_t SingleHeap::get_avail() { return get_size() - get_used(); } 59 | 60 | } // namespace rocshmem 61 | -------------------------------------------------------------------------------- /docs/introduction.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocSHMEM intra-kernel networking runtime for AMD GPUs on the ROCm platform. 3 | :keywords: rocSHMEM, API, ROCm, documentation, HIP, Networking, Communication 4 | 5 | .. _rocshmem-introduction: 6 | 7 | --------------------------- 8 | What is rocSHMEM? 9 | --------------------------- 10 | 11 | The ROCm OpenSHMEM (rocSHMEM) is an intra-kernel networking library that provides GPU-centric networking through an OpenSHMEM-like interface. It simplifies application code complexity and enables finer communication and computation overlap than traditional host-driven networking. rocSHMEM uses a single symmetric heap allocated on GPU memories. 12 | 13 | The rocSHMEM programming model 14 | ------------------------------- 15 | 16 | Defining how OpenSHMEM applications interact with GPUs remains an 17 | ongoing active discussion within the OpenSHMEM community, and the OpenSHMEM 18 | specification has yet to coalesce on this topic. 19 | rocSHMEM extends beyond the OpenSHMEM specification to add semantics that 20 | support GPU kernel communication while maintaining close resemblance to 21 | the original OpenSHMEM specification semantics. 22 | 23 | Applications using :doc:`HIP ` can interface with rocSHMEM. 24 | Using the HIP programming model, 25 | rocSHMEM provides ``__host__`` APIs for host code, 26 | and ``__device__`` APIs for GPU kernels. 27 | Device APIs without special suffixes or infixes , for example, ``_wg`` or ``_wave``, 28 | must be called by a single thread. 29 | GPU specific ``_wg`` and ``_wave`` APIs are designed to be called by multiple GPU threads 30 | and will block until the calling scope completes. 31 | These APIs can be called in divergent code paths, but this is not recommended. 32 | 33 | Wavefront APIs 34 | ============== 35 | Wavefront APIs are those with the ``_wave`` suffix. 36 | The parameters in which these routines are called must be 37 | the same for every thread in the wavefront. 38 | The behavior is undefined if any thread calls these routines with different parameters. These APIs will block until the calling wavefront is complete. 39 | 40 | Workgroup APIs 41 | ============== 42 | The workgroup APIs have the ``_wg`` suffix or ``_wg_`` infix. 43 | The parameters in which these routines are called must be 44 | the same for every thread in the workgroup. 45 | The behavior is undefined if any thread calls these routines with different parameters. These APIs will block until the calling workgroup is complete. 46 | -------------------------------------------------------------------------------- /src/gda/endian.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_GDA_ENDIAN_HPP_ 26 | #define LIBRARY_SRC_GDA_ENDIAN_HPP_ 27 | 28 | #include 29 | 30 | namespace rocshmem { 31 | 32 | template 33 | __device__ void swap_endian_store(T *dst, const T val); 34 | 35 | template <> 36 | __device__ void swap_endian_store(uint64_t *dst, const uint64_t val); 37 | 38 | template <> 39 | __device__ void swap_endian_store(int64_t *dst, const int64_t val); 40 | 41 | template <> 42 | __device__ void swap_endian_store(uint32_t *dst, const uint32_t val); 43 | 44 | template <> 45 | __device__ void swap_endian_store(int32_t *dst, const int32_t val); 46 | 47 | template <> 48 | __device__ void swap_endian_store(uint16_t *dst, const uint16_t val); 49 | 50 | template <> 51 | __device__ void swap_endian_store(int16_t *dst, const int16_t val); 52 | 53 | template 54 | __device__ T swap_endian_val(const T val) { 55 | T dst; 56 | swap_endian_store(&dst, val); 57 | return dst; 58 | } 59 | 60 | } // namespace rocshmem 61 | 62 | #endif // LIBRARY_SRC_GDA_ENDIAN_HPP_ 63 | -------------------------------------------------------------------------------- /cmake/rocm_local_targets.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # SPDX-License-Identifier: MIT 5 | # 6 | # Permission is hereby granted, free of charge, to any person obtaining a copy 7 | # of this software and associated documentation files (the "Software"), to 8 | # deal in the Software without restriction, including without limitation the 9 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | # sell copies of the Software, and to permit persons to whom the Software is 11 | # furnished to do so, subject to the following conditions: 12 | # 13 | # The above copyright notice and this permission notice shall be included in 14 | # all copies or substantial portions of the Software. 15 | # 16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | # IN THE SOFTWARE. 23 | ############################################################################### 24 | 25 | # Find available local ROCM targets 26 | # NOTE: This will eventually be part of ROCm-CMake and should be removed at that time 27 | function(rocm_local_targets VARIABLE) 28 | set(${VARIABLE} "NOTFOUND" PARENT_SCOPE) 29 | find_program(_rocm_agent_enumerator rocm_agent_enumerator HINTS /opt/rocm/bin ENV ROCM_PATH) 30 | if(NOT _rocm_agent_enumerator STREQUAL "_rocm_agent_enumerator-NOTFOUND") 31 | execute_process( 32 | COMMAND "${_rocm_agent_enumerator}" 33 | RESULT_VARIABLE _found_agents 34 | OUTPUT_VARIABLE _rocm_agents 35 | ERROR_QUIET 36 | ) 37 | if (_found_agents EQUAL 0) 38 | string(REPLACE "\n" ";" _rocm_agents "${_rocm_agents}") 39 | unset(result) 40 | foreach (agent IN LISTS _rocm_agents) 41 | if (NOT agent STREQUAL "gfx000") 42 | list(APPEND result "${agent}") 43 | endif() 44 | endforeach() 45 | if(result) 46 | list(REMOVE_DUPLICATES result) 47 | set(${VARIABLE} "${result}" PARENT_SCOPE) 48 | endif() 49 | endif() 50 | endif() 51 | endfunction() 52 | 53 | -------------------------------------------------------------------------------- /tests/unit_tests/symmetric_heap_gtest.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "symmetric_heap_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(SymmetricHeapTestFixture, malloc_free) { 30 | void *ptr{nullptr}; 31 | size_t request_bytes{48}; 32 | 33 | symmetric_heap_->malloc(&ptr, request_bytes); 34 | ASSERT_NE(ptr, nullptr); 35 | ASSERT_NO_FATAL_FAILURE(symmetric_heap_->free(ptr)); 36 | } 37 | 38 | TEST_F(SymmetricHeapTestFixture, window_info) { 39 | auto win_info_ptr{symmetric_heap_->get_window_info()}; 40 | 41 | WindowInfoMPI* window_info_mpi = dynamic_cast(win_info_ptr); 42 | if (window_info_mpi) { 43 | void *window_base_addr{nullptr}; 44 | int flag{0}; 45 | MPI_Win_get_attr(window_info_mpi->get_win(), MPI_WIN_BASE, &window_base_addr, 46 | &flag); 47 | ASSERT_NE(0, flag); 48 | ASSERT_NE(nullptr, window_base_addr); 49 | } 50 | } 51 | 52 | TEST_F(SymmetricHeapTestFixture, heap_bases) { 53 | auto heap_bases{symmetric_heap_->get_heap_bases()}; 54 | for (const auto &base : heap_bases) { 55 | ASSERT_NE(nullptr, base); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/unit_tests/pow2_bins_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_POW2_BINS_GTEST_HPP 26 | #define ROCSHMEM_POW2_BINS_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/memory/address_record.hpp" 31 | #include "../src/memory/heap_memory.hpp" 32 | #include "../src/memory/hip_allocator.hpp" 33 | #include "../src/memory/pow2_bins.hpp" 34 | 35 | namespace rocshmem { 36 | 37 | class Pow2BinsTestFixture : public ::testing::Test 38 | { 39 | /** 40 | * @brief Helper type for heap memory 41 | */ 42 | using HEAP_T = HeapMemory; 43 | 44 | /** 45 | * @brief Helper type for address records 46 | */ 47 | using AR_T = AddressRecord; 48 | 49 | /** 50 | * @brief Helper type for allocation strategy 51 | */ 52 | using STRAT_T = Pow2Bins; 53 | 54 | protected: 55 | /** 56 | * @brief Heap memory object 57 | */ 58 | HEAP_T heap_mem_ {}; 59 | 60 | /** 61 | * @brief Allocation strategy object 62 | */ 63 | STRAT_T strat_ {&heap_mem_}; 64 | }; 65 | 66 | } // namespace rocshmem 67 | 68 | #endif // ROCSHMEM_POW2_BINS_GTEST_HPP 69 | -------------------------------------------------------------------------------- /tests/unit_tests/remote_heap_info_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP 26 | #define ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include 31 | 32 | #include "../src/memory/heap_memory.hpp" 33 | #include "../src/memory/hip_allocator.hpp" 34 | #include "../src/memory/remote_heap_info.hpp" 35 | 36 | namespace rocshmem { 37 | 38 | class RemoteHeapInfoTestFixture : public ::testing::Test 39 | { 40 | /** 41 | * @brief Helper type for heap memory 42 | */ 43 | using HEAP_T = HeapMemory; 44 | 45 | /** 46 | * @brief Helper type for RemoteHeapInfo with MPI 47 | */ 48 | using MPI_T = RemoteHeapInfo; 49 | 50 | protected: 51 | /** 52 | * @brief Heap memory object 53 | */ 54 | HEAP_T heap_mem_ {}; 55 | 56 | /** 57 | * @brief Remote heap info with MPI Communicator 58 | */ 59 | MPI_T mpi_ {heap_mem_.get_ptr(), 60 | heap_mem_.get_size(), 61 | MPI_COMM_WORLD}; 62 | }; 63 | 64 | } // namespace rocshmem 65 | 66 | #endif // ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP 67 | -------------------------------------------------------------------------------- /tests/functional_tests/ping_all_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _PING_ALL_TESTER_HPP_ 26 | #define _PING_ALL_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * DEVICE TEST KERNEL 32 | *****************************************************************************/ 33 | __global__ void PingAllTest(int loop, int skip, long long int *start_time, 34 | long long int *end_time, int *r_buf); 35 | 36 | /****************************************************************************** 37 | * HOST TESTER CLASS 38 | *****************************************************************************/ 39 | class PingAllTester : public Tester { 40 | public: 41 | explicit PingAllTester(TesterArguments args); 42 | virtual ~PingAllTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(size_t size) override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | size_t size) override; 49 | 50 | virtual void verifyResults(size_t size) override; 51 | 52 | int *r_buf; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tests/functional_tests/team_ctx_infra_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _TEAM_CTX_INFRA_TESTER_HPP_ 26 | #define _TEAM_CTX_INFRA_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | class TeamCtxInfraTester : public Tester { 34 | public: 35 | explicit TeamCtxInfraTester(TesterArguments args); 36 | virtual ~TeamCtxInfraTester(); 37 | 38 | protected: 39 | virtual void resetBuffers(size_t size) override; 40 | 41 | virtual void preLaunchKernel() override; 42 | 43 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 44 | size_t size) override; 45 | 46 | virtual void postLaunchKernel() override; 47 | 48 | virtual void verifyResults(size_t size) override; 49 | 50 | char *s_buf = nullptr; 51 | char *r_buf = nullptr; 52 | 53 | TeamSplitType _splitType; 54 | rocshmem::rocshmem_team_t _parentTeam = rocshmem::ROCSHMEM_TEAM_WORLD; 55 | int _expected_pe; 56 | int _expected_n_pes; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /tests/functional_tests/ping_pong_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _PING_PONG_TESTER_HPP_ 26 | #define _PING_PONG_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * DEVICE TEST KERNEL 32 | *****************************************************************************/ 33 | __global__ void PingPongTest(int loop, int skip, long long int *start_time, 34 | long long int *end_time, int *r_buf); 35 | 36 | /****************************************************************************** 37 | * HOST TESTER CLASS 38 | *****************************************************************************/ 39 | class PingPongTester : public Tester { 40 | public: 41 | explicit PingPongTester(TesterArguments args); 42 | virtual ~PingPongTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(size_t size) override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | size_t size) override; 49 | 50 | virtual void verifyResults(size_t size) override; 51 | 52 | int *r_buf; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/sync/abql_block_mutex.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "sync/abql_block_mutex.hpp" 26 | 27 | #include "util.hpp" 28 | 29 | namespace rocshmem { 30 | 31 | __device__ ABQLBlockMutex::TicketT ABQLBlockMutex::lock() { 32 | TicketT my_ticket{grab_ticket_()}; 33 | wait_turn_(my_ticket); 34 | return my_ticket; 35 | } 36 | 37 | __device__ void ABQLBlockMutex::unlock(TicketT my_ticket) { 38 | TicketT next_ticket{my_ticket + 1}; 39 | signal_next_(next_ticket); 40 | } 41 | 42 | __device__ ABQLBlockMutex::TicketT ABQLBlockMutex::grab_ticket_() { 43 | TicketT ticket{atomicAdd(&ticket_, 1)}; 44 | return ticket; 45 | } 46 | 47 | __device__ bool ABQLBlockMutex::is_turn_(TicketT ticket) { 48 | size_t index{ticket % memory_channels_}; 49 | return turns_[index].vol_ == ticket; 50 | } 51 | 52 | __device__ void ABQLBlockMutex::wait_turn_(TicketT ticket) { 53 | size_t index{ticket % memory_channels_}; 54 | while (turns_[index].vol_ != ticket) { 55 | } 56 | } 57 | 58 | __device__ void ABQLBlockMutex::signal_next_(TicketT ticket) { 59 | size_t index{ticket % memory_channels_}; 60 | turns_[index].vol_ = ticket; 61 | __threadfence(); 62 | } 63 | 64 | } // namespace rocshmem 65 | -------------------------------------------------------------------------------- /src/ipc/ipc_team.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "ipc_team.hpp" 26 | 27 | #include "constants.hpp" 28 | #include "backend_type.hpp" 29 | #include "backend_ipc.hpp" 30 | 31 | namespace rocshmem { 32 | 33 | IPCTeam::IPCTeam(Backend *backend, TeamInfo *team_info_parent, 34 | TeamInfo *team_info_world, int num_pes, int my_pe, 35 | MPI_Comm mpi_comm, int pool_index) 36 | : Team(backend, team_info_parent, team_info_world, num_pes, my_pe, 37 | mpi_comm) { 38 | type = BackendType::IPC_BACKEND; 39 | const IPCBackend *b = static_cast(backend); 40 | 41 | pool_index_ = pool_index; 42 | 43 | barrier_pSync = &(b->barrier_pSync_pool[pool_index * ROCSHMEM_BARRIER_SYNC_SIZE]); 44 | reduce_pSync = &(b->reduce_pSync_pool[pool_index * ROCSHMEM_REDUCE_SYNC_SIZE]); 45 | bcast_pSync = &(b->bcast_pSync_pool[pool_index * ROCSHMEM_BCAST_SYNC_SIZE]); 46 | alltoall_pSync = &(b->alltoall_pSync_pool[pool_index * ROCSHMEM_ALLTOALL_SYNC_SIZE]); 47 | 48 | pWrk = reinterpret_cast(b->pWrk_pool) + ROCSHMEM_REDUCE_MIN_WRKDATA_SIZE * sizeof(double) * pool_index; 49 | } 50 | 51 | IPCTeam::~IPCTeam() {} 52 | 53 | } // namespace rocshmem 54 | -------------------------------------------------------------------------------- /src/gda/gda_team.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #include "gda_team.hpp" 26 | 27 | #include "constants.hpp" 28 | #include "backend_type.hpp" 29 | #include "backend_gda.hpp" 30 | #include "rocshmem/rocshmem_mpi.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | GDATeam::GDATeam(Backend *backend, TeamInfo *team_info_parent, 35 | TeamInfo *team_info_world, int num_pes, int my_pe, 36 | MPI_Comm mpi_comm, int pool_index) 37 | : Team(backend, team_info_parent, team_info_world, num_pes, my_pe, 38 | mpi_comm) { 39 | type = BackendType::GDA_BACKEND; 40 | const GDABackend *b = static_cast(backend); 41 | 42 | pool_index_ = pool_index; 43 | 44 | barrier_pSync = &(b->barrier_pSync_pool[pool_index * ROCSHMEM_BARRIER_SYNC_SIZE]); 45 | reduce_pSync = &(b->reduce_pSync_pool[pool_index * ROCSHMEM_REDUCE_SYNC_SIZE]); 46 | bcast_pSync = &(b->bcast_pSync_pool[pool_index * ROCSHMEM_BCAST_SYNC_SIZE]); 47 | alltoall_pSync = &(b->alltoall_pSync_pool[pool_index * ROCSHMEM_ALLTOALL_SYNC_SIZE]); 48 | 49 | pWrk = reinterpret_cast(b->pWrk_pool) + ROCSHMEM_REDUCE_MIN_WRKDATA_SIZE * sizeof(double) * pool_index; 50 | } 51 | 52 | GDATeam::~GDATeam() {} 53 | 54 | } // namespace rocshmem 55 | -------------------------------------------------------------------------------- /src/containers/strategies.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_CONTAINERS_STRATEGIES_HPP_ 26 | #define LIBRARY_SRC_CONTAINERS_STRATEGIES_HPP_ 27 | 28 | #include "index_strategy.hpp" 29 | #include "share_strategy.hpp" 30 | 31 | namespace rocshmem { 32 | 33 | struct ObjectStrategy { 34 | ShareStrategy share_strategy{}; 35 | IndexStrategy index_strategy_one{}; 36 | IndexStrategy index_strategy_two{}; 37 | IndexStrategy index_strategy_three{}; 38 | IndexStrategy index_strategy_four{}; 39 | }; 40 | 41 | class DefaultObjectStrategy { 42 | private: 43 | static DefaultObjectStrategy* _instance; 44 | 45 | DefaultObjectStrategy() { 46 | _os.share_strategy = ShareStrategy(ShareStrategyEnum::PRIVATE); 47 | _os.index_strategy_one = IndexStrategy(IndexStrategyEnum::TDBD); 48 | _os.index_strategy_two = IndexStrategy(IndexStrategyEnum::TDBD); 49 | _os.index_strategy_three = IndexStrategy(IndexStrategyEnum::TDBD); 50 | _os.index_strategy_four = IndexStrategy(IndexStrategyEnum::TDBD); 51 | } 52 | 53 | ObjectStrategy _os{}; 54 | 55 | public: 56 | static DefaultObjectStrategy* instance(); 57 | 58 | const ObjectStrategy* get() { return &_os; } 59 | }; 60 | 61 | struct Strategies {}; 62 | 63 | } // namespace rocshmem 64 | 65 | #endif // LIBRARY_SRC_CONTAINERS_STRATEGIES_HPP_ 66 | -------------------------------------------------------------------------------- /tests/functional_tests/team_sync_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _TEAM_SYNC_TESTER_HPP_ 26 | #define _TEAM_SYNC_TESTER_HPP_ 27 | 28 | #include 29 | #include 30 | 31 | #include "tester.hpp" 32 | 33 | using namespace rocshmem; 34 | 35 | /****************************************************************************** 36 | * HOST TESTER CLASS 37 | *****************************************************************************/ 38 | class TeamSyncTester : public Tester { 39 | public: 40 | explicit TeamSyncTester(TesterArguments args); 41 | virtual ~TeamSyncTester(); 42 | 43 | protected: 44 | virtual void resetBuffers(size_t size) override; 45 | 46 | virtual void preLaunchKernel() override; 47 | 48 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 49 | size_t size) override; 50 | 51 | virtual void postLaunchKernel() override; 52 | 53 | virtual void verifyResults(size_t size) override; 54 | 55 | private: 56 | int my_pe = 0; 57 | int n_pes = 0; 58 | /** 59 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 60 | * The default value for the maximum number of teams is 40. 61 | */ 62 | int num_teams = 39; 63 | rocshmem_team_t *team_sync_world_dup; 64 | }; 65 | 66 | #include "team_sync_tester.cpp" 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /tests/unit_tests/free_list_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_FREE_LIST_GTEST_HPP 26 | #define ROCSHMEM_FREE_LIST_GTEST_HPP 27 | 28 | #include 29 | #include 30 | 31 | #include "../src/containers/free_list_impl.hpp" 32 | #include "gtest/gtest.h" 33 | #include "../src/memory/hip_allocator.hpp" 34 | #include "wf_size.hpp" 35 | 36 | namespace rocshmem { 37 | 38 | template 39 | class FreeListTestFixture : public ::testing::Test { 40 | public: 41 | FreeListTestFixture() : h_input(num_elements) { 42 | std::iota(h_input.begin(), h_input.end(), T{1}); 43 | free_list = list_proxy.get(); 44 | } 45 | 46 | protected: 47 | void SetUp() override { 48 | free_list->push_back_range(h_input.begin(), h_input.end()); 49 | wf_size = get_wf_size(); 50 | } 51 | 52 | using T = ValueType; 53 | using Allocator = HIPAllocator; 54 | Allocator hip_allocator_ {}; 55 | const std::size_t num_elements{32}; 56 | std::vector h_input{}; 57 | int wf_size; 58 | 59 | FreeListProxy list_proxy{}; 60 | FreeList* free_list{}; 61 | }; 62 | 63 | using TestTypes = ::testing::Types; 64 | TYPED_TEST_SUITE(FreeListTestFixture, TestTypes); 65 | 66 | } // namespace rocshmem 67 | 68 | #endif // ROCSHMEM_FREE_LIST_GTEST_HPP 69 | -------------------------------------------------------------------------------- /src/hdp_proxy.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_HDP_PROXY_HPP_ 26 | #define LIBRARY_SRC_HDP_PROXY_HPP_ 27 | 28 | #include "device_proxy.hpp" 29 | #include "hdp_policy.hpp" 30 | 31 | namespace rocshmem { 32 | 33 | template 34 | class HdpProxy { 35 | using HdpProxyT = DeviceProxy; 36 | 37 | public: 38 | /* 39 | * Placement new the memory which is allocated by proxy_ 40 | */ 41 | HdpProxy(size_t num_elems = 1) : proxy_{num_elems} { 42 | new (proxy_.get()) HdpPolicy(); 43 | } 44 | 45 | HdpProxy(const HdpProxy& other) = delete; 46 | 47 | HdpProxy& operator=(const HdpProxy& other) = delete; 48 | 49 | HdpProxy(HdpProxy&& other) = default; 50 | 51 | HdpProxy& operator=(HdpProxy&& other) = default; 52 | 53 | /* 54 | * Since placement new is called in the constructor, then 55 | * delete must be called manually. 56 | */ 57 | ~HdpProxy() { 58 | proxy_.get()->~HdpPolicy(); 59 | } 60 | 61 | /* 62 | * @brief Provide access to the memory referenced by the proxy 63 | */ 64 | __host__ __device__ HdpPolicy* get() { return proxy_.get(); } 65 | 66 | private: 67 | /* 68 | * @brief Memory managed by the lifetime of this object 69 | */ 70 | HdpProxyT proxy_{}; 71 | }; 72 | 73 | } // namespace rocshmem 74 | 75 | #endif // LIBRARY_SRC_HDP_PROXY_HPP_ 76 | -------------------------------------------------------------------------------- /tests/functional_tests/team_barrier_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _TEAM_BARRIER_TESTER_HPP_ 26 | #define _TEAM_BARRIER_TESTER_HPP_ 27 | 28 | #include 29 | #include 30 | 31 | #include "tester.hpp" 32 | 33 | using namespace rocshmem; 34 | 35 | /************* ***************************************************************** 36 | * HOST TESTER CLASS 37 | *****************************************************************************/ 38 | class TeamBarrierTester : public Tester { 39 | public: 40 | explicit TeamBarrierTester(TesterArguments args); 41 | virtual ~TeamBarrierTester(); 42 | 43 | protected: 44 | virtual void resetBuffers(size_t size) override; 45 | 46 | virtual void preLaunchKernel() override; 47 | 48 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 49 | size_t size) override; 50 | 51 | virtual void postLaunchKernel() override; 52 | 53 | virtual void verifyResults(size_t size) override; 54 | 55 | private: 56 | int my_pe = 0; 57 | int n_pes = 0; 58 | /** 59 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 60 | * The default value for the maximum number of teams is 40. 61 | */ 62 | int num_teams = 39; 63 | rocshmem_team_t *team_barrier_world_dup; 64 | }; 65 | 66 | #include "team_barrier_tester.cpp" 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/wf_coal_policy.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_WF_COAL_POLICY_HPP_ 26 | #define LIBRARY_SRC_WF_COAL_POLICY_HPP_ 27 | 28 | #include 29 | 30 | #include "rocshmem/rocshmem_config.h" // NOLINT(build/include_subdir) 31 | #include "util.hpp" 32 | 33 | namespace rocshmem { 34 | 35 | class WfCoalOn { 36 | public: 37 | /** 38 | * Coalesce contiguous messages from a single wavefront. 39 | * 40 | * With regards to calling threads, the command must already be the 41 | * same for active threads otherwise they must have diverged at the 42 | * function call level. 43 | */ 44 | __device__ bool coalesce(int pe, const void *source, const void *dest, 45 | size_t *size); 46 | }; 47 | 48 | // clang-format off 49 | NOWARN(-Wunused-parameter, 50 | class WfCoalOff { 51 | public: 52 | __device__ bool coalesce(int pe, const void *source, const void *dest, 53 | size_t *size) { 54 | return true; 55 | } 56 | }; 57 | ) 58 | // clang-format on 59 | 60 | /** 61 | * Compile time configuration options will enable or disable this feature. 62 | */ 63 | #ifdef USE_WF_COAL 64 | typedef WfCoalOn WavefrontCoalescer; 65 | #else 66 | typedef WfCoalOff WavefrontCoalescer; 67 | #endif 68 | 69 | } // namespace rocshmem 70 | 71 | #endif // LIBRARY_SRC_WF_COAL_POLICY_HPP_ 72 | -------------------------------------------------------------------------------- /tests/unit_tests/binner_gtest.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef ROCSHMEM_BINNER_GTEST_HPP 26 | #define ROCSHMEM_BINNER_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include 31 | 32 | #include "../src/../src/memory/address_record.hpp" 33 | #include "../src/memory/bin.hpp" 34 | #include "../src/memory/binner.hpp" 35 | #include "../src/memory/heap_memory.hpp" 36 | #include "../src/memory/hip_allocator.hpp" 37 | 38 | namespace rocshmem { 39 | 40 | class BinnerTestFixture : public ::testing::Test 41 | { 42 | /** 43 | * @brief Helper type for address records 44 | */ 45 | using AR_T = AddressRecord; 46 | 47 | /** 48 | * @brief Helper type for size to bin maps 49 | */ 50 | using BINS_T = std::map>; 51 | 52 | /** 53 | * @brief Helper type for binner 54 | */ 55 | using BINNER_T = Binner; 56 | 57 | protected: 58 | /** 59 | * @brief a heap memory object 60 | */ 61 | HeapMemory hm_ {}; 62 | 63 | /** 64 | * @brief a bins object 65 | */ 66 | BINS_T bins_ {}; 67 | 68 | /** 69 | * @brief a binner object 70 | */ 71 | BINNER_T binner_ {&bins_, 72 | hm_.get_ptr(), 73 | hm_.get_size()}; 74 | }; 75 | 76 | } // namespace rocshmem 77 | 78 | #endif // ROCSHMEM_BINNER_GTEST_HPP 79 | -------------------------------------------------------------------------------- /docs/api/ctx.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :description: rocSHMEM intra-kernel networking runtime for AMD dGPUs on the ROCm platform. 3 | :keywords: rocSHMEM, API, ROCm, documentation, HIP, Networking, Communication 4 | 5 | .. _rocshmem-api-ctx: 6 | 7 | ----------------------------------- 8 | Context management routines 9 | ----------------------------------- 10 | 11 | ROCSHMEM_CTX_CREATE 12 | ------------------- 13 | 14 | .. cpp:function:: __device__ int rocshmem_wg_ctx_create(int64_t options, rocshmem_ctx_t *ctx) 15 | .. cpp:function:: __device__ int rocshmem_wg_team_create_ctx(rocshmem_team_t team, long options, rocshmem_ctx_t *ctx) 16 | 17 | :param team: Team handle to derive the context from. 18 | :param options: Options for context creation. Ignored in current design; use the value ``0``. 19 | :param ctx: A handle to the newly created context. 20 | 21 | :returns: All threads returns ``0`` if the context was created successfully. 22 | If any thread returns non-zero value, the operation fails, ctx is set to ``ROCSHMEM_CTX_INVALID`` and a 23 | higher number of ``ROCSHMEM_MAX_NUM_CONTEXTS`` is required. 24 | 25 | **Description:** 26 | This routine creates an rocSHMEM context. By design, the context is private to the calling work-group. 27 | It must be called collectively by all threads in the work-group. If the context was created successfully, a value 28 | of zero is returned and the context handle pointed to by ctx specifies a valid context; otherwise, a nonzero value 29 | is returned and ctx is set to ``ROCSHMEM_CTX_INVALID``. An unsuccessful context creation call is not treated as an 30 | error and the rocSHMEM library remains in a correct state. The creation call can be reattempted after additional 31 | resources become available. 32 | 33 | ROCSHMEM_CTX_DESTROY 34 | -------------------- 35 | 36 | .. cpp:function:: __device__ void rocshmem_wg_ctx_destroy(rocshmem_ctx_t *ctx) 37 | 38 | :param ctx: Context handle. 39 | 40 | :returns: None. 41 | 42 | **Description:** 43 | This routine destroys an rocSHMEM context. It must be called collectively by all threads in the work-group. 44 | If ctx has the value ``ROCSHMEM_CTX_INVALID``, no operation is performed. 45 | 46 | ROCSHMEM_GET_DEVICE_CTX 47 | ----------------------- 48 | 49 | .. cpp:function:: __host__ void * rocshmem_get_device_ctx() 50 | 51 | :param: None. 52 | 53 | :returns: Returns ``ROCSHMEM_CTX_DEFAULT`` device pointer that users. 54 | can query from one instance of rocSHMEM host library and 55 | use later for dynamic module initialization in 56 | kernel bitcode device library in the same application. 57 | 58 | **Description:** 59 | This routine queries rocSHMEM default device context from host API. 60 | -------------------------------------------------------------------------------- /src/gda/mlx5/segment_builder.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_GDA_SEGMENT_BUILDER_HPP_ 26 | #define LIBRARY_SRC_GDA_SEGMENT_BUILDER_HPP_ 27 | 28 | #include "gda/mlx5/provider_gda_mlx5.hpp" 29 | 30 | #include "util.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class SegmentBuilder { 35 | public: 36 | __device__ SegmentBuilder(uint64_t wqe_idx, void *base); 37 | 38 | __device__ void update_ctrl_seg(uint16_t pi, uint8_t opcode, uint8_t opmod, uint32_t qp_num, 39 | uint8_t fm_ce_se, uint8_t ds, uint8_t signature, uint32_t imm); 40 | 41 | __device__ void update_raddr_seg(uint64_t raddr, uint32_t rkey); 42 | 43 | __device__ void update_data_seg(uint64_t laddr, uint32_t size, uint32_t lkey); 44 | 45 | __device__ void update_inl_data_seg(const void* laddr, int32_t size); 46 | 47 | __device__ void update_atomic_seg(uint64_t atomic_data, uint64_t atomic_cmp); 48 | 49 | private: 50 | const int SEGMENTS_PER_WQE = 4; 51 | 52 | union mlx5_segment { 53 | mlx5_wqe_ctrl_seg ctrl_seg; 54 | mlx5_wqe_raddr_seg raddr_seg; 55 | mlx5_wqe_data_seg data_seg; 56 | mlx5_wqe_inl_data_seg inl_data_seg; 57 | mlx5_wqe_atomic_seg atomic_seg; 58 | }; 59 | 60 | mlx5_segment *segp; 61 | }; 62 | 63 | } // namespace rocshmem 64 | 65 | #endif // LIBRARY_SRC_GDA_SEGMENT_BUILDER_HPP_ 66 | -------------------------------------------------------------------------------- /src/constants.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef LIBRARY_SRC_CONSTANTS_HPP_ 26 | #define LIBRARY_SRC_CONSTANTS_HPP_ 27 | 28 | /** 29 | * @file constants.hpp 30 | * 31 | * @brief Contains global constants for rocSHMEM library 32 | */ 33 | 34 | namespace rocshmem { 35 | 36 | /** 37 | * @brief Minimum object alignment for symmetric heap. 38 | * 39 | * @note Cache line size on most systems is either 64 or 128. 40 | */ 41 | inline const unsigned ALIGNMENT{128}; 42 | 43 | /** 44 | * @brief Constant number which holds maximum workgroup size. 45 | * 46 | * @todo Remove this member from this class. It belongs in a class 47 | * that specifically holds device hardware information. If this 48 | * device class existed, we could consolidate the various flavours of 49 | * the Instinct cards into their own groups and then set these 50 | * hard-coded fields by querying the rocm runtime during our library 51 | * initialization. 52 | */ 53 | inline const unsigned MAX_WG_SIZE{1024}; 54 | 55 | /** 56 | * @brief Constant number which holds the wavefront size 57 | * 58 | * @note Wavefront size on most systems is either 32 or 64. 59 | */ 60 | #if defined(__gfx90a__) || defined(__gfx942__) || defined (__gfx950__) 61 | inline const int WF_SIZE{64}; 62 | #else 63 | inline const int WF_SIZE{32}; 64 | #endif 65 | 66 | } // namespace rocshmem 67 | 68 | #endif // LIBRARY_SRC_CONSTANTS_HPP_ 69 | -------------------------------------------------------------------------------- /tests/functional_tests/amo_bitwise_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _AMO_BITWISE_TESTER_HPP_ 26 | #define _AMO_BITWISE_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | template 34 | class AMOBitwiseTester : public Tester { 35 | public: 36 | explicit AMOBitwiseTester(TesterArguments args); 37 | virtual ~AMOBitwiseTester(); 38 | 39 | protected: 40 | virtual void resetBuffers(size_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | size_t size) override; 44 | 45 | virtual void verifyResults(size_t size) override; 46 | 47 | void verifyDestValues(); 48 | void verifyReturnValues(); 49 | 50 | int destIndex(int l, int elem_idx) const; 51 | int numElems() const; 52 | std::pair retChunk(int l, int elem_idx) const; 53 | 54 | T* dest{nullptr}; // symmetric target buffer [loop][elem] 55 | T* ret_val{nullptr}; // device returns [loop][thread] 56 | 57 | size_t n_in{0}; // num_wgs * wg_size 58 | size_t n_out{0}; // elements per loop: PerBlock->num_wgs, PerGrid->1 59 | size_t n_loops{0}; // loop + skip 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /tests/functional_tests/amo_standard_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _AMO_STANDARD_TESTER_HPP_ 26 | #define _AMO_STANDARD_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | template 34 | class AMOStandardTester : public Tester { 35 | public: 36 | explicit AMOStandardTester(TesterArguments args); 37 | virtual ~AMOStandardTester(); 38 | 39 | protected: 40 | virtual void resetBuffers(size_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | size_t size) override; 44 | 45 | virtual void verifyResults(size_t size) override; 46 | 47 | void verifyDestValues(); 48 | void verifyReturnValues(); 49 | 50 | int destIndex(int l, int elem_idx) const; 51 | int numElems() const; 52 | std::pair retChunk(int l, int elem_idx) const; 53 | 54 | T* dest{nullptr}; // symmetric target buffer [loop][elem] 55 | T* ret_val{nullptr}; // device returns [loop][thread] 56 | 57 | size_t n_in{0}; // num_wgs * wg_size 58 | size_t n_out{0}; // elements per loop: PerBlock->num_wgs, PerGrid->1 59 | size_t n_loops{0}; // loop + skip 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /tests/functional_tests/barrier_all_on_stream_tester.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (c) Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: MIT 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | *****************************************************************************/ 24 | 25 | #ifndef _BARRIER_ALL_ON_STREAM_TESTER_HPP_ 26 | #define _BARRIER_ALL_ON_STREAM_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | #include 30 | #include 31 | 32 | using namespace rocshmem; 33 | 34 | /****************************************************************************** 35 | * HOST TESTER CLASS 36 | *****************************************************************************/ 37 | class BarrierAllOnStreamTester : public Tester { 38 | public: 39 | explicit BarrierAllOnStreamTester(TesterArguments args); 40 | virtual ~BarrierAllOnStreamTester(); 41 | 42 | protected: 43 | virtual void resetBuffers(size_t size) override; 44 | 45 | virtual void preLaunchKernel() override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | size_t size) override; 49 | 50 | virtual void postLaunchKernel() override; 51 | 52 | virtual void verifyResults(size_t size) override; 53 | 54 | private: 55 | int my_pe; 56 | int n_pes; 57 | int num_streams = 1; 58 | bool use_default_stream = false; 59 | std::vector streams; 60 | std::vector start_events_timed; 61 | std::vector stop_events_timed; 62 | }; 63 | 64 | #include "barrier_all_on_stream_tester.cpp" 65 | 66 | #endif 67 | 68 | --------------------------------------------------------------------------------