-
Notifications
You must be signed in to change notification settings - Fork 6
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
namespace tt_driver_atomics { | ||
|
||
static inline __attribute__((always_inline)) void sfence() { | ||
// Full memory barrier (full system). ARM does not have a Store-Any barrier. | ||
// https://developer.arm.com/documentation/100941/0101/Barriers | ||
asm volatile ("DMB SY" : : : "memory"); | ||
} | ||
|
||
static inline __attribute__((always_inline)) void lfence() { | ||
// Load-Any barrier (full system) | ||
// https://developer.arm.com/documentation/100941/0101/Barriers | ||
asm volatile ("DMB LD" : : : "memory"); | ||
} | ||
|
||
static inline __attribute__((always_inline)) void mfence() { | ||
// Full memory barrier (full system). | ||
// https://developer.arm.com/documentation/100941/0101/Barriers | ||
asm volatile ("DMB SY" : : : "memory"); | ||
} | ||
|
||
} // namespace tt_driver_atomics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
namespace tt_driver_atomics { | ||
|
||
static inline __attribute__((always_inline)) void sfence() { | ||
asm volatile ("fence ow, ow" : : : "memory"); | ||
} | ||
|
||
static inline __attribute__((always_inline)) void lfence() { | ||
asm volatile ("fence ir, ir" : : : "memory"); | ||
} | ||
|
||
static inline __attribute__((always_inline)) void mfence() { | ||
asm volatile ("fence iorw, iorw" : : : "memory"); | ||
} | ||
|
||
} // namespace tt_driver_atomics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* SPDX-FileCopyrightText: (c) 2023 Tenstorrent Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <immintrin.h> | ||
|
||
namespace tt_driver_atomics { | ||
|
||
// Store-Any barrier. | ||
static inline __attribute__((always_inline)) void sfence() { | ||
_mm_sfence(); | ||
} | ||
// Load-Any barrier. | ||
static inline __attribute__((always_inline)) void lfence() { | ||
_mm_lfence(); | ||
} | ||
// Any-Any barrier. | ||
static inline __attribute__((always_inline)) void mfence() { | ||
_mm_mfence(); | ||
} | ||
|
||
} // namespace tt_driver_atomics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
|
||
#pragma once | ||
#include "device/tt_device.h" | ||
#include "device/driver_atomics.h" | ||
#include "driver_atomics.h" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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
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.
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
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