Files
rocm-systems/runtime/hsa-runtime/image/blit_src
Sean Keely 55a4f01b16 Update to modern cmake.
Adds support for find_package(), locates dependencies with
find_package(), swaps the roles of /hsa/include/hsa and /include/hsa
as well as /lib & /hsa/lib.

Kernel code objects no longer build at every make call but only
as needed.  Dependencies are tracked through to clang.

Device lib is still located with directory searches.  build_devicelibs.sh
does not yet install the cmake config files on the build systems.

Corrects DAZ mode mismatch in code object compilation.

Still needs updating to compiler properties rather than direct
manipulation of CMAKE_CXX_FLAGS.

Change-Id: I02d946c8a77d5cf753681f8e3d3153fca4aae86a
2020-06-19 22:33:36 -04:00
..
2020-06-19 22:33:36 -04:00

OVERVIEW

This directory contains the CMakeLists.txt for automatically generating the ASCII code object file, "opencl_blit_objects.cpp", which contains the blobs of the code object of the Image BLIT kernels for the devices supported on ROCm. The blobs are loaded by the image library and required to update whenever a new device is introduced.

ADD NEW DEVICE

To add a new supported device, the following steps are required:

  1. Declare an extern variable of the device XXX, by adding the line of "extern uint32_t ocl_blit_object_gfxNNN[];" in "blit_kernel.cpp"
  2. Update the BlitKernel::GetPatchedBlitObject() function to support the device by assigning "blit_code_object" to "ocl_blit_object_gfxNNN[]"
  3. Add the gfxNNN to the TARGET_DEVICES list in CMakeLists.txt
  4. If the new device requires XNACK, add it to the XNACK_DEVS list in CMakeLists.txt
  5. Rebuild the image library

REQUIREMENT

In order to create the code object file, the bitcodes of the kernels are generated by the compiler and the following bitcode libraries are required,

opencl.amdgcn.bc ocml.amdgcn.bc irif.amdgcn.bc oclc_correctly_rounded_sqrt_off.amdgcn.bc oclc_daz_opt_on.amdgcn.bc oclc_finite_only_off.amdgcn.bc oclc_isa_version_.amdgcn.bc oclc_unsafe_math_off.amdgcn.bc

where is the gfxip number of the GPU. The directory contains the bitcode libraries is specified in a CMake varaible.

There are several variables are required for CMake to build the code object file. All of them have default values, and defined as following:

  OPENCL_DIR - the location of installed OpenCL
               (Default: /opt/rocm/opencl)
 BITCODE_DIR - the directory contains the bitcode library
               (Default: ${OPENCL_DIR}/lib/x86_64/bitcode)
    LLVM_DIR - the directory contains the clang, llvm-link and llvm-dis
               executables
               (Default: ${PROJECT_BUILD_DIR}/../lightning/bin)

TARGET_DEVICES - list of gpu types for kernel builds (eg. "gfx900;gfx902") (Default: "gfx900;gfx902;gfx904")

STEPS TO BUILD

$ make build $ cd build $ cmake -D${OPENCL_DIR} -D${BITCODE_DIR} -D${LLVM_DIR} -D${TARGET_DEVICES} .. $ make opencl_blit_objects.cpp