Skip to content
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

Separate host arch specific code to directories #75

Closed
wants to merge 1 commit into from

Conversation

pjanevskiTT
Copy link
Contributor

Fixes #56

driver_atomics files separated into specific directories for each possible host arch that we want to support for now

TODO

  • tt-metal post commit
  • Proper place for these files. Currently these are in device/arch. Do we need to move it elsewhere, for example root host_arch directory or something like that

@@ -78,6 +78,17 @@ include(${PROJECT_SOURCE_DIR}/cmake/dependencies.cmake)
add_library(umd_common_directories INTERFACE)
target_include_directories(umd_common_directories INTERFACE ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/device ${PROJECT_SOURCE_DIR}/third_party/fmt/include)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
Copy link
Contributor

Choose a reason for hiding this comment

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

Per offline discussion, include .cpp sources by host arch instead of headers, that way interface to metal will be the same.

The drawback, though, will be that the compiler won't be able to remove function call in that case. Wondering if that might even be a problem... According to github copilot, this shouldn't be a problem.

It could be a perf hit though.
In anycase, these should be in a separate utils repo. Started an issue here: #78

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These function cannot be inline anymore since the implementation will move to .cpp files. Are we ok with this?

If we want to keep it inline, we could just guard include headers with defines like

#if defined (__x86_64__)
#include "x86/driver_atomics.h"
#endif

// empty file for device/driver_atomics.h

and move the implementation to separate .h files based on the architecture. This way we don't need to change cmake. Next step could be to add dependency on host arch to cmake (or investigate if there already is some dependency) in order to completely remove device/driver_atomics.h

@joelsmithTT
Copy link
Contributor

The conditional compilation for x86 vs arm vs riscv is fine as it's not something that the build system or user needs to worry about. I am not convinced that the additional complexity this introduces (multiple files, additional build logic) is worth the benefit.

@pjanevskiTT
Copy link
Contributor Author

This requires some changes in the build system of Metal, which is not a priority at the moment, I will move the PR to draft just to not forget and we can change what is needed later on

The conditional compilation for x86 vs arm vs riscv is fine as it's not something that the build system or user needs to worry about. I am not convinced that the additional complexity this introduces (multiple files, additional build logic) is worth the benefit.

OK, makes sense. If it somehow starts to blow up, we can come back and reconsider

@broskoTT broskoTT linked an issue Sep 26, 2024 that may be closed by this pull request
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.

Separate arch specific code to directories Remove conditional compilation
3 participants