-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[aarch64] cherry-pick Xbyak crash fix and linter error fixes from main (
#1649) * cleanup mkldnn patching (#1630) pytorch is moved to oneDNN v3.3.2 and some of the old patches are not applicable any more. * Add `aarch64_linux` to the list of linted files * Actually fix lint this type * aarch64: patch mkl-dnn for xbyak crashes due to /sys not accessible There are platforms with /sys not mounted. skip handling HW caps for such platforms. cherry-pick of: oneapi-src/oneDNN#1773 This fixes the issue# pytorch/pytorch#115482 --------- Co-authored-by: Nikita Shulga <[email protected]>
- Loading branch information
Showing
6 changed files
with
132 additions
and
45 deletions.
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
cpu: aarch64: fix xbyak functions for /sys access failures | ||
|
||
There are platforms with /sys not mounted. skip handling HW caps | ||
for such platforms. | ||
|
||
This fixes the issue# pytorch/pytorch#115482 | ||
--- | ||
.../xbyak_aarch64/src/util_impl_linux.h | 24 ++++++++++++++----- | ||
.../aarch64/xbyak_aarch64/src/util_impl_mac.h | 9 ++++--- | ||
2 files changed, 24 insertions(+), 9 deletions(-) | ||
|
||
diff --git a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h | ||
index 2c7b28e58b..860a05700f 100644 | ||
--- a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h | ||
+++ b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_linux.h | ||
@@ -144,8 +144,13 @@ private: | ||
regex_t regexBuf; | ||
regmatch_t match[1]; | ||
|
||
- if (regcomp(®exBuf, regex, REG_EXTENDED) != 0) | ||
- throw ERR_INTERNAL; | ||
+ if (regcomp(®exBuf, regex, REG_EXTENDED) != 0) { | ||
+ /* There are platforms with /sys not mounted. return empty buffers | ||
+ * in these scenarios | ||
+ */ | ||
+ buf[0] = '\0'; | ||
+ return 0; | ||
+ } | ||
|
||
const int retVal = regexec(®exBuf, path, 1, match, 0); | ||
regfree(®exBuf); | ||
@@ -187,8 +192,12 @@ private: | ||
regex_t regexBuf; | ||
regmatch_t match[2]; | ||
|
||
- if (regcomp(®exBuf, "index[0-9]*$", REG_EXTENDED) != 0) | ||
- throw ERR_INTERNAL; | ||
+ if (regcomp(®exBuf, "index[0-9]*$", REG_EXTENDED) != 0) { | ||
+ /* There are platforms with /sys not mounted. return gracefully | ||
+ * in these scenarios | ||
+ */ | ||
+ goto init_and_return_false; | ||
+ } | ||
|
||
if (regexec(®exBuf, dp->d_name, 1, match, 0) == 0) { // Found index[1-9][0-9]. directory | ||
char *dir_name = buf0; | ||
@@ -438,12 +447,15 @@ private: | ||
|
||
FILE *file = fopen(path_midr_el1, "r"); | ||
if (file == nullptr) { | ||
- throw Error(ERR_INTERNAL); | ||
+ /* There are platforms with /sys not mounted. return empty buffer | ||
+ * in these scenarios | ||
+ */ | ||
+ cacheInfo_.midr_el1 = 0xFE << 24; | ||
return; | ||
} | ||
|
||
if (fread(buf, sizeof(char), 64, file) == 0) { | ||
- throw Error(ERR_INTERNAL); | ||
+ cacheInfo_.midr_el1 = 0xFE << 24; | ||
return; | ||
} | ||
|
||
diff --git a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h | ||
index ebd6dba7c0..93bdae1d7a 100644 | ||
--- a/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h | ||
+++ b/src/cpu/aarch64/xbyak_aarch64/src/util_impl_mac.h | ||
@@ -102,18 +102,21 @@ private: | ||
size_t val = 0; | ||
size_t len = sizeof(val); | ||
|
||
+ /* There are platforms with /sys not mounted. skip | ||
+ * handling HW caps for such platforms. | ||
+ */ | ||
if (sysctlbyname(hw_opt_atomics, &val, &len, NULL, 0) != 0) | ||
- throw Error(ERR_INTERNAL); | ||
+ type_ = 0; | ||
else | ||
type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_ATOMIC : 0; | ||
|
||
if (sysctlbyname(hw_opt_fp, &val, &len, NULL, 0) != 0) | ||
- throw Error(ERR_INTERNAL); | ||
+ type_ = 0; | ||
else | ||
type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_FP : 0; | ||
|
||
if (sysctlbyname(hw_opt_neon, &val, &len, NULL, 0) != 0) | ||
- throw Error(ERR_INTERNAL); | ||
+ type_ = 0; | ||
else | ||
type_ |= (val == 1) ? (Type)XBYAK_AARCH64_HWCAP_ADVSIMD : 0; | ||
} | ||
-- | ||
2.34.1 | ||
|