Skip to content

Commit

Permalink
Disable the experimental hc::printf on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
scchan committed Jul 9, 2019
1 parent 1e09c7b commit 21f65db
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
11 changes: 8 additions & 3 deletions include/hc_printf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@

// The printf on the accelerator is only enabled when
// The HCC_ENABLE_ACCELERATOR_PRINTF is defined
//
//#define HCC_ENABLE_ACCELERATOR_PRINTF (1)

// Disabling hc::printf it's broken on certain platform
// and this experimental feature is not longer being maintained.
#ifdef HCC_ENABLE_ACCELERATOR_PRINTF
#undef HCC_ENABLE_ACCELERATOR_PRINTF
#warning "The experimental hc::printf is no longer supported and is disabled"
#endif

// Indicate whether hc::printf is supported
#define HC_FEATURE_PRINTF (1)
//#define HC_FEATURE_PRINTF (1)

// Enable extra debug messages
#define HC_PRINTF_DEBUG (0)
Expand Down
8 changes: 8 additions & 0 deletions lib/hsa/mcwamp_hsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3587,6 +3587,7 @@ class HSAContext final : public KalmarContext
}
def = Devices[first_gpu_index + HCC_DEFAULT_GPU];

#ifdef HC_PRINTF_SUPPORT_ENABLE
// pinned hc::printf_buffer so that the GPUs could access it
if (hc::printf_buffer_locked_va == nullptr) {
hsa_status_t status = HSA_STATUS_SUCCESS;
Expand All @@ -3595,6 +3596,7 @@ class HSAContext final : public KalmarContext
hsa_agents, agents.size(), (void**)&hc::printf_buffer_locked_va);
STATUS_CHECK(status, __LINE__);
}
#endif

init_success = true;
}
Expand All @@ -3621,6 +3623,7 @@ class HSAContext final : public KalmarContext
if (!init_success)
return;

#if HC_PRINTF_SUPPORT_ENABLE
// deallocate the printf buffer
if (HCC_ENABLE_PRINTF &&
hc::printf_buffer != nullptr) {
Expand All @@ -3632,6 +3635,7 @@ class HSAContext final : public KalmarContext
status = hsa_amd_memory_unlock(&hc::printf_buffer);
STATUS_CHECK(status, __LINE__);
hc::printf_buffer_locked_va = nullptr;
#endif

// destroy all KalmarDevices associated with this context
for (auto dev : Devices)
Expand Down Expand Up @@ -5792,6 +5796,8 @@ HSACopy::syncCopy() {
// ----------------------------------------------------------------------

extern "C" void *GetContextImpl() {

#ifdef HC_PRINTF_SUPPORT_ENABLE
// If hc::printf is enabled, it must be initialized *after* the Kalmar::ctx is created.
// We only want to do this once, but the call to initPrintfBuffer will recurse back
// into this getter. We use TLS to make sure the same thread is the one recursing.
Expand All @@ -5805,6 +5811,8 @@ extern "C" void *GetContextImpl() {
});
}
}
#endif

return Kalmar::ctx;
}

Expand Down
7 changes: 4 additions & 3 deletions scripts/cmake/MCWAMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ include(ImportedTargets)
macro(amp_target name )
set(CMAKE_CXX_COMPILER "${PROJECT_BINARY_DIR}/compiler/bin/clang++")
add_compile_options(-std=c++11)

# printf has to be disable on RHEL/CentOS 7.x due to unstable support of std::regex
if (NOT HCC_TOOLCHAIN_RHEL)
target_compile_definitions(${name} PRIVATE HC_PRINTF_SUPPORT_ENABLE)
endif()
# Disabling experimental hc::printf on all platforms due to breakage and lack of maintance
# target_compile_definitions(${name} PRIVATE HC_PRINTF_SUPPORT_ENABLE)

target_compile_definitions(${name} PRIVATE "GTEST_HAS_TR1_TUPLE=0")
target_include_directories(${name} SYSTEM PRIVATE ${GTEST_INC_DIR} ${LIBCXX_INC_DIR})
target_include_directories(${name} PRIVATE ${MCWAMP_INC_DIR})
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/HSA/printf.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: *
// RUN: %hc %s -DHCC_ENABLE_ACCELERATOR_PRINTF -lhc_am -o %t.out && %t.out | %FileCheck %s

#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/HSA/printf_error_check.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: *
// RUN: %hc %s -DHCC_ENABLE_ACCELERATOR_PRINTF -DCHECK_PRINTF_ERROR -lhc_am -o %t.out && %t.out | %FileCheck %s

#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/HSA/printf_excess_args.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: *
// RUN: %hc %s -DHCC_ENABLE_ACCELERATOR_PRINTF -lhc_am -o %t.out && %t.out | %FileCheck %s

#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/HSA/printf_minimal.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: *
// RUN: %hc %s -DHCC_ENABLE_ACCELERATOR_PRINTF -lhc_am -o %t.out && %t.out | %FileCheck %s

#include <hc.hpp>
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/HSA/printf_ptr_addr.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// XFAIL: *
// RUN: %hc %s -DHCC_ENABLE_ACCELERATOR_PRINTF -lhc_am -o %t.out && %t.out | %FileCheck %s

#include <hc.hpp>
Expand Down

0 comments on commit 21f65db

Please sign in to comment.