Only cmake can support static lib of hip rt.
Thus samples will support static lib of hip
rt when this is done.

Change-Id: I70e8d06e85084369a035b42c5d1d56287c874ac9


[ROCm/hip-tests commit: 5b8651c825]
Этот коммит содержится в:
Tao Sang
2020-09-01 12:54:32 -04:00
коммит произвёл Tao Sang
родитель 20f58a685e
Коммит 963e4cded7
23 изменённых файлов: 490 добавлений и 12 удалений
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(bit_extract)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(bit_extract bit_extract.cpp)
# Link with HIP
target_link_libraries(bit_extract hip::host)
+3 -7
Просмотреть файл
@@ -9,19 +9,15 @@ HIPCC=$(HIP_PATH)/bin/hipcc
# Show how to use PLATFORM to specify different options for each compiler:
ifeq (${HIP_PLATFORM}, nvcc)
HIPCC_FLAGS = -gencode=arch=compute_20,code=sm_20
HIPCC_FLAGS = -gencode=arch=compute_20,code=sm_20
endif
EXE=bit_extract
EXE_STATIC=bit_extract_static
$(EXE): bit_extract.cpp
$(HIPCC) $(HIPCC_FLAGS) $< -o $@
$(EXE_STATIC): bit_extract.cpp
$(HIPCC) -use-staticlib $(HIPCC_FLAGS) $< -o $@
all: $(EXE) $(EXE_STATIC)
all: $(EXE)
clean:
rm -f *.o $(EXE) $(EXE_STATIC)
rm -f *.o $(EXE)
+36
Просмотреть файл
@@ -0,0 +1,36 @@
project(module_api)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(runKernel.hip.out runKernel.cpp)
add_executable(launchKernelHcc.hip.out launchKernelHcc.cpp)
add_executable(defaultDriver.hip.out defaultDriver.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../vcpy_kernel.cpp -o vcpy_kernel.code
COMMENT "codeobj generated"
)
add_dependencies(runKernel.hip.out codeobj)
add_dependencies(launchKernelHcc.hip.out codeobj)
add_dependencies(defaultDriver.hip.out codeobj)
# Link with HIP
target_link_libraries(runKernel.hip.out hip::host)
target_link_libraries(launchKernelHcc.hip.out hip::host)
target_link_libraries(defaultDriver.hip.out hip::host)
+30
Просмотреть файл
@@ -0,0 +1,30 @@
project(modile_api_global)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(runKernel.hip.out runKernel.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../vcpy_kernel.cpp -o vcpy_kernel.code
COMMENT "codeobj generated"
)
add_dependencies(runKernel.hip.out codeobj)
# Link with HIP
target_link_libraries(runKernel.hip.out hip::host)
+21
Просмотреть файл
@@ -0,0 +1,21 @@
#Follow "README.md" to generate square.cpp if it's missing
project(square)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(square square.cpp)
# Link with HIP
target_link_libraries(square hip::host)
+2 -5
Просмотреть файл
@@ -11,7 +11,7 @@ else
SOURCES=square.cpp
endif
all: square.out square.out.static
all: square.out
# Step
square.cpp: square.cu
@@ -20,8 +20,5 @@ square.cpp: square.cu
square.out: $(SOURCES)
$(HIPCC) $(CXXFLAGS) $(SOURCES) -o $@
square.out.static: $(SOURCES)
$(HIPCC) -use-staticlib $(CXXFLAGS) $(SOURCES) -o $@
clean:
rm -f *.o *.out *.out.static square.cpp
rm -f *.o *.out square.cpp
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(hipBusBandwidth)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipBusBandwidth hipBusBandwidth.cpp ResultDatabase.cpp)
# Link with HIP
target_link_libraries(hipBusBandwidth hip::host)
+31
Просмотреть файл
@@ -0,0 +1,31 @@
project(hipCommander)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipCommander hipCommander.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../nullkernel.hip.cpp -o nullkernel.hsaco
COMMENT "codeobj generated"
)
add_dependencies(hipCommander codeobj)
# Link with HIP
target_link_libraries(hipCommander hip::host)
set_property(TARGET hipCommander PROPERTY CXX_STANDARD 11)
+35
Просмотреть файл
@@ -0,0 +1,35 @@
project(hipDispatchLatency)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipDispatchLatency hipDispatchLatency.cpp)
add_executable(hipDispatchEnqueueRateMT hipDispatchEnqueueRateMT.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../test_kernel.cpp -o test_kernel.code
COMMENT "codeobj generated"
)
add_dependencies(hipDispatchLatency codeobj)
add_dependencies(hipDispatchEnqueueRateMT codeobj)
# Link with HIP
target_link_libraries(hipDispatchLatency hip::host)
target_link_libraries(hipDispatchEnqueueRateMT hip::host)
set_property(TARGET hipDispatchLatency PROPERTY CXX_STANDARD 11)
set_property(TARGET hipDispatchEnqueueRateMT PROPERTY CXX_STANDARD 11)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(hipInfo)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipInfo hipInfo.cpp)
# Link with HIP
target_link_libraries(hipInfo hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(MatrixTranspose)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(MatrixTranspose MatrixTranspose.cpp)
# Link with HIP
target_link_libraries(MatrixTranspose hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(inline_asm)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(inline_asm inline_asm.cpp)
# Link with HIP
target_link_libraries(inline_asm hip::host)
+30
Просмотреть файл
@@ -0,0 +1,30 @@
project(texture2dDrv)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(texture2dDrv texture2dDrv.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../tex2dKernel.cpp -o tex2dKernel.code
COMMENT "codeobj generated"
)
add_dependencies(texture2dDrv codeobj)
# Link with HIP
target_link_libraries(texture2dDrv hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(occupancy)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(occupancy occupancy.cpp)
# Link with HIP
target_link_libraries(occupancy hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(hipEvent)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipEvent hipEvent.cpp)
# Link with HIP
target_link_libraries(hipEvent hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(sharedMemory)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(sharedMemory sharedMemory.cpp)
# Link with HIP
target_link_libraries(sharedMemory hip::host)
+20
Просмотреть файл
@@ -0,0 +1,20 @@
project(shfl)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(shfl shfl.cpp)
# Link with HIP
target_link_libraries(shfl hip::host)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
project(2dshfl)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(2dshfl 2dshfl.cpp)
# Link with HIP
target_link_libraries(2dshfl hip::host)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
project(dynamic_shared)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(dynamic_shared dynamic_shared.cpp)
# Link with HIP
target_link_libraries(dynamic_shared hip::host)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
project(stream)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(stream stream.cpp)
# Link with HIP
target_link_libraries(stream hip::host)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
project(peer2peer)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(peer2peer peer2peer.cpp)
# Link with HIP
target_link_libraries(peer2peer hip::host)
+19
Просмотреть файл
@@ -0,0 +1,19 @@
project(unroll)
cmake_minimum_required(VERSION 3.10)
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(unroll unroll.cpp)
# Link with HIP
target_link_libraries(unroll hip::host)
+27
Просмотреть файл
@@ -0,0 +1,27 @@
Build procedure
We provide Makefile and CMakeLists.txt to build the samples seperately.
1.Makefile supports shared lib of hip-rocclr runtime and nvcc.
To build a sample, just type in sample folder,
make
2.CMakeLists.txt can support shared and static libs of hip-rocclr runtime.
To build a sample, type in sample folder,
mkdir build (if build folder is missing)
cd build
cmake ..
make
If you want debug version, follow,
cmake -DCMAKE_BUILD_TYPE=Debug ..