Skip to content

Commit aec42e2

Browse files
authored
Hotfixes | diffLength and max compartments, rdesigneur+py3 etc, build system (#368)
* Don't run streamer multitab tests on OSX/Travis. * Disable all socket streamer tests. * IMplemented std::async to launch the thread with given policy. Needs profiling. minor refactoring. Since we can not order order in launching thread, setting moose.seed would not result in deterministic number #365 * temp commit. * removed npy support. On large files, it was not working properly. Only csv format is supported in Streamer. * Fixes to CylMesh x0/x1 and diffLength bug. * Added ASN support. Address leak in symbol table. No move in copy contructor. * Invalid chunk size again. minor cleanup. A bit of refactoring. Need to fix the RNG in Gsolve.cpp * Build is passing. * Fixes to travis file. * Fixes to tests. * Fixed test_gsolve_parallel. * NSDF related fixes. * Fixed boost compile flags.
1 parent 6addb09 commit aec42e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3337
-3262
lines changed

.travis.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ sudo: required
33

44
matrix:
55
include:
6-
- os : linux
7-
dist: xenial
8-
- os : osx
9-
- osx_image: xcode9.4
10-
- osx_image: xcode10.2
11-
allow_failures:
12-
- os: osx
13-
- osx_image: xcode10.2
6+
- os: linux
7+
dist: xenial
8+
- os: osx
9+
osx_image: xcode10.2
1410

1511
notifications:
1612
email:
@@ -30,12 +26,6 @@ before_script:
3026
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
3127
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi
3228

33-
34-
before_script:
35-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
36-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
37-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi
38-
3929
script:
4030
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_build_osx.sh; fi
4131
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/travis_build_linux.sh; fi

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ project(pymoose)
44
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
55
include(CheckCXXCompiler.cmake)
66
include(CheckIncludeFileCXX)
7-
include(FindPkgConfig)
87

98
# getgit revision number
109
find_program( GIT_EXEC git )
@@ -78,6 +77,7 @@ option(WITH_BOOST_ODE "Use boost library ode2 library instead of GSL" OFF)
7877
option(WITH_GSL "Use gsl-library. Alternative is WITH_BOOST" ON)
7978
option(PARALLELIZED_CLOCK "High level parallelization of moose::Clock (alpha)" OFF )
8079
option(USE_PRIVATE_RNG "Stochastic Objects use their private RNG" ON)
80+
option(WITH_ASAN "Use AddressSanitizer in DEBUG mode." OFF)
8181

8282

8383
############################ BUILD CONFIGURATION #################################
@@ -87,7 +87,7 @@ add_definitions(-DUSE_GENESIS_PARSER)
8787

8888
if(DEBUG OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
8989
message(STATUS "Building for Debug/Unit testing")
90-
add_definitions(-DDO_UNIT_TESTS)
90+
add_definitions(-DDO_UNIT_TESTS -O)
9191
set(CMAKE_BUILD_TYPE Debug)
9292
elseif(ENABLE_UNIT_TESTS)
9393
MESSAGE(STATUS "Enabled Unit tests")
@@ -109,8 +109,14 @@ if(GPROF AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
109109
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-pg")
110110
endif()
111111

112-
find_package(Threads)
113-
112+
if(WITH_ASAN AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
113+
message(STATUS "Compiling with ASAN")
114+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} \
115+
-fno-omit-frame-pointer -fsanitize=leak -fsanitize=address")
116+
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} \
117+
-fno-omit-frame-pointer -fsanitize=leak -fsanitize=address")
118+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
119+
endif()
114120

115121
################################### TARGETS ####################################
116122

@@ -132,8 +138,6 @@ if(WITH_BOOST_ODE)
132138
set(WITH_GSL OFF)
133139
endif(WITH_BOOST_ODE)
134140

135-
include_directories(msg basecode)
136-
137141
set_target_properties(libmoose PROPERTIES COMPILE_DEFINITIONS "MOOSE_LIB")
138142
set_target_properties(libmoose PROPERTIES PREFIX "")
139143

@@ -202,6 +206,7 @@ if(WITH_BOOST_ODE)
202206
list(APPEND SYSTEM_SHARED_LIBS ${Boost_LIBRARIES})
203207
endif(WITH_BOOST_ODE)
204208

209+
find_package( Threads )
205210
list(APPEND SYSTEM_SHARED_LIBS ${CMAKE_THREAD_LIBS_INIT})
206211

207212
# These libraries could be static of dynamic. We need to discrimate between
@@ -265,6 +270,7 @@ list(APPEND MOOSE_LIBRARIES
265270
msg
266271
benchmarks
267272
shell
273+
randnum
268274
scheduling
269275
moose_mpi
270276
biophysics

basecode/FuncOrder.h

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@
1313

1414
class FuncOrder
1515
{
16-
public:
17-
FuncOrder()
18-
: func_( 0 ), index_( 0 )
19-
{;}
16+
public:
17+
FuncOrder()
18+
: func_( 0 ), index_( 0 )
19+
{;}
2020

21-
const OpFunc* func() const {
22-
return func_;
23-
}
24-
unsigned int index() const {
25-
return index_;
26-
}
21+
const OpFunc* func() const
22+
{
23+
return func_;
24+
}
25+
unsigned int index() const
26+
{
27+
return index_;
28+
}
2729

28-
void set( const OpFunc* func, unsigned int index ) {
29-
func_ = func;
30-
index_ = index;
31-
}
30+
void set( const OpFunc* func, unsigned int index )
31+
{
32+
func_ = func;
33+
index_ = index;
34+
}
3235

33-
bool operator<( const FuncOrder& other ) const
34-
{
35-
return func_ < other.func_;
36-
}
37-
private:
38-
const OpFunc* func_;
39-
unsigned int index_;
36+
bool operator<( const FuncOrder& other ) const
37+
{
38+
return func_ < other.func_;
39+
}
40+
private:
41+
const OpFunc* func_;
42+
unsigned int index_;
4043
};

basecode/global.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace moose {
4949
{ "HSolve", {0.0, 0} }
5050
};
5151

52-
moose::RNG<double> rng;
52+
moose::RNG rng;
5353

5454
/* Check if path is OK */
5555
int checkPath( const string& path )
@@ -104,6 +104,11 @@ namespace moose {
104104
return moose::rng.uniform( );
105105
}
106106

107+
double mtrand( double a, double b )
108+
{
109+
return (b-a) * mtrand() + a;
110+
}
111+
107112
// MOOSE suffixes [0] to all elements to path. Remove [0] with null
108113
// character whenever possible. For n > 0, [n] should not be touched. Its
109114
// the user job to take the pain and write the correct path.

basecode/global.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extern unsigned int totalTests;
5656
namespace moose
5757
{
5858

59-
extern moose::RNG<double> rng;
59+
extern moose::RNG rng;
6060

6161
extern map<string, valarray<double>> solverProfMap;
6262

@@ -114,6 +114,18 @@ namespace moose
114114
*/
115115
double mtrand( void );
116116

117+
/* --------------------------------------------------------------------------*/
118+
/**
119+
* @Synopsis Overloaded function. Random number between a and b
120+
*
121+
* @Param a lower limit.
122+
* @Param b Upper limit.
123+
*
124+
* @Returns
125+
*/
126+
/* ----------------------------------------------------------------------------*/
127+
double mtrand( double a, double b );
128+
117129
/**
118130
* @brief Create a POSIX compatible path from a given string.
119131
* Remove/replace bad characters.

biophysics/Compartment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void Compartment::vRandInject( const Eref& e, double prob, double current)
268268

269269
#ifdef DO_UNIT_TESTS
270270

271-
#include "header.h"
271+
#include "../basecode/header.h"
272272
#include "../shell/Shell.h"
273273
//#include "../randnum/randnum.h"
274274

biophysics/ReadCell.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "../shell/Shell.h"
1212
#include "ReadCell.h"
1313
#include "../utility/utility.h"
14-
#include "../utility/numutil.h"
1514
#include "CompartmentBase.h"
1615
#include "Compartment.h"
1716
#include "SymCompartment.h"

builtins/Function.cpp

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@
4848
#include "../basecode/header.h"
4949
#include "../utility/utility.h"
5050
#include "../utility/numutil.h"
51+
#include "../utility/print_function.hpp"
5152
#include "Variable.h"
5253

5354
#include "Function.h"
5455
#include "../basecode/ElementValueFinfo.h"
5556

56-
#define PARSER_MAXVARS 100
57-
58-
5957
static const double TriggerThreshold = 0.0;
6058

6159
static SrcFinfo1<double> *valueOut()
@@ -345,12 +343,14 @@ Function::Function(): _t(0.0), _valid(false), _numVar(0), _lastValue(0.0),
345343
_valid = true;
346344
}
347345

348-
Function::Function(const Function& rhs): _numVar(rhs._numVar),
346+
Function::Function(const Function& rhs):
347+
_numVar(rhs._numVar),
349348
_lastValue(rhs._lastValue),
350349
_value(rhs._value), _rate(rhs._rate),
351350
_mode(rhs._mode),
352351
_useTrigger( rhs._useTrigger),
353-
_stoich(0)
352+
_stoich(0),
353+
map_(rhs.map_)
354354
{
355355
static Eref er;
356356
_independent = rhs._independent;
@@ -440,7 +440,7 @@ void Function::_clearBuffer()
440440

441441
void Function::_showError(mu::Parser::exception_type &e) const
442442
{
443-
cout << "Error occurred in parser.\n"
443+
cerr << "Error occurred in parser.\n"
444444
<< "Message: " << e.GetMsg() << "\n"
445445
<< "Formula: " << e.GetExpr() << "\n"
446446
<< "Token: " << e.GetToken() << "\n"
@@ -474,7 +474,7 @@ double * _functionAddVar(const char *name, void *data)
474474
string strname(name);
475475

476476
// Names starting with x are variables, everything else is constant.
477-
if (strname[0] == 'x')
477+
if (name[0] == 'x')
478478
{
479479
int index = atoi(strname.substr(1).c_str());
480480
if ((unsigned)index >= function->_varbuf.size()){
@@ -488,7 +488,7 @@ double * _functionAddVar(const char *name, void *data)
488488
}
489489
ret = &(function->_varbuf[index]->value);
490490
}
491-
else if (strname[0] == 'y')
491+
else if (name[0] == 'y')
492492
{
493493
int index = atoi(strname.substr(1).c_str());
494494
if ((unsigned)index >= function->_pullbuf.size()){
@@ -507,11 +507,11 @@ double * _functionAddVar(const char *name, void *data)
507507
}
508508
else
509509
{
510-
cerr << "Got an undefined symbol: " << name << endl
511-
<< "Variables must be named xi, yi, where i is integer index."
512-
<< " You must define the constants beforehand using LookupField c: c[name]"
510+
MOOSE_WARN( "Got an undefined symbol: " << strname << ".\n"
511+
<< "Variables must be named xi, yi, where i is integer index."
512+
<< " You must define the constants beforehand using LookupField c: c[name]"
513513
" = value"
514-
<< endl;
514+
);
515515
throw mu::ParserError("Undefined constant.");
516516
}
517517

@@ -741,21 +741,21 @@ void Function::process(const Eref &e, ProcPtr p)
741741
switch (_mode){
742742
case 1: {
743743
valueOut()->send(e, _value);
744-
break;
744+
return;
745745
}
746746
case 2: {
747747
derivativeOut()->send(e, getDerivative());
748-
break;
748+
return;
749749
}
750750
case 3: {
751751
rateOut()->send(e, _rate);
752-
break;
752+
return;
753753
}
754754
default: {
755755
valueOut()->send(e, _value);
756756
derivativeOut()->send(e, getDerivative());
757757
rateOut()->send(e, _rate);
758-
break;
758+
return;
759759
}
760760
}
761761
_lastValue = _value;
@@ -801,13 +801,4 @@ void Function::reinit(const Eref &e, ProcPtr p)
801801
}
802802
}
803803

804-
#if 0
805-
mu::value_type Function::muCallbackFMod( mu::value_type a, mu::value_type b)
806-
{
807-
cerr << "Callback: " << a << " " << b << endl;
808-
return fmod(a, b);
809-
}
810-
#endif
811-
812-
//
813804
// Function.cpp ends here

builtins/Function.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class Function
6868
void setExpr( const Eref& e, string expr);
6969
string getExpr( const Eref& e ) const;
7070

71-
7271
// get a list of variable identifiers.
7372
// this is created by the parser
7473
vector<string> getVars() const;
@@ -166,6 +165,10 @@ class Function
166165

167166
// Used by kinetic solvers when this is zombified.
168167
char* _stoich;
168+
169+
// These variables may be redundant but used for interfacing with
170+
// MooseParser.
171+
map<string, double*> map_;
169172
};
170173

171174

builtins/HDF5DataWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include "hdf5.h"
1414

15-
#include "header.h"
15+
#include "../basecode/header.h"
1616
#include "../utility/utility.h"
1717

1818
#include "HDF5DataWriter.h"

0 commit comments

Comments
 (0)