Blame src/components/infiniband_umad/linux-infiniband_umad.c

Packit Service a1973e
/****************************/
Packit Service a1973e
/* THIS IS OPEN SOURCE CODE */
Packit Service a1973e
/****************************/
Packit Service a1973e
Packit Service a1973e
/** 
Packit Service a1973e
 * @file    linux-infiniband_umad.c
Packit Service a1973e
 * @author  Heike Jagode (in collaboration with Michael Kluge, TU Dresden)
Packit Service a1973e
 *          jagode@eecs.utk.edu
Packit Service a1973e
 *
Packit Service a1973e
 * @ingroup papi_components 		
Packit Service a1973e
 * 
Packit Service a1973e
 * InfiniBand component 
Packit Service a1973e
 * 
Packit Service a1973e
 * Tested version of OFED: 1.4
Packit Service a1973e
 *
Packit Service a1973e
 * @brief
Packit Service a1973e
 *  This file has the source code for a component that enables PAPI-C to 
Packit Service a1973e
 *  access hardware monitoring counters for InfiniBand devices through the  
Packit Service a1973e
 *  OFED library. Since a new interface was introduced with OFED version 1.4 
Packit Service a1973e
 *  (released Dec 2008), the current InfiniBand component does not support 
Packit Service a1973e
 *  OFED versions < 1.4.
Packit Service a1973e
 */
Packit Service a1973e
#include <dlfcn.h>
Packit Service a1973e
Packit Service a1973e
#include "papi.h"
Packit Service a1973e
#include "papi_internal.h"
Packit Service a1973e
#include "papi_vector.h"
Packit Service a1973e
#include "papi_memory.h"
Packit Service a1973e
Packit Service a1973e
#include "linux-infiniband_umad.h"
Packit Service a1973e
Packit Service a1973e
void (*_dl_non_dynamic_init)(void) __attribute__((weak));
Packit Service a1973e
Packit Service a1973e
/********  CHANGE PROTOTYPES TO DECLARE Infiniband LIBRARY SYMBOLS AS WEAK  **********
Packit Service a1973e
 *  This is done so that a version of PAPI built with the infiniband component can   *
Packit Service a1973e
 *  be installed on a system which does not have the infiniband libraries installed. *
Packit Service a1973e
 *                                                                                   *
Packit Service a1973e
 *  If this is done without these prototypes, then all papi services on the system   *
Packit Service a1973e
 *  without the infiniband libraries installed will fail.  The PAPI libraries        *
Packit Service a1973e
 *  contain references to the infiniband libraries which are not installed.  The     *
Packit Service a1973e
 *  load of PAPI commands fails because the infiniband library references can not    *
Packit Service a1973e
 *  be resolved.                                                                     *
Packit Service a1973e
 *                                                                                   *
Packit Service a1973e
 *  This also defines pointers to the infiniband library functions that we call.     *
Packit Service a1973e
 *  These function pointers will be resolved with dlopen/dlsym calls at component    *
Packit Service a1973e
 *  initialization time.  The component then calls the infiniband library functions  *
Packit Service a1973e
 *  through these function pointers.                                                 *
Packit Service a1973e
 *************************************************************************************/
Packit Service a1973e
int                 __attribute__((weak)) umad_init              ( void );
Packit Service a1973e
int                 __attribute__((weak)) umad_get_cas_names     ( char [][UMAD_CA_NAME_LEN], int  );
Packit Service a1973e
int                 __attribute__((weak)) umad_get_ca            ( char *, umad_ca_t * );
Packit Service a1973e
void                __attribute__((weak)) mad_decode_field       ( unsigned char *, enum MAD_FIELDS, void *);
Packit Service a1973e
struct ibmad_port * __attribute__((weak)) mad_rpc_open_port      ( char *, int, int *, int );
Packit Service a1973e
int                 __attribute__((weak)) ib_resolve_self_via    ( ib_portid_t *, int *, ibmad_gid_t *, const struct ibmad_port * );
Packit Service a1973e
uint8_t *           __attribute__((weak)) performance_reset_via  ( void *, ib_portid_t *, int, unsigned, unsigned, unsigned, const struct ibmad_port * );
Packit Service a1973e
uint8_t *           __attribute__((weak)) pma_query_via          ( void *, ib_portid_t *, int, unsigned, unsigned, const struct ibmad_port * );
Packit Service a1973e
Packit Service a1973e
int                  (*umad_initPtr)             ( void );
Packit Service a1973e
int                  (*umad_get_cas_namesPtr)    ( char [][UMAD_CA_NAME_LEN], int );
Packit Service a1973e
int                  (*umad_get_caPtr)           ( char *, umad_ca_t * );
Packit Service a1973e
void                 (*mad_decode_fieldPtr)      ( unsigned char *, enum MAD_FIELDS, void * );
Packit Service a1973e
struct ibmad_port *  (*mad_rpc_open_portPtr)     ( char *, int, int *, int );
Packit Service a1973e
int                  (*ib_resolve_self_viaPtr)   (ib_portid_t *, int *, ibmad_gid_t *, const struct ibmad_port * );
Packit Service a1973e
uint8_t *            (*performance_reset_viaPtr) (void *, ib_portid_t *, int, unsigned, unsigned, unsigned, const struct ibmad_port * );
Packit Service a1973e
uint8_t *            (*pma_query_viaPtr)         (void *, ib_portid_t *, int, unsigned, unsigned, const struct ibmad_port * );
Packit Service a1973e
Packit Service a1973e
// file handles used to access Infiniband libraries with dlopen
Packit Service a1973e
static void* dl1 = NULL;
Packit Service a1973e
static void* dl2 = NULL;
Packit Service a1973e
Packit Service a1973e
static int linkInfinibandLibraries ();
Packit Service a1973e
Packit Service a1973e
papi_vector_t _infiniband_umad_vector;
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
struct ibmad_port *srcport;
Packit Service a1973e
static ib_portid_t portid;
Packit Service a1973e
static int ib_timeout = 0;
Packit Service a1973e
static int ibportnum = 0;
Packit Service a1973e
Packit Service a1973e
static counter_info *subscriptions[INFINIBAND_MAX_COUNTERS];
Packit Service a1973e
static int is_initialized = 0;
Packit Service a1973e
static int num_counters = 0;
Packit Service a1973e
static int is_finalized = 0;
Packit Service a1973e
Packit Service a1973e
/* counters are kept in a list */
Packit Service a1973e
static counter_info *root_counter = NULL;
Packit Service a1973e
/* IB ports found are kept in a list */
Packit Service a1973e
static ib_port *root_ib_port = NULL;
Packit Service a1973e
static ib_port *active_ib_port = NULL;
Packit Service a1973e
Packit Service a1973e
#define infiniband_native_table subscriptions
Packit Service a1973e
/* macro to initialize entire structs to 0 */
Packit Service a1973e
#define InitStruct(var, type) type var; memset(&var, 0, sizeof(type))
Packit Service a1973e
Packit Service a1973e
long long _papi_hwd_infiniband_register_start[INFINIBAND_MAX_COUNTERS];
Packit Service a1973e
long long _papi_hwd_infiniband_register[INFINIBAND_MAX_COUNTERS];
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*******************************************************************************
Packit Service a1973e
 ********  BEGIN FUNCTIONS  USED INTERNALLY SPECIFIC TO THIS COMPONENT *********
Packit Service a1973e
 ******************************************************************************/
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * use libumad to discover IB ports
Packit Service a1973e
 */
Packit Service a1973e
static void
Packit Service a1973e
init_ib_counter(  )
Packit Service a1973e
{
Packit Service a1973e
	char names[20][UMAD_CA_NAME_LEN];
Packit Service a1973e
	int n, i;
Packit Service a1973e
	char *ca_name;
Packit Service a1973e
	umad_ca_t ca;
Packit Service a1973e
	int r;
Packit Service a1973e
	int portnum;
Packit Service a1973e
Packit Service a1973e
//	if ( umad_init(  ) < 0 ) {
Packit Service a1973e
//		fprintf( stderr, "can't init UMAD library\n" );
Packit Service a1973e
//		exit( 1 );
Packit Service a1973e
//	}
Packit Service a1973e
Packit Service a1973e
	if ( ( n = (*umad_get_cas_namesPtr)( ( void * ) names, UMAD_CA_NAME_LEN ) ) < 0 ) {
Packit Service a1973e
		fprintf( stderr, "can't list IB device names\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < n; i++ ) {
Packit Service a1973e
		ca_name = names[i];
Packit Service a1973e
Packit Service a1973e
		if ( ( r = (*umad_get_caPtr)( ca_name, &ca ) ) < 0 ) {
Packit Service a1973e
			fprintf( stderr, "can't read ca from IB device\n" );
Packit Service a1973e
			exit( 1 );
Packit Service a1973e
		}
Packit Service a1973e
Packit Service a1973e
		if ( !ca.node_type )
Packit Service a1973e
			continue;
Packit Service a1973e
Packit Service a1973e
		/* port numbers are '1' based in OFED */
Packit Service a1973e
		for ( portnum = 1; portnum <= ca.numports; portnum++ )
Packit Service a1973e
			addIBPort( ca.ca_name, ca.ports[portnum] );
Packit Service a1973e
	}
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * add a counter to the list of available counters
Packit Service a1973e
 * @param name the short name of the counter
Packit Service a1973e
 * @param desc a longer description
Packit Service a1973e
 * @param unit the unit for this counter
Packit Service a1973e
 */
Packit Service a1973e
static counter_info *
Packit Service a1973e
addCounter( const char *name, const char *desc, const char *unit )
Packit Service a1973e
{
Packit Service a1973e
	counter_info *cntr, *last;
Packit Service a1973e
Packit Service a1973e
	cntr = ( counter_info * ) malloc( sizeof ( counter_info ) );
Packit Service a1973e
	if ( cntr == NULL ) {
Packit Service a1973e
		fprintf( stderr, "can not allocate memory for new counter\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
	cntr->name = strdup( name );
Packit Service a1973e
	cntr->description = strdup( desc );
Packit Service a1973e
	cntr->unit = strdup( unit );
Packit Service a1973e
	cntr->value = 0;
Packit Service a1973e
	cntr->next = NULL;
Packit Service a1973e
Packit Service a1973e
	if ( root_counter == NULL ) {
Packit Service a1973e
		root_counter = cntr;
Packit Service a1973e
	} else {
Packit Service a1973e
		last = root_counter;
Packit Service a1973e
		while ( last->next != NULL )
Packit Service a1973e
			last = last->next;
Packit Service a1973e
		last->next = cntr;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return cntr;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * add one IB port to the list of available ports and add the
Packit Service a1973e
 * counters related to this port to the global counter list
Packit Service a1973e
 */
Packit Service a1973e
static void
Packit Service a1973e
addIBPort( const char *ca_name, umad_port_t * port )
Packit Service a1973e
{
Packit Service a1973e
	ib_port *nwif, *last;
Packit Service a1973e
	char counter_name[512];
Packit Service a1973e
Packit Service a1973e
	nwif = ( ib_port * ) malloc( sizeof ( ib_port ) );
Packit Service a1973e
Packit Service a1973e
	if ( nwif == NULL ) {
Packit Service a1973e
		fprintf( stderr, "can not allocate memory for IB port description\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	sprintf( counter_name, "%s_%d", ca_name, port->portnum );
Packit Service a1973e
	nwif->name = strdup( counter_name );
Packit Service a1973e
Packit Service a1973e
	sprintf( counter_name, "%s_%d_recv", ca_name, port->portnum );
Packit Service a1973e
	nwif->recv_cntr =
Packit Service a1973e
		addCounter( counter_name, "bytes received on this IB port", "bytes" );
Packit Service a1973e
Packit Service a1973e
	sprintf( counter_name, "%s_%d_send", ca_name, port->portnum );
Packit Service a1973e
	nwif->send_cntr =
Packit Service a1973e
		addCounter( counter_name, "bytes written to this IB port", "bytes" );
Packit Service a1973e
Packit Service a1973e
	nwif->port_rate = port->rate;
Packit Service a1973e
	nwif->is_initialized = 0;
Packit Service a1973e
	nwif->port_number = port->portnum;
Packit Service a1973e
	nwif->next = NULL;
Packit Service a1973e
Packit Service a1973e
	num_counters += 2;
Packit Service a1973e
Packit Service a1973e
	if ( root_ib_port == NULL ) {
Packit Service a1973e
		root_ib_port = nwif;
Packit Service a1973e
	} else {
Packit Service a1973e
		last = root_ib_port;
Packit Service a1973e
		while ( last->next != NULL )
Packit Service a1973e
			last = last->next;
Packit Service a1973e
		last->next = nwif;
Packit Service a1973e
	}
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * initialize one IB port so that we are able to read values from it
Packit Service a1973e
 */
Packit Service a1973e
static int
Packit Service a1973e
init_ib_port( ib_port * portdata )
Packit Service a1973e
{
Packit Service a1973e
	int mgmt_classes[4] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS,
Packit Service a1973e
		IB_PERFORMANCE_CLASS
Packit Service a1973e
	};
Packit Service a1973e
	char *ca = 0;
Packit Service a1973e
	static uint8_t pc[1024];
Packit Service a1973e
	int mask = 0xFFFF;
Packit Service a1973e
Packit Service a1973e
	srcport = (*mad_rpc_open_portPtr)( ca, portdata->port_number, mgmt_classes, 4 );
Packit Service a1973e
	if ( !srcport ) {
Packit Service a1973e
		fprintf( stderr, "Failed to open '%s' port '%d'\n", ca,
Packit Service a1973e
				 portdata->port_number );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	if ( (*ib_resolve_self_viaPtr)( &portid, &ibportnum, 0, srcport ) < 0 ) {
Packit Service a1973e
		fprintf( stderr, "can't resolve self port\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* PerfMgt ClassPortInfo is a required attribute */
Packit Service a1973e
	/* might be redundant, could be left out for fast implementation */
Packit Service a1973e
	if ( !(*pma_query_viaPtr) ( pc, &portid, ibportnum, ib_timeout, CLASS_PORT_INFO, srcport ) ) {
Packit Service a1973e
		fprintf( stderr, "classportinfo query\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	if ( !(*performance_reset_viaPtr) ( pc, &portid, ibportnum, mask, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
Packit Service a1973e
		fprintf( stderr, "perf reset\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* read the initial values */
Packit Service a1973e
	(*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &portdata->last_send_val );
Packit Service a1973e
	portdata->sum_send_val = 0;
Packit Service a1973e
	(*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &portdata->last_recv_val );
Packit Service a1973e
	portdata->sum_recv_val = 0;
Packit Service a1973e
Packit Service a1973e
	portdata->is_initialized = 1;
Packit Service a1973e
Packit Service a1973e
	return 0;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * read and reset IB counters (reset on demand)
Packit Service a1973e
 */
Packit Service a1973e
static int
Packit Service a1973e
read_ib_counter(  )
Packit Service a1973e
{
Packit Service a1973e
	uint32_t send_val;
Packit Service a1973e
	uint32_t recv_val;
Packit Service a1973e
	uint8_t pc[1024];
Packit Service a1973e
	/* 32 bit counter FFFFFFFF */
Packit Service a1973e
	uint32_t max_val = 4294967295;
Packit Service a1973e
	/* if it is bigger than this -> reset */
Packit Service a1973e
	uint32_t reset_limit = max_val * 0.7;
Packit Service a1973e
	int mask = 0xFFFF;
Packit Service a1973e
Packit Service a1973e
	if ( active_ib_port == NULL )
Packit Service a1973e
		return 0;
Packit Service a1973e
Packit Service a1973e
	/* reading cost ~70 mirco secs */
Packit Service a1973e
	if ( !(*pma_query_viaPtr) ( pc, &portid, ibportnum, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
Packit Service a1973e
		fprintf( stderr, "perfquery\n" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	(*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &send_val );
Packit Service a1973e
	(*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &recv_val );
Packit Service a1973e
Packit Service a1973e
	/* multiply the numbers read by 4 as the IB port counters are not
Packit Service a1973e
	   counting bytes. they always count 32dwords. see man page of
Packit Service a1973e
	   perfquery for details
Packit Service a1973e
	   internally a uint64_t ia used to sum up the values */
Packit Service a1973e
	active_ib_port->sum_send_val +=
Packit Service a1973e
		( send_val - active_ib_port->last_send_val ) * 4;
Packit Service a1973e
	active_ib_port->sum_recv_val +=
Packit Service a1973e
		( recv_val - active_ib_port->last_recv_val ) * 4;
Packit Service a1973e
Packit Service a1973e
	active_ib_port->send_cntr->value = active_ib_port->sum_send_val;
Packit Service a1973e
	active_ib_port->recv_cntr->value = active_ib_port->sum_recv_val;
Packit Service a1973e
Packit Service a1973e
	if ( send_val > reset_limit || recv_val > reset_limit ) {
Packit Service a1973e
		/* reset cost ~70 mirco secs */
Packit Service a1973e
		if ( !(*performance_reset_viaPtr) ( pc, &portid, ibportnum, mask, ib_timeout, IB_GSI_PORT_COUNTERS, srcport ) ) {
Packit Service a1973e
			fprintf( stderr, "perf reset\n" );
Packit Service a1973e
			exit( 1 );
Packit Service a1973e
		}
Packit Service a1973e
Packit Service a1973e
		(*mad_decode_fieldPtr)( pc, IB_PC_XMT_BYTES_F, &active_ib_port->last_send_val );
Packit Service a1973e
		(*mad_decode_fieldPtr)( pc, IB_PC_RCV_BYTES_F, &active_ib_port->last_recv_val );
Packit Service a1973e
	} else {
Packit Service a1973e
		active_ib_port->last_send_val = send_val;
Packit Service a1973e
		active_ib_port->last_recv_val = recv_val;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return 0;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
void
Packit Service a1973e
host_read_values( long long *data )
Packit Service a1973e
{
Packit Service a1973e
	int loop;
Packit Service a1973e
Packit Service a1973e
	read_ib_counter(  );
Packit Service a1973e
Packit Service a1973e
	for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ ) {
Packit Service a1973e
		if ( subscriptions[loop] == NULL )
Packit Service a1973e
			break;
Packit Service a1973e
Packit Service a1973e
		data[loop] = subscriptions[loop]->value;
Packit Service a1973e
	}
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * find the pointer for a counter_info structure based on the counter name
Packit Service a1973e
 */
Packit Service a1973e
static counter_info *
Packit Service a1973e
counterFromName( const char *cntr )
Packit Service a1973e
{
Packit Service a1973e
	int loop = 0;
Packit Service a1973e
	char tmp[512];
Packit Service a1973e
	counter_info *local_cntr = root_counter;
Packit Service a1973e
Packit Service a1973e
	while ( local_cntr != NULL ) {
Packit Service a1973e
		if ( strcmp( cntr, local_cntr->name ) == 0 )
Packit Service a1973e
			return local_cntr;
Packit Service a1973e
Packit Service a1973e
		local_cntr = local_cntr->next;
Packit Service a1973e
		loop++;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	gethostname( tmp, 512 );
Packit Service a1973e
	fprintf( stderr, "can not find host counter: %s on %s\n", cntr, tmp );
Packit Service a1973e
	fprintf( stderr, "we only have: " );
Packit Service a1973e
	local_cntr = root_counter;
Packit Service a1973e
Packit Service a1973e
	while ( local_cntr != NULL ) {
Packit Service a1973e
		fprintf( stderr, "'%s' ", local_cntr->name );
Packit Service a1973e
		local_cntr = local_cntr->next;
Packit Service a1973e
		loop++;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	fprintf( stderr, "\n" );
Packit Service a1973e
	exit( 1 );
Packit Service a1973e
	/* never reached */
Packit Service a1973e
	return 0;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * allow external code to subscribe to a counter based on the counter name
Packit Service a1973e
 */
Packit Service a1973e
static uint64_t
Packit Service a1973e
host_subscribe( const char *cntr )
Packit Service a1973e
{
Packit Service a1973e
	int loop;
Packit Service a1973e
	int len;
Packit Service a1973e
	char tmp_name[512];
Packit Service a1973e
	ib_port *aktp;
Packit Service a1973e
Packit Service a1973e
	counter_info *counter = counterFromName( cntr );
Packit Service a1973e
Packit Service a1973e
	for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ ) {
Packit Service a1973e
		if ( subscriptions[loop] == NULL ) {
Packit Service a1973e
			subscriptions[loop] = counter;
Packit Service a1973e
			counter->idx = loop;
Packit Service a1973e
Packit Service a1973e
			/* we have an IB counter if the name ends with _send or _recv and
Packit Service a1973e
			   the prefix before that is in the ib_port list */
Packit Service a1973e
			if ( ( len = strlen( cntr ) ) > 5 ) {
Packit Service a1973e
				if ( strcmp( &cntr[len - 5], "_recv" ) == 0 ||
Packit Service a1973e
					 strcmp( &cntr[len - 5], "_send" ) == 0 ) {
Packit Service a1973e
					/* look through all IB_counters */
Packit Service a1973e
					strncpy( tmp_name, cntr, len - 5 );
Packit Service a1973e
					tmp_name[len - 5] = 0;
Packit Service a1973e
					aktp = root_ib_port;
Packit Service a1973e
					// printf("looking for IB port '%s'\n", tmp_name);
Packit Service a1973e
					while ( aktp != NULL ) {
Packit Service a1973e
						if ( strcmp( aktp->name, tmp_name ) == 0 ) {
Packit Service a1973e
							if ( !aktp->is_initialized ) {
Packit Service a1973e
								init_ib_port( aktp );
Packit Service a1973e
								active_ib_port = aktp;
Packit Service a1973e
							}
Packit Service a1973e
							return loop + 1;
Packit Service a1973e
						}
Packit Service a1973e
						/* name does not match, if this counter is
Packit Service a1973e
						   initialized, we can't have two active IB ports */
Packit Service a1973e
						if ( aktp->is_initialized ) {
Packit Service a1973e
#if 0	/* not necessary with OFED version >= 1.4 */
Packit Service a1973e
							fprintf( stderr,
Packit Service a1973e
									 "unable to activate IB port monitoring for more than one port\n" );
Packit Service a1973e
							exit( 1 );
Packit Service a1973e
#endif
Packit Service a1973e
						}
Packit Service a1973e
						aktp = aktp->next;
Packit Service a1973e
					}
Packit Service a1973e
				}
Packit Service a1973e
			}
Packit Service a1973e
			return loop + 1;
Packit Service a1973e
		}
Packit Service a1973e
	}
Packit Service a1973e
	fprintf( stderr, "please subscribe only once to each counter\n" );
Packit Service a1973e
	exit( 1 );
Packit Service a1973e
	/* never reached */
Packit Service a1973e
	return 0;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * return a newly allocated list of strings containing all counter names
Packit Service a1973e
 */
Packit Service a1973e
static string_list *
Packit Service a1973e
host_listCounter( int num_counters1 )
Packit Service a1973e
{
Packit Service a1973e
	string_list *list;
Packit Service a1973e
	counter_info *cntr = root_counter;
Packit Service a1973e
Packit Service a1973e
	list = malloc( sizeof ( string_list ) );
Packit Service a1973e
	if ( list == NULL ) {
Packit Service a1973e
		fprintf( stderr, "unable to allocate memory for new string_list" );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
	list->count = 0;
Packit Service a1973e
	list->data = ( char ** ) malloc( num_counters1 * sizeof ( char * ) );
Packit Service a1973e
Packit Service a1973e
	if ( list->data == NULL ) {
Packit Service a1973e
		fprintf( stderr,
Packit Service a1973e
				 "unable to allocate memory for %d pointers in a new string_list\n",
Packit Service a1973e
				 num_counters1 );
Packit Service a1973e
		exit( 1 );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	while ( cntr != NULL ) {
Packit Service a1973e
		list->data[list->count++] = strdup( cntr->name );
Packit Service a1973e
		cntr = cntr->next;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return list;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * finalizes the library
Packit Service a1973e
 */
Packit Service a1973e
static void
Packit Service a1973e
host_finalize(  )
Packit Service a1973e
{
Packit Service a1973e
	counter_info *cntr, *next;
Packit Service a1973e
Packit Service a1973e
	if ( is_finalized )
Packit Service a1973e
		return;
Packit Service a1973e
Packit Service a1973e
	cntr = root_counter;
Packit Service a1973e
Packit Service a1973e
	while ( cntr != NULL ) {
Packit Service a1973e
		next = cntr->next;
Packit Service a1973e
		free( cntr->name );
Packit Service a1973e
		free( cntr->description );
Packit Service a1973e
		free( cntr->unit );
Packit Service a1973e
		free( cntr );
Packit Service a1973e
		cntr = next;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	root_counter = NULL;
Packit Service a1973e
Packit Service a1973e
	is_finalized = 1;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/**
Packit Service a1973e
 * delete a list of strings
Packit Service a1973e
 */
Packit Service a1973e
static void
Packit Service a1973e
host_deleteStringList( string_list * to_delete )
Packit Service a1973e
{
Packit Service a1973e
	int loop;
Packit Service a1973e
Packit Service a1973e
	if ( to_delete->data != NULL ) {
Packit Service a1973e
		for ( loop = 0; loop < to_delete->count; loop++ )
Packit Service a1973e
			free( to_delete->data[loop] );
Packit Service a1973e
Packit Service a1973e
		free( to_delete->data );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	free( to_delete );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*****************************************************************************
Packit Service a1973e
 *******************  BEGIN PAPI's COMPONENT REQUIRED FUNCTIONS  *************
Packit Service a1973e
 *****************************************************************************/
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * This is called whenever a thread is initialized
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_init_thread( hwd_context_t * ctx )
Packit Service a1973e
{
Packit Service a1973e
	string_list *counter_list = NULL;
Packit Service a1973e
	int i;
Packit Service a1973e
	int loop;
Packit Service a1973e
Packit Service a1973e
	/* initialize portid struct of type ib_portid_t to 0 */
Packit Service a1973e
	InitStruct( portid, ib_portid_t );
Packit Service a1973e
Packit Service a1973e
	if ( is_initialized )
Packit Service a1973e
		return PAPI_OK;
Packit Service a1973e
Packit Service a1973e
	is_initialized = 1;
Packit Service a1973e
Packit Service a1973e
	init_ib_counter(  );
Packit Service a1973e
Packit Service a1973e
	for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ )
Packit Service a1973e
		subscriptions[loop] = NULL;
Packit Service a1973e
Packit Service a1973e
	counter_list = host_listCounter( num_counters );
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < counter_list->count; i++ )
Packit Service a1973e
		host_subscribe( counter_list->data[i] );
Packit Service a1973e
Packit Service a1973e
	( ( INFINIBAND_context_t * ) ctx )->state.ncounter = counter_list->count;
Packit Service a1973e
Packit Service a1973e
	host_deleteStringList( counter_list );
Packit Service a1973e
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/* Initialize hardware counters, setup the function vector table
Packit Service a1973e
 * and get hardware information, this routine is called when the 
Packit Service a1973e
 * PAPI process is initialized (IE PAPI_library_init)
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_init_component( int cidx )
Packit Service a1973e
{
Packit Service a1973e
	SUBDBG ("Entry: cidx: %d\n", cidx);
Packit Service a1973e
	int i;
Packit Service a1973e
Packit Service a1973e
	/* link in all the infiniband libraries and resolve the symbols we need to use */
Packit Service a1973e
	if (linkInfinibandLibraries() != PAPI_OK) {
Packit Service a1973e
		SUBDBG ("Dynamic link of Infiniband libraries failed, component will be disabled.\n");
Packit Service a1973e
		SUBDBG ("See disable reason in papi_component_avail output for more details.\n");
Packit Service a1973e
		return (PAPI_ENOSUPP);
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* make sure that the infiniband library finds the kernel module loaded. */
Packit Service a1973e
	if ( (*umad_initPtr)(  ) < 0 ) {
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Call to initialize umad library failed.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < INFINIBAND_MAX_COUNTERS; i++ ) {
Packit Service a1973e
		_papi_hwd_infiniband_register_start[i] = -1;
Packit Service a1973e
		_papi_hwd_infiniband_register[i] = -1;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* Export the component id */
Packit Service a1973e
	_infiniband_umad_vector.cmp_info.CmpIdx = cidx;
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * Link the necessary Infiniband libraries to use the Infiniband component.  If any of them can not be found, then
Packit Service a1973e
 * the Infiniband component will just be disabled.  This is done at runtime so that a version of PAPI built
Packit Service a1973e
 * with the Infiniband component can be installed and used on systems which have the Infiniband libraries installed
Packit Service a1973e
 * and on systems where these libraries are not installed.
Packit Service a1973e
 */
Packit Service a1973e
static int
Packit Service a1973e
linkInfinibandLibraries ()
Packit Service a1973e
{
Packit Service a1973e
	/* Attempt to guess if we were statically linked to libc, if so bail */
Packit Service a1973e
	if ( _dl_non_dynamic_init != NULL ) {
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "The Infiniband component does not support statically linking of libc.", PAPI_MAX_STR_LEN);
Packit Service a1973e
		return PAPI_ENOSUPP;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* Need to link in the Infiniband libraries, if not found disable the component */
Packit Service a1973e
	dl1 = dlopen("libibumad.so", RTLD_NOW | RTLD_GLOBAL);
Packit Service a1973e
	if (!dl1)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband library libibumad.so not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	umad_initPtr = dlsym(dl1, "umad_init");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function umad_init not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	umad_get_cas_namesPtr = dlsym(dl1, "umad_get_cas_names");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function umad_get_cas_names not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	umad_get_caPtr = dlsym(dl1, "umad_get_ca");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function umad_get_ca not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	/* Need to link in the Infiniband libraries, if not found disable the component */
Packit Service a1973e
	dl2 = dlopen("libibmad.so", RTLD_NOW | RTLD_GLOBAL);
Packit Service a1973e
	if (!dl2)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband library libibmad.so not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	mad_decode_fieldPtr = dlsym(dl2, "mad_decode_field");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function mad_decode_field not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	mad_rpc_open_portPtr = dlsym(dl2, "mad_rpc_open_port");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function mad_rpc_open_port not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	ib_resolve_self_viaPtr = dlsym(dl2, "ib_resolve_self_via");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function ib_resolve_self_via not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	performance_reset_viaPtr = dlsym(dl2, "performance_reset_via");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function performance_reset_via not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
	pma_query_viaPtr = dlsym(dl2, "pma_query_via");
Packit Service a1973e
	if (dlerror() != NULL)
Packit Service a1973e
	{
Packit Service a1973e
		strncpy(_infiniband_umad_vector.cmp_info.disabled_reason, "Infiniband function pma_query_via not found.",PAPI_MAX_STR_LEN);
Packit Service a1973e
		return ( PAPI_ENOSUPP );
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * Control of counters (Reading/Writing/Starting/Stopping/Setup)
Packit Service a1973e
 * functions
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_init_control_state( hwd_control_state_t * ctrl )
Packit Service a1973e
{
Packit Service a1973e
	( void ) ctrl;
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_start( hwd_context_t * ctx, hwd_control_state_t * ctrl )
Packit Service a1973e
{
Packit Service a1973e
	( void ) ctx;
Packit Service a1973e
	( void ) ctrl;
Packit Service a1973e
Packit Service a1973e
	host_read_values( _papi_hwd_infiniband_register_start );
Packit Service a1973e
Packit Service a1973e
	memcpy( _papi_hwd_infiniband_register, _papi_hwd_infiniband_register_start,
Packit Service a1973e
			INFINIBAND_MAX_COUNTERS * sizeof ( long long ) );
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_stop( hwd_context_t * ctx, hwd_control_state_t * ctrl )
Packit Service a1973e
{
Packit Service a1973e
	int i;
Packit Service a1973e
	( void ) ctx;
Packit Service a1973e
Packit Service a1973e
	host_read_values( _papi_hwd_infiniband_register );
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < ( ( INFINIBAND_context_t * ) ctx )->state.ncounter; i++ ) {
Packit Service a1973e
		( ( INFINIBAND_control_state_t * ) ctrl )->counts[i] =
Packit Service a1973e
			_papi_hwd_infiniband_register[i] -
Packit Service a1973e
			_papi_hwd_infiniband_register_start[i];
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_read( hwd_context_t * ctx, hwd_control_state_t * ctrl,
Packit Service a1973e
				 long_long ** events, int flags )
Packit Service a1973e
{
Packit Service a1973e
	int i;
Packit Service a1973e
	( void ) flags;
Packit Service a1973e
Packit Service a1973e
	host_read_values( _papi_hwd_infiniband_register );
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < ( ( INFINIBAND_context_t * ) ctx )->state.ncounter; i++ ) {
Packit Service a1973e
		( ( INFINIBAND_control_state_t * ) ctrl )->counts[i] =
Packit Service a1973e
			_papi_hwd_infiniband_register[i] -
Packit Service a1973e
			_papi_hwd_infiniband_register_start[i];
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	*events = ( ( INFINIBAND_control_state_t * ) ctrl )->counts;
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_shutdown_thread( hwd_context_t * ctx )
Packit Service a1973e
{
Packit Service a1973e
	( void ) ctx;
Packit Service a1973e
	host_finalize(  );
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_shutdown_component( void )
Packit Service a1973e
{
Packit Service a1973e
	// close the dynamic libraries needed by this component (opened in the init substrate call)
Packit Service a1973e
	dlclose(dl1);
Packit Service a1973e
	dlclose(dl2);
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/* This function sets various options in the component
Packit Service a1973e
 * The valid codes being passed in are PAPI_SET_DEFDOM,
Packit Service a1973e
 * PAPI_SET_DOMAIN, PAPI_SETDEFGRN, PAPI_SET_GRANUL * and PAPI_SET_INHERIT
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_ctl( hwd_context_t * ctx, int code, _papi_int_option_t * option )
Packit Service a1973e
{
Packit Service a1973e
	( void ) ctx;
Packit Service a1973e
	( void ) code;
Packit Service a1973e
	( void ) option;
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
//int INFINIBAND_ntv_code_to_bits ( unsigned int EventCode, hwd_register_t * bits );
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_update_control_state( hwd_control_state_t * ptr,
Packit Service a1973e
								 NativeInfo_t * native, int count,
Packit Service a1973e
								 hwd_context_t * ctx )
Packit Service a1973e
{
Packit Service a1973e
	( void ) ptr;
Packit Service a1973e
	( void ) ctx;
Packit Service a1973e
	int i, index;
Packit Service a1973e
Packit Service a1973e
	for ( i = 0; i < count; i++ ) {
Packit Service a1973e
		index = native[i].ni_event;
Packit Service a1973e
		native[i].ni_position = index;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * Infiniband counts are system wide, so this is the only domain we will respond to
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_set_domain( hwd_control_state_t * cntrl, int domain )
Packit Service a1973e
{
Packit Service a1973e
	(void) cntrl;
Packit Service a1973e
	if ( PAPI_DOM_ALL != domain )
Packit Service a1973e
		return ( PAPI_EINVAL );
Packit Service a1973e
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_reset( hwd_context_t * ctx, hwd_control_state_t * ctrl )
Packit Service a1973e
{
Packit Service a1973e
	INFINIBAND_start( ctx, ctrl );
Packit Service a1973e
	return ( PAPI_OK );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 * Native Event functions
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_ntv_enum_events( unsigned int *EventCode, int modifier )
Packit Service a1973e
{
Packit Service a1973e
	if ( modifier == PAPI_ENUM_FIRST ) {
Packit Service a1973e
		*EventCode = 0;
Packit Service a1973e
		return PAPI_OK;
Packit Service a1973e
	}
Packit Service a1973e
Packit Service a1973e
	if ( modifier == PAPI_ENUM_EVENTS ) {
Packit Service a1973e
		int index = *EventCode;
Packit Service a1973e
Packit Service a1973e
		if ( infiniband_native_table[index + 1] ) {
Packit Service a1973e
			*EventCode = *EventCode + 1;
Packit Service a1973e
			return ( PAPI_OK );
Packit Service a1973e
		} else
Packit Service a1973e
			return ( PAPI_ENOEVNT );
Packit Service a1973e
	} else
Packit Service a1973e
		return ( PAPI_EINVAL );
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_ntv_code_to_name( unsigned int EventCode, char *name, int len )
Packit Service a1973e
{
Packit Service a1973e
	strncpy( name, infiniband_native_table[EventCode]->name, len );
Packit Service a1973e
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_ntv_code_to_descr( unsigned int EventCode, char *name, int len )
Packit Service a1973e
{
Packit Service a1973e
	strncpy( name, infiniband_native_table[EventCode]->description, len );
Packit Service a1973e
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
int
Packit Service a1973e
INFINIBAND_ntv_code_to_bits( unsigned int EventCode, hwd_register_t * bits )
Packit Service a1973e
{
Packit Service a1973e
	memcpy( ( INFINIBAND_register_t * ) bits,
Packit Service a1973e
			infiniband_native_table[EventCode],
Packit Service a1973e
			sizeof ( INFINIBAND_register_t ) );
Packit Service a1973e
Packit Service a1973e
	return PAPI_OK;
Packit Service a1973e
}
Packit Service a1973e
Packit Service a1973e
Packit Service a1973e
/*
Packit Service a1973e
 *
Packit Service a1973e
 */
Packit Service a1973e
papi_vector_t _infiniband_umad_vector = {
Packit Service a1973e
	.cmp_info = {
Packit Service a1973e
				 /* default component information (unspecified values are initialized to 0) */
Packit Service a1973e
				 .name ="infiniband",
Packit Service a1973e
				 .short_name="infiniband",
Packit Service a1973e
				 .version = "4.2.1",
Packit Service a1973e
				 .description = "Infiniband statistics",
Packit Service a1973e
				 .num_mpx_cntrs = INFINIBAND_MAX_COUNTERS,
Packit Service a1973e
				 .num_cntrs = INFINIBAND_MAX_COUNTERS,
Packit Service a1973e
				 .default_domain = PAPI_DOM_ALL,
Packit Service a1973e
				 .available_domains = PAPI_DOM_ALL,
Packit Service a1973e
				 .default_granularity = PAPI_GRN_SYS,
Packit Service a1973e
				 .available_granularities = PAPI_GRN_SYS,
Packit Service a1973e
				 .hardware_intr_sig = PAPI_INT_SIGNAL,
Packit Service a1973e
Packit Service a1973e
				 /* component specific cmp_info initializations */
Packit Service a1973e
				 .fast_real_timer = 0,
Packit Service a1973e
				 .fast_virtual_timer = 0,
Packit Service a1973e
				 .attach = 0,
Packit Service a1973e
				 .attach_must_ptrace = 0,
Packit Service a1973e
				 }
Packit Service a1973e
	,
Packit Service a1973e
Packit Service a1973e
	/* sizes of framework-opaque component-private structures */
Packit Service a1973e
	.size = {
Packit Service a1973e
			 .context = sizeof ( INFINIBAND_context_t ),
Packit Service a1973e
			 .control_state = sizeof ( INFINIBAND_control_state_t ),
Packit Service a1973e
			 .reg_value = sizeof ( INFINIBAND_register_t ),
Packit Service a1973e
			 .reg_alloc = sizeof ( INFINIBAND_reg_alloc_t ),
Packit Service a1973e
			 }
Packit Service a1973e
	,
Packit Service a1973e
	/* function pointers in this component */
Packit Service a1973e
	.init_thread = INFINIBAND_init_thread,
Packit Service a1973e
	.init_component = INFINIBAND_init_component,
Packit Service a1973e
	.init_control_state = INFINIBAND_init_control_state,
Packit Service a1973e
	.start = INFINIBAND_start,
Packit Service a1973e
	.stop = INFINIBAND_stop,
Packit Service a1973e
	.read = INFINIBAND_read,
Packit Service a1973e
	.shutdown_component = INFINIBAND_shutdown_component,
Packit Service a1973e
	.shutdown_thread = INFINIBAND_shutdown_thread,
Packit Service a1973e
	.ctl = INFINIBAND_ctl,
Packit Service a1973e
Packit Service a1973e
	.update_control_state = INFINIBAND_update_control_state,
Packit Service a1973e
	.set_domain = INFINIBAND_set_domain,
Packit Service a1973e
	.reset = INFINIBAND_reset,
Packit Service a1973e
Packit Service a1973e
	.ntv_enum_events = INFINIBAND_ntv_enum_events,
Packit Service a1973e
	.ntv_code_to_name = INFINIBAND_ntv_code_to_name,
Packit Service a1973e
	.ntv_code_to_descr = INFINIBAND_ntv_code_to_descr,
Packit Service a1973e
	.ntv_code_to_bits = INFINIBAND_ntv_code_to_bits,
Packit Service a1973e
};