Building with CFLAGS=-DBUILD_MEMORY=1 (FIRST_TOUCH) does not export non-static __kmp_ft_page_allocate() function into a final library
| Bugzilla Link | 30734 |
| Resolution | FIXED |
| Resolved on | Jul 26, 2018 11:17 |
| Version | unspecified |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @AndreyChurbanov,@hahnjo,@jpeyton52 |
| Fixed by commit(s) | r338052 |
Extended Description
I guess following is missing in kmp.h:
#if (BUILD_MEMORY==FIRST_TOUCH) extern void * __kmp_ft_page_allocate( size_t size ); #endif
...somewhere before this:
extern void * ___kmp_page_allocate( size_t size KMP_SRC_LOC_DECL );
Removed in r338052
I've uploaded https://reviews.llvm.org/D49802, proposing to get rid of the function.
The code
p = kmpc_alinged_malloc(size, getpagesize()); // check p != NULL *p = 0; // touch first page
is functionally similar to
p = __kmp_ft_page_allocate(size); // check p != NULL
Do you think making the __kmp_ft_page_allocate accessible and writing corresponding free routine worth efforts and library size just to save single line of code? Note that on Linux you can save performance via calling the getpagesize once and reusing the value, comparing to __kmp_ft_page_allocate which calls the getpagesize at each invocation.
I would not mind to enable the __kmp_ft_page_allocate (and implement corresponding e.g. __kmp_ft_page_free()) if you prove it gives a value, but currently I don't see the reason to do this. You said you wanted to make an experiment, can you try the kmpc_aligned_malloc + manual touch instead? It should give identical performance without extra changes in the library.
Found it by reading the source code, no documentation though...
Does it mean definite end to "Memory Allocation and First-Touch" story?
Was it documented somewhere? Or did you only find out by reading the source code?
Does it mean definite end to "Memory Allocation and First-Touch" story?
I support removing the function, as opposed to making it alive.
The kmpc_aligned_malloc (+ manual touch if needed) can be used instead.
If even Intel doesn't know what this code does and where it came from, I think it's safe to remove:
- It's not enabled by default and used nowhere in the runtime.
- Even if, it's not
extern "C"so the name will be mangled. - The symbol is not exported in the linker script.
Opinions?
It is hard to use the __kmp_ft_page_allocate function, because it does not have paired "free" entry, and thus you basically cannot free memory allocated by this routine (kmpc_free may work by chance, but it is a pair for kmpc_malloc, and usually each alloc should have corresponding free).
Another strange point is the routine aligns memory to (pagesize + sizeof(void*)), whereas it would be more logical to align it to (pagesize).
I don't know the history of this strange code...
How should I remember, it was an year ago... AFAIR it's not called by compiler-generated code, but something tells me I may of tried to use it from the workload directly just to check if this can give me any performance benefit whatsoever.
I'm not sure why the function __kmp_ft_page_allocate is needed: A quick grep shows no usage. Is this function called by the compiler?
assigned to @hahnjo