Forum Discussion
jackgreen
New Contributor
5 years agoNot sure how many active users are still using this forum. For what is worth, I want to share my results for solving this problem. Hope this could help people who come across the same problem.
The problem indeed lies in the MMD library. In all current version of csoc5 BSPs and RTEs, Version 14.1 MMD is used. The newest MMD is of version 18.1 which I found in Intel Opencl FPGA SDK Pro 20.4. Seems like this version was just resleased.
In the MMD 18.1, it mentioned in the source file about fixing this bug in 14.1.
// global variables used for handling multi-devices and its helper functions
// Use a DeviceMapManager to manage a heap-allocated map for storing device information
// instead of using a static global map because of a segmentation fault which occurs in
// the following situation:
// 1) Host program contains a global variable which calls clReleaseContext in its destructor.
// When the program ends the global goes out of scope and the destructor is called.
// 2) clReleaseContext calls a function in the MMD library which modifies the static global map in
// the MMD library.
// In this situation it was discovered that the destructor of the static global map is called before
// the destructor of the global in the host program, thus resulting in a segmentation fault when
// clReleaseContext calls a function that modifies the internal map after it has been destroyed.
// Using a heap-allocated map avoids this issue as the lifetime of the map persists until it is
// deleted or the process is completely terminated.
So when I remove my global variables, everything works.