Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove simulator device from offline devices #319

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/acl_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const char *acl_get_offline_device_user_setting(int *use_offline_only_ret) {
}
if (setting) {
use_offline_only = ACL_CONTEXT_MPSIM;
result = setting;
result = 0;
}
}

Expand Down
15 changes: 3 additions & 12 deletions src/acl_hal_mmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,28 +1178,19 @@ void l_close_device(unsigned int physical_device_id,

static acl_mmd_dispatch_t *get_msim_mmd_layer() {
#ifdef _WIN32

const char *acl_root_dir = acl_getenv("INTELFPGAOCLSDKROOT");
info_assert(acl_root_dir,
"INTELFPGAOCLSDKROOT environment variable is missing!");
const std::string mmd_lib_name_aoc_str =
const std::string mmd_lib_name_str =
std::string(acl_root_dir) + "\\host\\windows64\\bin\\aoc_cosim_mmd.dll";
const std::string mmd_lib_name_ipa_str =
std::string(acl_root_dir) + "\\host\\windows64\\bin\\ipa_cosim_mmd.dll";

const char *mmd_lib_name_aoc = mmd_lib_name_aoc_str.c_str();
const char *mmd_lib_name_ipa = mmd_lib_name_ipa_str.c_str();
const char *mmd_lib_name = mmd_lib_name_str.c_str();
const char *sym_name = "msim_mmd_layer";
#else
const char *mmd_lib_name_aoc = "libaoc_cosim_mmd.so";
const char *mmd_lib_name_ipa = "libipa_cosim_mmd.so";
const char *mmd_lib_name = "libaoc_cosim_mmd.so";
const char *sym_name = "msim_mmd_layer";
#endif

const char *ipa_simulator = acl_getenv("ACL_IPA_SIM");
const char *mmd_lib_name =
ipa_simulator ? mmd_lib_name_ipa : mmd_lib_name_aoc;

char *error_msg = nullptr;
auto *mmd_lib = my_dlopen(mmd_lib_name, &error_msg);
typedef acl_mmd_dispatch_t *(*fcn_type)();
Expand Down
39 changes: 9 additions & 30 deletions src/acl_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ void acl_init_platform(void) {
const char *offline_device =
acl_get_offline_device_user_setting(&acl_platform.offline_mode);
if (offline_device) {
if (acl_platform.offline_mode == ACL_CONTEXT_MPSIM) {
acl_platform.offline_device = ACL_MPSIM_DEVICE_NAME;
} else {
acl_platform.offline_device = offline_device;
}
acl_platform.offline_device = offline_device;
}

acl_platform.name = "Intel(R) FPGA SDK for OpenCL(TM)";
Expand Down Expand Up @@ -591,21 +587,6 @@ static void l_initialize_offline_devices(int offline_mode) {
board_def->num_devices = 1;
}

if (offline_mode == ACL_CONTEXT_MPSIM) {
auto &board_def = shipped_board_defs.emplace_back();
board_def.emplace();
std::string err_msg;
if (!acl_load_device_def_from_str(acl_shipped_board_cfgs[0].cfg,
board_def->device[0].autodiscovery_def,
err_msg)) {
board_def.reset();
} else {
board_def->num_devices = 1;
// Need to change the name here or before we send the string
board_def->device[0].autodiscovery_def.name = ACL_MPSIM_DEVICE_NAME;
}
}

if (!acl_platform.offline_device.empty()) {
unsigned int board_count = 1;
int device_index = 0;
Expand All @@ -624,16 +605,15 @@ static void l_initialize_offline_devices(int offline_mode) {
board_def->device[0].autodiscovery_def.name)
continue;

const bool is_present = (offline_mode == ACL_CONTEXT_MPSIM);
for (unsigned j = 0; j < board_count; j++) {
// Bail if not present and we haven't been told to use absent devices
if (!is_present && acl_platform.offline_device !=
board_def->device[0].autodiscovery_def.name)
// Bail if we haven't been told to use absent devices
if (acl_platform.offline_device !=
board_def->device[0].autodiscovery_def.name)
continue;
// Add HW specific device definition
acl_platform.device[device_index].def =
board_def->device[0]; // Struct Copy
acl_platform.device[device_index].present = is_present;
acl_platform.device[device_index].present = false;
device_index++;
}
}
Expand Down Expand Up @@ -661,11 +641,10 @@ static void l_initialize_devices(const acl_system_def_t *present_board_def,
if (offline_mode == ACL_CONTEXT_OFFLINE_AND_AUTODISCOVERY ||
offline_mode == ACL_CONTEXT_MPSIM) {
unsigned int num_platform_devices = acl_platform.num_devices;
if (!acl_platform.offline_device.empty() &&
offline_mode != ACL_CONTEXT_MPSIM) {
num_platform_devices -=
1; // In this case there's an extra offline devices at the end of the
// list. Do not check it.
if (!acl_platform.offline_device.empty()) {
// In this case there's an extra offline devices at the end of the list.
// Do not check it.
num_platform_devices -= 1;
}

// Then add the present devices, if any.
Expand Down