Skip to content

Commit

Permalink
CMake downgrade & fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kiritigowda committed Apr 24, 2020
2 parents 2603aab + 594cba7 commit 5fe982f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 112 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vscode
build*
sample_test
build.sh
temp/
Gtest
cmake-3.16.0-rc2-Linux-x86_64/
stb-test/
hip_build/
39 changes: 31 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
cmake_minimum_required(VERSION 3.15)
# Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

cmake_minimum_required(VERSION 3.5)
project(amd_rpp VERSION 0.2)

message("${PROJECT_NAME} - ${PROJECT_VERSION}")
message("cmake minimum version required: ${CMAKE_MINIMUM_REQUIRED_VERSION}")
message("cmake version found: ${CMAKE_VERSION}")

include(CheckCXXCompilerFlag)
# set default backend to OPENCL
if (NOT DEFINED BACKEND)
SET(BACKEND "OCL")
endif()

if(WIN32 AND CMAKE_CROSSCOMPILING)
set(WINE_CMD "wine")
Expand Down Expand Up @@ -137,7 +163,6 @@ enable_cppcheck(
)


add_library(${PROJECT_NAME} SHARED include/rpp.h)

# Find required packages
find_package(OpenCL REQUIRED) # OpenCL_INCLUDE_DIRS, OpenCL_LIBRARIES
Expand Down Expand Up @@ -247,6 +272,7 @@ if (NOT DEFINED SIMD_ENABLE)
SET(SIMD_ENABLE "1")
endif()

add_library(${PROJECT_NAME} SHARED include/rpp.h $<TARGET_OBJECTS:modules>)
if( "${SIMD_ENABLE}" STREQUAL "1")
target_compile_definitions(${PROJECT_NAME} PUBLIC ENABLE_SIMD_INTRINSICS=1)
message("-- ${Green}${PROJECT_NAME} built with ENABLE_SIMD_INTRINSICS")
Expand All @@ -255,7 +281,6 @@ else()
message("-- ${Green}${PROJECT_NAME} not built with ENABLE_SIMD_INTRINSICS")
endif()


# target setting
option(Boost_USE_STATIC_LIBS "Use boost static libraries" ON)
set(BOOST_COMPONENTS filesystem system)
Expand All @@ -265,10 +290,8 @@ find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(${PROJECT_NAME} ${MODULES_LIST} ${SUB_MODULES_LIST} ${SUB_MODULES_LIST_HIP} ${LINK_LIST} ${LINK_LIST_HIP} OpenMP::OpenMP_CXX)
endif()
target_link_libraries(${PROJECT_NAME} ${MODULES_LIST} ${LINK_LIST} ${LINK_LIST_HIP})


target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand Down
89 changes: 47 additions & 42 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ RPP is developed for __Linux__ operating system.
3. [ROCm](https://github.com/RadeonOpenCompute/ROCm#installing-from-amd-rocm-repositories)

## Functions Included

### Image Augmentation Category

#### Enhancements
* Brightness modification
* Contrast modification
Expand All @@ -23,18 +25,21 @@ RPP is developed for __Linux__ operating system.
* Vignette effect
* Gamma Correction
* Histogram Balance

#### Self Driving Car Specs
* Exposure modifications
* Foggy
* Rainy
* Snowy
* RandomShadow

#### Geometric Distortion Nodes
* Rotate
* Warp-affine
* Flip (horizontally or vertically)
* Fish Eye Effect
* Lens correction

#### Other Augmentations
* Resize
* RandomResizeCrop
Expand All @@ -45,6 +50,7 @@ RPP is developed for __Linux__ operating system.
* Blurring
* Adding Jitter
* RandomCropLetterBox

### Vision Functions
* Absolute Difference
* Accumulate
Expand Down Expand Up @@ -136,58 +142,57 @@ Extended RPP support as a functionality through OpenVX [MIVisionX](https://githu
#### RPP stand-alone code snippet using OCL

````
err = clGetPlatformIDs(1, &platform_id, NULL);
err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
theContext = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
theQueue = clCreateCommandQueue(theContext, device_id, 0, &err);
d_a = clCreateBuffer(theContext, CL_MEM_READ_ONLY, bytes, NULL, NULL);
d_c = clCreateBuffer(theContext, CL_MEM_WRITE_ONLY, bytes, NULL, NULL);
err = clEnqueueWriteBuffer(theQueue, d_a, CL_TRUE, 0, bytes, h_a, 0, NULL, NULL);
cl_mem d_f;
d_f = clCreateBuffer(theContext, CL_MEM_READ_ONLY, f_bytes, NULL, NULL);
err = clEnqueueWriteBuffer(theQueue, d_f, CL_TRUE, 0, f_bytes, h_f, 0, NULL, NULL)
err = clGetPlatformIDs(1, &platform_id, NULL);
err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
theContext = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
theQueue = clCreateCommandQueue(theContext, device_id, 0, &err);
d_a = clCreateBuffer(theContext, CL_MEM_READ_ONLY, bytes, NULL, NULL);
d_c = clCreateBuffer(theContext, CL_MEM_WRITE_ONLY, bytes, NULL, NULL);
err = clEnqueueWriteBuffer(theQueue, d_a, CL_TRUE, 0, bytes, h_a, 0, NULL, NULL);
cl_mem d_f;
d_f = clCreateBuffer(theContext, CL_MEM_READ_ONLY, f_bytes, NULL, NULL);
err = clEnqueueWriteBuffer(theQueue, d_f, CL_TRUE, 0, f_bytes, h_f, 0, NULL, NULL)
Rpp32f alpha=2;
Rpp32s beta=1;
Rpp32f alpha=2;
Rpp32s beta=1;
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brighten_8u_pln1_gpu( d_a, srcSize, d_c, alpha, beta, theQueue);//device side API call
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brighten_8u_pln1_gpu( d_a, srcSize, d_c, alpha, beta, theQueue);//device side API call
````

#### RPP stand-alone code snippet using HOST

```
rppHandle_t handle;
rppCreateWithBatchSize(&handle, noOfImages);
rppi_resize_u8_pkd3_batchDD_host(input, srcSize, output, dstSize, noOfImages, handle);
Rpp32f alpha=2;
Rpp32s beta=1;
rppHandle_t handle;
rppCreateWithBatchSize(&handle, noOfImages);
rppi_resize_u8_pkd3_batchDD_host(input, srcSize, output, dstSize, noOfImages, handle);
Rpp32f alpha=2;
Rpp32s beta=1;
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brighten_8u_pln1_gpu( d_a, srcSize, d_c, alpha, beta, theQueue);//device side API call
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brighten_8u_pln1_gpu( d_a, srcSize, d_c, alpha, beta, theQueue);//device side API call
```

#### RPP stand-alone code snippet using HIP

```
hipMalloc(&d_input, ioBufferSize * sizeof(Rpp8u));
hipMalloc(&d_output, ioBufferSize * sizeof(Rpp8u));
check_hip_error();
hipMemcpy(d_input, input, ioBufferSize * sizeof(Rpp8u), hipMemcpyHostToDevice);
check_hip_error();
Rpp32f alpha=2;
Rpp32s beta=1;
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brightness_u8_pkd3_gpu(d_input, srcSize[0], d_output, alpha, beta, handle); //device side API call
hipMalloc(&d_input, ioBufferSize * sizeof(Rpp8u));
hipMalloc(&d_output, ioBufferSize * sizeof(Rpp8u));
check_hip_error();
hipMemcpy(d_input, input, ioBufferSize * sizeof(Rpp8u), hipMemcpyHostToDevice);
check_hip_error();
Rpp32f alpha=2;
Rpp32s beta=1;
RppiSize srcSize;
srcSize.height=height;
srcSize.width=width;
rppi_brightness_u8_pkd3_gpu(d_input, srcSize[0], d_output, alpha, beta, handle); //device side API call
```

#### RPP with [GDF](https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/blob/master/utilities/runvx/README.md#amd-runvx)(uses OpenVX) code snippet
Expand All @@ -198,7 +203,7 @@ read input ../images/face.jpg
view input inputWindow
view output brightnessWindow
#import RPP library
# import RPP library
import vx_rpp
# create input and output images
data input = image:480,360,RGB2
Expand All @@ -210,8 +215,8 @@ data luma = image-virtual:0,0,U008
node org.khronos.openvx.color_convert input yuv
node org.khronos.openvx.channel_extract yuv !CHANNEL_Y luma
#compute brightness and contrast in luma image using Brightness function
# compute brightness and contrast in luma image using Brightness function
data alpha = scalar:FLOAT32,1.0 #contrast control
data beta = scalar:INT32,30 #brightness control
node org.rpp.Brightness luma output alpha beta
```
```
28 changes: 9 additions & 19 deletions src/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
cmake_minimum_required(VERSION 3.5)
project(modules)

if (${BACKEND} MATCHES OCL)
file(GLOB RPP_KERNELS cl/kernel/*.cl)
endif()

if (${BACKEND} MATCHES HIP)
file(GLOB RPP_KERNELS hip/kernel/*.cpp)
endif()


if( ${BACKEND} MATCHES "OCL" OR ${BACKEND} STREQUAL "HIPOC" OR ${BACKEND} STREQUAL "HIP")
list(APPEND Rpp_Source ${PROJECT_BINARY_DIR}/rpp_kernels.h)
MESSAGE("Add Custome Command")
Expand All @@ -33,7 +29,6 @@ if( ${BACKEND} MATCHES "OCL" OR ${BACKEND} STREQUAL "HIPOC" OR ${BACKEND} STREQU
add_custom_target(rpp_tidy_inlining
DEPENDS ${PROJECT_BINARY_DIR}/rpp_kernels.h ${PROJECT_BINARY_DIR}/rpp_kernel_includes.h
)

add_dependencies(tidy rpp_tidy_inlining)
endif()

Expand Down Expand Up @@ -78,7 +73,6 @@ file( GLOB CPPFILES "*.cpp" )
list(APPEND Rpp_Source ${CPPFILES})
list(APPEND Rpp_Source ${PROJECT_BINARY_DIR}/kernel.cpp)
list(APPEND Rpp_Source ${PROJECT_BINARY_DIR}/kernel_includes.cpp)

# Backend Specific Settings
if( "${TIME_INFO}" STREQUAL "1")
add_definitions(-DTIME_INFO)
Expand All @@ -92,11 +86,10 @@ if( "${BACKEND}" STREQUAL "HIP")
add_definitions(-DSTATIC)
endif()
set(BACKEND_HIPOC 1)
add_subdirectory( hip )
#add_subdirectory( hip )
# add_subdirectory( hipoc )
set(CMAKE_CXX_COMPILER ${COMPILER_FOR_HIP})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_HIPCC_FLAGS} -fopenmp -Ofast -msse4.2 -msse4.1 -mssse3 -mavx2 -g3 -std=c++14")

# set(LINK_LIST_HIPOC ${PROJECT_NAME}-hipoc ${LINK_LIST})
set(LINK_LIST_HIP ${PROJECT_NAME}-hip ${LINK_LIST})
# set(SUB_MODULES_LIST_HIPOC ${PROJECT_NAME}-hipoc ${SUB_MODULES_LIST} PARENT_SCOPE)
Expand All @@ -106,30 +99,27 @@ if( "${BACKEND}" STREQUAL "HIP")
set(HIP_INC "/opt/rocm/hip/include")
set(INCLUDE_LIST ${HIP_INC} ${INCLUDE_LIST})
elseif( "${BACKEND}" STREQUAL "OCL")
add_subdirectory( cl )
set(SUB_MODULES_LIST ${PROJECT_NAME}-opencl ${SUB_MODULES_LIST} PARENT_SCOPE)
file( GLOB MOD_CL_CPP "cl/*.cpp" )
list(APPEND Rpp_Source ${CPPFILES} ${MOD_CL_CPP})
set(CMAKE_CXX_COMPILER ${COMPILER_FOR_OPENCL}) # GCC and G++ donst work for creating .so file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Ofast -msse4.2 -msse4.1 -mssse3 -mavx2 -g3 -std=c++14 -Wno-deprecated-declarations")
set(LINK_LIST ${PROJECT_NAME}-opencl ${OpenCL_LIBRARIES} ${LINK_LIST})
add_definitions(-DRPP_CACHE_DIR="${CACHE_DIR}")
set(ROCM_INC "/opt/rocm/include")
list(APPEND OpenCL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/include/cl/)
MESSAGE("OPenCL incude directories are ${OpenCL_INCLUDE_DIRS}")
add_definitions(-DMOD_CL_PATH="${CMAKE_CURRENT_LIST_DIR}/cl/kernel/")
add_definitions(-DRPP_CACHE_DIR="${CACHE_DIR}")
add_definitions(-DOCL_COMPILE)
set(INCLUDE_LIST ${OpenCL_INCLUDE_DIRS} ${INCLUDE_LIST} ${ROCM_INC})
add_definitions(-DOCL_COMPILE)
add_definitions(-DRPP_BACKEND_OPENCL)
endif()

add_kernels("${RPP_KERNELS}")
add_kernel_includes("${RPP_KERNEL_INCLUDES}")


add_library( ${PROJECT_NAME} OBJECT ${Rpp_Source})

clang_tidy_check(${PROJECT_NAME})

add_library(${PROJECT_NAME} OBJECT ${Rpp_Source} )
# target setting

set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries (${PROJECT_NAME} ${LINK_LIST})
target_include_directories( ${PROJECT_NAME}
PUBLIC
${CMAKE_SOURCE_DIR}/include
Expand Down
43 changes: 0 additions & 43 deletions src/modules/cl/CMakeLists.txt

This file was deleted.

0 comments on commit 5fe982f

Please sign in to comment.