{"id":19706092,"url":"https://github.com/llnl/mpileaks","last_synced_at":"2025-10-19T02:43:16.352Z","repository":{"id":3400426,"uuid":"4450067","full_name":"LLNL/mpileaks","owner":"LLNL","description":"Tool to detect and report leaked MPI objects like MPI_Requests and MPI_Datatypes","archived":false,"fork":false,"pushed_at":"2014-09-17T19:15:12.000Z","size":624,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-06-15T00:02:34.556Z","etag":null,"topics":["mpi","shell"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LLNL.png","metadata":{"files":{"readme":"README","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-25T20:54:31.000Z","updated_at":"2023-10-30T14:10:44.000Z","dependencies_parsed_at":"2022-09-21T12:45:30.265Z","dependency_job_id":null,"html_url":"https://github.com/LLNL/mpileaks","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLNL%2Fmpileaks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLNL%2Fmpileaks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLNL%2Fmpileaks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LLNL%2Fmpileaks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LLNL","download_url":"https://codeload.github.com/LLNL/mpileaks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224179696,"owners_count":17269109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mpi","shell"],"created_at":"2024-11-11T21:33:50.372Z","updated_at":"2025-10-19T02:43:11.300Z","avatar_url":"https://github.com/LLNL.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n===================================================================\nIntroduction\n===================================================================\n\nmpileaks is a library to detect application leaks of MPI objects. Using\nthe MPI profiling interface, it keeps track of all MPI calls that\n\"allocate\" and \"free\" objects.  Any unfreed objects are identified and\nreported either during MPI_Finalize or whenever MPI_Pcontrol is called.\n\nmpileaks displays the stack trace where the leak occurred. The trace\nincludes file name and line number of the allocation call. Since many\nMPI tasks often have the same leak, mpileaks computes and reports\nthe total number of objects leaked across all processes for a given\nsource code location.  To acquire stack traces, mpileaks internally\nuses Todd Gamblin's Callpath class.\n\nhttps://github.com/scalability-llnl/callpath\n\nTo obtain stack traces, applications must be compiled with the\n'-g' option. However, it is not necessary to link to mpileaks to\nuse it.  One may select to use mpileaks at run time with existing\nexecutables (see using mpileaks below). \n\nThe following objects are tracked:\n   x ==\u003e supported\n   - ==\u003e still todo\n\n   x Requests\n     x pt2pt\n     x persistent pt2pt\n     x nonblocking file IO\n     x generalized requests\n   x Datatypes\n   x Groups\n   x Communicators\n     x dup / split / create\n     x intercomm create / merge\n     x topology\n     x dynamic processes\n   x User-defined reduction ops\n   x Files\n   x Windows\n   x Info objects\n   x Attribute keyvals\n   x Errhandlers (need example)\n   x Memory\n   - Ports\n   - Published names\n\n\n===================================================================\nBuilding and using mpileaks\n===================================================================\n\nA basic build and install:\n\n  ./configure \\\n    --prefix=\u003cinstalldir\u003e \\\n    --with-adept-utils=\u003cadeptutils_installdir\u003e \\\n    --with-callpath=\u003ccallpath_installdir\u003e\n  make\n  make install\n\nJust before running, set:\n\n  export LD_PRELOAD=\"\u003cinstalldir\u003e/lib/libmpileaks.so\"\n\nBy default, mpileaks reports a single line from the stacktrace,\nbut one may increase the number of lines by setting the\n$MPILEAKS_STACK_DEPTH environment variable.  For example, to\nget two lines:\n\n  export MPILEAKS_STACK_DEPTH=2\n\nTo get the entire stacktrace, set this value to -1.\n\nAlso, by default, mpileaks chops off the first 4 function calls\nin the stack trace, which are internal to the mpileaks library.\nOne can adjust the number of functions removed from the\ninitial part of the trace by setting $MPILEAKS_STACK_START to\nany non-negative integer (the default value is 4).  This feature\nis useful for MPI implementations in which the Fortran API is\njust a thin wrapper around the C API. For instance, if the\nFortran-to-C wrapper imposes one more level of function calls\nbetween the application and the MPI library, one may increase\nthis number from 4 to 5 to shave off this single layer so that\nthe stack trace begins in application code.\n\nAs a convenience, mpileaks installs SLURM srun wrappers.\nIt creates an srun-mpileaks wrapper for C and C++ codes and\nanother srun-mpileaksf wrapper for Fortran applications.\nThese scripts run the application within an environment that\nsets LD_PRELOAD, MPILEAKS_STACK_START, and MPILEAKS_STACK_DEPTH.\nThis way, the user simply must replace \"srun\" with the\ncorresponding script to enable mpileaks.\n\nDifferent systems and different MPI libraries may require\ndifferent values for MPILEAKS_STACK_START.  There are configure\noptions to set different values in the srun wrappers.  For example,\nto set MPILEAKS_STACK_START to 4 in srun-mpileaks and to 6 in\nsrun-mpileaksf, specify the following during configure:\n\n  --with-stack-start-c=4\n  --with-stack-start-fortran=6\n\n\n===================================================================\nExtending MPILEAKS to handle other types\n===================================================================\n   \nmpileaks is really a framework to detect mismatched function calls. As\nsuch it can be extended to detect other types of leaks. To use this\nframework, one must: (a) register the handle type used to uniquely\nidentify the function calls of interest; and (b) use the provided\nfunctions 'allocate' and 'free' to associate a function call as\nallocating or freeing resources. We provide an example below that,\nfor any given program, identifies MPI open files that are not closed.  \n\n--\n#include \"mpi.h\"\n#include \"mpileaks.h\"                 /* Handle2Callpath */ \n\n/*\n * Instantiate class with the specific handle-type that identifies\n * one function call from another (MPI_File in this case). \n * Define 'is_handle_null' for your specific handle type. \n */\n \nstatic class MPI_File2Callpath : public Handle2Callpath\u003cMPI_File\u003e\n{\npublic: \n  bool is_handle_null(MPI_File handle) {\n    return (handle == MPI_FILE_NULL) ? 1 : 0; \n  }\n} File2Callpath; \n\n\n/* \n * Associate function calls as \"allocate\" or \"free\" functions. \n */ \n\nint MPI_File_open(MPI_Comm comm, char *filename, int amode, \n                  MPI_Info info, MPI_File *fh)\n{\n  int rc = PMPI_File_open(comm, filename, amode, info, fh); \n  File2Callpath.allocate(*fh); \n  return rc; \n}\n\n\nint MPI_File_close(MPI_File *fh) \n{\n  MPI_File handle_copy = *fh; \n  \n  int rc = PMPI_File_close(fh);  \n  File2Callpath.free(handle_copy); \n  \n  return rc; \n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllnl%2Fmpileaks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllnl%2Fmpileaks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllnl%2Fmpileaks/lists"}