darshan-core-init-finalize.c 1.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (C) 2015 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

#define _XOPEN_SOURCE 500
#define _GNU_SOURCE

#include "darshan-runtime-config.h"

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>

#include "darshan.h"
#include "darshan-core.h"
18
#include "darshan-dynamic.h"
19

20 21 22
DARSHAN_FORWARD_DECL(PMPI_Finalize, int, ());
DARSHAN_FORWARD_DECL(PMPI_Init, int, (int *argc, char ***argv));
DARSHAN_FORWARD_DECL(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided));
23

24
int DARSHAN_DECL(MPI_Init)(int *argc, char ***argv)
25 26 27
{
    int ret;

28
    MAP_OR_FAIL(PMPI_Init);
29

30
    ret = __real_PMPI_Init(argc, argv);
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    if(ret != MPI_SUCCESS)
    {
        return(ret);
    }

    if(argc && argv)
    {
        darshan_core_initialize(*argc, *argv);
    }
    else
    {
        /* we don't see argc and argv here in fortran */
        darshan_core_initialize(0, NULL);
    }

    return(ret);
}
48
DARSHAN_WRAPPER_MAP(PMPI_Init, int, (int *argc, char ***argv), MPI_Init(argc,argv))
49

50
int DARSHAN_DECL(MPI_Init_thread)(int *argc, char ***argv, int required, int *provided)
51 52 53
{
    int ret;

54
    MAP_OR_FAIL(PMPI_Init_thread);
55

56
    ret = __real_PMPI_Init_thread(argc, argv, required, provided);
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    if(ret != MPI_SUCCESS)
    {
        return(ret);
    }

    if(argc && argv)
    {
        darshan_core_initialize(*argc, *argv);
    }
    else
    {
        /* we don't see argc and argv here in fortran */
        darshan_core_initialize(0, NULL);
    }

    return(ret);
}
74
DARSHAN_WRAPPER_MAP(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided), MPI_Init_thread(argc,argv,required,provided))
75

76
int DARSHAN_DECL(MPI_Finalize)(void)
77 78 79
{
    int ret;

80
    MAP_OR_FAIL(PMPI_Finalize);
81

82 83
    darshan_core_shutdown();

84
    ret = __real_PMPI_Finalize();
85 86
    return(ret);
}
87
DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize())
88 89 90 91 92 93 94 95 96

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ts=8 sts=4 sw=4 expandtab
 */