Skip to content

Commit 2e99b5d

Browse files
sharmag1-Gauravzibaiwan
authored andcommitted
updated callback fn and ran clang-format
1 parent afad3c4 commit 2e99b5d

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

include/acl_context.h

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

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

src/acl_context.cpp

Lines changed: 17 additions & 9 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,15 @@ 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",
590+
ENV_CL_CONTEXT_COMPILER_MODE_ALTERA,
591+
ENV_CL_CONTEXT_COMPILER_MODE_INTELFPGA);
590592
}
591593

592594
if (override) {
@@ -619,8 +621,9 @@ static cl_int l_load_properties(cl_context context,
619621
// If the env var is not set, then use "aocl_program_library" in the
620622
// current directory.
621623
const auto *default_root = acl_getenv(
622-
"CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA"); // this one is public,
623-
// in cl_ext_intelfpga.h
624+
ENV_CL_CONTEXT_PROGRAM_EXE_LIBRARY_ROOT_INTELFPGA); // this one is public,
625+
// in
626+
// cl_ext_intelfpga.h
624627
if (!default_root) {
625628
default_root = "aocl_program_library";
626629
}
@@ -632,7 +635,8 @@ static cl_int l_load_properties(cl_context context,
632635
// Get user-specified compile command.
633636
// The default command depends on effective compiler mode, so defer
634637
// until later.
635-
const char *default_cmd = acl_getenv("CL_CONTEXT_COMPILE_COMMAND_INTELFPGA");
638+
const char *default_cmd =
639+
acl_getenv(ENV_CL_CONTEXT_COMPILE_COMMAND_INTELFPGA);
636640
if (default_cmd) {
637641
status = l_update_compile_command(context, default_cmd);
638642
if (status != CL_SUCCESS)
@@ -1314,6 +1318,10 @@ void acl_context_callback(cl_context context, const std::string errinfo) {
13141318
notify_fn(errinfo.c_str(), 0, 0, notify_user_data);
13151319
}
13161320
}
1321+
1322+
if (context && acl_getenv(ENV_ACL_CONTEXT_CALLBACK_DEBUG)) {
1323+
std::cout << "[acl_context_callback] Error Info: " << errinfo << std::endl;
1324+
}
13171325
}
13181326

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

0 commit comments

Comments
 (0)