Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def setup_extension_modules(self):
# If user wishes to specify number of groups at compile time
if self.num_groups:
for k in self.compiler_flags:
self.compiler_flags[k].append('-DNGROUPS=' +
self.compiler_flags[k].append('-DNRGROUPS=' +
str(self.num_groups))

# If the user wishes to compile using debug mode, append the debugging
Expand Down Expand Up @@ -432,6 +432,13 @@ def setup_extension_modules(self):
for cc in self.include_directories.keys():
self.include_directories[cc].append(numpy_include)

# Add the python dev libraries
import sysconfig
python_include = sysconfig.get_path('include')
print(python_include)
for cc in self.include_directories.keys():
self.include_directories[cc].append(python_include)

# Add the mpi4py module directory
try:
import mpi4py
Expand All @@ -451,6 +458,9 @@ def setup_extension_modules(self):
if self.cc == 'mpicc':
self.swig_flags += ['-DMPIx']

# Dedup rpath

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(try to)

self.linker_flags[self.cc] = list(dict.fromkeys(self.linker_flags[self.cc]))

self.extensions.append(
Extension(name = '_openmoc',
sources = copy.deepcopy(self.sources[self.cc]),
Expand Down
4 changes: 2 additions & 2 deletions openmoc/swig/openmoc.i
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
%ignore twiddleRead(boundaryType* ptr, size_t size, size_t nmemb, FILE* stream);
%ignore twiddleRead(double* ptr, size_t size, size_t nmemb, FILE* stream);
%ignore twiddleRead(long* ptr, size_t size, size_t nmemb, FILE* stream);
%ignore setRuntimeParameters(RuntimeParameters &RP, int argc, char *argv[]);
%ignore setRuntimeParameters(RuntimeParameters &RP, int argc, char *argv[]);

/* Instruct SWIG to ignore methods used in getting CSR Matrix format and Vector
* attributes. These attributes should be used internally only by the Matrix and
Expand All @@ -105,7 +105,7 @@

%exception {
try {
$function
$action
} catch (const std::exception &e) {
SWIG_exception(SWIG_RuntimeError, e.what());
}
Expand Down
2 changes: 1 addition & 1 deletion profile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ ifeq ($(OPTIMIZE),yes)
CFLAGS += -O3 -ffast-math -fvectorize -fpic
endif
# Set the number of groups at compile time
#CFLAGS += -DNGROUPS=70
#CFLAGS += -DNRGROUPS=70
# Set the source to linear source at compile time
#CFLAGS += -DLINEARSOURCE
# Set the dimension to 3D at compile time
Expand Down
4 changes: 2 additions & 2 deletions src/CPUSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#undef track_flux
/** Optimization macro to facilitate SIMD vectorization */
#ifdef NGROUPS
#define _NUM_GROUPS (NGROUPS)
#ifdef NRGROUPS
#define _NUM_GROUPS (NRGROUPS)
#else
#define _NUM_GROUPS (_num_groups)
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/MOCKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
MOCKernel::MOCKernel(TrackGenerator* track_generator) {
_count = 0;
_max_tau = track_generator->retrieveMaxOpticalLength();
#ifndef NGROUPS
#ifndef NRGROUPS
_num_groups = track_generator->getGeometry()->getNumEnergyGroups();
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,12 +829,12 @@ void Solver::initializeFSRs() {
_track_generator->initializeFSRVolumesBuffer();
_FSR_volumes = _track_generator->getFSRVolumes();

#ifdef NGROUPS
if (_geometry->getNumEnergyGroups() != NGROUPS)
#ifdef NRGROUPS
if (_geometry->getNumEnergyGroups() != NRGROUPS)
log_printf(ERROR, "OpenMOC has been compiled for %d groups, and the "
"current case is in %d groups, please re-compile with the right "
"number of groups for the -DNGROUPS flag or without that flag.",
NGROUPS, _geometry->getNumEnergyGroups());
"number of groups for the -DNRGROUPS flag or without that flag.",
NRGROUPS, _geometry->getNumEnergyGroups());
#endif

/* Retrieve simulation parameters from the Geometry */
Expand Down
18 changes: 18 additions & 0 deletions src/TrackGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/* Modified from so/33745364/sched-getcpu-equivalent-for-os-x */
#ifndef __linux__
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
#include <cpuid.h>

inline int sched_getcpu() {
Expand All @@ -41,6 +42,23 @@ inline int sched_getcpu() {
if (CPU < 0) CPU = 0;
return CPU;
}
#else
#include <iostream>
#include <sys/types.h>
#include <sys/sysctl.h>
inline int sched_getcpu() {
char buffer[128];
size_t bufferlen = sizeof(buffer);

if (sysctlbyname("machdep.cpu.brand_string", &buffer, &bufferlen, NULL, 0) == 0) {
return atoi(buffer);
}
else
std::cerr << "Failed to get CPU id" << std::endl;

return 0;
}
#endif
#endif

/**
Expand Down
14 changes: 7 additions & 7 deletions src/TrackTraversingAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ LinearExpansionGenerator::LinearExpansionGenerator(CPULSSolver* solver)
_FSR_volumes = track_generator->getFSRVolumesBuffer();
_FSR_locks = track_generator->getFSRLocks();
_quadrature = track_generator->getQuadrature();
#ifndef NGROUPS
#ifndef NRGROUPS
_NUM_GROUPS = solver->getNumEnergyGroups();
#endif

Expand Down Expand Up @@ -528,7 +528,7 @@ LinearExpansionGenerator::~LinearExpansionGenerator() {


/**
* @brief When executed, the LinearExpansionGenerator Kernel loops over all
* @brief When executed, the LinearExpansionGenerator Kernel loops over all
* Tracks to compute constant terms used to compute the linear source.
*/
void LinearExpansionGenerator::execute() {
Expand Down Expand Up @@ -843,7 +843,7 @@ TransportSweep::TransportSweep(CPUSolver* cpu_solver)
_ls_solver = dynamic_cast<CPULSSolver*>(cpu_solver);
TrackGenerator* track_generator = cpu_solver->getTrackGenerator();
_geometry = _track_generator->getGeometry();
#ifndef NGROUPS
#ifndef NRGROUPS
_NUM_GROUPS = _geometry->getNumEnergyGroups();
#endif
}
Expand Down Expand Up @@ -936,7 +936,7 @@ void TransportSweep::onTrack(Track* track, segment* segments) {

/* Allocate a temporary flux buffer on the stack (free) and initialize it */
/* Select right size for buffer */
#ifndef NGROUPS
#ifndef NRGROUPS
int _NUM_GROUPS = _cpu_solver->getNumEnergyGroups();
#endif
#ifndef LINEARSOURCE
Expand Down Expand Up @@ -975,7 +975,7 @@ void TransportSweep::onTrack(Track* track, segment* segments) {
else
#endif
_ls_solver->tallyLSScalarFlux(curr_segment, azim_index, polar_index,
fsr_flux, fsr_flux_x, fsr_flux_y,
fsr_flux, fsr_flux_x, fsr_flux_y,
fsr_flux_z, track_flux, direction);

/* Accumulate contribution of segments to scalar flux before changing fsr */
Expand Down Expand Up @@ -1023,7 +1023,7 @@ void TransportSweep::onTrack(Track* track, segment* segments) {
else
#endif
_ls_solver->tallyLSScalarFlux(curr_segment, azim_index, polar_index,
fsr_flux, fsr_flux_x, fsr_flux_y,
fsr_flux, fsr_flux_x, fsr_flux_y,
fsr_flux_z, track_flux, direction);

/* Accumulate contribution of segments to scalar flux before changing fsr */
Expand Down Expand Up @@ -1240,7 +1240,7 @@ void ReadSegments::onTrack(Track* track, segment* segments) {


/**
* @brief Constructor for TransportSweepOTF calls the TraverseSegments
* @brief Constructor for TransportSweepOTF calls the TraverseSegments
* constructor.
* @param track_generator Track generator to generate the tracks
*/
Expand Down
6 changes: 3 additions & 3 deletions src/accel/cuda/GPUSolver.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/** The number of FSRs */
__constant__ long num_FSRs;

#ifndef NGROUPS
#ifndef NRGROUPS
/** The number of energy groups */
__constant__ int NUM_GROUPS;
#endif
Expand Down Expand Up @@ -1263,7 +1263,7 @@ void GPUSolver::initializeMaterials(solverMode mode) {
log_printf(ERROR, "Attempt to initialize GPU XS data with zero or less energy groups.");

/* Copy the number of energy groups to constant memory on the GPU */
#ifndef NGROUPS
#ifndef NRGROUPS
cudaMemcpyToSymbol(NUM_GROUPS, &_NUM_GROUPS, sizeof(int));
getLastCudaError();
#endif
Expand Down Expand Up @@ -1292,7 +1292,7 @@ void GPUSolver::initializeMaterials(solverMode mode) {
* on the device */
cudaMalloc(&_materials, _num_materials * sizeof(dev_material));
getLastCudaError();

for (iter=host_materials.begin(); iter != host_materials.end(); ++iter) {
clone_material(iter->second, &_materials[material_index]);

Expand Down
8 changes: 4 additions & 4 deletions src/accel/cuda/GPUSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
#include "GPUQuery.h"

/** If number of groups is known at compile time */
#ifdef NGROUPS
#define NUM_GROUPS (NGROUPS)
#define _NUM_GROUPS (NGROUPS)
#ifdef NRGROUPS
#define NUM_GROUPS (NRGROUPS)
#define _NUM_GROUPS (NRGROUPS)
#else
#define _NUM_GROUPS (_num_groups)
#endif
Expand Down Expand Up @@ -170,7 +170,7 @@ class GPUSolver : public Solver {
double computeResidual(residualType res_type);

void computeFSRFissionRates(double* fission_rates, long num_FSRs, bool nu = false);

/// Missing implementations
void resetFixedSources() {};
void printCycle(long track_start, int domain_start, int length) {};
Expand Down
6 changes: 5 additions & 1 deletion src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void set_log_level(const char* new_level) {

/**
* @brief Sets the minimum log message level which will be printed to the
* console and to the log file. This is an overloaded version to handle
* console and to the log file. This is an overloaded version to handle
* a logLevel type input.
* @param new_level the minimum logging level as an int (or enum type logLevel)
*/
Expand Down Expand Up @@ -584,6 +584,10 @@ void log_printf(logLevel level, const char* format, ...) {
log_file << msg_string;
log_file.close();

// Need to make sure this gets initialized
static std::once_flag init_flag;
std::call_once(init_flag, []{ omp_init_lock(&log_error_lock); });

/* Write the log message to the shell */
if (level == ERROR) {
omp_set_lock(&log_error_lock);
Expand Down