Skip to content

Commit d89e424

Browse files
updated context callback fn
1 parent 8cfe0db commit d89e424

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

include/acl_context.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ extern "C" {
1616
#pragma GCC visibility push(protected)
1717
#endif
1818

19+
// Constants
20+
static constexpr const char* ENV_CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA = "CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA";
21+
static constexpr const char* ENV_AOCL_EAGERLY_LOAD_FIRST_BINARY = "AOCL_EAGERLY_LOAD_FIRST_BINARY";
22+
static constexpr const char* ENV_CL_CONTEXT_COMPILER_MODE_INTELFPGA = "CL_CONTEXT_COMPILER_MODE_INTELFPGA";
23+
static constexpr const char* ENV_CL_CONTEXT_COMPILER_MODE_ALTERA = "CL_CONTEXT_COMPILER_MODE_ALTERA";
24+
static constexpr const char* ENV_CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA = "CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA";
25+
static constexpr const char* ENV_CL_CONTEXT_COMPILE_COMMAND_INTELFPGA = "CL_CONTEXT_COMPILE_COMMAND_INTELFPGA";
26+
static constexpr const char* ENV_ACL_CONTEXT_CALLBACK_DEBUG = "ACL_CONTEXT_CALLBACK_DEBUG";
27+
1928
// Update data structures in response to async msgs from devices.
2029
// Do this as part of a waiting loop, along with acl_hal_yield().
2130
void acl_update_context(cl_context context);

src/acl_context.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ static cl_context l_create_context(const cl_context_properties *properties,
474474
// Blocking multiple_processing
475475
const char *allow_mp = NULL;
476476
// Check if user wants to disable the check.
477-
allow_mp = acl_getenv("CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA");
477+
allow_mp = acl_getenv(ENV_CL_CONTEXT_ALLOW_MULTIPROCESSING_INTELFPGA);
478478
if (!allow_mp && platform_owner_pid != 0 &&
479479
platform_owner_pid != acl_get_pid()) {
480480
if (pfn_notify) {
@@ -565,7 +565,7 @@ static cl_int l_load_properties(cl_context context,
565565

566566
// This one is only overridden with an environment variable.
567567
{
568-
const char *override = acl_getenv("AOCL_EAGERLY_LOAD_FIRST_BINARY");
568+
const char *override = acl_getenv(ENV_AOCL_EAGERLY_LOAD_FIRST_BINARY);
569569
if (override) {
570570
// There was a string.
571571
char *endptr = 0;
@@ -580,13 +580,13 @@ static cl_int l_load_properties(cl_context context,
580580
{
581581
const char *override = 0;
582582
const char *override_deprecated = 0;
583-
override = acl_getenv("CL_CONTEXT_COMPILER_MODE_INTELFPGA");
584-
override_deprecated = acl_getenv("CL_CONTEXT_COMPILER_MODE_ALTERA");
583+
override = acl_getenv(ENV_CL_CONTEXT_COMPILER_MODE_INTELFPGA);
584+
override_deprecated = acl_getenv(ENV_CL_CONTEXT_COMPILER_MODE_ALTERA);
585585
if (!override && override_deprecated) {
586586
override = override_deprecated;
587587
fprintf(stderr,
588-
"Warning: CL_CONTEXT_COMPILER_MODE_ALTERA has been deprecated. "
589-
"Use CL_CONTEXT_COMPILER_MODE_INTELFPGA instead.\n");
588+
"Warning: %s has been deprecated. "
589+
"Use %s instead.\n", ENV_CL_CONTEXT_COMPILER_MODE_ALTERA, ENV_CL_CONTEXT_COMPILER_MODE_INTELFPGA);
590590
}
591591

592592
if (override) {
@@ -619,7 +619,7 @@ static cl_int l_load_properties(cl_context context,
619619
// If the env var is not set, then use "aocl_program_library" in the
620620
// current directory.
621621
const auto *default_root = acl_getenv(
622-
"CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA"); // this one is public,
622+
ENV_CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA); // this one is public,
623623
// in cl_ext_intelfpga.h
624624
if (!default_root) {
625625
default_root = "aocl_program_library";
@@ -632,7 +632,7 @@ static cl_int l_load_properties(cl_context context,
632632
// Get user-specified compile command.
633633
// The default command depends on effective compiler mode, so defer
634634
// until later.
635-
const char *default_cmd = acl_getenv("CL_CONTEXT_COMPILE_COMMAND_INTELFPGA");
635+
const char *default_cmd = acl_getenv(ENV_CL_CONTEXT_COMPILE_COMMAND_INTELFPGA);
636636
if (default_cmd) {
637637
status = l_update_compile_command(context, default_cmd);
638638
if (status != CL_SUCCESS)
@@ -1314,6 +1314,10 @@ void acl_context_callback(cl_context context, const std::string errinfo) {
13141314
notify_fn(errinfo.c_str(), 0, 0, notify_user_data);
13151315
}
13161316
}
1317+
1318+
if (context && acl_getenv(ENV_ACL_CONTEXT_CALLBACK_DEBUG)) {
1319+
std::cout << "[acl_context_callback] " << errinfo << std::endl;
1320+
}
13171321
}
13181322

13191323
// Called when runtime has been waiting for device update for a while

0 commit comments

Comments
 (0)