-
Notifications
You must be signed in to change notification settings - Fork 70
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
Cache context offline device setting specified by environment variables #235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sophimao ! Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sophimao, looks good. Please see two minor nitpicks below.
There remain two further calls of acl_get_offline_device_user_setting()
as detailed below. Why are these still needed, i.e., why can't they use the cached setting? This might be worthwhile commenting on in the commit message.
fpga-runtime-for-opencl/src/acl_globals.cpp
Lines 161 to 173 in 3c5c4f2
// Initialize the HAL and load the builtin system definition. | |
// | |
// It will handle setting up an offline device, either exclusively (by | |
// default), or in addition to devices found via HAL probing. | |
// | |
// This function returns CL_TRUE if a hal is initialized and CL_FALSE | |
// if it is not. | |
cl_bool acl_init_from_hal_discovery(void) { | |
int use_offline_only = 0; | |
const acl_hal_t *board_hal; | |
acl_assert_locked(); | |
(void)acl_get_offline_device_user_setting(&use_offline_only); |
fpga-runtime-for-opencl/src/acl_hal_mmd.cpp
Lines 1250 to 1251 in 3c5c4f2
// Dynamically load board mmd & symbols | |
(void)acl_get_offline_device_user_setting(&use_offline_only); |
These are called before the variable is cached. The reason why I cached the variable in I personally think it is cleaner to cache the variable in the |
I see. The call graph here is
so to avoid multiple calls,
Yes, this is about design only, and now I think your commit is fine without further comment. Let's keep this commit as is for 2023.1 and work out the full design in #234. |
Yes, for the regular flow that is correct. However, for unit test, there is another call graph:
So we would also need to add a call to I will keep the design this way for now, and address this in #234. |
Currently runtime queries context offline device setting from environment variables whenever this setting is needed, therefore introduces performance overhead. The caching is done to avoid this performance overhead.
3c5c4f2
to
8ea53b9
Compare
Of course, I missed that despite being right above the other entry point 🤦
The separate entry points for testing and production are unfortunate, but that topic should probably be handled separately from the revision in #234. I suggest you rebase that PR onto the |
Currently runtime queries context offline device setting from environment variables whenever this setting is needed, therefore introduces performance overhead. The caching is done to avoid this performance overhead.