Skip to content

Add proxy_pool #185

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

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Add proxy_pool #185

merged 1 commit into from
Feb 8, 2024

Conversation

igchor
Copy link
Member

@igchor igchor commented Jan 30, 2024

a pool that forwards all (supported) requests to the memory provider.

@igchor igchor requested a review from a team as a code owner January 30, 2024 00:02
@igchor
Copy link
Member Author

igchor commented Jan 31, 2024

Ok, I was debugging the windows failure and it looks like there is a problem with exporting global variables (like OPS vars).

Accordingly to the documentation: "Using __declspec(dllimport) is optional on function declarations, but the compiler produces more efficient code if you use this keyword. However, you must use __declspec(dllimport) for the importing executable to access the DLL's public data symbols and objects".

So, this means that we would need to define UMF_EXPORT like this:

#if defined(UMF_EXPORTS) && defined(UMF_SHARED_LIBRARY)
    #define UMF_EXPORT __declspec(dllexport)
#elif defined(UMF_SHARED_LIBRARY)
    #define UMF_EXPORT __declspec(dllimport)
#endif

but... then we have a problem when we build UMF as a static library because using __declspel(dllimport) on symbols from static library will result in linking failure (see here). To solve this users would need to define UMF_SHARED_LIBRARY in their application whenever linking with libumf as a shared library (or the other way around, define something for static library).

I don't think forcing users to define this is a good ideas to perhaps we could just avoid global variables altogether? Instead of global UMF_*_POOL_OPS variables we could just define functions that would return proper ops. @pbalcer @bratpiorka @vinser52 any thoughts?

@lplewa
Copy link
Contributor

lplewa commented Jan 31, 2024

Ok, I was debugging the windows failure and it looks like there is a problem with exporting global variables (like OPS vars).

Accordingly to the documentation: "Using __declspec(dllimport) is optional on function declarations, but the compiler produces more efficient code if you use this keyword. However, you must use __declspec(dllimport) for the importing executable to access the DLL's public data symbols and objects".

So, this means that we would need to define UMF_EXPORT like this:

#if defined(UMF_EXPORTS) && defined(UMF_SHARED_LIBRARY)
    #define UMF_EXPORT __declspec(dllexport)
#elif defined(UMF_SHARED_LIBRARY)
    #define UMF_EXPORT __declspec(dllimport)
#endif

but... then we have a problem when we build UMF as a static library because using __declspel(dllimport) on symbols from static library will result in linking failure (see here). To solve this users would need to define UMF_SHARED_LIBRARY in their application whenever linking with libumf as a shared library (or the other way around, define something for static library).

I don't think forcing users to define this is a good ideas to perhaps we could just avoid global variables altogether? Instead of global UMF_*_POOL_OPS variables we could just define functions that would return proper ops. @pbalcer @bratpiorka @vinser52 any thoughts?

Imho solution is to use DEF file on Windows instead of dllexport. It's similar to linux map file, and it's hides windows mess from header.

@igchor
Copy link
Member Author

igchor commented Jan 31, 2024

Imho solution is to use DEF file on Windows instead of dllexport. It's similar to linux map file, and it's hides windows mess from header.

@lplewa +1 for using .def files but accordingly to https://learn.microsoft.com/en-us/cpp/build/reference/exports?view=msvc-170 this won't really solve the issue here:

"When you export a variable from a DLL by using a .DEF file, you do not have to specify __declspec(dllexport) on the variable. However, in any file that uses the DLL, you must still use __declspec(dllimport) on the declaration of data".

@lplewa
Copy link
Contributor

lplewa commented Jan 31, 2024

Imho solution is to use DEF file on Windows instead of dllexport. It's similar to linux map file, and it's hides windows mess from header.

@lplewa +1 for using .def files but accordingly to https://learn.microsoft.com/en-us/cpp/build/reference/exports?view=msvc-170 this won't really solve the issue here:

"When you export a variable from a DLL by using a .DEF file, you do not have to specify __declspec(dllexport) on the variable. However, in any file that uses the DLL, you must still use __declspec(dllimport) on the declaration of data".

Windows....

Can we replace exported global variable with an exported "get" function, which returns global "nonexported" variable from dll?

@igchor
Copy link
Member Author

igchor commented Jan 31, 2024

Imho solution is to use DEF file on Windows instead of dllexport. It's similar to linux map file, and it's hides windows mess from header.

@lplewa +1 for using .def files but accordingly to https://learn.microsoft.com/en-us/cpp/build/reference/exports?view=msvc-170 this won't really solve the issue here:
"When you export a variable from a DLL by using a .DEF file, you do not have to specify __declspec(dllexport) on the variable. However, in any file that uses the DLL, you must still use __declspec(dllimport) on the declaration of data".

Windows....

Can we replace exported global variable with an exported "get" function, which returns global "nonexported" variable from dll?

Yeah, that was my idea as well - I think this should work (although I haven't tried that yet, and it's windows so anything is possible). I just wanted to ask first, and see if there's a better way.

@lplewa
Copy link
Contributor

lplewa commented Jan 31, 2024

I will vote to switch to def files, and instead exporting variables, export getters.

@pbalcer
Copy link
Contributor

pbalcer commented Jan 31, 2024

I will vote to switch to def files, and instead exporting variables, export getters.

👍

@igchor
Copy link
Member Author

igchor commented Jan 31, 2024

Ok, I'll make a PR to replace all variables with getters. This is not strictly necessary for every variable since some of them are only in static libraries, e.g. disjoint_pool but I think it's better to be consistent + we may choose to build those libs as DLLs in future.

@igchor igchor force-pushed the proxy_pool branch 4 times, most recently from 8a3e86c to f90821a Compare January 31, 2024 21:38
@igchor igchor force-pushed the proxy_pool branch 3 times, most recently from c9c3e36 to 5d71fa9 Compare February 5, 2024 23:07
@igchor igchor requested a review from bratpiorka February 5, 2024 23:08
a pool that forwards all (supported) requests to the
memory provider
@bratpiorka bratpiorka merged commit e9c9d9f into oneapi-src:main Feb 8, 2024
@igchor igchor deleted the proxy_pool branch February 8, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants