Skip to content

Commit

Permalink
Begin new omp target update PR to replace hpc4cmb#603
Browse files Browse the repository at this point in the history
  • Loading branch information
tskisner committed Apr 4, 2023
1 parent 819bb46 commit 8eded22
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 11 deletions.
23 changes: 18 additions & 5 deletions etc/pyomptarget/Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@

# GCC 12.1.0 with offload support
CXX := g++-12
CXXFLAGS := -O0 -g -fPIC -pthread -std=c++11 -fcf-protection=none -fno-stack-protector
CXX_OMP_FLAGS := -fopenmp -foffload=nvptx-none='-Wa,-m,sm_80 -misa=sm_80 -fPIC -lm -latomic'
#CXX := g++-12
#CXXFLAGS := -O0 -g -fPIC -pthread -std=c++11 -fcf-protection=none -fno-stack-protector
#CXX_OMP_FLAGS := -fopenmp -foffload=nvptx-none='-Wa,-m,sm_80 -misa=sm_80 -fPIC -lm -latomic'

# NVHPC
# CXX = nvc++
# CXXFLAGS = -O0 -g -fPIC -pthread -std=c++11
# CXX_OMP_FLAGS = -mp=gpu -Minfo=mp -gpu=cc86

# AMD LLVM
CXX := amdclang++
CXXFLAGS := -O3 -g -fPIC -std=c++11
CXX_OMP_FLAGS := -fPIC -fopenmp -fopenmp-target-debug=3 -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx1030
CXX_LD_FLAGS := -lomp -lomptarget -lomptarget.rtl.amdgpu

pybind := ../../src/toast/pybind11
modext := $(shell python3-config --extension-suffix)
pyincl := $(shell python3-config --includes)


all : device_info test pyomptarget$(modext)


pyomptarget$(modext) : module.o
$(CXX) -shared -o pyomptarget$(modext) module.o $(CXX_OMP_FLAGS)
$(CXX) -shared $(CXX_OMP_FLAGS) -o pyomptarget$(modext) module.o $(CXX_LD_FLAGS)

module.o : module.cpp
$(CXX) $(CXXFLAGS) $(CXX_OMP_FLAGS) -I. -I$(pybind)/include $(pyincl) -c -o module.o module.cpp

device_info : device_info.cpp
$(CXX) $(CXXFLAGS) $(CXX_OMP_FLAGS) -o device_info device_info.cpp $(CXX_LD_FLAGS)

test : test.cpp
$(CXX) $(CXXFLAGS) $(CXX_OMP_FLAGS) -o test test.cpp $(CXX_LD_FLAGS)

clean :
rm -f *.so *.o
rm -f *.so *.o device_info test

17 changes: 17 additions & 0 deletions etc/pyomptarget/device_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include <omp.h>
//#include "omptarget.h"
#include <iostream>

int main(int argc, char **argv) {
int ndev = omp_get_num_devices();
std::cout << "OMP found " << ndev << " available target offload devices" << std::endl;
int target = ndev - 1;
int host = omp_get_initial_device();
int defdev = omp_get_default_device();
std::cout << "OMP initial host device = " << host << std::endl;
std::cout << "OMP target device = " << target << std::endl;
std::cout << "OMP default device = " << defdev << std::endl;
return 0;
}

Loading

0 comments on commit 8eded22

Please sign in to comment.