okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ad33b8074
main
1//==--------------- shmem_utils.hpp ---------------*- C++ -*----------------==// 2// 3// Copyright (C) Intel Corporation 4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5// See https://llvm.org/LICENSE.txt for license information. 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef __DPCT_SHMEM_UTILS_HPP__ 10#define __DPCT_SHMEM_UTILS_HPP__ 11 12namespace dpct::shmemx { 13 14enum flags {RUNTIME_MPI = 1 <<1 ,RUNTIME_OPENSHMEM = 1 <<2 }; 15 16/// Initialize Intel SHMEM library based on exisiting communicator 17/// \param [in] runtime_flags specify the underlying communicator like MPI/ 18/// OpenSHMEM to initialize iSHMEM for launcher agnostic bootstrapping 19/// \param [in] attr Additional attributes for initializing the iSHMEM library. 20void init_attr (unsigned runtime_flags ,ishmemx_attr_t * attr ) { 21if (runtime_flags == 0 ) { 22// if no runtime flags are present, initialize iSHMEM normally 23ishmem_init (); 24 }else { 25unsigned ishmem_runtime_flags = 0 ; 26 27if (runtime_flags & RUNTIME_MPI ) 28ishmem_runtime_flags |=ISHMEMX_RUNTIME_MPI ; 29if (runtime_flags & RUNTIME_OPENSHMEM ) 30ishmem_runtime_flags |=ISHMEMX_RUNTIME_OPENSHMEM ; 31 32attr -> runtime = static_cast < ishmemx_runtime_type_t > (ishmem_runtime_flags ); 33ishmemx_init_attr (attr ); 34 } 35} 36 37/// Update signal address with signal using signal operation 38/// \param [out] sig_addr Symmetric address of the signal data object to be 39/// updated on the remote PE. 40/// \param [in] signal Unsigned 64-bit value that is used for updating the 41/// remote sig_addr signal data object. 42/// \param [in] sig_op Operator used to update signal data object 43/// \param [in] pe Processing element 44void signal_op (uint64_t * sig_addr ,uint64_t signal ,int sig_op ,int pe ) { 45if (sig_op == ISHMEM_SIGNAL_SET ) { 46ishmemx_signal_set (sig_addr ,signal ,pe ); 47 }else if (sig_op == ISHMEM_SIGNAL_ADD ) { 48ishmemx_signal_add (sig_addr ,signal ,pe ); 49 }else { 50throw std::runtime_error ("Unsupported signal operator!" ); 51 } 52} 53 54}// namespace dpct::shmemx 55 56#endif // __DPCT_SHMEM_UTILS_HPP__