NVIDIA / NVIDIA/AMGX

feature request : enable multiple instances of the resource handle

Open
#109 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

usage question
Dominant language
Cuda
Stars
692
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hi Marat
I had to open a new issue as I was not sure if you get notifications for the issue that is closed.
I have one more question,
So the solver supports multi stream solves (such as solving for solid and fluid at the same setup, not related to multi-stream in cuda), I have an interface class and hence I construct several objects using different configs, the solution is correct but since now I free resources (although they belong to different instances of the same class), I get an error in the clean up phase as follows,
If I have a single object there are no issues.

AMGX_solver_destroy() 
!!! detected some memory leaks in the code: trying to free non-empty temporary device pool !!!

if I comment out AMGX_SAFE_CALL(AMGX_resources_destroy(m_resources)); then the error changes to, which makes sense as it detects the non freed resources handle.

*** Process received signal ***
 Signal: Segmentation fault (11)
Signal code:  (128)
Failing at address: (nil)
[ 0] /lib64/libpthread.so.0(+0xf630)[0x7f85af5b5630]
[ 1] /lib64/libcuda.so.1(+0x1f3b8d)[0x7f856b8e1b8d]
[ 2] /lib64/libcuda.so.1(+0x1ddbc7)[0x7f856b8cbbc7]
[ 3] /lib64/libcuda.so.1(+0xf9b4b)[0x7f856b7e7b4b]
[ 4] /lib64/libcuda.so.1(cuEventDestroy_v2+0x59)[0x7f856b969ae9]
[ 5] centos/7/nvidia/cuda/10.2.89/lib64/libcublas.so.10(+0x5e8dd0)[0x7f858178cdd0]
[ 6] /tools/centos/7/nvidia/cuda/10.2.89/lib64/libcublas.so.10(+0x61cea4)[0x7f85817c0ea4]
[ 7] /tools/centos/7/nvidia/cuda/10.2.89/lib64/libcublas.so.10(+0x29aad)[0x7f85811cdaad]
[ 8] /tools/centos/7/nvidia/cuda/10.2.89/lib64/libcublas.so.10(+0x2ae16)[0x7f85811cee16]
[ 9] /centos/7/nvidia/cuda/10.2.89/lib64/libcublas.so.10(cublasDestroy_v2+0xe7)[0x7f858125cf77]
[10] libamgxsh.so(_ZN4amgx6Cublas14destroy_handleEv+0x25)[0x7f8588d15085]
[11] libamgxsh.so(_ZN4amgx9ResourcesD1Ev+0x5d)[0x7f8588d14ead]
[12] lib/libamgxsh.so(_ZNSt15_Sp_counted_ptrIPN4amgx9ResourcesELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x12)[0x7f8587dcff32]
[13] libamgxsh.so(_ZNSt15_Sp_counted_ptrIPN4amgx11CWrapHandleIP28AMGX_resources_handle_structNS0_9ResourcesEEELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0xba)[0x7f8587dd308a]
[14] libamgxsh.so(_ZNSt8_Rb_treeIPN4amgx11CWrapHandleIP28AMGX_resources_handle_structNS0_9ResourcesEEESt4pairIKS6_St10shared_ptrIS5_EESt10_Select1stISB_ESt4lessIS6_ESaISB_EE8_M_eraseEPSt13_Rb_tree_nodeISB_E+
[15] libamgxsh.so(_ZN4amgx10MemManagerIJNS_11CWrapHandleIP28AMGX_resources_handle_structNS_9ResourcesEEEEED1Ev+0x2c)[0x7f8587e42e5c]
[16] /lib64/libc.so.6(+0x39ce9)[0x7f8586377ce9]
[17] /lib64/libc.so.6(+0x39d37)[0x7f8586377d37]
[18] /lib64/libc.so.6(__libc_start_main+0xfc)[0x7f858636055c]
[19]
*** End of error message ***

Hopefully this is the last test case, I would like to know your advice on this before debugging further
I highly doubt that order of destruction is the issue as it would affect the single object case but I am listing it here just for the sake of completeness

      AMGX_SAFE_CALL(AMGX_vector_destroy(m_rhs));
      AMGX_SAFE_CALL(AMGX_vector_destroy(m_solution));
      AMGX_SAFE_CALL(AMGX_matrix_destroy(m_matrix));
       AMGX_SAFE_CALL(AMGX_solver_destroy(m_solver));
      AMGX_SAFE_CALL(AMGX_resources_destroy(m_resources));
      AMGX_SAFE_CALL(AMGX_config_destroy(m_config));

It is probably related to

  size_t n_erased = get_mode_bookkeeper<Envelope>().erase(envl);
   bool flag = get_mem_manager<LetterW>().template free<LetterW>(letter);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the multi-object case around AMGX_solver_destroy() and AMGX_resources_destroy(), using the reported destruction order as the starting point. Inspect the get_mode_bookkeeper().erase and get_mem_manager().free paths, then verify that independently constructed resources can be destroyed without leaks, segmentation faults, or non-empty temporary device pools.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
hpc
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.