2
0

Add CMake file for examples folder

[ROCm/rocshmem commit: 1f3b242e12]
Este cometimento está contido em:
avinashkethineedi
2024-11-12 21:46:38 +00:00
ascendente bae2b2aece
cometimento 6bfcb173ee
6 ficheiros modificados com 114 adições e 36 eliminações
+1
Ver ficheiro
@@ -199,6 +199,7 @@ set_target_properties(
add_subdirectory(src)
add_subdirectory(docs)
add_subdirectory(tests)
add_subdirectory(examples)
###############################################################################
# HIP
+53
Ver ficheiro
@@ -0,0 +1,53 @@
###############################################################################
# Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
###############################################################################
###############################################################################
# SOURCES
###############################################################################
set(EXAMPLE_SOURCES
rocshmem_allreduce_test.cc
rocshmem_alltoall_test.cc
rocshmem_broadcast_test.cc
rocshmem_getmem_test.cc
)
foreach(SOURCE_FILE IN LISTS EXAMPLE_SOURCES)
get_filename_component(EXECUTABLE_NAME ${SOURCE_FILE} NAME_WE)
add_executable(${EXECUTABLE_NAME} ${SOURCE_FILE})
target_include_directories(
${EXECUTABLE_NAME}
PRIVATE
rocshmem::rocshmem
)
target_link_libraries(
${EXECUTABLE_NAME}
PRIVATE
rocshmem::rocshmem
-fgpu-rdc
# xnack allows address translation fault recovery
# required option for managed heap configs
# -mxnack
)
endforeach()
+15 -9
Ver ficheiro
@@ -1,19 +1,23 @@
/*
** hipcc -c -fgpu-rdc -x hip rocshmem_allreduce_test.cc -I/opt/rocm/include
** -I$ROCHSMEM_INSTALL_DIR/include -I$OPENMPI_UCX_INSTALL_DIR/include/
** hipcc -fgpu-rdc --hip-link rocshmem_allreduce_test.o -o rocshmem_allreduce_test
** $ROCHSMEM_INSTALL_DIR/lib/librocshmem.a $OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so
** -L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
**
** ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_allreduce_test
hipcc -c -fgpu-rdc -x hip rocshmem_allreduce_test.cc \
-I/opt/rocm/include \
-I$ROCSHMEM_SRC_DIR/include \
-I$ROCHSMEM_INSTALL_DIR/include \
-I$OPENMPI_UCX_INSTALL_DIR/include/
hipcc -fgpu-rdc --hip-link rocshmem_allreduce_test.o -o rocshmem_allreduce_test \
$ROCHSMEM_INSTALL_DIR/lib/librocshmem.a \
$OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so \
-L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_allreduce_test
*/
#include <iostream>
#define __HIP_PLATFORM_AMD__
#include <hip/hip_runtime_api.h>
#include <hip/hip_runtime.h>
#include <roc_shmem.hpp>
#include <roc_shmem/roc_shmem.hpp>
#define CHECK_HIP(condition) { \
hipError_t error = condition; \
@@ -92,6 +96,8 @@ int main (int argc, char **argv)
int *dest = (int *)roc_shmem_malloc(nelem * sizeof(int));
if (NULL == source || NULL == dest) {
std::cout << "Error allocating memory from symmetric heap" << std::endl;
std::cout << "source: " << source << ", dest: " << dest << ", size: "
<< sizeof(int) * nelem << std::endl;
roc_shmem_global_exit(1);
}
+15 -9
Ver ficheiro
@@ -1,19 +1,23 @@
/*
** hipcc -c -fgpu-rdc -x hip rocshmem_alltoall_test.cc -I/opt/rocm/include
** -I$ROCHSMEM_INSTALL_DIR/include -I$OPENMPI_UCX_INSTALL_DIR/include/
** hipcc -fgpu-rdc --hip-link rocshmem_alltoall_test.o -o rocshmem_alltoall_test
** $ROCHSMEM_INSTALL_DIR/lib/librocshmem.a $OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so
** -L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
**
** ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_allreduce_test
hipcc -c -fgpu-rdc -x hip rocshmem_alltoall_test.cc \
-I/opt/rocm/include \
-I$ROCSHMEM_SRC_DIR/include \
-I$ROCHSMEM_INSTALL_DIR/include \
-I$OPENMPI_UCX_INSTALL_DIR/include/
hipcc -fgpu-rdc --hip-link rocshmem_alltoall_test.o -o rocshmem_alltoall_test \
$ROCHSMEM_INSTALL_DIR/lib/librocshmem.a \
$OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so \
-L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_alltoall_test
*/
#include <iostream>
#define __HIP_PLATFORM_AMD__
#include <hip/hip_runtime_api.h>
#include <hip/hip_runtime.h>
#include <roc_shmem.hpp>
#include <roc_shmem/roc_shmem.hpp>
#define CHECK_HIP(condition) { \
hipError_t error = condition; \
@@ -97,6 +101,8 @@ int main (int argc, char **argv)
int *dest = (int *)roc_shmem_malloc(nelem * npes * sizeof(int));
if (NULL == source || NULL == dest) {
std::cout << "Error allocating memory from symmetric heap" << std::endl;
std::cout << "source: " << source << ", dest: " << dest << ", size: "
<< sizeof(int) * nelem * npes << std::endl;
roc_shmem_global_exit(1);
}
+15 -9
Ver ficheiro
@@ -1,19 +1,23 @@
/*
** hipcc -c -fgpu-rdc -x hip rocshmem_broadcast_test.cc -I/opt/rocm/include
** -I$ROCHSMEM_INSTALL_DIR/include -I$OPENMPI_UCX_INSTALL_DIR/include/
** hipcc -fgpu-rdc --hip-link rocshmem_broadcast_test.o -o rocshmem_broadcast_test
** $ROCHSMEM_INSTALL_DIR/lib/librocshmem.a $OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so
** -L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
**
** ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_broadcast_test
hipcc -c -fgpu-rdc -x hip rocshmem_broadcast_test.cc \
-I/opt/rocm/include \
-I$ROCSHMEM_SRC_DIR/include \
-I$ROCHSMEM_INSTALL_DIR/include \
-I$OPENMPI_UCX_INSTALL_DIR/include/
hipcc -fgpu-rdc --hip-link rocshmem_broadcast_test.o -o rocshmem_broadcast_test \
$ROCHSMEM_INSTALL_DIR/lib/librocshmem.a \
$OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so \
-L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 8 ./rocshmem_broadcast_test
*/
#include <iostream>
#define __HIP_PLATFORM_AMD__
#include <hip/hip_runtime_api.h>
#include <hip/hip_runtime.h>
#include <roc_shmem.hpp>
#include <roc_shmem/roc_shmem.hpp>
#define CHECK_HIP(condition) { \
hipError_t error = condition; \
@@ -90,6 +94,8 @@ int main(int argc, char **argv)
int *dest = (int *)roc_shmem_malloc(nelem * sizeof(int));
if (NULL == source || NULL == dest) {
std::cout << "Error allocating memory from symmetric heap" << std::endl;
std::cout << "source: " << source << ", dest: " << dest << ", size: "
<< sizeof(int) * nelem << std::endl;
roc_shmem_global_exit(1);
}
+15 -9
Ver ficheiro
@@ -1,19 +1,23 @@
/*
** hipcc -c -fgpu-rdc -x hip rocshmem_getmem_test.cc -I/opt/rocm/include
** -I$ROCHSMEM_INSTALL_DIR/include -I$OPENMPI_UCX_INSTALL_DIR/include/
** hipcc -fgpu-rdc --hip-link rocshmem_getmem_test.o -o rocshmem_getmem_test
** $ROCHSMEM_INSTALL_DIR/lib/librocshmem.a $OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so
** -L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
**
** ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 2 ./rocshmem_getmem_test
hipcc -c -fgpu-rdc -x hip rocshmem_getmem_test.cc \
-I/opt/rocm/include \
-I$ROCSHMEM_SRC_DIR/include \
-I$ROCHSMEM_INSTALL_DIR/include \
-I$OPENMPI_UCX_INSTALL_DIR/include/
hipcc -fgpu-rdc --hip-link rocshmem_getmem_test.o -o rocshmem_getmem_test \
$ROCHSMEM_INSTALL_DIR/lib/librocshmem.a \
$OPENMPI_UCX_INSTALL_DIR/lib/libmpi.so \
-L/opt/rocm/lib -lamdhip64 -lhsa-runtime64
ROC_SHMEM_MAX_NUM_CONTEXTS=2 mpirun -np 2 ./rocshmem_getmem_test
*/
#include <iostream>
#define __HIP_PLATFORM_AMD__
#include <hip/hip_runtime_api.h>
#include <hip/hip_runtime.h>
#include <roc_shmem.hpp>
#include <roc_shmem/roc_shmem.hpp>
#define CHECK_HIP(condition) { \
hipError_t error = condition; \
@@ -62,6 +66,8 @@ int main (int argc, char **argv)
int *dst = (int *)roc_shmem_malloc(nelem * sizeof(int));
if (NULL == src || NULL == dst) {
std::cout << "Error allocating memory from symmetric heap" << std::endl;
std::cout << "source: " << src << ", dest: " << dst << ", size: "
<< sizeof(int) * nelem << std::endl;
roc_shmem_global_exit(1);
}