Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory pool aborts on zero allocation request, returns NULL for < minimum #939

Closed
ibaned opened this issue Jul 10, 2017 · 16 comments
Closed
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Milestone

Comments

@ibaned
Copy link
Contributor

ibaned commented Jul 10, 2017

Moving this out of #786 for @kyungjoo-kim.
He wrote:

there is a bug in memory pool. The following is the error message. The code requested 9480 and the pool clearly has enough space but it returns a NULL pointer.

requested = 9480
pool_size(4194304) superblock_size(1048576)
Superblock[ 0 / 4 ] { block_size(65536) block_count( 3 / 16 )
Superblock[ 1 / 4 ] { block_size(131072) block_count( 1 / 8 )
Superblock[ 2 / 4 ] { block_size(32768) block_count( 1 / 32 )
Superblock[ 3 / 4 ] { block_size(262144) block_count( 2 / 4 )
>> Error in file /home/kyukim/Work/lib/trilinos/temp/packages/shylu/tacho/refactor/src/TachoExp_TaskFunctor_CholSupernodes.hpp, line 84, error 1 
   bufmemory pool allocation fails
@ibaned ibaned added the Question For Kokkos internal and external contributors and users label Jul 10, 2017
@ibaned
Copy link
Contributor Author

ibaned commented Jul 10, 2017

@kyungjoo-kim I think what is happening here is your are asking for an allocation that is smaller than the minimum allocation size that you gave to the memory pool constructor, which is not allowed. Can you confirm what is the minimum allocation size passed to the constructor?

@ibaned
Copy link
Contributor Author

ibaned commented Jul 10, 2017

@kyungjoo-kim also wrote in #786

Another bug... When it has 0 allocation, it aborts (it should return a NULL).

before allocate 0
Kokkos MemoryPool allocation request exceeded specified maximum allocation size
Program received signal SIGABRT, Aborted.

I believe this is the same problem, unless you passed in zero as the minimum allocation size to the memory pool constructor.

@hcedwar
Copy link
Contributor

hcedwar commented Jul 10, 2017

  • Should return NULL for 0 allocation size - is a bug.
  • Should search for superblock with smallest available block size greater than or equal to requested allocations size instead of a choosing a prescribed block size - is an enhancement.

@hcedwar hcedwar added Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) Enhancement Improve existing capability; will potentially require voting labels Jul 10, 2017
@ibaned ibaned changed the title Memory pool returns NULL with space Memory pool aborts on zero allocation request, returns NULL for < minimum Jul 10, 2017
@kyungjoo-kim
Copy link
Contributor

@ibaned the minimum block size that I set in the constructor is "1". If it is modified, it is modified in kokkos. The minimum allocation size does not matter as far as I know. If the requested memory size is small, it should return it from the smallest block size.

@ibaned
Copy link
Contributor Author

ibaned commented Jul 10, 2017

Hmm okay I thought previously it did matter and was a hard limit (seems like this is true due to the bug report), but as @hcedwar pointed out we can move to a more relaxed behavior where it chooses the smallest block size. We also need to document the behavior more clearly.

@kyungjoo-kim
Copy link
Contributor

So, this means that I can bypass the allocation failure of smallest block size with

const auto bufsize = max(poolmin_block_size(), request);

Correct ?

@ibaned
Copy link
Contributor Author

ibaned commented Jul 10, 2017

I think thats true... until we change the code to do this internally.

@hcedwar
Copy link
Contributor

hcedwar commented Jul 10, 2017

Unfortunately no. If superblocks are all used by larger-than-minimum block size then the allocation will currently fail due to not searching.

@ibaned
Copy link
Contributor Author

ibaned commented Jul 10, 2017

That sounds like a bug as well... worst case it could prevent any allocations smaller than the maximum value.

@kyungjoo-kim
Copy link
Contributor

I tested and it does not work. I query the min block size and it remains "1".

requested = 80688 , min block size = 1
pool_size(4194304) superblock_size(1048576)
Superblock[ 0 / 4 ] { block_size(524288) block_count( 1 / 2 )
Superblock[ 1 / 4 ] { block_size(65536) block_count( 2 / 16 )
Superblock[ 2 / 4 ] { block_size(32768) block_count( 3 / 32 )
Superblock[ 3 / 4 ] { block_size(262144) block_count( 1 / 4 )

@hcedwar
Copy link
Contributor

hcedwar commented Jul 10, 2017

OK - let's call both of these cases functionality bugs that require enhancing implementation to fix.

@hcedwar hcedwar removed Enhancement Improve existing capability; will potentially require voting Question For Kokkos internal and external contributors and users labels Jul 10, 2017
@hcedwar hcedwar added this to the 2017-August (middle) milestone Jul 10, 2017
@kyungjoo-kim
Copy link
Contributor

deallocate(buf, bufsize); where buf is NULL and bufsize is zero. This should do no-op but it also triggers abort.

@kyungjoo-kim
Copy link
Contributor

Another feature request.

I have a situation that I repeatedly solve a problem with the same symbolic structure. I roughly allocate memory pool with loose estimation of tasks and memory requirement.

Can I get some useful information from scheduler or memory pool ? so that in the next iteration, I can set more tight (optimal) bound of my memory pool.

@hcedwar hcedwar added this to Backlog in On-node Task DAG Jul 20, 2017
@hcedwar hcedwar moved this from Backlog to In Progress in On-node Task DAG Jul 20, 2017
hcedwar added a commit that referenced this issue Jul 24, 2017
No-op for allocation size zero or deallocation NULL pointer.
Allocation will search for superblock of larger allocation size
if superblock of desired allocation size is not available.
@hcedwar
Copy link
Contributor

hcedwar commented Jul 24, 2017

@kyungjoo-kim
Currently on the 'task-dag' branch: The zero size and NULL bug fixed. Using a larger block size when the desired block size is unavailable enhancement is done.

  MemoryPool<...>::usage_statistics tmp ;
  MemoryPool<...>::get_usage_statistics( tmp );

Will fill the tmp data structure with allocation usage statistics.

@kyungjoo-kim
Copy link
Contributor

Thanks. I will try and test 'task-dag' branch.

@kyungjoo-kim
Copy link
Contributor

soon we also need to merge the branch to master and snapshotted to trilinos so that sierra can see the code fix.

@hcedwar hcedwar moved this from In Progress to In Develop in On-node Task DAG Jul 25, 2017
@crtrott crtrott closed this as completed Jul 27, 2017
@hcedwar hcedwar moved this from In Develop to Done in On-node Task DAG Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Projects
No open projects
Development

No branches or pull requests

4 participants