Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Commit 41b0cff

Browse files
committed
Merge branch 'master' into amd-master
Change-Id: Ieac16a172dacdcd6d57e253a82bb13e6632f5cab
2 parents c7e197d + a75ae53 commit 41b0cff

1,597 files changed

Lines changed: 284 additions & 10365696 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,3 @@
11
*.o
22

3-
rodinia_3.0/hip/b+tree/b+tree
4-
rodinia_3.0/hip/b+tree/output.txt
5-
rodinia_3.0/hip/b+tree/run0.diff
6-
rodinia_3.0/hip/b+tree/run0.out
7-
rodinia_3.0/hip/backprop/backprop
8-
rodinia_3.0/hip/backprop/out_hip.txt
9-
rodinia_3.0/hip/backprop/run0.diff
10-
rodinia_3.0/hip/backprop/run0.out
11-
rodinia_3.0/hip/bfs/bfs
12-
rodinia_3.0/hip/bfs/run0.diff
13-
rodinia_3.0/hip/bfs/run0.out
14-
rodinia_3.0/hip/bfs/run1.diff
15-
rodinia_3.0/hip/bfs/run1.out
16-
rodinia_3.0/hip/cfd/density
17-
rodinia_3.0/hip/cfd/density_energy
18-
rodinia_3.0/hip/cfd/euler3d
19-
rodinia_3.0/hip/cfd/momentum
20-
rodinia_3.0/hip/cfd/run0.diff
21-
rodinia_3.0/hip/cfd/run0.out
22-
rodinia_3.0/hip/cfd/run1.diff
23-
rodinia_3.0/hip/cfd/run1.out
24-
rodinia_3.0/hip/dwt2d/192.bmp.dwt.b
25-
rodinia_3.0/hip/dwt2d/192.bmp.dwt.g
26-
rodinia_3.0/hip/dwt2d/192.bmp.dwt.r
27-
rodinia_3.0/hip/dwt2d/dwt2d
28-
rodinia_3.0/hip/dwt2d/rgb.bmp.dwt.b
29-
rodinia_3.0/hip/dwt2d/rgb.bmp.dwt.g
30-
rodinia_3.0/hip/dwt2d/rgb.bmp.dwt.r
31-
rodinia_3.0/hip/dwt2d/run0.diff
32-
rodinia_3.0/hip/dwt2d/run0.out
33-
rodinia_3.0/hip/dwt2d/run1.diff
34-
rodinia_3.0/hip/dwt2d/run1.out
35-
rodinia_3.0/hip/gaussian/gaussian
36-
rodinia_3.0/hip/gaussian/run0.diff
37-
rodinia_3.0/hip/gaussian/run0.out
38-
rodinia_3.0/hip/gaussian/run1.diff
39-
rodinia_3.0/hip/gaussian/run1.out
40-
rodinia_3.0/hip/gaussian/run2.diff
41-
rodinia_3.0/hip/gaussian/run2.out
42-
rodinia_3.0/hip/gaussian/run3.diff
43-
rodinia_3.0/hip/gaussian/run3.out
44-
rodinia_3.0/hip/gaussian/run4.diff
45-
rodinia_3.0/hip/gaussian/run4.out
46-
rodinia_3.0/hip/heartwall/heartwall
47-
rodinia_3.0/hip/heartwall/run0.diff
48-
rodinia_3.0/hip/heartwall/run0.out
49-
rodinia_3.0/hip/hotspot/hotspot
50-
rodinia_3.0/hip/hotspot/run0.diff
51-
rodinia_3.0/hip/hotspot/run0.out
52-
rodinia_3.0/hip/hybridsort/hybridsort
53-
rodinia_3.0/hip/hybridsort/run0.diff
54-
rodinia_3.0/hip/hybridsort/run0.out
55-
rodinia_3.0/hip/kmeans/kmeans
56-
rodinia_3.0/hip/kmeans/run0.diff
57-
rodinia_3.0/hip/kmeans/run0.out
58-
rodinia_3.0/hip/kmeans/run1.diff
59-
rodinia_3.0/hip/kmeans/run1.out
60-
rodinia_3.0/hip/kmeans/run2.diff
61-
rodinia_3.0/hip/kmeans/run2.out
62-
rodinia_3.0/hip/kmeans/run3.diff
63-
rodinia_3.0/hip/kmeans/run3.out
64-
rodinia_3.0/hip/lavaMD/lavaMD
65-
rodinia_3.0/hip/lavaMD/run0.diff
66-
rodinia_3.0/hip/lavaMD/run0.out
67-
rodinia_3.0/hip/lavaMD/run1.diff
68-
rodinia_3.0/hip/lavaMD/run1.out
69-
rodinia_3.0/hip/lavaMD/run2.diff
70-
rodinia_3.0/hip/lavaMD/run2.out
71-
rodinia_3.0/hip/lavaMD/run3.diff
72-
rodinia_3.0/hip/lavaMD/run3.out
73-
rodinia_3.0/hip/lavaMD/run4.diff
74-
rodinia_3.0/hip/lavaMD/run4.out
75-
rodinia_3.0/hip/lud/lud_cuda
76-
rodinia_3.0/hip/lud/run0.diff
77-
rodinia_3.0/hip/lud/run0.out
78-
rodinia_3.0/hip/myocyte/myocyte
79-
rodinia_3.0/hip/myocyte/output.txt
80-
rodinia_3.0/hip/myocyte/run0.diff
81-
rodinia_3.0/hip/myocyte/run0.out
82-
rodinia_3.0/hip/nn/nn
83-
rodinia_3.0/hip/nn/run0.diff
84-
rodinia_3.0/hip/nn/run0.out
85-
rodinia_3.0/hip/nw/nw
86-
rodinia_3.0/hip/nw/run0.diff
87-
rodinia_3.0/hip/nw/run0.out
88-
rodinia_3.0/hip/pathfinder/pathfinder
89-
rodinia_3.0/hip/pathfinder/run0.diff
90-
rodinia_3.0/hip/pathfinder/run0.out
91-
rodinia_3.0/hip/srad/image_out.pgm
92-
rodinia_3.0/hip/srad/run0.diff
93-
rodinia_3.0/hip/srad/run0.out
94-
rodinia_3.0/hip/srad/srad_v1/srad
95-
rodinia_3.0/hip/srad/srad_v2/sradCPU
96-
rodinia_3.0/hip/srad/srad_v2/sradGPU
97-
rodinia_3.0/hip/streamcluster/output.txt
98-
rodinia_3.0/hip/streamcluster/run0.diff
99-
rodinia_3.0/hip/streamcluster/run0.out
100-
rodinia_3.0/hip/streamcluster/streamcluster
1013
vectorAdd/vectoradd_hip.exe

add4/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ common.o: common.cpp common.h Makefile
66

77
HIP_PATH?= $(wildcard /opt/rocm/hip)
88
ifeq (,$(HIP_PATH))
9-
HIP_PATH=../../..
9+
HIP_PATH=/opt/rocm
1010
endif
1111
HIPCC=$(HIP_PATH)/bin/hipcc
1212

cuda-stream/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
HIP_PATH?= $(wildcard /opt/rocm/hip)
22
ifeq (,$(HIP_PATH))
3-
HIP_PATH=../../..
3+
HIP_PATH=/opt/rocm
44
endif
55
HIPCC=$(HIP_PATH)/bin/hipcc
66

gpu-burn/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
HIP_PATH ?= /opt/rocm/hip
1+
HIP_PATH?= $(wildcard /opt/rocm/hip)
2+
ifeq (,$(HIP_PATH))
3+
HIP_PATH=/opt/rocm
4+
endif
5+
6+
27
HCC_PATH ?= /opt/rocm/hcc
38
HIP_PLATFORM = $(shell $(HIP_PATH)/bin/hipconfig --platform)
49
HIP_INCLUDE = -I${HIP_PATH}/include -I${HCC_PATH}/include

mini-nbody/hip/HIP-nbody-block.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [ -d /opt/rocm/hip ]
1717
then
1818
HIP_PATH=/opt/rocm/hip
1919
else
20-
echo "Please install rocm package"
20+
HIP_PATH=/opt/rocm
2121
fi
2222

2323
fi

mini-nbody/hip/HIP-nbody-orig.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ -d /opt/rocm/hip ]
1414
then
1515
HIP_PATH=/opt/rocm/hip
1616
else
17-
echo "Please install rocm package"
17+
HIP_PATH=/opt/rocm
1818
fi
1919

2020
fi

mini-nbody/hip/HIP-nbody-soa.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [ -d /opt/rocm/hip ]
1717
then
1818
HIP_PATH=/opt/rocm/hip
1919
else
20-
echo "Please install rocm package"
20+
HIP_PATH=/opt/rocm
2121
fi
2222

2323
fi

openmp-helloworld/CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
project(openmp_helloworld)
2+
3+
cmake_minimum_required(VERSION 3.16)
4+
5+
# Search for rocm in common locations
6+
if(WIN32)
7+
list(APPEND CMAKE_PREFIX_PATH "C:/hip")
8+
list(APPEND CMAKE_PREFIX_PATH "C:/Program Files/AMD HIP SDK/hip")
9+
else()
10+
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm)
11+
endif()
12+
13+
# Find HIP.
14+
# The user may override AMDGPU_TARGETS defined in the HIP config file
15+
# to select the AMDGPU archs to compile for.
16+
# ex. set(AMDGPU_TARGETS "gfx803;gfx900;gfx906")
17+
find_package(hip REQUIRED)
18+
19+
# Find OpenMP.
20+
find_package(OpenMP REQUIRED)
21+
22+
# Set compiler and linker.
23+
if(NOT WIN32)
24+
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
25+
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
26+
endif()
27+
28+
set(CMAKE_BUILD_TYPE Release)
29+
30+
if(WIN32)
31+
# Compile for OpenMP code (Windows requires this).
32+
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
33+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
34+
# Tell CMake where to find the OpenMP libraries (libomp.lib).
35+
link_directories("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\Llvm\\x64\\lib")
36+
endif()
37+
38+
# Source files.
39+
set(CPP_SOURCES ${CMAKE_SOURCE_DIR}/openmp_helloworld.cpp)
40+
41+
# Preparing the executable.
42+
add_executable(test_openmp_helloworld ${CPP_SOURCES})
43+
44+
# Link Libraries - HIP Device and OpenMP.
45+
target_compile_options(test_openmp_helloworld PRIVATE ${OpenMP_CXX_FLAGS})
46+
target_link_libraries(test_openmp_helloworld PRIVATE hip::device ${OpenMP_CXX_FLAGS})
47+
48+
if(WIN32)
49+
target_link_libraries(test_openmp_helloworld PRIVATE OpenMP::OpenMP_CXX)
50+
endif()

openmp-helloworld/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
HIP_PATH?= $(wildcard /opt/rocm/hip)
2+
ifeq (,$(HIP_PATH))
3+
HIP_PATH=/opt/rocm
4+
endif
5+
6+
HIPCC=$(HIP_PATH)/bin/hipcc
7+
CXX=$(HIPCC)
8+
CXXFLAGS =-fopenmp
9+
10+
SOURCES = openmp_helloworld.cpp
11+
12+
EXECUTABLE=./openmp_helloworld.exe
13+
14+
.PHONY: test
15+
16+
17+
all: $(EXECUTABLE) test
18+
19+
20+
$(EXECUTABLE):
21+
$(CXX) $(CXXFLAGS) $(SOURCES) -o $@
22+
23+
24+
test: $(EXECUTABLE)
25+
$(EXECUTABLE)
26+
27+
28+
clean:
29+
rm -f $(EXECUTABLE) *.o
30+

openmp-helloworld/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Simple OpenMP hello world example written directly to the HIP interface.
2+
3+
## Requirements
4+
* Installed ROCm 3.9 or newer. See [ROCm Installation Guide](https://rocmdocs.amd.com/en/latest/Installation_Guide/Installation-Guide.html).
5+
6+
## Windows Requirements
7+
* Set HIP_DIR to the HIP installation location.
8+
* libamdhip64.dll and amd_comgr.dll must be in PATH or in System32.
9+
* Install MS Visual Studio 2019 for C++ development with Optional C++ Clang tools for Windows.
10+
* Ensure libomp.dll from MSVC C++ Clang tools is in PATH (by default, location is C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin).
11+
* Modify the CMakeLists.txt of this project to the corresponding libomp.lib location.
12+
13+
## How to run this code:
14+
15+
### Using Make on Linux:
16+
* To build and run: `make`.
17+
* To clean the environment: `make clean`.
18+
19+
20+
### Using CMake on Linux:
21+
* To build: `mkdir -p build; cd build; cmake ..; make`
22+
* To run the test: `./test_openmp_helloworld`
23+
* To clean the build environment: `make clean`
24+
25+
### Using CMake on Windows:
26+
* CMake Command: `cmake -G Ninja -DCMAKE_C_COMPILER=<HIP_DIR>/bin/clang.exe -DCMAKE_CXX_COMPILER=<HIP_DIR>/bin/clang++.exe`
27+
* To build: `ninja`
28+
* To run the test: `./test_openmp_helloworld`
29+
30+
**Note:** You may override `AMDGPU_TARGETS` in the HIP config file by modifying the CMakeLists.txt.
31+
32+
## Expected Results:
33+
```
34+
info: running on device Device 66a3
35+
Hello World... from OMP thread = 0
36+
Hello World... from OMP thread = 15
37+
Hello World... from OMP thread = 3
38+
Hello World... from OMP thread = 13
39+
Hello World... from OMP thread = 11
40+
Hello World... from OMP thread = 8
41+
Hello World... from OMP thread = 4
42+
Hello World... from OMP thread = 1
43+
Hello World... from OMP thread = 10
44+
Hello World... from OMP thread = 9
45+
Hello World... from OMP thread = 7
46+
Hello World... from OMP thread = 12
47+
Hello World... from OMP thread = 6
48+
Hello World... from OMP thread = 14
49+
Hello World... from OMP thread = 5
50+
Hello World... from OMP thread = 2
51+
Hello World... from HIP thread = 0
52+
Hello World... from HIP thread = 2
53+
Hello World... from HIP thread = 5
54+
Hello World... from HIP thread = 14
55+
Hello World... from HIP thread = 6
56+
Hello World... from HIP thread = 12
57+
Hello World... from HIP thread = 7
58+
Hello World... from HIP thread = 9
59+
Hello World... from HIP thread = 1
60+
Hello World... from HIP thread = 11
61+
Hello World... from HIP thread = 10
62+
Hello World... from HIP thread = 4
63+
Hello World... from HIP thread = 8
64+
Hello World... from HIP thread = 13
65+
Hello World... from HIP thread = 15
66+
Hello World... from HIP thread = 3
67+
Device Results:
68+
A_d[0] = 0
69+
A_d[1] = 1
70+
A_d[2] = 2
71+
A_d[3] = 3
72+
A_d[4] = 4
73+
A_d[5] = 5
74+
A_d[6] = 6
75+
A_d[7] = 7
76+
A_d[8] = 8
77+
A_d[9] = 9
78+
A_d[10] = 10
79+
A_d[11] = 11
80+
A_d[12] = 12
81+
A_d[13] = 13
82+
A_d[14] = 14
83+
A_d[15] = 15
84+
PASSED!
85+
```
86+
87+
**Note:** HIP thread's printf may not display on builds with printf support disabled.

0 commit comments

Comments
 (0)