-
Notifications
You must be signed in to change notification settings - Fork 9
Issue 112 #114
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
Issue 112 #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| module MKL | ||
|
|
||
| using LinearAlgebra: LinearAlgebra, BLAS | ||
| using Libdl | ||
|
|
||
| const MKL_PATH = Ref{Union{Nothing, String}}(nothing) | ||
|
|
||
|
|
@@ -41,15 +42,19 @@ end | |
| mkl_get_dynamic() | ||
| Wrapper around the MKL function [`mkl_get_dynamic`](https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-fortran/top/support-functions/threading-control/mkl-get-dynamic.html). | ||
| """ | ||
| mkl_get_dynamic() = @ccall mkl_fullpath().mkl_get_dynamic()::Cint | ||
| function mkl_get_dynamic() | ||
| sym = Libdl.dlsym(Libdl.dlopen(mkl_fullpath()), :mkl_get_dynamic) | ||
| ccall(sym, Cint, ()) | ||
| end | ||
|
|
||
| """ | ||
| mkl_set_dynamic(flag::Integer) | ||
|
|
||
| Wrapper around the MKL function [`mkl_set_dynamic`](https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/support-functions/threading-control/mkl-set-dynamic.html). | ||
| """ | ||
| function mkl_set_dynamic(flag::Integer) | ||
| @ccall mkl_fullpath().MKL_Set_Dynamic(flag::Cint)::Cvoid | ||
| sym = Libdl.dlsym(Libdl.dlopen(mkl_fullpath()), :MKL_Set_Dynamic) | ||
| ccall(sym, Cvoid, (Cint,), flag) | ||
|
Comment on lines
55
to
+57
|
||
| end | ||
|
|
||
| end # module | ||
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.
Libdl.dlopen(mkl_fullpath())is executed on every call, and the resulting handle is never explicitly closed or cached. This can add overhead and may temporarily increase the dlopen refcount until GC runs. Consider caching the handle (e.g., aconst Refinitialized once) or using theLibdl.dlopen(path) do lib ... endform to ensure timelydlclose.