<commit_before>cmake_minimum_required (VERSION 2.6)

# remove CMAKE_CXX_COMPILER entry from cache since it will be pointing to hipcc
unset(CMAKE_CXX_COMPILER CACHE)
# remove HIP_PATH entry from cache since we might be running tests with a different configuration
unset(HIP_PATH CACHE)

project(HIP_Unit_Tests)
include(CTest)
set(HIPTEST_SOURCE_DIR ${PROJECT_SOURCE_DIR})

# Enable multi-gpu tests
if(NOT DEFINED HIP_MULTI_GPU)
    set(HIP_MULTI_GPU 0 CACHE BOOL "Run tests requiring more than one GPU")
endif()

# Determine HIP_PATH
if(NOT DEFINED HIP_PATH)
        if(NOT DEFINED ENV{HIP_PATH})
        # We are going to use HIP source...
        get_filename_component(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../.. ABSOLUTE)
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -E remove_directory hip
                OUTPUT_QUIET
                ERROR_QUIET
                )
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -E make_directory hip
                OUTPUT_QUIET
                ERROR_QUIET
                )
        message(STATUS "Configuring HIP")
        # ...so need to build HIP locally.
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/hip/localbuild ${HIP_SRC_PATH}
                WORKING_DIRECTORY hip
                RESULT_VARIABLE hip_build_result
                OUTPUT_QUIET
                ERROR_QUIET
                )
        if(hip_build_result)
            message(FATAL_ERROR "Error configuring HIP")
        else()
            message(STATUS "Configuring HIP - done")
            message(STATUS "Building HIP")
        endif()
        execute_process(
                COMMAND "${CMAKE_COMMAND}" --build . --target install
                WORKING_DIRECTORY hip
                RESULT_VARIABLE hip_build_result
                OUTPUT_QUIET
                ERROR_QUIET
                )
        if(hip_build_result)
            message(FATAL_ERROR "Error building HIP")
        else()
            # Building HIP is successful. Point HIP_PATH to this location.
            message(STATUS "Building HIP - done")
            get_filename_component(HIP_PATH ${CMAKE_CURRENT_BINARY_DIR}/hip/localbuild ABSOLUTE)
        endif()
        # Add a target to rebuild HIP if HIP source changes.
        add_custom_target(
                hip ALL<commit_msg>directed tests: Show HIP build errors during configure stage<commit_after>cmake_minimum_required (VERSION 2.6)

# remove CMAKE_CXX_COMPILER entry from cache since it will be pointing to hipcc
unset(CMAKE_CXX_COMPILER CACHE)
# remove HIP_PATH entry from cache since we might be running tests with a different configuration
unset(HIP_PATH CACHE)

project(HIP_Unit_Tests)
include(CTest)
set(HIPTEST_SOURCE_DIR ${PROJECT_SOURCE_DIR})

# Enable multi-gpu tests
if(NOT DEFINED HIP_MULTI_GPU)
    set(HIP_MULTI_GPU 0 CACHE BOOL "Run tests requiring more than one GPU")
endif()

# Determine HIP_PATH
if(NOT DEFINED HIP_PATH)
        if(NOT DEFINED ENV{HIP_PATH})
        # We are going to use HIP source...
        get_filename_component(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../.. ABSOLUTE)
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -E remove_directory hip
                OUTPUT_QUIET
                ERROR_QUIET
                )
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -E make_directory hip
                OUTPUT_QUIET
                ERROR_QUIET
                )
        message(STATUS "Configuring HIP")
        # ...so need to build HIP locally.
        execute_process(
                COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/hip/localbuild ${HIP_SRC_PATH}
                WORKING_DIRECTORY hip
                RESULT_VARIABLE hip_build_result
                OUTPUT_QUIET
                ERROR_QUIET
                )
        if(hip_build_result)
            message(FATAL_ERROR "Error configuring HIP")
        else()
            message(STATUS "Configuring HIP - done")
            message(STATUS "Building HIP")
        endif()
        execute_process(
                COMMAND "${CMAKE_COMMAND}" --build . --target install
                WORKING_DIRECTORY hip
                RESULT_VARIABLE hip_build_result
                OUTPUT_VARIABLE hip_build_log
                ERROR_QUIET
                )
        if(hip_build_result)
            message(${hip_build_log})
            message(FATAL_ERROR "Error building HIP")
        else()
            # Building HIP is successful. Point HIP_PATH to this location.
            message(STATUS "Building HIP - done")
            get_filename_component(HIP_PATH ${CMAKE_CURRENT_BINARY_DIR}/hip/localbuild ABSOLUTE)
        endif()
        # Add a target to rebuild HIP if HIP source changes.
        add_custom_target(
                hip ALL
{'fraction_non_alphanumeric': 0.0644234714813295, 'fraction_numerical': 0.0012310217480508822, 'mean_word_length': 2.0718336483931945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4520278', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1382, 'n_words': 353}