ROCm / HIP-Examples

Examples for HIP
199 stars 90 forks source link

Add HIP-Examples for OpenMP Hello World #22

Closed aaronenyeshi closed 3 years ago

aaronenyeshi commented 3 years ago

Many projects such as math libraries may use ROCm installed omp.h. This example shows how to compile and run a simple OpenMP app, and does not require additional includes or linking directives.

Fixes: SWDEV-257119

aaronenyeshi commented 3 years ago

I will replace this Makefile with a CMake build as requested by Math libs.

aaronenyeshi commented 3 years ago

This latest cmake file is working, I will update the README and the test_all.sh script.

aaronenyeshi commented 3 years ago

This patch is ready to be reviewed.

root@e6915ef660c7:~/hip-examples/openmp-helloworld/build# cmake ..; make
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Configuring done
-- Generating done
-- Build files have been written to: /root/hip-examples/openmp-helloworld/build
Scanning dependencies of target test_openmp_helloworld
[ 50%] Building CXX object CMakeFiles/test_openmp_helloworld.dir/openmp_helloworld.cpp.o
clang-12: warning: -lclang_rt.builtins-x86_64: 'linker' input unused [-Wunused-command-line-argument]
[100%] Linking CXX executable test_openmp_helloworld
[100%] Built target test_openmp_helloworld
root@e6915ef660c7:~/hip-examples/openmp-helloworld/build# ./test_openmp_helloworld
Hello World... from thread = 0
Hello World... from thread = 8
Hello World... from thread = 6
Hello World... from thread = 22
Hello World... from thread = 25
Hello World... from thread = 3
Hello World... from thread = 1
Hello World... from thread = 9
Hello World... from thread = 31
Hello World... from thread = 11
Hello World... from thread = 30
Hello World... from thread = 4
Hello World... from thread = 12
Hello World... from thread = 14
Hello World... from thread = 28
Hello World... from thread = 10
Hello World... from thread = 16
Hello World... from thread = 19
Hello World... from thread = 13
Hello World... from thread = 2
Hello World... from thread = 5
Hello World... from thread = 17
Hello World... from thread = 23
Hello World... from thread = 15
Hello World... from thread = 29
Hello World... from thread = 18
Hello World... from thread = 27
Hello World... from thread = 20
Hello World... from thread = 7
Hello World... from thread = 21
Hello World... from thread = 24
Hello World... from thread = 26
PASSED!
yxsamliu commented 3 years ago

Better add a simple kernel launching to the test.

aaronenyeshi commented 3 years ago

Better add a simple kernel launching to the test.

Did you mean a simple kernel in HIP, or using AOMP?

yxsamliu commented 3 years ago

Better add a simple kernel launching to the test.

Did you mean a simple kernel in HIP, or using AOMP?

in HIP.

aaronenyeshi commented 3 years ago

Better add a simple kernel launching to the test.

Did you mean a simple kernel in HIP, or using AOMP?

in HIP.

Done

aaronenyeshi commented 3 years ago

ping

saadrahim commented 3 years ago

Why is there no CI for this PR? deepcode-ci-bot doesn't really test anything relevant.

aaronenyeshi commented 3 years ago

Why is there no CI for this PR? deepcode-ci-bot doesn't really test anything relevant.

I think DevOps have been working on adding CI to these repos for awhile.