Skip to content

Add the possibility to use openmp target to offload from sx-aurora to the host. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set(ENABLE_LIBOMPTARGET ON)
# Since the device plugins are only supported on Linux anyway,
# there is no point in trying to compile libomptarget on other OSes.
# Disable libomptarget on VE also since it doesn't work at the moment.
if (APPLE OR WIN32 OR ("${LIBOMP_ARCH}" STREQUAL "ve") OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP14_FLAG)
set(ENABLE_LIBOMPTARGET OFF)
endif()

Expand Down
176 changes: 167 additions & 9 deletions openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
# components of libomptarget. These are the dependencies we have:
#
# libelf : required by some targets to handle the ELF files at runtime.
# libffi : required to launch target kernels given function and argument
# libffi : required to launch target kernels given function and argument
# pointers.
# CUDA : required to control offloading to NVIDIA GPUs.
# VEOS : required to control offloading to NEC Aurora.
# VHCALL : required to control offloading from NEC Aurora to the host.
# VEPSEUDO : required to control offloading from NEC Aurora to the host.

include (FindPackageHandleStandardArgs)

Expand Down Expand Up @@ -46,18 +49,18 @@ find_library (
/sw/lib
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

set(LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS ${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
find_package_handle_standard_args(
LIBOMPTARGET_DEP_LIBELF
LIBOMPTARGET_DEP_LIBELF
DEFAULT_MSG
LIBOMPTARGET_DEP_LIBELF_LIBRARIES
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS)

mark_as_advanced(
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS
LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS
LIBOMPTARGET_DEP_LIBELF_LIBRARIES)

################################################################################
# Looking for libffi...
################################################################################
Expand Down Expand Up @@ -99,15 +102,15 @@ endif()

set(LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS ${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
find_package_handle_standard_args(
LIBOMPTARGET_DEP_LIBFFI
LIBOMPTARGET_DEP_LIBFFI
DEFAULT_MSG
LIBOMPTARGET_DEP_LIBFFI_LIBRARIES
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS)

mark_as_advanced(
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS
LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIRS
LIBOMPTARGET_DEP_LIBFFI_LIBRARIES)

################################################################################
# Looking for CUDA...
################################################################################
Expand All @@ -125,7 +128,7 @@ endif(NOT "${LIBOMP_ARCH}" STREQUAL "ve")
set(LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIRS})

mark_as_advanced(
LIBOMPTARGET_DEP_CUDA_FOUND
LIBOMPTARGET_DEP_CUDA_FOUND
LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS)

################################################################################
Expand Down Expand Up @@ -166,6 +169,161 @@ find_package_handle_standard_args(

mark_as_advanced(LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES)

################################################################################
# Looking for VEO...
################################################################################

find_path (
LIBOMPTARGET_DEP_VEO_INCLUDE_DIR
NAMES
ve_offload.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
/opt/nec/ve/veos/include
ENV CPATH
PATH_SUFFIXES
libveo)

find_library (
LIBOMPTARGET_DEP_VEO_LIBRARIES
NAMES
veo
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
/opt/nec/ve/veos/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

find_library(
LIBOMPTARGET_DEP_VEOSINFO_LIBRARIES
NAMES
veosinfo
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
/opt/nec/ve/veos/lib64
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

set(LIBOMPTARGET_DEP_VEO_INCLUDE_DIRS ${LIBOMPTARGET_DEP_VEO_INCLUDE_DIR})
find_package_handle_standard_args(
LIBOMPTARGET_DEP_VEO
DEFAULT_MSG
LIBOMPTARGET_DEP_VEO_LIBRARIES
LIBOMPTARGET_DEP_VEOSINFO_LIBRARIES
LIBOMPTARGET_DEP_VEO_INCLUDE_DIRS)

mark_as_advanced(
LIBOMPTARGET_DEP_VEO_FOUND
LIBOMPTARGET_DEP_VEO_INCLUDE_DIRS)

################################################################################
# Looking for VHCALL
################################################################################
find_path (
LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIR
NAMES
libvhcall.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
/opt/nec/ve/include
ENV CPATH
PATH_SUFFIXES
libvhcall) # TODO is this neccessary?

# Needed on vh side
find_path (
LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIR
NAMES
libvepseudo.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
/opt/nec/ve/include
/opt/nec/ve/veos/include
ENV CPATH
PATH_SUFFIXES
libvhcall) # TODO is this neccessary?

find_library (
LIBOMPTARGET_DEP_VHCALL_LIBRARIES
NAMES
sysve
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
/opt/nec/ve/lib
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

set(LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIRS ${LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIR})
find_package_handle_standard_args(
LIBOMPTARGET_DEP_VHCALL
DEFAULT_MSG
LIBOMPTARGET_DEP_VHCALL_LIBRARIES
LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIRS)

mark_as_advanced(
LIBOMPTARGET_DEP_VHCALL_FOUND
LIBOMPTARGET_DEP_VHCALL_INCLUDE_DIRS)

################################################################################
# Looking for VEPSEUDO
################################################################################

find_path (
LIBOMPTARGET_DEP_VEPSEUDO_INCLUDE_DIR
NAMES
libvepseudo.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
/opt/nec/ve/veos/include
ENV CPATH
PATH_SUFFIXES
libvhcall) # TODO is this neccessary?

find_library (
LIBOMPTARGET_DEP_VEPSEUDO_LIBRARIES
NAMES
vepseudo
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
/opt/nec/ve/veos/lib
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

set(LIBOMPTARGET_DEP_VEPSEUDO_INCLUDE_DIRS ${LIBOMPTARGET_DEP_VEPSEUDO_INCLUDE_DIR})
find_package_handle_standard_args(
LIBOMPTARGET_DEP_VEPSEUDO
DEFAULT_MSG
LIBOMPTARGET_DEP_VEPSEUDO_LIBRARIES
LIBOMPTARGET_DEP_VEPSEUDO_INCLUDE_DIRS)

mark_as_advanced(
LIBOMPTARGET_DEP_VEPSEUDO_FOUND
LIBOMPTARGET_DEP_VEPSEUDO_INCLUDE_DIRS)

################################################################################
# Looking for CUDA libdevice subdirectory
#
Expand Down
5 changes: 4 additions & 1 deletion openmp/libomptarget/deviceRTLs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
#
##===----------------------------------------------------------------------===##

add_subdirectory(nvptx)
# Offloading from a nec sx aurora device to a nvidia device makes no sense
if(NOT "${LIBOMP_ARCH}" STREQUAL "ve")
add_subdirectory(nvptx)
endif()
45 changes: 25 additions & 20 deletions openmp/libomptarget/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
##===----------------------------------------------------------------------===##
#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#
##===----------------------------------------------------------------------===##
#
# Build plugins for the user system if available.
Expand All @@ -19,41 +19,41 @@ macro(build_generic_elf64 tmachine tmachine_name tmachine_libname tmachine_tripl
if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
if(LIBOMPTARGET_DEP_LIBELF_FOUND)
if(LIBOMPTARGET_DEP_LIBFFI_FOUND)

libomptarget_say("Building ${tmachine_name} offloading plugin.")

include_directories(${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR})
include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})

# Define macro to be used as prefix of the runtime messages for this target.
add_definitions("-DTARGET_NAME=${tmachine_name}")

# Define macro with the ELF ID for this target.
add_definitions("-DTARGET_ELF_ID=${elf_machine_id}")
add_library("omptarget.rtl.${tmachine_libname}" SHARED

add_library("omptarget.rtl.${tmachine_libname}" SHARED
${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp)

# Install plugin under the lib destination folder.
install(TARGETS "omptarget.rtl.${tmachine_libname}"
install(TARGETS "omptarget.rtl.${tmachine_libname}"
LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")

target_link_libraries(
"omptarget.rtl.${tmachine_libname}"
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
dl
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")

list(APPEND LIBOMPTARGET_TESTED_PLUGINS
"omptarget.rtl.${tmachine_libname}")

# Report to the parent scope that we are building a plugin.
set(LIBOMPTARGET_SYSTEM_TARGETS
set(LIBOMPTARGET_SYSTEM_TARGETS
"${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple}" PARENT_SCOPE)
set(LIBOMPTARGET_TESTED_PLUGINS
"${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)

else(LIBOMPTARGET_DEP_LIBFFI_FOUND)
libomptarget_say("Not building ${tmachine_name} offloading plugin: libffi dependency not found.")
endif(LIBOMPTARGET_DEP_LIBFFI_FOUND)
Expand All @@ -65,11 +65,16 @@ else()
endif()
endmacro()

add_subdirectory(aarch64)
add_subdirectory(cuda)
add_subdirectory(ppc64)
add_subdirectory(ppc64le)
add_subdirectory(x86_64)
# Offloading to these targets from a nec sx-aurora device makes no sense and is thus disabled.
if(NOT "${LIBOMP_ARCH}" STREQUAL "ve")
add_subdirectory(aarch64)
add_subdirectory(cuda)
add_subdirectory(ppc64)
add_subdirectory(ppc64le)
add_subdirectory(ve)
add_subdirectory(x86_64)
endif()
add_subdirectory(vh)

# Make sure the parent scope can see the plugins that will be created.
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE)
Expand Down
49 changes: 49 additions & 0 deletions openmp/libomptarget/plugins/ve/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
##===----------------------------------------------------------------------===##
#
# Build a plugin for a NEC Aurora machine if available. (Can also run on host)
#
##===----------------------------------------------------------------------===##


if(${LIBOMPTARGET_DEP_VEO_FOUND})
libomptarget_say("Building SX-Aurora VE offloading plugin.")
set(additional_libs "")
set(additional_libs ${LIBOMPTARGET_DEP_VEO_LIBRARIES}
${LIBOMPTARGET_DEP_VEOSINFO_LIBRARIES}
${additional_libs})

set(tmachine_name "ve")
set(tmachine_libname "ve")
set(tmachine_triple "ve-unknown-linux-unknown")
set(elf_machine_id 251)

include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIR})
include_directories(${LIBOMPTARGET_DEP_VEO_INCLUDE_DIR})


# Define macro to be used as prefix of the runtime messages for this target.
add_definitions("-DTARGET_NAME=${tmachine_name}")

# Define macro with the ELF ID for this target.
add_definitions("-DTARGET_ELF_ID=${elf_machine_id}")

add_library("omptarget.rtl.${tmachine_libname}" SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/rtl.cpp)

# Install plugin under the lib destination folder.
install(TARGETS "omptarget.rtl.${tmachine_libname}"
LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX})

target_link_libraries(
"omptarget.rtl.${tmachine_libname}"
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
${additional_libs}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs")

# Report to the parent scope that we are building a plugin.
set(LIBOMPTARGET_SYSTEM_TARGETS
"${LIBOMPTARGET_SYSTEM_TARGETS} ${tmachine_triple}" PARENT_SCOPE)
else()
libomptarget_say("Not building ve plugin: libveo or libveosinfo not found.")
endif()
Loading