Hello all,
I am trying to compile a SYCL project using the below provided Makefile. The machine contains both an INTEL and NVIDIA GPUs and for AOT compilation I use the -fsycl-targets flags.
Here is the sycl-ls output:
[opencl:acc:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device 1.2 [2023.16.7.0.21_160000]
[opencl:cpu:1] Intel(R) OpenCL, Genuine Intel(R) CPU 0000%@ 3.0 [2023.16.7.0.21_160000]
[opencl:cpu:2] Intel(R) OpenCL, Genuine Intel(R) CPU 0000%@ 3.0 [2023.16.12.0.12_195853.xmain-hotfix]
[opencl:gpu:3] Intel(R) OpenCL Graphics, Intel(R) Data Center GPU Max 1100 3.0 [23.43.27642.40]
[opencl:acc:4] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device 1.2 [2023.16.12.0.12_195853.xmain-hotfix]
[ext_oneapi_cuda:gpu:0] NVIDIA CUDA BACKEND, NVIDIA A100-PCIE-40GB 8.8 [CUDA 12.4]
[ext_oneapi_cuda:gpu:1] NVIDIA CUDA BACKEND, NVIDIA A100-PCIE-40GB 8.8 [CUDA 12.4]
Using -fsycl-targets=spir64,nvptx64-nvidia-cuda
the compiler throws the following error
icpx -fsycl -fsycl-targets=spir64,nvptx64-nvidia-cuda -Wno-unknown-cuda-version -DMKL_ILP64 -qmkl=parallel -qtbb -O3 -Iinclude -c src/bandwidth_reduction.cpp -o obj/bandwidth_reduction.o
/usr/people/shared/tools/centos/7/intel_oneapi/2023.2.1/compiler/2023.2.1/linux/bin-llvm/clang-offload-bundler: error: Opaque pointers are only supported in -opaque-pointers mode (Producer: 'Intel.oneAPI.DPCPP.Compiler_2023.2.0' Reader: 'Intel.oneAPI.DPCPP.Compiler_2023.2.0')
icpx: error: clang-offload-bundler command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:63: obj/bandwidth_reduction.o] Error 1
Using -fsycl-targets=nvptx64-nvidia-cuda,spir64
, the compilation is successful but the program fails while running on the Intel GPU with the following error (It runs fine on the NVIDIA GPU):
Device Name: Intel(R) Data Center GPU Max 1100
Device Set || Name: Intel(R) Data Center GPU Max 1100
terminate called after throwing an instance of 'sycl::_V1::exception'
what(): Native API failed. Native API returns: -46 (PI_ERROR_INVALID_KERNEL_NAME)
Aborted (core dumped)
Using -fsycl-targets=spir64
, the program compiles and runs on the Intel GPU just fine.
Could someone please explain to me what I am missing here ?
Here is the Makefile:
# Makefile for SYCL project
#The Makefile should be present in the directory which contains the source files in "src" directory and include files (.h) in "include" directory
# Compiler
ICPX := icpx
# Common Compiler flags
ICPXFLAGS := -fsycl -fsycl-targets=nvptx64-nvidia-cuda,spir64 -Wno-unknown-cuda-version -DMKL_ILP64 -qmkl=parallel -qtbb
LINKFLAGS := -fsycl -fsycl-targets=nvptx64-nvidia-cuda,spir64 -Wno-unknown-cuda-version -qmkl=parallel -qtbb
# Debug flags
ICPXFLAGS_DEBUG := -g -O0
# Release flags
ICPXFLAGS_RELEASE := -O3
# GPU architecture
# Directories
SRC_DIR := src
INCLUDE_DIR := include
OBJ_DIR := obj
BIN_DIR := bin
# Source files
CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
H_FILES := $(wildcard $(INCLUDE_DIR)/*.h)
# Object files
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(CPP_FILES))
# Target executables
TARGET_DEBUG := $(BIN_DIR)/ex_sycl_debug.exe
TARGET_RELEASE := $(BIN_DIR)/ex_sycl_release.exe
# Main target
all: debug
# Create the necessary directories
$(OBJ_DIR) $(BIN_DIR):
mkdir -p $@
debug: ICPXFLAGS += $(ICPXFLAGS_DEBUG)
debug: LINKFLAGS += $(ICPXFLAGS_DEBUG)
debug: $(OBJ_DIR) $(BIN_DIR) $(TARGET_DEBUG)
# Rule for C++ files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(H_FILES)
$(ICPX) $(ICPXFLAGS) $(ARCH) -I$(INCLUDE_DIR) -c $< -o $@
# Linking step
$(TARGET_DEBUG): $(OBJ_FILES)
$(ICPX) $(ICPXFLAGS) $(LINKFLAGS) $(ARCH) $^ -o $@
release: ICPXFLAGS += $(ICPXFLAGS_RELEASE)
release: LINKFALGS += $(ICPXFLAGS_RELEASE)
release: $(OBJ_DIR) $(BIN_DIR) $(TARGET_RELEASE)
# Rule for C++ files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(H_FILES)
$(ICPX) $(ICPXFLAGS) $(ARCH) -I$(INCLUDE_DIR) -c $< -o $@
# Linking step
$(TARGET_RELEASE): $(OBJ_FILES)
$(ICPX) $(ICPXFLAGS) $(LINKFLAGS) $(ARCH) $^ -o $@
# Clean target
clean:
rm -rf $(OBJ_DIR)
clean_all:
rm -rf $(OBJ_DIR) $(TARGET_DEBUG) $(TARGET_RELEASE)
clean_debug:
rm -rf $(OBJ_DIR) $(TARGET_DEBUG)
clean_release:
rm -rf $(OBJ_DIR) $(TARGET_RELEASE)```