Skip to content

using dumpi cortex

Matthieu Dorier edited this page Oct 8, 2019 · 13 revisions

Tutorial

Using dumpi-cortex

Reading a DUMPI file

dumpi-cortex's API is very similar to that of libundumpi (the reader part of DUMPI). It exposes the same set of functions, but prefixed by cortex_. The following code sample illustrates how to read a DUMPI file with the dumpi-cortex API and install a callback so that a message is printed on stdout when MPI_Init is encountered.

#include <cortex/cortex.h>
#include <cortex/post.h>
#include <string.h>

/**
 * This function will be called whenever MPI_Init is encountered when
 * reading the DUMPI file.
 */
static int handleDUMPIInit(const dumpi_init *prm, uint16_t thread,
                        const dumpi_time *cpu, const dumpi_time *wall,
                        const dumpi_perfinfo *perf, void *uarg) {
        printf("MPI_Init called\n");
        return 0;
}

int main(int argc, char** argv) {

        if(argc != 2) {
                printf("Usage: %s dumpifile.bin\n", argv[0]);
                exit(-1);
        }

        const char* filename = argv[1];

        /* Open a DUMPI file and get a cortex_dumpi_profile pointer */
        /* job id : 0, size of MPI_COMM_WORLD : 1, rank in MPI_COMM_WORLD : 0 */
        cortex_dumpi_profile* profile = cortex_undumpi_open(filename, 0, 1, 0);

        if(!profile) {
                fprintf(stderr,"Unable to open file %s\n",filename);
                exit(-1);
        }

        /* Create a set of callbacks to associate with MPI calls */
        libundumpi_callbacks cbacks;
        memset(&cbacks,0,sizeof(cbacks));
        cbacks.on_init = handleDUMPIInit;

        /* Start reading the file */
        cortex_dumpi_start_stream_read(profile);

        /* Read the stream of function calls from the file */
        cortex_undumpi_read_stream(profile,&cbacks,CORTEX_NO_TRANSLATION,NULL);

        /* Close the file */
        cortex_undumpi_close(profile);

        return 0;
}

Note that contrary to DUMPI's API, you don't need to define all the callbacks when creating your libundumpi_callbacks structure; default callbacks are provided that simply do nothing of their corresponding MPI call.

To compile this example, make sure to link against libcortex (-lcortex).

Enabling translations

The point of dumpi-cortex is to be able to translate an MPI call (a collective communication, for instance) into a set of other MPI calls (point to point, for instance). Cortex comes with a set of translation functions that convert MPI collectives into point-to-point the way MPICH would execute them. This translation can be enabled by changing CORTEX_NO_TRANSLATION into CORTEX_MPICH_TRANSLATION in the above code. You will also have to add #include <cortex/cortex-mpich.h>, and to compile against libcortex-mpich (-lcortex-mpich must come before -lcortex in the linker command).

Continue the tutorial...

Clone this wiki locally