├── .github └── CODEOWNERS ├── .gitignore ├── .readthedocs.yaml ├── AUTHORS.md ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── cmake ├── rocm_local_targets.cmake └── rocshmem_config.h.in ├── docs ├── .gitignore ├── README.md ├── api │ ├── amo.rst │ ├── coll.rst │ ├── ctx.rst │ ├── init.rst │ ├── memory_management.rst │ ├── memory_ordering.rst │ ├── pt2pt_sync.rst │ ├── rma.rst │ ├── sigops.rst │ └── teams.rst ├── compile_and_run.rst ├── conf.py ├── doxygen │ └── Doxyfile ├── index.rst ├── install.rst ├── introduction.rst ├── license.md └── sphinx │ ├── _toc.yml.in │ ├── requirements.in │ └── requirements.txt ├── examples ├── CMakeLists.txt ├── rocshmem_allreduce_test.cc ├── rocshmem_alltoall_test.cc ├── rocshmem_broadcast_test.cc ├── rocshmem_getmem_test.cc ├── rocshmem_init_attr_test.cc └── rocshmem_put_signal_test.cc ├── include └── rocshmem │ ├── rocshmem.hpp │ ├── rocshmem_AMO.hpp │ ├── rocshmem_COLL.hpp │ ├── rocshmem_P2P_SYNC.hpp │ ├── rocshmem_RMA.hpp │ ├── rocshmem_RMA_X.hpp │ ├── rocshmem_SIG_OP.hpp │ ├── rocshmem_common.hpp │ └── rocshmem_debug.hpp ├── scripts ├── build_configs │ ├── codecov │ ├── ipc_single │ ├── ipc_tests_only │ ├── ro_ipc │ ├── ro_net │ └── ro_net_debug ├── functional_tests │ ├── GDB_README │ ├── driver.py │ ├── driver.sh │ ├── gdbrun │ ├── gdbscript │ └── shmem_allLib_build_and_test.sh ├── install_dependencies.sh └── unit_tests │ └── driver.sh ├── src ├── CMakeLists.txt ├── assembly.hpp ├── atomic.hpp ├── atomic_return.cpp ├── atomic_return.hpp ├── backend_bc.cpp ├── backend_bc.hpp ├── backend_type.hpp ├── bootstrap │ ├── CMakeLists.txt │ ├── bootstrap.cpp │ ├── bootstrap.hpp │ ├── socket.cpp │ ├── socket.hpp │ ├── utils.cpp │ └── utils.hpp ├── constants.hpp ├── containers │ ├── CMakeLists.txt │ ├── array.hpp │ ├── array_impl.hpp │ ├── atomic_wf_queue.hpp │ ├── atomic_wf_queue_impl.hpp │ ├── free_list.hpp │ ├── free_list_impl.hpp │ ├── helper_macros.hpp │ ├── index_strategy.hpp │ ├── matrix.hpp │ ├── matrix_impl.hpp │ ├── share_strategy.cpp │ ├── share_strategy.hpp │ ├── strategies.cpp │ └── strategies.hpp ├── context.hpp ├── context_device.cpp ├── context_host.cpp ├── context_incl.hpp ├── context_tmpl_device.hpp ├── context_tmpl_host.hpp ├── device_proxy.hpp ├── fence_policy.hpp ├── hdp_policy.hpp ├── hdp_proxy.hpp ├── host │ ├── CMakeLists.txt │ ├── host.cpp │ ├── host.hpp │ ├── host_helpers.hpp │ └── host_templates.hpp ├── ipc │ ├── CMakeLists.txt │ ├── backend_ipc.cpp │ ├── backend_ipc.hpp │ ├── context_ipc_device.cpp │ ├── context_ipc_device.hpp │ ├── context_ipc_device_coll.cpp │ ├── context_ipc_host.cpp │ ├── context_ipc_host.hpp │ ├── context_ipc_tmpl_device.hpp │ ├── context_ipc_tmpl_host.hpp │ ├── ipc_context_proxy.hpp │ ├── ipc_team.cpp │ └── ipc_team.hpp ├── ipc_policy.cpp ├── ipc_policy.hpp ├── memory │ ├── CMakeLists.txt │ ├── address_record.hpp │ ├── bin.hpp │ ├── binner.hpp │ ├── dlmalloc.cpp │ ├── dlmalloc.hpp │ ├── heap_memory.hpp │ ├── heap_type.hpp │ ├── hip_allocator.hpp │ ├── memory_allocator.cpp │ ├── memory_allocator.hpp │ ├── notifier.hpp │ ├── pow2_bins.hpp │ ├── remote_heap_info.hpp │ ├── shmem_allocator_strategy.hpp │ ├── single_heap.cpp │ ├── single_heap.hpp │ ├── symmetric_heap.hpp │ └── window_info.hpp ├── mpi_init_singleton.cpp ├── mpi_init_singleton.hpp ├── reverse_offload │ ├── CMakeLists.txt │ ├── backend_proxy.hpp │ ├── backend_ro.cpp │ ├── backend_ro.hpp │ ├── block_handle.hpp │ ├── commands_types.hpp │ ├── context_proxy.hpp │ ├── context_ro_device.cpp │ ├── context_ro_device.hpp │ ├── context_ro_host.cpp │ ├── context_ro_host.hpp │ ├── context_ro_tmpl_device.hpp │ ├── context_ro_tmpl_host.hpp │ ├── mpi_transport.cpp │ ├── mpi_transport.hpp │ ├── profiler.hpp │ ├── queue.cpp │ ├── queue.hpp │ ├── queue_desc_proxy.hpp │ ├── queue_proxy.hpp │ ├── ro_net_team.cpp │ ├── ro_net_team.hpp │ ├── ro_team_proxy.hpp │ ├── team_info_proxy.hpp │ ├── transport.hpp │ └── window_proxy.hpp ├── rocshmem.cpp ├── rocshmem_calc.hpp ├── rocshmem_gpu.cpp ├── stats.hpp ├── sync │ ├── CMakeLists.txt │ ├── abql_block_mutex.cpp │ └── abql_block_mutex.hpp ├── team.cpp ├── team.hpp ├── team_tracker.cpp ├── team_tracker.hpp ├── templates.hpp ├── templates_host.hpp ├── util.cpp ├── util.hpp ├── wf_coal_policy.cpp └── wf_coal_policy.hpp ├── tests ├── CMakeLists.txt ├── functional_tests │ ├── CMakeLists.txt │ ├── amo_bitwise_tester.cpp │ ├── amo_bitwise_tester.hpp │ ├── amo_extended_tester.cpp │ ├── amo_extended_tester.hpp │ ├── amo_standard_tester.cpp │ ├── amo_standard_tester.hpp │ ├── barrier_all_tester.cpp │ ├── barrier_all_tester.hpp │ ├── default_ctx_primitive_tester.cpp │ ├── default_ctx_primitive_tester.hpp │ ├── empty_tester.cpp │ ├── empty_tester.hpp │ ├── ping_all_tester.cpp │ ├── ping_all_tester.hpp │ ├── ping_pong_tester.cpp │ ├── ping_pong_tester.hpp │ ├── primitive_mr_tester.cpp │ ├── primitive_mr_tester.hpp │ ├── primitive_tester.cpp │ ├── primitive_tester.hpp │ ├── random_access_tester.cpp │ ├── random_access_tester.hpp │ ├── shmem_ptr_tester.cpp │ ├── shmem_ptr_tester.hpp │ ├── signaling_operations_tester.cpp │ ├── signaling_operations_tester.hpp │ ├── sync_all_tester.cpp │ ├── sync_all_tester.hpp │ ├── sync_tester.cpp │ ├── sync_tester.hpp │ ├── team_alltoall_tester.cpp │ ├── team_alltoall_tester.hpp │ ├── team_barrier_tester.cpp │ ├── team_barrier_tester.hpp │ ├── team_broadcast_tester.cpp │ ├── team_broadcast_tester.hpp │ ├── team_ctx_infra_tester.cpp │ ├── team_ctx_infra_tester.hpp │ ├── team_ctx_primitive_tester.cpp │ ├── team_ctx_primitive_tester.hpp │ ├── team_fcollect_tester.cpp │ ├── team_fcollect_tester.hpp │ ├── team_reduction_tester.cpp │ ├── team_reduction_tester.hpp │ ├── test_driver.cpp │ ├── tester.cpp │ ├── tester.hpp │ ├── tester_arguments.cpp │ ├── tester_arguments.hpp │ ├── verify_results_kernels.hpp │ ├── wavefront_primitives.cpp │ ├── wavefront_primitives.hpp │ ├── workgroup_primitives.cpp │ └── workgroup_primitives.hpp └── unit_tests │ ├── CMakeLists.txt │ ├── abql_block_mutex_gtest.cpp │ ├── abql_block_mutex_gtest.hpp │ ├── address_record_gtest.cpp │ ├── address_record_gtest.hpp │ ├── atomic_wf_queue_gtest.cpp │ ├── atomic_wf_queue_gtest.hpp │ ├── bin_gtest.cpp │ ├── bin_gtest.hpp │ ├── binner_gtest.cpp │ ├── binner_gtest.hpp │ ├── bitwise_gtest.cpp │ ├── bitwise_gtest.hpp │ ├── dlmalloc_gtest.cpp │ ├── dlmalloc_gtest.hpp │ ├── free_list_gtest.cpp │ ├── free_list_gtest.hpp │ ├── heap_memory_gtest.cpp │ ├── heap_memory_gtest.hpp │ ├── hipmalloc_gtest.cpp │ ├── hipmalloc_gtest.hpp │ ├── index_strategy_gtest.cpp │ ├── index_strategy_gtest.hpp │ ├── ipc_impl_simple_coarse_gtest.cpp │ ├── ipc_impl_simple_coarse_gtest.hpp │ ├── ipc_impl_simple_fine_gtest.cpp │ ├── ipc_impl_simple_fine_gtest.hpp │ ├── ipc_impl_tiled_fine_gtest.cpp │ ├── ipc_impl_tiled_fine_gtest.hpp │ ├── mpi_init_singleton_gtest.cpp │ ├── mpi_init_singleton_gtest.hpp │ ├── notifier_gtest.cpp │ ├── notifier_gtest.hpp │ ├── pow2_bins_gtest.cpp │ ├── pow2_bins_gtest.hpp │ ├── remote_heap_info_gtest.cpp │ ├── remote_heap_info_gtest.hpp │ ├── shmem_gtest.cpp │ ├── single_heap_gtest.cpp │ ├── single_heap_gtest.hpp │ ├── symmetric_heap_gtest.cpp │ ├── symmetric_heap_gtest.hpp │ ├── wavefront_size_gtest.cpp │ └── wavefront_size_gtest.hpp └── utils └── header_files_gen ├── AMO.py ├── COLL.py ├── P2P_SYNC.py ├── RMA.py ├── RMA_X.py ├── SIG_OP.py └── header_files_gen.py /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @avinashkethineedi @akolliasAMD @Yiltan @BKP @abouteiller @edgargabriel @gaoikawa 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog for rocSHMEM 2 | 3 | ## Unreleased - rocSHMEM 2.x.x for ROCm x.x.x 4 | 5 | ### Added 6 | 7 | * Added the Reverse Offload conduit 8 | * Added new APIs: 9 | * `rocshmem_ctx_barrier` 10 | * `rocshmem_ctx_barrier_wave` 11 | * `rocshmem_ctx_barrier_wg` 12 | * `rocshmem_ctx_barrier_all` 13 | * `rocshmem_ctx_barrier_all_wave` 14 | * `rocshmem_ctx_barrier_all_wg` 15 | * `rocshmem_ctx_sync` 16 | * `rocshmem_ctx_sync_wave` 17 | * `rocshmem_ctx_sync_wg` 18 | * `rocshmem_ctx_sync_all` 19 | * `rocshmem_ctx_sync_all_wave` 20 | * `rocshmem_ctx_sync_all_wg` 21 | * `rocshmem_init_attr` 22 | * `rocshmem_get_uniqueid` 23 | * `rocshmem_set_attr_uniqueid_args` 24 | * Added dlmalloc based allocator 25 | * Added XNACK support 26 | * Added support for initialization with MPI communicators other than `MPI_COMM_WORLD` 27 | 28 | ### Changed 29 | 30 | * Changed collective APIs to use `_wg` suffix rather than `_wg_` infix 31 | 32 | ### Resolved Issues 33 | 34 | * Resolved incorrect output for `rocshmem_ctx_my_pe` and `rocshmem_ctx_n_pes` 35 | * Resolved multi-team errors by providing team specific buffers in `rocshmem_ctx_wg_team_sync` 36 | * Resolved segfault in `rocshmem_wg_ctx_create`, now provides nullptr if ctx cannot be created 37 | * Resolved missing implementation of `rocshmem_g` for IPC conduit 38 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to fork from us 2 | 3 | To keep our development fast and conflict free, we recommend you to [fork](https://github.com/ROCm/rocSHMEM/fork) our repository and start your work from our `dev` branch in your private repository. 4 | 5 | Afterwards, git clone your repository to your local machine. But that is not it! To keep track of the original develop repository, add it as another remote. 6 | 7 | ``` 8 | git remote add mainline https://github.com/ROCm/rocSHMEM.git 9 | git checkout dev 10 | ``` 11 | 12 | As always in git, start a new branch with 13 | 14 | ``` 15 | git checkout -b topic- 16 | ``` 17 | 18 | and apply your changes there. 19 | 20 | ## How to contribute to rocSHMEM 21 | 22 | ### Did you find a bug? 23 | 24 | - Ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/ROCm/rocSHMEM/issues). 25 | 26 | - If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/ROCm/rocSHMEM/issues/new). 27 | 28 | ### Did you write a patch that fixes a bug? 29 | 30 | - Open a new GitHub [pull request](https://github.com/ROCm/rocSHMEM/compare) with the patch. 31 | 32 | - Ensure the PR description clearly describes the problem and solution. If there is an existing GitHub issue open describing this bug, please include it in the description so we can close it. 33 | 34 | - Ensure the PR is based on the `dev` branch of the rocSHMEM GitHub repository. 35 | 36 | - rocSHMEM requires new commits to include a "Signed-off-by" token in the commit message (typically enabled via the `git commit -s` option), indicating your agreement to the projects's [Developer's Certificate of Origin](https://developercertificate.org/) and compatability with the project [LICENSE](https://github.com/ROCm/rocSHMEM/blob/main/LICENSE): 37 | 38 | 39 | > (a) The contribution was created in whole or in part by me and I 40 | > have the right to submit it under the open source license 41 | > indicated in the file; or 42 | > 43 | > (b) The contribution is based upon previous work that, to the best 44 | > of my knowledge, is covered under an appropriate open source 45 | > license and I have the right under that license to submit that 46 | > work with modifications, whether created in whole or in part 47 | > by me, under the same open source license (unless I am 48 | > permitted to submit under a different license), as indicated 49 | > in the file; or 50 | > 51 | > (c) The contribution was provided directly to me by some other 52 | > person who certified (a), (b) or (c) and I have not modified 53 | > it. 54 | > 55 | > (d) I understand and agree that this project and the contribution 56 | > are public and that a record of the contribution (including all 57 | > personal information I submit with it, including my sign-off) is 58 | > maintained indefinitely and may be redistributed consistent with 59 | > this project or the open source license(s) involved. 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_THREADS 30 | #cmakedefine USE_SHARED_CTX 31 | #cmakedefine USE_WF_COAL 32 | #cmakedefine USE_COHERENT_HEAP 33 | #cmakedefine USE_MANAGED_HEAP 34 | #cmakedefine USE_HOST_HEAP 35 | #cmakedefine USE_HIP_HOST_HEAP 36 | #cmakedefine USE_ALLOC_DLMALLOC 37 | #cmakedefine USE_ALLOC_POW2BINS 38 | #cmakedefine USE_FUNC_CALL 39 | #cmakedefine USE_SINGLE_NODE 40 | #cmakedefine USE_HOST_SIDE_HDP_FLUSH 41 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | _doxygen/ 3 | doxygen/html/ 4 | doxygen/xml/ 5 | sphinx/_toc.yml 6 | -------------------------------------------------------------------------------- /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 ./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 ./requirements.txt 19 | sphinx-build -M latexpdf . _build 20 | open _build/latex/rocshmem.pdf 21 | ``` 22 | -------------------------------------------------------------------------------- /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: Context handle. 20 | 21 | :returns: All threads returns ``0`` if the context was created successfully. 22 | If any thread returns non-zero value, the operation fails and a higher number of 23 | ``ROCSHMEM_MAX_NUM_CONTEXTS`` is required. 24 | 25 | **Description:** 26 | This routine creates an OpenSHMEM 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. 28 | 29 | ROCSHMEM_CTX_DESTROY 30 | -------------------- 31 | 32 | .. cpp:function:: __device__ void rocshmem_wg_ctx_destroy(rocshmem_ctx_t *ctx) 33 | 34 | :param ctx: Context handle. 35 | 36 | :returns: None. 37 | 38 | **Description:** 39 | This routine destroys an rocSHMEM context. 40 | It must be called collectively by all threads in the work-group. 41 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 (SHEAP) 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:`Remote memory access routines <./api/rma>` 31 | * :doc:`Atomic memory operations <./api/amo>` 32 | * :doc:`Signaling operations <./api/sigops>` 33 | * :doc:`Collective routines <./api/coll>` 34 | * :doc:`Point-to-point synchronization routines <./api/pt2pt_sync>` 35 | * :doc:`Memory ordering routines <./api/memory_ordering>` 36 | 37 | To contribute to the documentation, refer to 38 | `Contributing to ROCm `_. 39 | 40 | You can find licensing information on the 41 | `Licensing `_ page. 42 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /docs/license.md: -------------------------------------------------------------------------------- 1 | # License 2 | 3 | ```{include} ../LICENSE.md 4 | ``` 5 | -------------------------------------------------------------------------------- /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/rma.rst 32 | title: Remote memory access routines 33 | - file: api/amo.rst 34 | title: Atomic memory operations 35 | - file: api/sigops.rst 36 | title: Signaling operations 37 | - file: api/coll.rst 38 | title: Collective routines 39 | - file: api/pt2pt_sync.rst 40 | title: Point-to-point synchronization routines 41 | - file: api/memory_ordering.rst 42 | title: Memory ordering routines 43 | 44 | - caption: About 45 | entries: 46 | - file: license.rst 47 | -------------------------------------------------------------------------------- /docs/sphinx/requirements.in: -------------------------------------------------------------------------------- 1 | rocm-docs-core==1.18.4 2 | 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /scripts/build_configs/codecov: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export CODE_COV="ON" 6 | 7 | src_path=$(dirname "$(realpath $0)") 8 | 9 | mkdir -p ipc && pushd ipc 10 | $src_path/ipc_single 11 | popd 12 | 13 | mkdir -p ro_net && pushd ro_net 14 | $src_path/ro_net 15 | popd 16 | 17 | mkdir -p ro_ipc && pushd ro_ipc 18 | $src_path/ro_ipc 19 | popd 20 | 21 | mkdir -p ./test_output 22 | export PROFRAW_DIR=./coverage-report/profraw 23 | mkdir -p $PROFRAW_DIR 24 | 25 | # Unit Tests 26 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ipc_unit-%p.profraw" ../scripts/unit_tests/driver.sh ./ipc/tests/unit_tests/rocshmem_unit_tests all 27 | 28 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ro_net-unit-%p.profraw" ../scripts/unit_tests/driver.sh ./ro_net/tests/unit_tests/rocshmem_unit_tests all 29 | 30 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ro_ipc-unit-%p.profraw" ../scripts/unit_tests/driver.sh ./ro_ipc/tests/unit_tests/rocshmem_unit_tests all 31 | 32 | # Functional Tests 33 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ipc-functional-%p.profraw" ../scripts/functional_tests/driver.sh ./ipc/tests/functional_tests/rocshmem_example_driver all ./test_output/ 34 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ro_net-functional-%p.profraw" ../scripts/functional_tests/driver.sh ./ro_net/tests/functional_tests/rocshmem_example_driver all ./test_output/ 35 | LLVM_PROFILE_FILE="$PROFRAW_DIR/ro_ipc-functional-%p.profraw" ../scripts/functional_tests/driver.sh ./ro_ipc/tests/functional_tests/rocshmem_example_driver all ./test_output/ 36 | 37 | # Coverage Report 38 | /opt/rocm/llvm/bin/llvm-profdata merge -sparse $PROFRAW_DIR/*.profraw -o ./coverage-report/rocshmem.profdata 39 | /opt/rocm/llvm/bin/llvm-cov report \ 40 | -object ./ipc/tests/unit_tests/rocshmem_unit_tests \ 41 | -object ./ipc/tests/functional_tests/rocshmem_example_driver \ 42 | -object ./ro_net/tests/unit_tests/rocshmem_unit_tests \ 43 | -object ./ro_net/tests/functional_tests/rocshmem_example_driver \ 44 | -object ./ro_ipc/tests/unit_tests/rocshmem_unit_tests \ 45 | -object ./ro_ipc/tests/functional_tests/rocshmem_example_driver \ 46 | -instr-profile=./coverage-report/rocshmem.profdata \ 47 | --ignore-filename-regex=".*test.*" 48 | 49 | /opt/rocm/llvm/bin/llvm-cov show \ 50 | -object ./ipc/tests/unit_tests/rocshmem_unit_tests \ 51 | -object ./ipc/tests/functional_tests/rocshmem_example_driver \ 52 | -object ./ro_net/tests/unit_tests/rocshmem_unit_tests \ 53 | -object ./ro_net/tests/functional_tests/rocshmem_example_driver \ 54 | -object ./ro_ipc/tests/unit_tests/rocshmem_unit_tests \ 55 | -object ./ro_ipc/tests/functional_tests/rocshmem_example_driver \ 56 | -instr-profile=./coverage-report/rocshmem.profdata \ 57 | --ignore-filename-regex=".*test.*" 58 | -format=html \ 59 | -output-dir=coverage-report 60 | cd coverage-report && python3 -m http.server 61 | 62 | -------------------------------------------------------------------------------- /scripts/build_configs/ipc_single: -------------------------------------------------------------------------------- 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 | #!/bin/bash 26 | 27 | set -e 28 | 29 | if [ -z $1 ] 30 | then 31 | install_path=~/rocshmem 32 | else 33 | install_path=$1 34 | fi 35 | 36 | src_path=$(dirname "$(realpath $0)")/../../ 37 | 38 | cmake \ 39 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 40 | -DCMAKE_BUILD_TYPE=Release \ 41 | -DCMAKE_INSTALL_PREFIX=$install_path \ 42 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 43 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 44 | -DDEBUG=OFF \ 45 | -DPROFILE=OFF \ 46 | -DUSE_RO=OFF \ 47 | -DUSE_IPC=ON \ 48 | -DUSE_COHERENT_HEAP=ON \ 49 | -DUSE_THREADS=OFF \ 50 | -DUSE_WF_COAL=OFF \ 51 | -DUSE_SINGLE_NODE=ON \ 52 | -DUSE_HOST_SIDE_HDP_FLUSH=OFF \ 53 | -DBUILD_LOCAL_GPU_TARGET_ONLY=OFF \ 54 | -DBUILD_FUNCTIONAL_TESTS=ON \ 55 | -DBUILD_UNIT_TESTS=ON \ 56 | $src_path 57 | cmake --build . --parallel 8 58 | cmake --install . 59 | -------------------------------------------------------------------------------- /scripts/build_configs/ipc_tests_only: -------------------------------------------------------------------------------- 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 | #!/bin/bash 26 | 27 | set -e 28 | 29 | if [ -z $1 ] 30 | then 31 | install_path=~/rocshmem 32 | else 33 | install_path=$1 34 | fi 35 | 36 | if [ -z $1 ] && [ -z $ROCSHMEM_HOME ] 37 | then 38 | export ROCSHMEM_HOME=/opt/rocm/ 39 | fi 40 | 41 | src_path=$(dirname "$(realpath $0)")/../../ 42 | 43 | cmake \ 44 | -DCMAKE_BUILD_TYPE=Release \ 45 | -DCMAKE_INSTALL_PREFIX=$install_path \ 46 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 47 | -DDEBUG=OFF \ 48 | -DPROFILE=OFF \ 49 | -DUSE_RO=OFF \ 50 | -DUSE_IPC=ON \ 51 | -DUSE_COHERENT_HEAP=ON \ 52 | -DUSE_THREADS=OFF \ 53 | -DUSE_WF_COAL=OFF \ 54 | -DUSE_SINGLE_NODE=ON \ 55 | -DUSE_HOST_SIDE_HDP_FLUSH=OFF \ 56 | -DBUILD_LOCAL_GPU_TARGET_ONLY=OFF \ 57 | -DBUILD_TESTS_ONLY=ON \ 58 | -DBUILD_FUNCTIONAL_TESTS=ON \ 59 | -DBUILD_EXAMPLES=ON \ 60 | -DBUILD_UNIT_TESTS=OFF \ 61 | $src_path 62 | cmake --build . --parallel 8 63 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_ipc: -------------------------------------------------------------------------------- 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 | #!/bin/bash 26 | 27 | set -e 28 | 29 | if [ -z $1 ] 30 | then 31 | install_path=~/rocshmem 32 | else 33 | install_path=$1 34 | fi 35 | 36 | src_path=$(dirname "$(realpath $0)")/../../ 37 | 38 | cmake \ 39 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 40 | -DCMAKE_BUILD_TYPE=Release \ 41 | -DCMAKE_INSTALL_PREFIX=$install_path \ 42 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 43 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 44 | -DDEBUG=OFF \ 45 | -DPROFILE=OFF \ 46 | -DUSE_IPC=ON \ 47 | -DUSE_COHERENT_HEAP=ON \ 48 | -DUSE_THREADS=OFF \ 49 | -DUSE_WF_COAL=OFF \ 50 | -DUSE_HOST_SIDE_HDP_FLUSH=OFF\ 51 | -DUSE_MANAGED_HEAP=OFF \ 52 | -DUSE_RO=ON \ 53 | -DBUILD_FUNCTIONAL_TESTS=ON \ 54 | -DBUILD_UNIT_TESTS=ON \ 55 | $src_path 56 | cmake --build . --parallel 8 57 | cmake --install . 58 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_net: -------------------------------------------------------------------------------- 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 | #!/bin/bash 26 | 27 | set -e 28 | 29 | if [ -z $1 ] 30 | then 31 | install_path=~/rocshmem 32 | else 33 | install_path=$1 34 | fi 35 | 36 | src_path=$(dirname "$(realpath $0)")/../../ 37 | 38 | cmake \ 39 | -DBUILD_CODE_COVERAGE=${CODE_COV:-OFF} \ 40 | -DCMAKE_BUILD_TYPE=Release \ 41 | -DCMAKE_INSTALL_PREFIX=$install_path \ 42 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 43 | -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ 44 | -DDEBUG=OFF \ 45 | -DPROFILE=OFF \ 46 | -DUSE_IPC=OFF \ 47 | -DUSE_COHERENT_HEAP=ON \ 48 | -DUSE_THREADS=OFF \ 49 | -DUSE_WF_COAL=OFF \ 50 | -DUSE_HOST_SIDE_HDP_FLUSH=OFF\ 51 | -DUSE_MANAGED_HEAP=OFF \ 52 | -DUSE_RO=ON \ 53 | -DBUILD_FUNCTIONAL_TESTS=ON \ 54 | -DBUILD_UNIT_TESTS=ON \ 55 | $src_path 56 | cmake --build . --parallel 8 57 | cmake --install . 58 | -------------------------------------------------------------------------------- /scripts/build_configs/ro_net_debug: -------------------------------------------------------------------------------- 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 | #!/bin/bash 26 | 27 | set -e 28 | 29 | if [ -z $1 ] 30 | then 31 | install_path=~/rocshmem 32 | else 33 | install_path=$1 34 | fi 35 | 36 | src_path=$(dirname "$(realpath $0)")/../../ 37 | 38 | cmake \ 39 | -DCMAKE_BUILD_TYPE=Debug \ 40 | -DCMAKE_INSTALL_PREFIX=$install_path \ 41 | -DCMAKE_VERBOSE_MAKEFILE=OFF \ 42 | -DDEBUG=OFF \ 43 | -DPROFILE=OFF \ 44 | -DUSE_IPC=OFF \ 45 | -DUSE_COHERENT_HEAP=ON \ 46 | -DUSE_THREADS=OFF \ 47 | -DUSE_WF_COAL=OFF \ 48 | -DUSE_HOST_SIDE_HDP_FLUSH=OFF\ 49 | -DUSE_MANAGED_HEAP=OFF \ 50 | -DUSE_RO=ON \ 51 | -DBUILD_FUNCTIONAL_TESTS=ON \ 52 | -DBUILD_UNIT_TESTS=ON \ 53 | $src_path 54 | cmake --build . --parallel 8 55 | cmake --install . 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_example_driver -t 1 -w 1 -s 32768 -a $1 -x 8 33 | test $? -eq 0 || exit 1 34 | done 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | #include 30 | 31 | #include "memory/symmetric_heap.hpp" 32 | #include "util.hpp" 33 | 34 | namespace rocshmem { 35 | 36 | const int max_nb_atomic = 4096; 37 | 38 | struct atomic_ret_t { 39 | uint64_t* atomic_base_ptr; 40 | uint32_t atomic_lkey; 41 | uint64_t atomic_counter; 42 | }; 43 | 44 | void allocate_atomic_region(atomic_ret_t** atomic_ret, int num_wg); 45 | 46 | void init_g_ret(SymmetricHeap* heap_handle, MPI_Comm thread_comm, int num_wg, 47 | char** g_ret); 48 | 49 | } // namespace rocshmem 50 | 51 | #endif // LIBRARY_SRC_ATOMIC_RETURN_HPP_ 52 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | inline const int WF_SIZE{64}; 61 | 62 | } // namespace rocshmem 63 | 64 | #endif // LIBRARY_SRC_CONSTANTS_HPP_ 65 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | #ifdef USE_RO 32 | #include "reverse_offload/context_ro_device.hpp" 33 | #include "reverse_offload/context_ro_host.hpp" 34 | #else 35 | #include "ipc/context_ipc_device.hpp" 36 | #include "ipc/context_ipc_host.hpp" 37 | #endif 38 | 39 | #endif // LIBRARY_SRC_CONTEXT_INCL_HPP_ 40 | -------------------------------------------------------------------------------- /src/fence_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_FENCE_POLICY_HPP_ 26 | #define LIBRARY_SRC_FENCE_POLICY_HPP_ 27 | 28 | #include "rocshmem/rocshmem.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | /** 33 | * @brief Controls the behavior of device code which may need to stall 34 | */ 35 | class Fence { 36 | public: 37 | /** 38 | * Secondary constructor 39 | */ 40 | __host__ __device__ Fence() = default; 41 | 42 | /** 43 | * Primary constructor 44 | * 45 | * @param[in] options interpreted as a bitfield using bitwise operations 46 | */ 47 | __host__ __device__ Fence(long option) { 48 | if (option & ROCSHMEM_CTX_NOSTORE) { 49 | flush_ = false; 50 | } 51 | } 52 | 53 | /** 54 | * @brief Wait for outstanding memory operations to complete 55 | * 56 | * This can be useful when code needs guarantees about visibility 57 | * before moving past the flush. 58 | * 59 | * @return void 60 | */ 61 | __device__ void flush() { 62 | if (flush_) { 63 | __threadfence(); 64 | } 65 | } 66 | 67 | private: 68 | /** 69 | * @brief Used to toggle flushes behavior on and off 70 | * 71 | * @note By default, flushing is enabled. 72 | */ 73 | bool flush_{true}; 74 | }; 75 | 76 | } // namespace rocshmem 77 | 78 | #endif // LIBRARY_SRC_FENCE_POLICY_HPP_ 79 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 "../backend_type.hpp" 28 | #include "backend_ipc.hpp" 29 | 30 | namespace rocshmem { 31 | 32 | IPCTeam::IPCTeam(Backend *backend, TeamInfo *team_info_parent, 33 | TeamInfo *team_info_world, int num_pes, int my_pe, 34 | MPI_Comm mpi_comm, int pool_index) 35 | : Team(backend, team_info_parent, team_info_world, num_pes, my_pe, 36 | mpi_comm) { 37 | type = BackendType::IPC_BACKEND; 38 | const IPCBackend *b = static_cast(backend); 39 | 40 | pool_index_ = pool_index; 41 | 42 | barrier_pSync = 43 | &(b->barrier_pSync_pool[pool_index * ROCSHMEM_BARRIER_SYNC_SIZE]); 44 | reduce_pSync = 45 | &(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 = 48 | &(b->alltoall_pSync_pool[pool_index * ROCSHMEM_ALLTOALL_SYNC_SIZE]); 49 | 50 | pWrk = reinterpret_cast(b->pWrk_pool) + 51 | ROCSHMEM_REDUCE_MIN_WRKDATA_SIZE * sizeof(double) * pool_index; 52 | pAta = reinterpret_cast(b->pAta_pool) + 53 | ROCSHMEM_ATA_MAX_WRKDATA_SIZE * sizeof(double) * pool_index; 54 | } 55 | 56 | IPCTeam::~IPCTeam() {} 57 | 58 | } // namespace rocshmem 59 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/memory/bin.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_MEMORY_BIN_HPP_ 26 | #define LIBRARY_SRC_MEMORY_BIN_HPP_ 27 | 28 | #include 29 | #include 30 | 31 | /** 32 | * @file bin.hpp 33 | * 34 | * @brief Simple container class 35 | * 36 | * The class wraps a stack and provides simple mutators. A different internal 37 | * container class might be preferable to a stack. 38 | */ 39 | 40 | namespace rocshmem { 41 | 42 | template 43 | class Bin { 44 | public: 45 | /** 46 | * @brief Is stack empty? 47 | * 48 | * @return A boolean denoting stack emptiness 49 | */ 50 | bool empty() { return stack_.empty(); } 51 | 52 | /** 53 | * @brief How many elements in stack? 54 | * 55 | * @return The number of elements in the stack 56 | */ 57 | size_t size() { return stack_.size(); } 58 | 59 | /** 60 | * @brief Emplace an element in stack 61 | * 62 | * @param[in] An element 63 | */ 64 | void put(T element) { stack_.emplace(element); } 65 | 66 | /** 67 | * @brief Retrieve an element from stack 68 | * 69 | * @return An element 70 | */ 71 | T get() { 72 | assert(stack_.size()); 73 | auto top = stack_.top(); 74 | stack_.pop(); 75 | return top; 76 | } 77 | 78 | private: 79 | /** 80 | * @brief Implementation container 81 | */ 82 | std::stack stack_{}; 83 | }; 84 | 85 | } // namespace rocshmem 86 | 87 | #endif // LIBRARY_SRC_MEMORY_BIN_HPP_ 88 | -------------------------------------------------------------------------------- /src/memory/heap_type.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_MEMORY_HEAP_TYPE_HPP_ 26 | #define LIBRARY_SRC_MEMORY_HEAP_TYPE_HPP_ 27 | 28 | #include "rocshmem_config.h" // NOLINT(build/include_subdir) 29 | #include "hip_allocator.hpp" 30 | 31 | /** 32 | * @file heap_type.hpp 33 | * 34 | * @brief Contains the type of heap memory used to allocate the symmetric heap 35 | * 36 | * The heap type in this file is used by other classes to select the allocation 37 | * policy for the symmetric heap. The heap type choices depend on whether 38 | * the heap is cacheable in hardware and if the heap is a managed memory type. 39 | */ 40 | 41 | namespace rocshmem { 42 | 43 | #if defined USE_MANAGED_HEAP 44 | using HEAP_T = HeapMemory; 45 | #elif defined USE_COHERENT_HEAP 46 | using HEAP_T = HeapMemory; 47 | #elif defined USE_HOST_HEAP 48 | using HEAP_T = HeapMemory; 49 | #elif defined USE_HIP_HOST_HEAP 50 | using HEAP_T = HeapMemory; 51 | #else 52 | using HEAP_T = HeapMemory; 53 | #endif 54 | 55 | } // namespace rocshmem 56 | 57 | #endif // LIBRARY_SRC_MEMORY_HEAP_TYPE_HPP_ 58 | -------------------------------------------------------------------------------- /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 | if (auto heap_size_cstr = getenv("ROCSHMEM_HEAP_SIZE")) { 33 | std::stringstream sstream(heap_size_cstr); 34 | size_t heap_size; 35 | sstream >> heap_size; 36 | heap_mem_ = HEAP_T{heap_size}; 37 | strat_ = STRAT_T{&heap_mem_}; 38 | } 39 | } 40 | 41 | void SingleHeap::malloc(void** ptr, size_t size) { 42 | strat_.alloc(reinterpret_cast(ptr), size); 43 | } 44 | 45 | __device__ void SingleHeap::malloc(void** ptr, size_t size) {} 46 | 47 | void SingleHeap::free(void* ptr) { 48 | if (!ptr) { 49 | return; 50 | } 51 | strat_.free(reinterpret_cast(ptr)); 52 | } 53 | 54 | __device__ void SingleHeap::free(void* ptr) {} 55 | 56 | void* SingleHeap::realloc(void* ptr, size_t size) { return nullptr; } 57 | 58 | void* SingleHeap::malign(size_t alignment, size_t size) { return nullptr; } 59 | 60 | char* SingleHeap::get_base_ptr() { return heap_mem_.get_ptr(); } 61 | 62 | size_t SingleHeap::get_size() { return heap_mem_.get_size(); } 63 | 64 | size_t SingleHeap::get_used() { return strat_.get_used(); } 65 | 66 | size_t SingleHeap::get_avail() { return get_size() - get_used(); } 67 | 68 | } // namespace rocshmem 69 | -------------------------------------------------------------------------------- /src/mpi_init_singleton.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_init_singleton.hpp" 26 | 27 | namespace rocshmem { 28 | 29 | MPIInitSingleton* MPIInitSingleton::instance{nullptr}; 30 | 31 | MPIInitSingleton::MPIInitSingleton() { 32 | MPI_Initialized(&pre_init_done); 33 | 34 | if (!pre_init_done) { 35 | int provided; 36 | MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); 37 | } 38 | 39 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs_); 40 | MPI_Comm_rank(MPI_COMM_WORLD, &my_rank_); 41 | } 42 | 43 | MPIInitSingleton::~MPIInitSingleton() { 44 | int finalized{0}; 45 | MPI_Finalized(&finalized); 46 | if (!finalized && !pre_init_done) { 47 | MPI_Finalize(); 48 | } 49 | } 50 | 51 | MPIInitSingleton* MPIInitSingleton::GetInstance() { 52 | if (!instance) { 53 | instance = new MPIInitSingleton(); 54 | return instance; 55 | } 56 | return instance; 57 | } 58 | 59 | int MPIInitSingleton::get_rank() { return my_rank_; } 60 | 61 | int MPIInitSingleton::get_nprocs() { return nprocs_; } 62 | 63 | } // namespace rocshmem 64 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /src/reverse_offload/queue.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_QUEUE_HPP_ 26 | #define LIBRARY_SRC_REVERSE_OFFLOAD_QUEUE_HPP_ 27 | 28 | #include "../hdp_proxy.hpp" 29 | #include "queue_proxy.hpp" 30 | #include "queue_desc_proxy.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class MPITransport; 35 | 36 | class Queue { 37 | public: 38 | Queue(); 39 | 40 | Queue(size_t max_queues, size_t queue_size); 41 | 42 | bool process(uint64_t queue_index, MPITransport* transport); 43 | 44 | uint64_t get_read_index(uint64_t queue_index); 45 | 46 | void increment_read_index(uint64_t queue_index); 47 | 48 | void flush_hdp(); 49 | 50 | void sfence_flush_hdp(); 51 | 52 | void notify(volatile char *status); 53 | 54 | uint64_t size(); 55 | 56 | __host__ __device__ queue_desc_t* descriptor(uint64_t index); 57 | 58 | queue_element_t* elements(uint64_t index); 59 | 60 | private: 61 | queue_element* next_element(uint64_t queue_index); 62 | 63 | void copy_element_to_cache(uint64_t queue_index); 64 | 65 | QueueProxyT queue_proxy_{}; 66 | 67 | QueueDescProxyT queue_desc_proxy_{}; 68 | 69 | QueueElementProxyT queue_element_cache_proxy_{}; 70 | 71 | HdpProxy hdp_proxy_{}; 72 | 73 | bool gpu_queue{false}; 74 | 75 | size_t max_queues_{}; 76 | 77 | size_t queue_size_{}; 78 | }; 79 | 80 | } // namespace rocshmem 81 | 82 | #endif // LIBRARY_SRC_REVERSE_OFFLOAD_QUEUE_HPP_ 83 | -------------------------------------------------------------------------------- /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/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 | #define MAX_ATA_BUFF_SIZE (1024 * 1024 * 128) 31 | 32 | namespace rocshmem { 33 | 34 | class Backend; 35 | 36 | class ROTeam : public Team { 37 | public: 38 | ROTeam(Backend* handle, TeamInfo* team_info_wrt_parent, 39 | TeamInfo* team_info_wrt_world, int num_pes, int my_pe, 40 | MPI_Comm team_comm); 41 | 42 | virtual ~ROTeam(); 43 | 44 | void* ata_buffer; 45 | }; 46 | 47 | } // namespace rocshmem 48 | 49 | #endif // LIBRARY_SRC_REVERSE_OFFLOAD_RO_NET_TEAM_HPP_ 50 | -------------------------------------------------------------------------------- /src/reverse_offload/team_info_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_REVERSE_OFFLOAD_TEAM_INFO_PROXY_HPP_ 26 | #define LIBRARY_SRC_REVERSE_OFFLOAD_TEAM_INFO_PROXY_HPP_ 27 | 28 | #include "../device_proxy.hpp" 29 | #include "../team.hpp" 30 | 31 | namespace rocshmem { 32 | 33 | template 34 | class TeamInfoProxy { 35 | using ProxyT = DeviceProxy; 36 | 37 | public: 38 | /* 39 | * Placement new the memory which is allocated by proxy_ 40 | */ 41 | TeamInfoProxy(Team* parent_team, int pe_start, int stride, int size, 42 | size_t num_elems = 1) : proxy_{num_elems} { 43 | new (proxy_.get()) TeamInfo(parent_team, pe_start, stride, size); 44 | } 45 | 46 | TeamInfoProxy(const TeamInfoProxy& other) = delete; 47 | 48 | TeamInfoProxy& operator=(const TeamInfoProxy& other) = delete; 49 | 50 | TeamInfoProxy(TeamInfoProxy&& other) = default; 51 | 52 | TeamInfoProxy& operator=(TeamInfoProxy&& other) = default; 53 | 54 | /* 55 | * Since placement new is called in the constructor, then 56 | * delete must be called manually. 57 | */ 58 | ~TeamInfoProxy() { proxy_.get()->~TeamInfo(); } 59 | 60 | /* 61 | * @brief Provide access to the memory referenced by the proxy 62 | */ 63 | __host__ __device__ TeamInfo* get() { return proxy_.get(); } 64 | 65 | private: 66 | /* 67 | * @brief Memory managed by the lifetime of this object 68 | */ 69 | ProxyT proxy_{}; 70 | }; 71 | 72 | using TeamInfoProxyT = TeamInfoProxy; 73 | 74 | } // namespace rocshmem 75 | 76 | #endif // LIBRARY_SRC_REVERSE_OFFLOAD_TEAM_INFO_PROXY_HPP_ 77 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | 29 | namespace rocshmem { 30 | 31 | TeamTracker::TeamTracker() { 32 | char* value{nullptr}; 33 | if ((value = getenv("ROCSHMEM_MAX_NUM_TEAMS"))) { 34 | max_num_teams_ = atoi(value); 35 | } 36 | } 37 | 38 | void TeamTracker::track(rocshmem_team_t team) { 39 | if (team == ROCSHMEM_TEAM_INVALID) { 40 | return; 41 | } 42 | teams_.push_back(team); 43 | } 44 | 45 | void TeamTracker::untrack(rocshmem_team_t team) { 46 | auto it{std::find(teams_.begin(), teams_.end(), team)}; 47 | assert(it != teams_.end()); 48 | teams_.erase(it); 49 | } 50 | 51 | } // namespace rocshmem 52 | -------------------------------------------------------------------------------- /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_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/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 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | uint64_t size) override; 44 | 45 | virtual void verifyResults(uint64_t size) override; 46 | 47 | dim3 _gridSize{}; 48 | char *_r_buf; 49 | T *_ret_val; 50 | T *_s_buf; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /tests/functional_tests/amo_extended_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_EXTENDED_TESTER_HPP_ 26 | #define _AMO_EXTENDED_TESTER_HPP_ 27 | 28 | #include "tester.hpp" 29 | 30 | /****************************************************************************** 31 | * HOST TESTER CLASS 32 | *****************************************************************************/ 33 | template 34 | class AMOExtendedTester : public Tester { 35 | public: 36 | explicit AMOExtendedTester(TesterArguments args); 37 | virtual ~AMOExtendedTester(); 38 | 39 | protected: 40 | virtual void resetBuffers(uint64_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | uint64_t size) override; 44 | 45 | virtual void verifyResults(uint64_t size) override; 46 | 47 | dim3 _gridSize{}; 48 | char *_r_buf; 49 | T *_ret_val; 50 | T *_s_buf; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | uint64_t size) override; 44 | 45 | virtual void verifyResults(uint64_t size) override; 46 | 47 | dim3 _gridSize{}; 48 | char *_r_buf; 49 | T *_ret_val; 50 | T *_s_buf; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 45 | 46 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 47 | uint64_t size) override; 48 | 49 | virtual void verifyResults(uint64_t size) override; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tests/functional_tests/empty_tester.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 "empty_tester.hpp" 26 | 27 | #include 28 | 29 | using namespace rocshmem; 30 | 31 | /****************************************************************************** 32 | * DEVICE TEST KERNEL 33 | *****************************************************************************/ 34 | __global__ void EmptyTest(int loop, int skip, long long int *start_time, 35 | long long int *end_time, int size, TestType type, 36 | ShmemContextType ctx_type) { 37 | __shared__ rocshmem_ctx_t ctx; 38 | rocshmem_wg_init(); 39 | rocshmem_wg_ctx_create(ctx_type, &ctx); 40 | 41 | rocshmem_wg_ctx_destroy(&ctx); 42 | rocshmem_wg_finalize(); 43 | } 44 | 45 | /****************************************************************************** 46 | * HOST TESTER CLASS METHODS 47 | *****************************************************************************/ 48 | EmptyTester::EmptyTester(TesterArguments args) : Tester(args) {} 49 | 50 | EmptyTester::~EmptyTester() {} 51 | 52 | void EmptyTester::resetBuffers(uint64_t size) {} 53 | 54 | void EmptyTester::launchKernel(dim3 gridSize, dim3 blockSize, int loop, 55 | uint64_t size) { 56 | size_t shared_bytes = 0; 57 | 58 | hipLaunchKernelGGL(EmptyTest, gridSize, blockSize, shared_bytes, stream, 59 | loop, args.skip, start_time, end_time, size, _type, 60 | _shmem_context); 61 | } 62 | 63 | void EmptyTester::verifyResults(uint64_t size) {} 64 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | }; 46 | 47 | #endif // ROCSHMEM_CLIENTS_FUNCTIONAL_TESTS_EMPTY_TESTER_HPP 48 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | uint64_t size) override; 49 | 50 | virtual void verifyResults(uint64_t size) override; 51 | 52 | int *r_buf; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | uint64_t size) override; 49 | 50 | virtual void verifyResults(uint64_t size) override; 51 | 52 | int *r_buf; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /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 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | 46 | char *s_buf = nullptr; 47 | char *r_buf = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | 46 | char *r_buf = nullptr; 47 | int *_available = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 41 | 42 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 43 | uint64_t size) override; 44 | 45 | virtual void verifyResults(uint64_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 | -------------------------------------------------------------------------------- /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 _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 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(uint64_t size) override; 45 | 46 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 47 | uint64_t size) override; 48 | 49 | virtual void verifyResults(uint64_t size) override; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /tests/functional_tests/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 _SYNC_TESTER_HPP_ 26 | #define _SYNC_TESTER_HPP_ 27 | 28 | #include 29 | 30 | #include "tester.hpp" 31 | 32 | using namespace rocshmem; 33 | 34 | /****************************************************************************** 35 | * HOST TESTER CLASS 36 | *****************************************************************************/ 37 | class SyncTester : public Tester { 38 | public: 39 | explicit SyncTester(TesterArguments args); 40 | virtual ~SyncTester(); 41 | 42 | protected: 43 | virtual void resetBuffers(uint64_t size) override; 44 | 45 | virtual void preLaunchKernel() override; 46 | 47 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 48 | uint64_t size) override; 49 | 50 | virtual void postLaunchKernel() override; 51 | 52 | virtual void verifyResults(uint64_t size) override; 53 | 54 | private: 55 | /** 56 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 57 | * The default value for the maximum number of teams is 40. 58 | */ 59 | int num_teams = 39; 60 | rocshmem_team_t *team_sync_world_dup; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /tests/functional_tests/team_alltoall_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_ALLTOALL_TESTER_HPP_ 26 | #define _TEAM_ALLTOALL_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 | template 39 | class TeamAlltoallTester : public Tester { 40 | public: 41 | explicit TeamAlltoallTester(TesterArguments args); 42 | virtual ~TeamAlltoallTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(uint64_t size) override; 46 | 47 | virtual void preLaunchKernel() override; 48 | 49 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 50 | uint64_t size) override; 51 | 52 | virtual void postLaunchKernel() override; 53 | 54 | virtual void verifyResults(uint64_t size) override; 55 | 56 | T1 *source_buf = nullptr; 57 | T1 *dest_buf = nullptr; 58 | 59 | private: 60 | int my_pe = 0; 61 | int n_pes = 0; 62 | 63 | /** 64 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 65 | * The default value for the maximum number of teams is 40. 66 | */ 67 | int num_teams = 39; 68 | rocshmem_team_t *team_alltoall_world_dup; 69 | }; 70 | 71 | #include "team_alltoall_tester.cpp" 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 45 | 46 | virtual void preLaunchKernel() override; 47 | 48 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 49 | uint64_t size) override; 50 | 51 | virtual void postLaunchKernel() override; 52 | 53 | virtual void verifyResults(uint64_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 | -------------------------------------------------------------------------------- /tests/functional_tests/team_broadcast_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_BROADCAST_TESTER_HPP_ 26 | #define _TEAM_BROADCAST_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 | template 39 | class TeamBroadcastTester : public Tester { 40 | public: 41 | explicit TeamBroadcastTester(TesterArguments args); 42 | virtual ~TeamBroadcastTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(uint64_t size) override; 46 | 47 | virtual void preLaunchKernel() override; 48 | 49 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 50 | uint64_t size) override; 51 | 52 | virtual void postLaunchKernel() override; 53 | 54 | virtual void verifyResults(uint64_t size) override; 55 | 56 | T1 *source_buf; 57 | T1 *dest_buf; 58 | 59 | private: 60 | int my_pe = 0; 61 | int n_pes = 0; 62 | /** 63 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 64 | * The default value for the maximum number of teams is 40. 65 | */ 66 | int num_teams = 39; 67 | rocshmem_team_t *team_bcast_world_dup; 68 | }; 69 | 70 | #include "team_broadcast_tester.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void preLaunchKernel() override; 42 | 43 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 44 | uint64_t size) override; 45 | 46 | virtual void postLaunchKernel() override; 47 | 48 | virtual void verifyResults(uint64_t size) override; 49 | 50 | char *s_buf = nullptr; 51 | char *r_buf = nullptr; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void preLaunchKernel() override; 42 | 43 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 44 | uint64_t size) override; 45 | 46 | virtual void postLaunchKernel() override; 47 | 48 | virtual void verifyResults(uint64_t size) override; 49 | 50 | char *source = nullptr; 51 | char *dest = nullptr; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /tests/functional_tests/team_fcollect_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_FCOLLECT_TESTER_HPP_ 26 | #define _TEAM_FCOLLECT_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 | template 39 | class TeamFcollectTester : public Tester { 40 | public: 41 | explicit TeamFcollectTester(TesterArguments args); 42 | virtual ~TeamFcollectTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(uint64_t size) override; 46 | 47 | virtual void preLaunchKernel() override; 48 | 49 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 50 | uint64_t size) override; 51 | 52 | virtual void postLaunchKernel() override; 53 | 54 | virtual void verifyResults(uint64_t size) override; 55 | 56 | T1 *source_buf; 57 | T1 *dest_buf; 58 | 59 | private: 60 | int my_pe = 0; 61 | int n_pes = 0; 62 | /** 63 | * This constant should equal ROCSHMEM_MAX_NUM_TEAMS - 1. 64 | * The default value for the maximum number of teams is 40. 65 | */ 66 | int num_teams = 39; 67 | rocshmem_team_t *team_fcollect_world_dup; 68 | }; 69 | 70 | #include "team_fcollect_tester.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /tests/functional_tests/team_reduction_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_REDUCTION_TESTER_HPP_ 26 | #define _TEAM_REDUCTION_TESTER_HPP_ 27 | 28 | #include 29 | #include 30 | 31 | #include "tester.hpp" 32 | 33 | /****************************************************************************** 34 | * HOST TESTER CLASS 35 | *****************************************************************************/ 36 | template 37 | class TeamReductionTester : public Tester { 38 | public: 39 | explicit TeamReductionTester( 40 | TesterArguments args, std::function f1, 41 | std::function(const T1 &, const T1 &)> f2); 42 | virtual ~TeamReductionTester(); 43 | 44 | protected: 45 | virtual void resetBuffers(uint64_t size) override; 46 | 47 | virtual void preLaunchKernel() override; 48 | 49 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 50 | uint64_t size) override; 51 | 52 | virtual void postLaunchKernel() override; 53 | 54 | virtual void verifyResults(uint64_t size) override; 55 | 56 | T1 *s_buf; 57 | T1 *r_buf; 58 | T1 *pWrk; 59 | long *pSync; 60 | 61 | private: 62 | std::function init_buf; 63 | std::function(const T1 &, const T1 &)> 64 | verify_buf; 65 | }; 66 | 67 | #include "team_reduction_tester.cpp" 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /tests/functional_tests/test_driver.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 26 | #include 27 | 28 | #include "tester.hpp" 29 | #include "tester_arguments.hpp" 30 | 31 | using namespace rocshmem; 32 | 33 | int main(int argc, char *argv[]) { 34 | /** 35 | * Setup the tester arguments. 36 | */ 37 | TesterArguments args(argc, argv); 38 | 39 | /*** 40 | * Select a GPU 41 | */ 42 | int rank = rocshmem_my_pe(); 43 | int ndevices, my_device = 0; 44 | CHECK_HIP(hipGetDeviceCount(&ndevices)); 45 | my_device = rank % ndevices; 46 | CHECK_HIP(hipSetDevice(my_device)); 47 | 48 | /** 49 | * Must initialize rocshmem to access arguments needed by the tester. 50 | */ 51 | rocshmem_init(); 52 | 53 | /** 54 | * Now grab the arguments from rocshmem. 55 | */ 56 | args.get_rocshmem_arguments(); 57 | 58 | /** 59 | * Using the arguments we just constructed, call the tester factory 60 | * method to get the tester (specified by the arguments). 61 | */ 62 | std::vector tests = Tester::create(args); 63 | 64 | /** 65 | * Run the tests 66 | */ 67 | for (auto test : tests) { 68 | test->execute(); 69 | 70 | /** 71 | * The tester factory method news the tester to create it so we clean 72 | * up the memory here. 73 | */ 74 | delete test; 75 | } 76 | 77 | /** 78 | * The rocshmem library needs to be cleaned up with this call. It pairs 79 | * with the init function above. 80 | */ 81 | rocshmem_finalize(); 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /tests/functional_tests/tester_arguments.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 _TESTER_ARGUMENTS_HPP_ 26 | #define _TESTER_ARGUMENTS_HPP_ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class TesterArguments { 35 | public: 36 | TesterArguments(int argc, char *argv[]); 37 | 38 | /** 39 | * Initialize rocshmem members 40 | * Valid after rocshmem_init function called. 41 | */ 42 | void get_rocshmem_arguments(); 43 | 44 | private: 45 | /** 46 | * Output method which displays available command line options 47 | */ 48 | static void show_usage(std::string executable_name); 49 | 50 | public: 51 | /** 52 | * Arguments obtained from command line 53 | */ 54 | unsigned num_wgs = 1; 55 | unsigned num_threads = 1; 56 | unsigned algorithm = 0; 57 | uint64_t min_msg_size = 1; 58 | uint64_t max_msg_size = 1 << 20; 59 | unsigned wg_size = 64; 60 | unsigned thread_access = 64; 61 | unsigned coal_coef = 64; 62 | unsigned op_type = 0; 63 | unsigned shmem_context = rocshmem::ROCSHMEM_CTX_WG_PRIVATE; 64 | 65 | /** 66 | * Arguments obtained from rocshmem 67 | */ 68 | int numprocs = INT_MAX; 69 | int myid = INT_MAX; 70 | 71 | /** 72 | * Defaults tester values 73 | */ 74 | int loop = 10; 75 | int skip = 10; 76 | int loop_large = 10; 77 | uint64_t large_message_size = 32768; 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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(uint64_t size) override; 40 | 41 | virtual void launchKernel(dim3 gridSize, dim3 blockSize, int loop, 42 | uint64_t size) override; 43 | 44 | virtual void verifyResults(uint64_t size) override; 45 | 46 | char *source = nullptr; 47 | char *dest = nullptr; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | 30 | #include 31 | #include 32 | 33 | #include "../src/containers/free_list_impl.hpp" 34 | #include "gtest/gtest.h" 35 | #include "../src/memory/hip_allocator.hpp" 36 | 37 | namespace rocshmem { 38 | 39 | template 40 | class FreeListTestFixture : public ::testing::Test { 41 | public: 42 | FreeListTestFixture() : h_input(num_elements) { 43 | std::iota(h_input.begin(), h_input.end(), T{1}); 44 | d_input = h_input; 45 | free_list = list_proxy.get(); 46 | } 47 | 48 | protected: 49 | void SetUp() override { 50 | free_list->push_back_range(h_input.begin(), h_input.end()); 51 | } 52 | 53 | using T = ValueType; 54 | using Allocator = HIPAllocator; 55 | const std::size_t num_elements{32}; 56 | std::vector h_input{}; 57 | thrust::device_vector d_input{}; 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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /tests/unit_tests/mpi_init_singleton_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_init_singleton_gtest.hpp" 26 | 27 | using namespace rocshmem; 28 | 29 | TEST_F(MPIInitSingletonTestFixture, library_initialize_destroy) {} 30 | 31 | TEST_F(MPIInitSingletonTestFixture, rank) { 32 | ASSERT_NO_FATAL_FAILURE(s_ptr_->get_rank()); 33 | } 34 | 35 | TEST_F(MPIInitSingletonTestFixture, nprocs) { 36 | ASSERT_EQ(s_ptr_->get_nprocs(), 4); 37 | } 38 | -------------------------------------------------------------------------------- /tests/unit_tests/mpi_init_singleton_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_INIT_SINGLETON_GTEST_HPP 26 | #define ROCSHMEM_MPI_INIT_SINGLETON_GTEST_HPP 27 | 28 | #include "gtest/gtest.h" 29 | 30 | #include "../src/mpi_init_singleton.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class MPIInitSingletonTestFixture : public ::testing::Test 35 | { 36 | public: 37 | MPIInitSingletonTestFixture() { 38 | s_ptr_ = s_ptr_->GetInstance(); 39 | } 40 | 41 | protected: 42 | /** 43 | * @brief A singleton object used to initialize MPI 44 | */ 45 | MPIInitSingleton* s_ptr_ {nullptr}; 46 | }; 47 | 48 | } // namespace rocshmem 49 | 50 | #endif // ROCSHMEM_MPI_INIT_SINGLETON_GTEST_HPP 51 | -------------------------------------------------------------------------------- /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.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/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 "../src/memory/heap_memory.hpp" 31 | #include "../src/memory/hip_allocator.hpp" 32 | #include "../src/memory/remote_heap_info.hpp" 33 | 34 | namespace rocshmem { 35 | 36 | class RemoteHeapInfoTestFixture : 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 RemoteHeapInfo with MPI 45 | */ 46 | using MPI_T = RemoteHeapInfo; 47 | 48 | protected: 49 | /** 50 | * @brief Heap memory object 51 | */ 52 | HEAP_T heap_mem_ {}; 53 | 54 | /** 55 | * @brief Remote heap info with MPI Communicator 56 | */ 57 | MPI_T mpi_ {heap_mem_.get_ptr(), 58 | heap_mem_.get_size()}; 59 | }; 60 | 61 | } // namespace rocshmem 62 | 63 | #endif // ROCSHMEM_REMOTE_HEAP_INFO_GTEST_HPP 64 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | void *window_base_addr{nullptr}; 42 | int flag{0}; 43 | MPI_Win_get_attr(win_info_ptr->get_win(), MPI_WIN_BASE, &window_base_addr, 44 | &flag); 45 | ASSERT_NE(0, flag); 46 | ASSERT_NE(nullptr, window_base_addr); 47 | } 48 | 49 | TEST_F(SymmetricHeapTestFixture, heap_bases) { 50 | auto heap_bases{symmetric_heap_.get_heap_bases()}; 51 | for (const auto &base : heap_bases) { 52 | ASSERT_NE(nullptr, base); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /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 "gtest/gtest.h" 29 | 30 | #include "../src/memory/symmetric_heap.hpp" 31 | 32 | namespace rocshmem { 33 | 34 | class SymmetricHeapTestFixture : public ::testing::Test 35 | { 36 | protected: 37 | /** 38 | * @brief Symmetric heap object 39 | */ 40 | SymmetricHeap symmetric_heap_ {}; 41 | }; 42 | 43 | } // namespace rocshmem 44 | 45 | #endif // ROCSHMEM_SYMMETRIC_HEAP_GTEST_HPP 46 | -------------------------------------------------------------------------------- /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 | TEST_F(WavefrontSizeTestFixture, constant_matches_runtime) { 32 | int device_count = 0; 33 | hipDeviceProp_t prop; 34 | 35 | CHECK_HIP(hipGetDeviceCount(&device_count)); 36 | ASSERT_GT(device_count, 0); 37 | 38 | for (int i = 0; i < device_count; i++) { 39 | CHECK_HIP(hipGetDeviceProperties(&prop, i)); 40 | ASSERT_EQ(WF_SIZE, prop.warpSize); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /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 | 30 | namespace rocshmem { 31 | 32 | class WavefrontSizeTestFixture : public ::testing::Test { }; 33 | 34 | } // namespace rocshmem 35 | 36 | #endif // ROCSHMEM_WAVEFRONT_SIZE_GTEST_HPP 37 | --------------------------------------------------------------------------------