Skip to content

Commit

Permalink
Updated HIP to release 0.84.01
Browse files Browse the repository at this point in the history
  • Loading branch information
mangupta committed Apr 25, 2016
2 parents 0790810 + 87e2be1 commit 8e556a5
Show file tree
Hide file tree
Showing 342 changed files with 14,760 additions and 13,907 deletions.
193 changes: 193 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
cmake_minimum_required(VERSION 2.8.3)
project(hip)

#############################
# Setup version information
#############################
set(HIP_VERSION_MAJOR "0")
set(HIP_VERSION_MINOR "84")
set(HIP_VERSION_PATCH "01")

#############################
# Configure variables
#############################
# Determine HIP_PLATFORM
if(NOT DEFINED HIP_PLATFORM)
if(NOT DEFINED ENV{HIP_PLATFORM})
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/hipconfig --platform
OUTPUT_VARIABLE HIP_PLATFORM
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(HIP_PLATFORM $ENV{HIP_PLATFORM} CACHE STRING "HIP Platform")
endif()
endif()
message(STATUS "HIP Platform: " ${HIP_PLATFORM})

# If HIP_PLATFORM is hcc, we need HCC_HOME and HSA_PATH to be defined
if(HIP_PLATFORM STREQUAL "hcc")
# Determine HCC_HOME
if(NOT DEFINED HCC_HOME)
if(NOT DEFINED ENV{HCC_HOME})
set(HCC_HOME "/opt/rocm/hcc" CACHE PATH "Path to which HCC has been installed")
else()
set(HCC_HOME $ENV{HCC_HOME} CACHE PATH "Path to which HCC has been installed")
endif()
endif()
if(IS_ABSOLUTE ${HCC_HOME} AND EXISTS ${HCC_HOME} AND IS_DIRECTORY ${HCC_HOME})
message(STATUS "Looking for HCC in: " ${HCC_HOME})
else()
message(FATAL_ERROR "Don't know where to find HCC. Please specify abolute path using -DHCC_HOME")
endif()

# Determine HSA_PATH
if(NOT DEFINED HSA_PATH)
if(NOT DEFINED ENV{HSA_PATH})
set(HSA_PATH "/opt/rocm/hsa" CACHE PATH "Path to which HSA runtime has been installed")
else()
set(HSA_PATH $ENV{HSA_PATH} CACHE PATH "Path to which HSA runtime has been installed")
endif()
endif()
if(IS_ABSOLUTE ${HSA_PATH} AND EXISTS ${HSA_PATH} AND IS_DIRECTORY ${HSA_PATH})
message(STATUS "Looking for HSA runtime in: " ${HSA_PATH})
else()
message(FATAL_ERROR "Don't know where to find HSA runtime. Please specify absolute path using -DHSA_PATH")
endif()
endif()

# Set default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

# Determine HIP install path
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND CMAKE_INSTALL_PREFIX MATCHES "/usr/local")
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Installation path for HIP" FORCE)
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_INSTALL_PREFIX "/opt/rocm/hip" CACHE PATH "Installation path for HIP" FORCE)
else()
message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE specified. Valid values are Debug and Release")
endif()
endif()
if(IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX})
message(STATUS "HIP will be installed in: " ${CMAKE_INSTALL_PREFIX})
else()
message(FATAL_ERROR "Don't know where to install HIP. Please specify absolute path using -DCMAKE_INSTALL_PREFIX")
endif()

# Set if we need to build shared or static library
if(NOT DEFINED ENV{HIP_USE_SHARED_LIBRARY})
set(HIP_USE_SHARED_LIBRARY 0)
else()
set(HIP_USE_SHARED_LIBRARY $ENV{HIP_USE_SHARED_LIBRARY})
endif()

#############################
# Build steps
#############################
# Build hip_hcc if platform is hcc
if(HIP_PLATFORM STREQUAL "hcc")
include_directories(${PROJECT_SOURCE_DIR}/include)

set(CMAKE_CXX_COMPILER "${HCC_HOME}/bin/hcc")
set(CMAKE_C_COMPILER "${HCC_HOME}/bin/hcc")

set(CMAKE_CXX_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -stdlib=libc++ ")
set(CMAKE_C_FLAGS " -hc -I${HCC_HOME}/include -I${HSA_PATH}/include -stdlib=libc++ ")

set(SOURCE_FILES src/device_util.cpp
src/hip_hcc.cpp
src/hip_device.cpp
src/hip_error.cpp
src/hip_event.cpp
src/hip_memory.cpp
src/hip_peer.cpp
src/hip_stream.cpp
src/staging_buffer.cpp)

if(${HIP_USE_SHARED_LIBRARY} EQUAL 1)
add_library(hip_hcc SHARED ${SOURCE_FILES})
else()
#add_library(hip_hcc STATIC ${SOURCE_FILES})
add_library(hip_hcc OBJECT ${SOURCE_FILES})
endif()

endif()

#############################
# Install steps
#############################
# Install hip_hcc if platform is hcc
if(HIP_PLATFORM STREQUAL "hcc")
if(${HIP_USE_SHARED_LIBRARY} EQUAL 1)
install(TARGETS hip_hcc DESTINATION lib)
else()
#install(TARGETS hip_hcc DESTINATION lib)
install(DIRECTORY ${PROJECT_BINARY_DIR}/CMakeFiles/hip_hcc.dir/src/ DESTINATION lib)
endif()
endif()

# Install src, bin, include if necessary
execute_process(COMMAND test ${CMAKE_INSTALL_PREFIX} -ef ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE INSTALL_SOURCE)
if(NOT ${INSTALL_SOURCE} EQUAL 0)
install(DIRECTORY src DESTINATION .)
install(DIRECTORY bin DESTINATION . USE_SOURCE_PERMISSIONS)
install(DIRECTORY include DESTINATION .)
endif()

#############################
# Packaging steps
#############################
# Package: hip_base
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_base)
configure_file(packaging/hip_base.txt ${BUILD_DIR}/CMakeLists.txt @ONLY)
configure_file(packaging/hip_base.postinst ${BUILD_DIR}/postinst @ONLY)
configure_file(packaging/hip_base.prerm ${BUILD_DIR}/prerm @ONLY)
add_custom_target(pkg_hip_base COMMAND ${CMAKE_COMMAND} .
COMMAND rm -rf *.deb *.rpm *.tar.gz
COMMAND make package
COMMAND cp *.deb ${PROJECT_BINARY_DIR}
COMMAND cp *.rpm ${PROJECT_BINARY_DIR}
COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${BUILD_DIR})

# Package: hip_hcc
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_hcc)
configure_file(packaging/hip_hcc.txt ${BUILD_DIR}/CMakeLists.txt @ONLY)
configure_file(packaging/hip_hcc.postinst ${BUILD_DIR}/postinst @ONLY)
configure_file(packaging/hip_hcc.prerm ${BUILD_DIR}/prerm @ONLY)
add_custom_target(pkg_hip_hcc COMMAND ${CMAKE_COMMAND} .
COMMAND rm -rf *.deb *.rpm *.tar.gz
COMMAND make package
COMMAND cp *.deb ${PROJECT_BINARY_DIR}
COMMAND cp *.rpm ${PROJECT_BINARY_DIR}
COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${BUILD_DIR}
DEPENDS hip_hcc)

# Package: hip_nvcc
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_nvcc)
configure_file(packaging/hip_nvcc.txt ${BUILD_DIR}/CMakeLists.txt @ONLY)
add_custom_target(pkg_hip_nvcc COMMAND ${CMAKE_COMMAND} .
COMMAND rm -rf *.deb *.rpm *.tar.gz
COMMAND make package
COMMAND cp *.deb ${PROJECT_BINARY_DIR}
COMMAND cp *.rpm ${PROJECT_BINARY_DIR}
COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${BUILD_DIR})

# Package: hip_doc
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_doc)
configure_file(packaging/hip_doc.txt ${BUILD_DIR}/CMakeLists.txt @ONLY)
add_custom_target(pkg_hip_doc COMMAND ${CMAKE_COMMAND} .
COMMAND rm -rf *.deb *.rpm *.tar.gz
COMMAND make package
COMMAND cp *.deb ${PROJECT_BINARY_DIR}
COMMAND cp *.rpm ${PROJECT_BINARY_DIR}
COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${BUILD_DIR})

# Package: all
add_custom_target(package DEPENDS pkg_hip_base pkg_hip_hcc pkg_hip_nvcc pkg_hip_doc)

19 changes: 16 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The granularity is one day, so __hcc_workweek__ can only be used to distinguish

Additionally, hcc binary can print the work-week to stdout: ("16014" in the version info below.)4
```
> /opt/hcc/bin/hcc -v
> /opt/rocm/hcc/bin/hcc -v
HCC clang version 3.5.0 (based on HCC 0.8.16014-81f8a3f-f155163-5a1009a LLVM 3.5.0svn)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Expand All @@ -52,8 +52,21 @@ The unix `date` command can print the HCC-format work-week for a specific date ,

HIP includes unit tests in the tests/src directory.
When adding a new HIP feature, add a new unit test as well.
The tests/src/hipMemtest.cpp file contains a simple unit test and is a good starting point for other tests.
Modify tests/src/CMakefiles.txt to add the test to the build environment.
See [tests/README.md](README.md) for more information.

## Development Flow
It is recommended that developers set the flag HIP_BUILD_LOCAL=1 so that the unit testing environment automatically rebuilds libhip_hcc.a and the tests when a change it made to the HIP source.
Directed tests provide a great place to develop new features alongside the associated test.

For applications and benchmarks outside the directed test environment, developments should use a two-step development flow:
- #1. Compile, link, and install HCC. See [Installation](README.md#Installation) notes.
- #2. Relink the target application to include changes in the libhip_hcc.a file.

## Environment Variables
- **HIP_PATH** : Location of HIP include, src, bin, lib directories.
- **HCC_HOME** : Path to HCC compiler. Default /opt/rocm/hcc.
- **HSA_PATH** : Path to HSA include, lib. Default /opt/rocm/hsa.
- **CUDA_PATH* : On nvcc system, this points to root of CUDA installation.

### Contribution guidelines ###

Expand Down
13 changes: 7 additions & 6 deletions CUDA_Runtime_API_functions_supported_by_HIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| `cudaGetDevice` | `hipGetDevice` | Returns which device is currently being used. |
| `cudaGetDeviceCount` | `hipGetDeviceCount` | Returns the number of compute-capable devices. |
| `cudaGetDeviceFlags` | | Gets the flags for the current device. |
| `cudaGetDeviceProperties` | `hipDeviceGetProperties` | Returns information about the compute-device. |
| `cudaGetDeviceProperties` | `hipGetDeviceProperties` | Returns information about the compute-device. |
| `cudaIpcCloseMemHandle` | | Close memory mapped with cudaIpcOpenMemHandle. |
| `cudaIpcGetEventHandle` | | Gets an interprocess handle for a previously allocated event. |
| `cudaIpcGetMemHandle` | | Gets an interprocess memory handle for an existing device memory allocation. |
Expand Down Expand Up @@ -97,16 +97,16 @@
| `cudaGetMipmappedArrayLevel` | | Gets a mipmap level of a CUDA mipmapped array. |
| `cudaGetSymbolAddress` | | Finds the address associated with a CUDA symbol. |
| `cudaGetSymbolSize` | | Finds the size of the object associated with a CUDA symbol. |
| `cudaHostAlloc` | | Allocates page-locked memory on the host. |
| `cudaHostGetDevicePointer` | | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. |
| `cudaHostGetFlags` | | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. |
| `cudaHostAlloc` | `hipHostMalloc` | Allocates page-locked memory on the host. |
| `cudaHostGetDevicePointer` | `hipHostGetDevicePointer` | Passes back device pointer of mapped host memory allocated by cudaHostAlloc or registered by cudaHostRegister. |
| `cudaHostGetFlags` | `hipHostGetFlags` | Passes back flags used to allocate pinned host memory allocated by cudaHostAlloc. |
| `cudaHostRegister` | | Registers an existing host memory range for use by CUDA. |
| `cudaHostUnregister` | | Unregisters a memory range that was registered with cudaHostRegister. |
| `cudaMalloc` | `hipMalloc` | Allocate memory on the device. |
| `cudaMalloc3D` | | Allocates logical 1D, 2D, or 3D memory objects on the device. |
| `cudaMalloc3DArray` | | Allocate an array on the device. |
| `cudaMallocArray` | | Allocate an array on the device. |
| `cudaMallocHost` | `hipHostAlloc` | Allocates page-locked memory on the host. |
| `cudaMallocHost` | `hipHostMalloc` | Allocates page-locked memory on the host. |
| `cudaMallocManaged` | | Allocates memory that will be automatically managed by the Unified Memory system. |
| `cudaMallocMipmappedArray` | | Allocate a mipmapped array on the device. |
| `cudaMallocPitch` | | Allocates pitched memory on the device. |
Expand Down Expand Up @@ -149,7 +149,7 @@

| **CUDA** | **HIP** | **CUDA description** |
|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `cudaPointerGetAttributes` | | Returns attributes about a specified pointer. |
| `cudaPointerGetAttributes` | `hipPointerGetAttributes` | Returns attributes about a specified pointer. |

**9. Peer Device Memory Access**

Expand Down Expand Up @@ -227,6 +227,7 @@
| `cudaRuntimeGetVersion` | | Returns the CUDA Runtime version. |

**17. C++ API Routines (7.0 contains, 7.5 doesn’t)**
> Will not support for HIP (probably)
| **CUDA** | **HIP** | **CUDA description** |
|-----------------------------------------------------------|-------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
Expand Down
22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

Loading

0 comments on commit 8e556a5

Please sign in to comment.