Files
AMSS-NCKU/AMSS_NCKU_source/perf.h
CGH0S7 caf192b2e4 Remove MPI dependency, replace with single-process stub for non-MPI builds
- Add mpi_stub.h providing all MPI types/constants/functions as no-ops
  (nprocs=1, myrank=0) with memcpy-based Allreduce and clock_gettime Wtime
- Replace #include <mpi.h> with conditional #ifdef MPI_STUB in 31 files
  (19 headers + 12 source files) preserving ability to build with real MPI
- Change makefile.inc: CLINKER mpiicpx->icpx, add -DMPI_STUB to CXXAPPFLAGS
- Update makefile_and_run.py: run ./ABE directly instead of mpirun -np N
- Set MPI_processes=1 in AMSS_NCKU_Input.py

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-10 22:51:11 +08:00

64 lines
1.3 KiB
C++

#ifndef PERF_H
#define PERF_H
#ifdef newc
#include <iostream>
#include <iomanip>
#include <fstream>
#include <strstream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
#else
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#endif
/* for open/read/close */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifdef MPI_STUB
#include "mpi_stub.h"
#else
#include <mpi.h>
#endif
/* Real time */
#define TimerSignal SIGALRM
#define TimerType ITIMER_REAL
class perf
{
public:
static size_t mem_peak;
static size_t mem_current;
/* The sampling interval of the timer in ms, <= 0 disables the timer. */
static int sampling_interval;
static char statm[40];
static bool have_statm;
static struct itimerval new_it, old;
static struct sigaction sa, old_sa;
public:
perf();
~perf();
static void sample_mem_usage(int dummy);
size_t MemoryUsage(size_t *current_min, size_t *current_avg, size_t *current_max,
size_t *peak_min, size_t *peak_avg, size_t *peak_max,
int nprocs);
};
#endif /* PERF_H */