Skip to content

Instantly share code, notes, and snippets.

@cwsmith
Last active December 17, 2015 21:59
Show Gist options
  • Save cwsmith/5678291 to your computer and use it in GitHub Desktop.
Save cwsmith/5678291 to your computer and use it in GitHub Desktop.
malloc_stats test code ran on CCNI BGQ with the XL compiler
module load xl
mpicxx mallocStatsTest.cc -o mallocStatsTestXL
#include <stdio.h>
#include <unistd.h>
#include <mpi.h>
#include <malloc.h>
int main (int argc, char** argv)
{
int rank, size;
MPI_Init (&argc, &argv); /* starts MPI */
MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
mtrace();
if ( 0 == rank ) {
malloc_stats();
char* buf = (char*) malloc(1000000*sizeof(char));
malloc_stats();
free(buf);
malloc_stats();
}
if ( 0 == rank ) {
malloc_stats();
char* buf = new char[1000000];
malloc_stats();
delete buf;
malloc_stats();
}
muntrace();
MPI_Finalize();
return 0;
}
#!/bin/sh
export MALLOC_TRACE=trace.out
time srun ./mallocStatsTestXL
malloc and free - pre alloc
Arena 0:
system bytes = 9272392
in use bytes = 7104248
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189688
max mmap regions = 1
max mmap bytes = 1085440
malloc and free - post alloc
Arena 0:
system bytes = 9272392
in use bytes = 7104280
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189720
max mmap regions = 1
max mmap bytes = 1085440
malloc and free - post delete
Arena 0:
system bytes = 9272392
in use bytes = 7104248
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189688
max mmap regions = 1
max mmap bytes = 1085440
new and delete - pre alloc
Arena 0:
system bytes = 9272392
in use bytes = 7104248
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189688
max mmap regions = 1
max mmap bytes = 1085440
new and delete - post alloc
Arena 0:
system bytes = 9272392
in use bytes = 7104280
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189720
max mmap regions = 1
max mmap bytes = 1085440
new and delete - post delete
Arena 0:
system bytes = 9272392
in use bytes = 7104248
Total (incl. mmap):
system bytes = 10357832
in use bytes = 8189688
max mmap regions = 1
max mmap bytes = 1085440
sbatch -t 2 -N 1 -n 1 ./run.sh
= Start
@ [0x1000464] + 0x19c5756220 0x4
@ [0x100048c] - 0x19c5756220
@ [0x14094e8] + 0x19c5756220 0x4
@ [0x140af78] - 0x19c5756220
= End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment