Skip to content

Commit

Permalink
HSA 1.0 Runtime Conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards-AMD committed Sep 23, 2015
0 parents commit 37d2652
Show file tree
Hide file tree
Showing 402 changed files with 87,347 additions and 0 deletions.
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project (hsa_conformance C)

cmake_minimum_required(VERSION 2.8)

## Windows is currently not supported. Disable windows builds.
if(WIN32)
MESSAGE("-------- Windows build is not supported.")
RETURN()
endif()

## Specify the location of the configuration files.
set (CMAKE_CONFIG_DIR "${CMAKE_SOURCE_DIR}/cmake")

## Set the CMAKE module path the CMAKE_CONFIG_DIR.
set (CMAKE_MODULE_PATH ${CMAKE_CONFIG_DIR})

## Disable RPATH options
set (CMAKE_SKIP_RPATH TRUE)

## Determine if the required packages are installed.
find_package(Check REQUIRED)
include_directories(${CHECK_INCLUDE_DIRS})

find_package(HSA REQUIRED)
include_directories(${HSA_RUNTIME_INCLUDE_DIRS})

## Include common settings.
include (common)

## Create the test utilities library.
include (utils)

## Enable testing.
enable_testing()

## Build the tests.
include (kernel)
include (script)
include (api)
include (agent)
include (aql)
include (async)
include (code)
include (init)
include (memory)
include (atomics)
include (queue)
include (signals)
include (ext_api)
include (finalization)
include (image_clear)
include (image_copy)
include (image_import_export)
38 changes: 38 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The University of Illinois/NCSA
Open Source License (NCSA)

Copyright (c) 2014, Advanced Micro Devices, Inc.
All rights reserved.

Developed by:

AMD Research and AMD HSA Software Development

Advanced Micro Devices, Inc.

www.amd.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal with 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:

- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimers in
the documentation and/or other materials provided with the distribution.
- Neither the names of <Name of Development Group, Name of Institution>,
nor the names of its contributors may be used to endorse or promote
products derived from this Software without specific prior written
permission.

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 CONTRIBUTORS 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 WITH THE SOFTWARE.
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
USING THE RUNTIME CONFORMANCE SUITE

The HSA Runtime Conformance Suite build environment utilizes the cmake
for automatic makefile generation targeting specific platforms.
The required version of cmake is version 2.8. The build & execution
environment requires the check test framework, version 0.9.12 or later,
and the 1.0 Final HSA runtime.

In normal builds, CMake automatically determines the toolchain for host
builds based on system introspection and defaults. In cross-compiling
scenarios, a toolchain file may be specified with information about compiler
and utility paths. Please consult CMake documentation for more information.

Linux Environment Setup

The following steps will install the appropriate versions of
cmake, check and HSA in the default PATH and LD_LIBRARY_PATH directories.
Consult the appropriate documentation regarding installing the
executables and libraries in different locations.

1) Install the appropriate level of cmake on your system. The latest version
of cmake can be obtained from http://www.cmake.org/download/, where both
binary and source distributions are available. On ubuntu the cmake package
may come as a pre-installed package, but the following command will install
the default version for the current system:

'sudo apt-get install cmake'

2) Install the appropriate version of the check framework on the
build system. The check framework can be downloaded from
http://sourceforge.net/projects/check/files/latest/download. On ubuntu the
check test framework will install the default version on the
current system:

'sudo apt-get install check'

3) If the HSA runtime isn't installed, get the desired version of the runtime
from https://github.com/HSAFoundation/HSA-Runtime-AMD. Install the runtime
from either the fedora rpm or the ubuntu deb package provided in the repository.
This will install the runtime in the /opt/hsa directory.

Windows Environment Setup

The Runtime conformance suite can only be built on Windows if Cygwin development
environment is available. To install the required Cygwin resources execute the
link https://cygwin.com/setup-x86_64.exe. This will download the Cygwin installer
to the local system. Launch the Cygwin installer and install the entire Devel
category. Not all of the packages in Devel are required for Runtime conformance,
but it is safer and easier to install them all than to manually select the (several)
required components.

BUILDING THE CONFORMANCE SUITE

Before building the suite the locations of the HSA libraries and header files
must be specified using the HSA_INCLUDE_DIR and the HSA_LIBRARY_DIR cmake
variables. This is only required the HSA headers and libraries aren't installed
in the standard system directories or in the default /opt/hsa location. For
example, if HSA is installed for a local user, the cmake variables should
be specified on the cmake command line like this:

`cmake -D HSA_INCLUDE_DIR:STRING=/home/<user>/hsa/include
-D HSA_LIBRARY_DIR=/home/<user>/hsa/lib CMakeLists.txt`

On a Windows system the cmake command should be executed in a Cygwin64 terminal shell.
Also on Windows, the HSA_INCLUDE_DIR and HSA_LIBRARY_DIR cmake variables must
be set; there are no valid default locations. The HSA_LIBRARY_DIR variable
should point to the directory that contains the hsa-runtime64.dll file, not the
associated hsa-runtime64.lib file.

To build the suite, create a build directory and run cmake on the CMakeLists.txt
file. After the make infrastructure is created, build the binaries with the
make command. The following sequence of commands, if run from the top level
directory, would build the conformance suite:

`mkdir build && cd build && cmake <-D ...> .. && make`

INSTALLING THE CONFORMANCE SUITE

The conformance suite can be installed in a directory by issuing the `make install`
command. The default installation directory is '/usr/local/hsa_conformance'. This
can be changed to another location using the `cmake -D CMAKE_INSTALL_PREFIX=<dir> ..`
option.

The user must have proper access to the install directory to both install
and execute the tests.

RUNNING THE TESTS USING CMAKE

Before running the tests the LD_LIBRARY_PATH environment variable must include
the PATH of the HSA runtime libraries.

The HSA conformance tests can use the ctest execution environment. After build the
conformance test all currently enabled tests can be run by building the 'test'
target:

`make test`

RUNNING THE TESTS USING EXECUTION SCRIPTS

It is also possible to use the execute.sh script provided in the installation to
run the test suite. First, install the test suite:

`make install`

This will transfer all of the tests, brig files and execution scripts to the install
directory (/usr/local/hsa_conformance is the default install directory). Change to
the install directory and run the following command to execute the conformance suite:

`execute.sh test.lst`

FREQUENTLY ASKED QUESTIONS

Q1: When debugging a test case with gdb I can't step into the test functions? How do
I enable debugging?
A1: By default the check test framework will fork a new process for each test and
determines if it passes or fails by the code returned to the parent process. This allows
the parent process to remain insulated from signals (SIGSEGV) that are sent to the
child process. On most systems, GDB has no special support for debugging programs
which create additional processes using the fork function. When a program forks, GDB will
continue to debug the parent process and the child process will run unimpeded. This forking
behavior can be turned of by setting the CK_FORK environment varialble to 'no', e.g.
"export CK_FORK=no".

Q2: Check appears to be generating a segfault when I run a test:
../../src/check_pack.c:312: ../../src/check_msg.c:75: No messaging setup Segmentation fault (core dumped)

A2: The check assertion system isn't particularly robust when it comes to multiple threads, especially if
CK_FORK=no is set. This segfault usually indicates that a multi-threaded test case is failing and
several of the threads are generating an ASSERT message concurrently.
28 changes: 28 additions & 0 deletions cmake/FindCheck.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if (CHECK_INCLUDE_DIR)
## The check information is already in the cache.
set (CHECK_FIND_QUIETLY TRUE)
endif (CHECK_INCLUDE_DIR)

## If the CHECK_INSTALL_DIR cmake variable is set,
## add it to the list of system directories to search
## for the check library. This is done in the find_path
## and find_library calls below.

## Look for the check include file.
find_path (CHECK_INCLUDE_DIR NAMES check.h ${CHECK_INSTALL_DIR}/include)
## Look for the check library.
find_library (CHECK_LIBRARY NAMES check ${CHECK_INSTALL_DIR}/lib)

## Handle the QUIETLY and REQUIRED arguments and set CHECK_FOUND to TRUE if
## all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Check "Please install 'check' and 'check-devel' packages" CHECK_LIBRARY CHECK_INCLUDE_DIR)

if (CHECK_FOUND)
set (CHECK_LIBRARIES ${CHECK_LIBRARY})
else (CHECK_FOUND)
set (CHECK_LIBRARIES)
endif(CHECK_FOUND)

mark_as_advanced (CHECK_INCLUDE_DIR)
mark_as_advanced (CHECK_LIBRARY)
23 changes: 23 additions & 0 deletions cmake/FindELF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if (ELF_INCLUDE_DIR)
## The elf information is already in the cache.
set (ELF_FIND_QUIETLY TRUE)
endif (ELF_INCLUDE_DIR)

## Look for the check include file.
find_path (ELF_INCLUDE_DIR NAMES libelf.h)
## Look for the check library.
find_library (ELF_LIBRARY NAMES elf)

## Handle the QUIETLY and REQUIRED arguments and set ELF_FOUND to TRUE if
## all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (ELF "Please install the 'elfutils' package" ELF_LIBRARY ELF_INCLUDE_DIR)

if (ELF_FOUND)
set (ELF_LIBRARIES ${ELF_LIBRARY})
else (ELF_FOUND)
set (ELF_LIBRARIES)
endif(ELF_FOUND)

mark_as_advanced (ELF_INCLUDE_DIR)
mark_as_advanced (ELF_LIBRARY)
59 changes: 59 additions & 0 deletions cmake/FindHSA.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
if (HSA_RUNTIME_INCLUDE_DIR)
## The HSA information is already in the cache.
set (HSA_RUNTIME_FIND_QUIETLY TRUE)
endif (HSA_RUNTIME_INCLUDE_DIR)

## Look for the hsa include file path.

## If the HSA_INCLUDE_DIR variable is set,
## use it for the HSA_RUNTIME_INCLUDE_DIR variable.
## Otherwise set the value to /opt/hsa/include.
## Note that this can be set when running cmake
## by specifying -D HSA_INCLUDE_DIR=<directory>.

if(NOT DEFINED HSA_INCLUDE_DIR)
set (HSA_INCLUDE_DIR "/opt/hsa/include")
endif()

MESSAGE("HSA_INCLUDE_DIR=${HSA_INCLUDE_DIR}")

find_path (HSA_RUNTIME_INCLUDE_DIR NAMES hsa.h PATHS ${HSA_INCLUDE_DIR})

## If the HSA_LIBRARY_DIR environment variable is set,
## use it for the HSA_RUNTIME_LIBRARY_DIR variable.
## Otherwise set the value to /opt/hsa/lib.
## Note that this can be set when running cmake
## by specifying -D HSA_LIBRARY_DIR=<directory>.

if(NOT DEFINED HSA_LIBRARY_DIR)
set (HSA_LIBRARY_DIR "/opt/hsa/lib")
endif()

MESSAGE("HSA_LIBRARY_DIR=${HSA_LIBRARY_DIR}")

## Look for the hsa library and, if found, generate the directory.
if(DEFINED CYGWIN)
## In CYGWIN set the library name directly to the hsa-runtime64.dll.
## This is a temporary work-around for cmake limitations, and requires
## that the HSA_RUNTIME_LIBRARY environment variable is set by the user.
set(HSA_RUNTIME_LIBRARY "${HSA_LIBRARY_DIR}/hsa-runtime64.dll")
else()
find_library (HSA_RUNTIME_LIBRARY NAMES hsa-runtime64 PATHS ${HSA_LIBRARY_DIR})
endif()

get_filename_component(HSA_RUNTIME_LIBRARY_DIR ${HSA_RUNTIME_LIBRARY} DIRECTORY)

## Handle the QUIETLY and REQUIRED arguments and set HSA_FOUND to TRUE if
## all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (HSA "Please install 'hsa-runtime' package" HSA_RUNTIME_LIBRARY HSA_RUNTIME_INCLUDE_DIR)

if (HSA_FOUND)
set (HSA_LIBRARIES ${HSA_LIBRARY})
else (HSA_FOUND)
set (HSA_LIBRARIES)
endif(HSA_FOUND)

mark_as_advanced (HSA_RUNTIME_INCLUDE_DIR)
mark_as_advanced (HSA_RUNTIME_LIBRARY_DIR)
mark_as_advanced (HSA_RUNTIME_LIBRARY)
14 changes: 14 additions & 0 deletions cmake/agent.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Target executable name.
set (TARGET hsa_agent)

## Specify the SRC_DIR.
set (SRC_DIR "${CMAKE_SOURCE_DIR}/src/core/agent")

## Included source files.
set (SOURCE_FILES hsa_agent.c test_concurrent_iterate.c test_concurrent_query.c test_iterate_null_data.c test_iterate_terminate.c test_query_attributes.c test_query_system_attributes.c)

## Test list.
set (TEST_LIST iterate_null_data iterate_terminate iterate_query_attributes concurrent_query concurrent_iterate query_system_attributes)

include (build)
include (test)
Loading

0 comments on commit 37d2652

Please sign in to comment.