Skip to content

Conversation

@john-michaelburke
Copy link
Contributor

@john-michaelburke john-michaelburke commented Mar 2, 2023

  • Adds a stripped-down version of the official ${MKLROOT}/lib/cmake/mkl/MKLConfig.cmake.
  • Attempts to find three static libraries off of known path MKLROOT
-- Found MKL: /opt/intel/oneapi/mkl/latest  
-- Found MKL: /opt/intel/oneapi/mkl/latest/lib/intel64/libmkl_intel_lp64.a  
-- Found MKL: /opt/intel/oneapi/mkl/latest/lib/intel64/libmkl_gnu_thread.a  
-- Found MKL: /opt/intel/oneapi/mkl/latest/lib/intel64/libmkl_core.a
  • If MKL_ROOT it will first check to see if MKLROOT is defined, then try to fall back on a known location before failing.
  • Using MKLROOT we deduce the include folder.
  • Here is an example of how this would be called in orion-engine:
if(ENABLE_MKL)
  find_package(MKL)
  if (MKL_FOUND)
    foreach(TARGET IN LISTS TESTS-OE EXE-OE LIBS-OE)
      target_link_libraries(${TARGET} PRIVATE MKL::MKL)
    endforeach()
  endif()
endif()

Copy link
Contributor

@jungleraptor jungleraptor left a comment

Choose a reason for hiding this comment

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

So the good thing about this version is they're using modern cmake conventions.

I do want to ask however, is the version we worked on not working?

This script is almost 900 lines of really complicated configurations. The goal of it is to "just work" for a huge number of potential target platforms.

However, for our needs, we probably only need to target one or two platforms and compilers. So I'd prefer if we checked in a simpler script that only targets our use cases.

We'll need to eventually port this to bazel and it'll go much smoother if we know exactly what options and settings we're building this library with, instead of having to filter through all this noise.

@john-michaelburke
Copy link
Contributor Author

So the good thing about this version is they're using modern cmake conventions.

I do want to ask however, is the version we worked on not working?

This script is almost 900 lines of really complicated configurations. The goal of it is to "just work" for a huge number of potential target platforms.

However, for our needs, we probably only need to target one or two platforms and compilers. So I'd prefer if we checked in a simpler script that only targets our use cases.

We'll need to eventually port this to bazel and it'll go much smoother if we know exactly what options and settings we're building this library with, instead of having to filter through all this noise.

What we had was working in CI for orion-engine but not for orion (although it seemed like they were using the same Dockerfile which is puzzling). I was hoping this could also be more friendly for local development than what we spun up. As for porting to bazel, I see that Tensorflow supports mkl in their bazel builds so hopefully, we can reuse if not just copy their implementation for our usecase. In the meantime, I can take a stab at gutting some of this config.

FindMKL.cmake Outdated
Comment on lines 842 to 212
target_compile_options(
MKL::MKL INTERFACE $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:${MKL_C_COPT}> $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,Fortran>:${MKL_F_COPT}>
$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${MKL_CXX_COPT}> $<IF:$<BOOL:${ENABLE_OMP_OFFLOAD}>,${MKL_OFFLOAD_COPT},>)
target_link_libraries(MKL::MKL INTERFACE ${MKL_LINK_LINE} ${MKL_THREAD_LIB} ${MKL_SUPP_LINK})
Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestions would be to capture whatever these lines end up expanding to for our target and hardcoding that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry just saw this now. I'll add that after the hackathon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@isaactorz I have addressed your concerns and hardcoded these blocks.

@john-michaelburke john-michaelburke force-pushed the john-michaelburke/official-mkl branch from 6c8b5d9 to c55d6ec Compare March 5, 2023 21:02
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/official-mkl branch 2 times, most recently from ae94b33 to 954b023 Compare April 13, 2023 17:52
@john-michaelburke john-michaelburke force-pushed the john-michaelburke/official-mkl branch from 954b023 to 4261355 Compare April 13, 2023 17:53
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@john-michaelburke john-michaelburke marked this pull request as ready for review April 14, 2023 19:12
Copy link
Contributor

@jungleraptor jungleraptor left a comment

Choose a reason for hiding this comment

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

Just one small nit otherwise this is a lot clearer as to what options we're actually setting up in our build 👍🏼 .

FindMKL.cmake Outdated
Comment on lines 45 to 47
set(MKL_ARCH intel64)
set(MKL_INTERFACE_FULL intel_lp64)
set(MKL_THREADING gnu_thread)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider getting rid of these variables and just adding them directly to MKL_LINK_LINE below. Having them more localized to where they're actually used will make this a bit more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Fair enough.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

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.

2 participants