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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to