예제 #1
0
void UIntMap_GetItems( void* map, unsigned* nItems, unsigned** keys, unsigned** values ) {
	UIntMap*		self = (UIntMap*)map;
	UIntMap_ParseStruct	parseStruct;

	assert( self );

	parseStruct.curItem = 0;
	parseStruct.keys = Memory_Alloc_Array_Unnamed( unsigned, self->size );
	parseStruct.vals = Memory_Alloc_Array_Unnamed( unsigned, self->size );
	BTree_ParseTree( self->btree, UIntMap_ParseNode, &parseStruct );

	*nItems = self->size;
	*keys = parseStruct.keys;
	*values = parseStruct.vals;
}
예제 #2
0
double Stg_MemMonitor_End( Stg_MemMonitor* tm ) {
	double memAvgDiff = 0.0;
#ifdef MEMORY_STATS
	long memDiff;
	long memMaxDiff;
	long memMinDiff;
	long memSumDiff;
	long memMax;
	
	int rank;
	int size;
	
	tm->t2 = stgMemory->stamp;
	MemoryField_UpdateAsSumOfSubFields( stgMemory->types );
	tm->totalMem2 = stgMemory->types->currentAllocation;
	memDiff = tm->totalMem2 - tm->totalMem1;
	
	MPI_Comm_size( tm->comm, &size );
	/*
	MPI_Reduce( &memDiff, &memMaxDiff, 1, MPI_LONG, MPI_MAX, 0, tm->comm );
	MPI_Reduce( &memDiff, &memMinDiff, 1, MPI_LONG, MPI_MIN, 0, tm->comm );
	MPI_Allreduce( &memDiff, &memSumDiff, 1, MPI_LONG, MPI_SUM, tm->comm );
	MPI_Reduce( &tm->totalMem2, &memMax, 1, MPI_LONG, MPI_MAX, 0, tm->comm );
	
	memAvgDiff = (double)memSumDiff / size;
	*/
	/* Above is commented and replaced with below. See TimeMonitor.c for reason */
	memMaxDiff = memDiff;
	memMinDiff = memDiff;
	memSumDiff = memDiff;
	memMax = tm->totalMem2;
	memAvgDiff = (double)memDiff;
	
	/* Note: maybe Stg_Components should store rank and comm??? how do the find their comm? */
	
	MPI_Comm_rank( tm->comm, &rank );
	if( rank == 0 && tm->print ) {
		if( !tm->criteria || (double)memMaxDiff > Stg_MemoryWatchCriteria * memMax ) {
			void* args[3];
			SizeT threshold = (SizeT)(Stg_MemoryWatchCriteria * memMax);
			
			if( size == 1 ) {
				Journal_Printf( 
					Journal_Register( Info_Type, Stg_MemMonitor_InfoStreamName ),
					"\t%s(%s): ms: %.2gmb, dt(%.2f%%): %.2gmb\n", 
					Stg_MemMonitor_InfoStreamName,
					tm->tag,
					(double)memMax / 1048576,
					(memAvgDiff) / memMax * 100.0,
					(double)memDiff / 1048576 );
			}
			else {
				Journal_Printf( 
					Journal_Register( Info_Type, Stg_MemMonitor_InfoStreamName ),
					"\t%s(%s): ms: %.2gmb, dt(%.f%%): %.2g/%.2g/%.2gmb\n", 
					Stg_MemMonitor_InfoStreamName,
					tm->tag,
					(double)memMax / 1048576,
					(memAvgDiff) / memMax * 100.0,
					(double)memMaxDiff / 1048576,
					(double)memMinDiff / 1048576,
					(double)memAvgDiff / 1048576 );
			}
			args[0] = &threshold;
			args[1] = &tm->t1;
			args[2] = &tm->t2;
			BTree_ParseTree( stgMemory->pointers, _Memory_Print_AllocsAboveThreshold_Helper, (void*)args );
		}
	}
	
#endif
	return memAvgDiff;
}