3.1-rc3 (revision d9ca08bb)
otf2_mpi_reader_example.c

MPI reading example

/*
* This file is part of the Score-P software (http://www.score-p.org)
*
* Copyright (c) 2009-2013,
* RWTH Aachen University, Germany
*
* Copyright (c) 2009-2013,
* Gesellschaft fuer numerische Simulation mbH Braunschweig, Germany
*
* Copyright (c) 2009-2014,
* Technische Universitaet Dresden, Germany
*
* Copyright (c) 2009-2013,
* University of Oregon, Eugene, USA
*
* Copyright (c) 2009-2014,
* Forschungszentrum Juelich GmbH, Germany
*
* Copyright (c) 2009-2013,
* German Research School for Simulation Sciences GmbH, Juelich/Aachen, Germany
*
* Copyright (c) 2009-2013,
* Technische Universitaet Muenchen, Germany
*
* This software may be modified and distributed under the terms of
* a BSD-style license. See the COPYING file in the package base
* directory for details.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <mpi.h>
#include <otf2/otf2.h>
#if MPI_VERSION < 3
#define OTF2_MPI_UINT64_T MPI_UNSIGNED_LONG
#define OTF2_MPI_INT64_T MPI_LONG
#endif
Enter_print( OTF2_LocationRef location,
void* userData,
OTF2_AttributeList* attributes,
OTF2_RegionRef region )
{
printf( "Entering region %u at location %" PRIu64 " at time %" PRIu64 ".\n",
region, location, time );
}
Leave_print( OTF2_LocationRef location,
void* userData,
OTF2_AttributeList* attributes,
OTF2_RegionRef region )
{
printf( "Leaving region %u at location %" PRIu64 " at time %" PRIu64 ".\n",
region, location, time );
}
struct vector
{
size_t capacity;
size_t size;
uint64_t members[];
};
GlobDefLocation_Register( void* userData,
OTF2_LocationRef location,
OTF2_LocationType locationType,
uint64_t numberOfEvents,
OTF2_LocationGroupRef locationGroup )
{
struct vector* locations = userData;
if ( locations->size == locations->capacity )
{
}
locations->members[ locations->size++ ] = location;
}
int
main( int argc,
char** argv )
{
MPI_Init( &argc, &argv );
int size;
MPI_Comm_size( MPI_COMM_WORLD, &size );
int rank;
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
OTF2_Reader* reader = OTF2_Reader_Open( "ArchivePath/ArchiveName.otf2" );
OTF2_MPI_Reader_SetCollectiveCallbacks( reader, MPI_COMM_WORLD );
uint64_t number_of_locations;
&number_of_locations );
struct vector* locations = malloc( sizeof( *locations )
+ number_of_locations
* sizeof( *locations->members ) );
locations->capacity = number_of_locations;
locations->size = 0;
OTF2_GlobalDefReader* global_def_reader = OTF2_Reader_GetGlobalDefReader( reader );
&GlobDefLocation_Register );
global_def_reader,
global_def_callbacks,
locations );
OTF2_GlobalDefReaderCallbacks_Delete( global_def_callbacks );
uint64_t definitions_read = 0;
global_def_reader,
&definitions_read );
uint64_t number_of_locations_to_read = 0;
for ( size_t i = 0; i < locations->size; i++ )
{
if ( locations->members[ i ] % size != rank )
{
continue;
}
number_of_locations_to_read++;
OTF2_Reader_SelectLocation( reader, locations->members[ i ] );
}
bool successful_open_def_files =
for ( size_t i = 0; i < locations->size; i++ )
{
if ( locations->members[ i ] % size != rank )
{
continue;
}
if ( successful_open_def_files )
{
OTF2_DefReader* def_reader =
OTF2_Reader_GetDefReader( reader, locations->members[ i ] );
if ( def_reader )
{
uint64_t def_reads = 0;
def_reader,
&def_reads );
OTF2_Reader_CloseDefReader( reader, def_reader );
}
}
OTF2_EvtReader* evt_reader =
OTF2_Reader_GetEvtReader( reader, locations->members[ i ] );
}
if ( successful_open_def_files )
{
}
if ( number_of_locations_to_read > 0 )
{
OTF2_GlobalEvtReader* global_evt_reader = OTF2_Reader_GetGlobalEvtReader( reader );
&Enter_print );
&Leave_print );
global_evt_reader,
event_callbacks,
NULL );
uint64_t events_read = 0;
global_evt_reader,
&events_read );
OTF2_Reader_CloseGlobalEvtReader( reader, global_evt_reader );
}
OTF2_Reader_Close( reader );
free( locations );
MPI_Finalize();
return EXIT_SUCCESS;
}