Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite659814

Browse files
sebergcharris
authored andcommitted
BUG: Fix cache use regression
gh-29006 got the branching wrong leaving the cache undefined on mostGCC/clang, which means we wouldn't use it.Also move it up so that we can just remove the unused globals entirely.
1 parent152a776 commite659814

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

‎numpy/_core/src/multiarray/alloc.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@
2727
#endif
2828
#endif
2929

30-
#defineNBUCKETS 1024/* number of buckets for data*/
31-
#defineNBUCKETS_DIM 16/* number of buckets for dimensions/strides */
32-
#defineNCACHE 7/* number of cache entries per bucket */
30+
/* Do not enable the alloc cache if the GIL is disabled, or if ASAN or MSAN
31+
* instrumentation is enabled. The cache makes ASAN use-after-free or MSAN
32+
* use-of-uninitialized-memory warnings less useful. */
33+
#defineUSE_ALLOC_CACHE 1
34+
#ifdefPy_GIL_DISABLED
35+
# defineUSE_ALLOC_CACHE 0
36+
#elif defined(__has_feature)
37+
# if__has_feature(address_sanitizer)||__has_feature(memory_sanitizer)
38+
# defineUSE_ALLOC_CACHE 0
39+
# endif
40+
#endif
41+
42+
#ifUSE_ALLOC_CACHE
43+
# defineNBUCKETS 1024/* number of buckets for data*/
44+
# defineNBUCKETS_DIM 16/* number of buckets for dimensions/strides */
45+
# defineNCACHE 7/* number of cache entries per bucket */
3346
/* this structure fits neatly into a cacheline */
3447
typedefstruct {
3548
npy_uintpavailable;/* number of cached pointers */
3649
void*ptrs[NCACHE];
3750
}cache_bucket;
3851
staticcache_bucketdatacache[NBUCKETS];
3952
staticcache_bucketdimcache[NBUCKETS_DIM];
40-
53+
#endif/* USE_ALLOC_CACHE */
4154

4255
/*
4356
* This function tells whether NumPy attempts to call `madvise` with
@@ -99,20 +112,6 @@ indicate_hugepages(void *p, size_t size) {
99112
}
100113

101114

102-
/* Do not enable the alloc cache if the GIL is disabled, or if ASAN or MSAN
103-
* instrumentation is enabled. The cache makes ASAN use-after-free or MSAN
104-
* use-of-uninitialized-memory warnings less useful. */
105-
#ifdefPy_GIL_DISABLED
106-
#defineUSE_ALLOC_CACHE 0
107-
#elif defined(__has_feature)
108-
# if__has_feature(address_sanitizer)||__has_feature(memory_sanitizer)
109-
# defineUSE_ALLOC_CACHE 0
110-
# endif
111-
#else
112-
#defineUSE_ALLOC_CACHE 1
113-
#endif
114-
115-
116115
/* as the cache is managed in global variables verify the GIL is held */
117116

118117
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp