Skip to content

Conversation

@niuxiaog
Copy link
Contributor

To solve issue #293.

@niuxiaog niuxiaog requested review from Menooker and crazydemo August 28, 2024 02:24
static thread_local FILOMemoryPool threadMemoryPool_{threadlocalChunkSize};

extern "C" void *gcAlignedMalloc(size_t sz) noexcept {
#if defined _WIN32 || defined __CYGWIN__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should move this macro to a shared header in CPURuntime folder, as many cpp files will need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be move it even higher? I believe it's required not only for CPURuntime. What about renaming gc_version.h to gc.h and putting the common staff there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be move it even higher? I believe it's required not only for CPURuntime.

What about to do this only when there is a real requirement?

renaming gc_version.h to gc.h and putting the common staff there

The name gc_version.h conveys more specific information and may be a better name. The newly added CPURuntime/Utils.h and gc_version.h contains macros with totally different purpose. Currently these is no file which needs to include them both. So putting them together may not be necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to do this only when there is a real requirement?

Currently, except of CPURuntime, we need it at least for lib/gc/ExecutionEngine/OpenCLRuntime/OpenCLRuntimeWrappers.cpp and src/dnnl/dnnl_graph_compiler.cpp

@Menooker
Copy link

Suggest to co-work with @huanghaixin008 . The brgemm library also needs to export the symbols.

@huanghaixin008
Copy link
Contributor

Suggest to co-work with @huanghaixin008 . The brgemm library also needs to export the symbols.

@niuxiaog I will push my changes to this branch

@niuxiaog niuxiaog changed the title [CPU][Runtime] Set gcAligned* funcs visibility to default [CPU][Runtime] Set some CPURuntime funcs visibility to default Aug 28, 2024
//
//===----------------------------------------------------------------------===//

#if defined _WIN32 || defined __CYGWIN__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the include guard for this header. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh Oh Sorry for the mistake.

#else
#define OCL_RUNTIME_EXPORT
#endif // _WIN32
#include "gc_utils.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the CMakeList.txt to add the directory of newly added "gc_utils.h" to resolve the build error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks for the advice! I will come back to this PR soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose moving this file into the gc folder, in order to have all the headers under the single root, and renaming to Utils.h, to be consistent with the naming style of all other headers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The folder gc is a mirror of llvm/mlir/include/mlir, which contains real functions. Instead, the gc_version.h and gc_utils.h contain macros, so it may be better to keep them outside.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gc_utils.h may contain not only macros, for example, logging functions could be added there.
I'm thinking also from the installation point of view. Imagine that we have built a dev package. All these headers are installed to /usr/include and I think it's more convenient to have all the files in a single dir.

target_include_directories(GcOpenclRuntime PRIVATE
${MLIR_INCLUDE_DIRS}
${OpenCL_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, you can just add GcInterface to target_link_libraries(). It should propagate all the common includes, build options, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's also a reasonable way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you plan to change this?

Which way do you think is better?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't ${PROJECT_SOURCE_DIR}/include already in include path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${PROJECT_SOURCE_DIR}/include is not in include path, which causes the including error of gc_utils.h. But now gc_utils.h is moved into /include/gc, I will modify this now. Thanks for the reminder!

@niuxiaog niuxiaog linked an issue Sep 10, 2024 that may be closed by this pull request
@ciyongch
Copy link
Contributor

Please rebase the PR and address the comments, then we can merge it for OV integration.

Copy link
Contributor

@kurapov-peter kurapov-peter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kurapov-peter kurapov-peter merged commit c94a772 into main Sep 16, 2024
@kurapov-peter kurapov-peter deleted the xgniu/dll_export_gcmalloc branch September 16, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OV-gc-mlir integration: some symbols not found

7 participants