You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/07/01 18:43:54 UTC
[GitHub] [incubator-mxnet] mozga-intel opened a new pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
mozga-intel opened a new pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412
## Description ##
[Performance optimization] . This pull-request aims in the cpu-memory allocator. Typically, the size of a memory page is 4 KB. However, the modern operating system is able to support 2MB memory pages. This may improve performance results on a CPU in some scenarios.
# How to measure?
Basically: ways were used to measure the impact (a few of them), as following:
1. The first thing to measure is the number of TLB misses
2. The second thing to measure is the number of TLB misses
3. How much those misses cost for the CPU.
* Setting: Let’s turn the THP on.
# Result #
## After ##
### Perf: event aliases for dTLB ###
1. dTLB-loads and dTLB-load-misses (data loads)
2. dTLB-stores and dTLB-store-misses for data stores hits and misses
```
35.957945866 5918306862 dTLB-loads
35.957945866 3793195 dTLB-load-misses # 0,03% of all dTLB cache hits
35.957945866 1081002566 dTLB-stores
35.957945866 831964 dTLB-store-misses
= 1085627725 of TLB misses.
```
### Perf: event aliases for iTLB ###
1. iTLB-Load and iTLB-load-misses
```
35.518704631 5355733 iTLB-load
35.518704631 346871 iTLB-load-misses # 1,62% of all iTLB cache hits
= 346871 of iTLB misses ~ 1,62% of all iTLB cache hits
```
Let’s take a look at how much those misses cost for the CPU:
```
35.569491823 5624072755 cycles
35.569491823 48401471 dcycles
35.569491823 13984776 icycles
```
More than **90%** of CPU cycles were spent doing the page table walking
## Before ##
### Perf: event aliases for dTLB ###
1. dTLB-loads and dTLB-load-misses (data loads)
2. dTLB-stores and dTLB-store-misses for data stores hits and misses
```
36.257627478 11048485906 dTLB-loads
36.257627478 8580404 dTLB-load-misses # 0,06% of all dTLB cache hits
36.257627478 2244357468 dTLB-stores
36.257627478 1529163 dTLB-store-misses
= 2254467035 of TLB misses.
```
### Perf: event aliases for iTLB ###
1. iTLB-Load and iTLB-load-misses
```
35.004442377 17154527 iTLB-load
35.004442377 1043883 iTLB-load-misses # 4,75% of all iTLB cache hits
= 1043883 of iTLB misses ~ 4,75% of all iTLB cache hits
```
Let’s take a look at how much those misses cost for the CPU:
```
35.111981425 21648496310 cycles
35.111981425 159387423 dcycles
35.111981425 51165398 icycles
```
More than 97% of CPU cycles were spent doing the page table walking
## Checklist ##
### Essentials ###
- [ ] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
- [ ] Changes are complete (i.e. I finished coding on this PR)
- [ ] All changes have test coverage
- [ ] Code is well-documented
### Changes ###
- [ ] Feature1, tests, (and when applicable, API doc)
- [ ] Feature2, tests, (and when applicable, API doc)
## Comments ##
- If this change is a backward incompatible change, why must this change be made.
- Interesting edge cases to note here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-878121038
@anko-intel the inference, the image net model, C-API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-872895204
Jenkins CI successfully triggered : [unix-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r754989260
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
Review comment:
Of course, we can replace N with a suitable number, but it is not easy! Depending on the processor architecture, there are at least two different huge page sizes. On the 86_64 architecture: there is available 2MB and 1GB. This `grep pse /proc/cpuinfo | uniq` if this command returns a string and a string is non-empty; then either 2MB pages are supported or maybe 1GB is supported `grep pdpe1gb /proc/cpuinfo | uniq` (The 1GiB THP is supported only on the processors with the pdpeg1b CPU flag). Well, the default page size is equal to 4KiB ~ in my scenario, I had only the possibility to check max: ~2MB THP. I agree with it, that we suffer from size and alignment restrictions and still we have limited reach.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r754989260
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
Review comment:
Of course, we can replace N with some suitable number, but it is not easy! Depending on the processor architecture, there are at least two different huge page size. On the 86_64 architecture: there is available 2MB and 1GB. This `grep pse /proc/cpuinfo | uniq` if this command returns a string and a string is non-empty; then either 2MB pages are supported or maybe 1GB is supported `grep pdpe1gb /proc/cpuinfo | uniq` (The 1GiB THP is supported only on the processors with the pdpeg1b CPU flag). Well, the default page size is equal to 4KiB ~ in my scenario I had only possibility to check max: ~2MB THP.
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
+ madvise(ptr, size, MADV_HUGEPAGE);
Review comment:
Yeah, by default THP is `madvise` in which case it’s necessary to call `madvise(...MADV_HUGEPAGE)`. It gives opportunity to specifically enable THP for a range of memory. Well, Linux (THP) support does not guarantee that HP will be allocated. It means that it works only if THP support is enabled (the status of THP can be checked under /sys/kernel/). Hence, madvise should sets a flag for all the memory mapping corresponding to the a region that is passed directly to it ~ which will be the case in most Linux distribution.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-961258193
@szha Could you please review it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel edited a comment on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel edited a comment on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-878121038
@anko-intel These collected data was gathered on a CPU/inference/CAPI/ImageNet model.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-881351748
@mxnet-bot run ci [centos-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-881351796
Jenkins CI successfully triggered : [centos-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-872469331
Hey @mozga-intel , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:
- To trigger all jobs: @mxnet-bot run ci [all]
- To trigger specific jobs: @mxnet-bot run ci [job1, job2]
***
**CI supported jobs**: [unix-cpu, windows-cpu, sanity, centos-gpu, centos-cpu, windows-gpu, website, miscellaneous, clang, edge, unix-gpu]
***
_Note_:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-880021080
@mxnet-bot run ci [centos-cpu, centos-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] szha commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r743909951
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
Review comment:
on linux the `posix_memalign` would be called twice. intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-961094532
Jenkins CI successfully triggered : [miscellaneous, unix-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
anko-intel commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r754144419
##########
File path: include/mxnet/base.h
##########
@@ -541,7 +541,11 @@ inline std::ostream& operator<<(std::ostream &out, const Context &ctx) {
#if MXNET_USE_ONEDNN == 1 || MXNET_USE_INTGEMM == 1
-constexpr size_t kDNNLAlign = 64;
+#ifdef __linux__
+constexpr size_t kDNNLAlign = 1 << 21;
Review comment:
is there any system value we can use as huge page size?
If not you can define earlier gHugePage2MB here.
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
+ madvise(ptr, size, MADV_HUGEPAGE);
Review comment:
from manual:
Most common kernels configurations provide MADV_HUGEPAGE-
style behavior by default, and thus MADV_HUGEPAGE is
normally not necessary.
Did you check if the setting is really needed?
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
Review comment:
alignment here already has value (1<<21)
see src/storage/cpu_device_storage.h:55
##########
File path: include/mxnet/base.h
##########
@@ -541,7 +541,11 @@ inline std::ostream& operator<<(std::ostream &out, const Context &ctx) {
#if MXNET_USE_ONEDNN == 1 || MXNET_USE_INTGEMM == 1
-constexpr size_t kDNNLAlign = 64;
+#ifdef __linux__
+constexpr size_t kDNNLAlign = 1 << 21;
+#else
+constexpr size_t kDNNLAlign = 4096ul;
Review comment:
I guess it is standard page size, on windows. Maybe we can use something like https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info ?
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
Review comment:
what about in performance point of view
```suggestion
if (size >= 2 * gHugePage2MB) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-961094310
@mxnet-bot run ci [miscellaneous , unix-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] szha commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r743909951
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
Review comment:
on linux the `posix_memalign` would be called twice. intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-880021155
Jenkins CI successfully triggered : [centos-gpu, centos-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-877053707
@mozga-intel, The results are collected during which test/model/inference/training?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-961258193
@szha Could you please review it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on pull request #20412: [DO NOT MERGE] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#issuecomment-872895147
@mxnet-bot run ci [unix-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r754989153
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
Review comment:
Good catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mozga-intel commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
mozga-intel commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r752237839
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
Review comment:
Good catch! It should be called once.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] szha commented on a change in pull request #20412: [master][optimization] CPU memory allocator using Transparent Huge Pages
Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #20412:
URL: https://github.com/apache/incubator-mxnet/pull/20412#discussion_r743909951
##########
File path: src/common/utils.h
##########
@@ -983,9 +986,21 @@ inline bool AlignedMemAlloc(void** ptr, size_t size, size_t alignment) {
if (*ptr == nullptr)
return false;
#else
- int res = posix_memalign(ptr, alignment, size);
- if (res != 0)
+ int res = posix_memalign(ptr, alignment, size);
+#if __linux__
+ constexpr size_t gHugePage2MB = 1 << 21;
+ if (size >= gHugePage2MB) {
+ // TODO(mozga-intel): Enable MacOS Huge Pages if desired
+ res = posix_memalign(ptr, gHugePage2MB, size);
+ if (res == 0) {
Review comment:
on linux the `posix_memalign` would be called twice. intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org