From 1a989a2ae95a7880a8786409a2551b242d1e8128 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Mon, 28 Sep 2020 17:04:56 -0400 Subject: [PATCH 1/9] Made unrecognized generator error fatal. --- Source/Core/LMCGeneratorToolbox.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/LMCGeneratorToolbox.cc b/Source/Core/LMCGeneratorToolbox.cc index 2af0a7e1..2c1e45fd 100644 --- a/Source/Core/LMCGeneratorToolbox.cc +++ b/Source/Core/LMCGeneratorToolbox.cc @@ -69,6 +69,7 @@ namespace locust if( newGenerator == nullptr ) { LERROR( lmclog, "Unrecognized generator name: " << (*it)().as_string() ); + exit(-1); // TODO: this should also be a fatal error continue; } From 8d4171370039bb9e895f0688cac83b5fd2bb6f82 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Tue, 29 Sep 2020 17:50:28 -0400 Subject: [PATCH 2/9] Configure generators only if config information is present. This avoids having to specify empty config brackets in the config file for generators without parameters. --- Source/Core/LMCGeneratorToolbox.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Core/LMCGeneratorToolbox.cc b/Source/Core/LMCGeneratorToolbox.cc index 2c1e45fd..62351d87 100644 --- a/Source/Core/LMCGeneratorToolbox.cc +++ b/Source/Core/LMCGeneratorToolbox.cc @@ -99,10 +99,15 @@ namespace locust if( ! aNode.has( nextGenerator->GetName() ) ) { LDEBUG( lmclog, "No configuration information present" ); + nextGenerator = nextGenerator->GetNextGenerator(); continue; } - nextGenerator->Configure( aNode[ nextGenerator->GetName() ].as_node() ); - nextGenerator = nextGenerator->GetNextGenerator(); + else + { + nextGenerator->Configure( aNode[ nextGenerator->GetName() ].as_node() ); + nextGenerator = nextGenerator->GetNextGenerator(); + } + } LINFO( lmclog, "Generator toolbox configuration complete" ); From 6d51c786bc4000793773683157382167302cde12 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Tue, 6 Oct 2020 10:39:26 -0400 Subject: [PATCH 3/9] Made fatal exit(-1) Non-value-type array element found in generator-list. --- Source/Core/LMCGeneratorToolbox.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Core/LMCGeneratorToolbox.cc b/Source/Core/LMCGeneratorToolbox.cc index 62351d87..08bbaaff 100644 --- a/Source/Core/LMCGeneratorToolbox.cc +++ b/Source/Core/LMCGeneratorToolbox.cc @@ -56,7 +56,7 @@ namespace locust if( ! it->is_value() ) { LERROR( lmclog, "Non-value-type array element found in generator-list" ); - // TODO: this indicates a problem in the config and should result in locust exiting + exit(-1); continue; } // else @@ -70,7 +70,6 @@ namespace locust { LERROR( lmclog, "Unrecognized generator name: " << (*it)().as_string() ); exit(-1); - // TODO: this should also be a fatal error continue; } From b83091de09f30e8b3c3f3d7e21c05573909ebc06 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Tue, 6 Oct 2020 22:31:46 -0400 Subject: [PATCH 4/9] Return false in LMCGeneratorToolbox::Configure if aNode[generators] is either missing or not an array. --- Source/Core/LMCGeneratorToolbox.cc | 8 ++++++++ Source/Core/LMCGeneratorToolbox.hh | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Core/LMCGeneratorToolbox.cc b/Source/Core/LMCGeneratorToolbox.cc index 08bbaaff..e66cd4bd 100644 --- a/Source/Core/LMCGeneratorToolbox.cc +++ b/Source/Core/LMCGeneratorToolbox.cc @@ -13,6 +13,7 @@ #include "factory.hh" + namespace locust { LOGGER( lmclog, "GeneratorToolbox" ); @@ -44,6 +45,13 @@ namespace locust // TODO: this line will throw an exception if "generators" is not present or it's not an array // TODO: this should either check that those are the case and return false if not, or // TODO: catch the exception and then return false + + if (!(aNode.has("generators")&&aNode["generators"].is_array())) + { + LERROR( lmclog, "generators array is either not present or not an array." ); + return false; + } + const scarab::param_array& generatorList = aNode["generators"].as_array(); diff --git a/Source/Core/LMCGeneratorToolbox.hh b/Source/Core/LMCGeneratorToolbox.hh index 818c881d..20f17c3f 100644 --- a/Source/Core/LMCGeneratorToolbox.hh +++ b/Source/Core/LMCGeneratorToolbox.hh @@ -7,7 +7,7 @@ #ifndef LMCGENERATORTOOLBOX_HH_ #define LMCGENERATORTOOLBOX_HH_ - +#include "LMCException.hh" namespace scarab { From 1bebc4794e867651390ef2150bc543d7ca5981c5 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Wed, 13 Jan 2021 12:57:18 -0500 Subject: [PATCH 5/9] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e757a530..25592fd5 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,12 @@ or to avoid mounting the $HOME directory > singularity shell --no-home /path/to/local/sif/locust-latest.sif ``` +and to mount a local directory for e.g. I/O to the container +``` +> singularity shell --no-home --bind /path/to/local/directory:/usr/local/p8/locust/v2.1.5/output ./locust_mc_latest.sif +``` + + From d8c19081b15145026fc545dc01f3be23f0724da3 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Fri, 22 Jan 2021 13:18:04 -0500 Subject: [PATCH 6/9] Updated LMCTemplateGenerator.cc and added LocustBlankTemplate.json.in config file. --- Config/CMakeLists.txt | 20 ++++++----- Config/LocustBlankTemplate.json.in | 39 ++++++++++++++++++++ Source/Generators/LMCTemplateGenerator.cc | 43 ++++++++++++++++++++--- Source/Generators/LMCTemplateGenerator.hh | 10 +++++- 4 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 Config/LocustBlankTemplate.json.in diff --git a/Config/CMakeLists.txt b/Config/CMakeLists.txt index 03be8b14..db0a9deb 100644 --- a/Config/CMakeLists.txt +++ b/Config/CMakeLists.txt @@ -14,6 +14,7 @@ configure_file( LocustTestSignal.json.in LocustTestSignal.json ) configure_file( plotfieldmap.c.in plotfieldmap.c ) configure_file( katydid.json.in katydid.json ) configure_file( ChannelAggregatorConfig.yaml.in ChannelAggregatorConfig.yaml ) +configure_file( LocustBlankTemplate.json.in LocustBlankTemplate.json ) set (EXAMPLE_CONFIGFILES @@ -23,15 +24,16 @@ set (EXAMPLE_CONFIGFILES ${CMAKE_CURRENT_BINARY_DIR}/LocustKass_FreeSpace_Template.xml WaveguideGeometry.xml FreeSpaceGeometry.xml - ${CMAKE_CURRENT_BINARY_DIR}/LocustWaveguideTemplate.json - ${CMAKE_CURRENT_BINARY_DIR}/LocustFreeSpaceTemplate.json - ${CMAKE_CURRENT_BINARY_DIR}/LocustPlaneWaveTemplate.json - ${CMAKE_CURRENT_BINARY_DIR}/LocustFakeTrack.json - ${CMAKE_CURRENT_BINARY_DIR}/LocustMagDipoleAntennaTemplate.json - ${CMAKE_CURRENT_BINARY_DIR}/LocustTestSignal.json - ${CMAKE_CURRENT_BINARY_DIR}/katydid.json - ${CMAKE_CURRENT_BINARY_DIR}/ChannelAggregatorConfig.yaml - ${CMAKE_CURRENT_BINARY_DIR}/plotfieldmap.c + ${CMAKE_CURRENT_BINARY_DIR}/LocustWaveguideTemplate.json + ${CMAKE_CURRENT_BINARY_DIR}/LocustFreeSpaceTemplate.json + ${CMAKE_CURRENT_BINARY_DIR}/LocustPlaneWaveTemplate.json + ${CMAKE_CURRENT_BINARY_DIR}/LocustFakeTrack.json + ${CMAKE_CURRENT_BINARY_DIR}/LocustMagDipoleAntennaTemplate.json + ${CMAKE_CURRENT_BINARY_DIR}/LocustTestSignal.json + ${CMAKE_CURRENT_BINARY_DIR}/katydid.json + ${CMAKE_CURRENT_BINARY_DIR}/ChannelAggregatorConfig.yaml + ${CMAKE_CURRENT_BINARY_DIR}/LocustBlankTemplate.json + ${CMAKE_CURRENT_BINARY_DIR}/plotfieldmap.c ) pbuilder_install_config (${EXAMPLE_CONFIGFILES}) diff --git a/Config/LocustBlankTemplate.json.in b/Config/LocustBlankTemplate.json.in new file mode 100644 index 00000000..f3761aae --- /dev/null +++ b/Config/LocustBlankTemplate.json.in @@ -0,0 +1,39 @@ +{ + "generators": + [ + "digitizer" + ], + + "lpf-fft": + { + + }, + + "decimate-signal": + { + + }, + + + "simulation": + { + "egg-filename": "${CMAKE_INSTALL_PREFIX}/output/locust_mc.egg", + "n-records": 1, + "record-size": 8192, + "n-channels": 1 + }, + + "gaussian-noise": + { + "noise-floor-psd": 2.76e-22, + "domain": "time" + }, + + "digitizer": + { + "v-range": 2.0e-5, + "v-offset": -1.0e-5 + } + +} + diff --git a/Source/Generators/LMCTemplateGenerator.cc b/Source/Generators/LMCTemplateGenerator.cc index c1e2a74e..b764b968 100644 --- a/Source/Generators/LMCTemplateGenerator.cc +++ b/Source/Generators/LMCTemplateGenerator.cc @@ -16,7 +16,8 @@ namespace locust MT_REGISTER_GENERATOR([name]Generator, "config-name"); [name]Generator::[name]Generator( const std::string& aName ) : - Generator( aName ) + Generator( aName ), + fDoGenerateFunc( &[name]Generator::DoGenerateTime ) { fRequiredSignalState = Signal::k[domain]; } @@ -36,13 +37,47 @@ namespace locust return; } - bool [name]Generator::DoGenerate( Signal* aSignal ) + Signal::State [name]Generator::GetDomain() const + { + return fRequiredSignalState; + } + + void [name]Generator::SetDomain( Signal::State aDomain ) { - for( unsigned index = 0; index < aSignal->[domain]Size(); ++index ) + if( aDomain == fRequiredSignalState ) return; + fRequiredSignalState = aDomain; + if( fRequiredSignalState == Signal::kTime ) + { + fDoGenerateFunc = &[name]Generator::DoGenerateTime; + } + else if( fRequiredSignalState == Signal::kFreq ) { - aSignal->Signal[domain]S( index ) += ???; + fDoGenerateFunc = &[name]Generator::DoGenerateFreq; } + else + { + LWARN( lmclog, "Unknown domain requested: " << aDomain ); + } + return; + } + + + bool [name]Generator::DoGenerate( Signal* aSignal ) + { + return (this->*fDoGenerateFunc)( aSignal ); + } + + bool [name]Generator::DoGenerateTime( Signal* aSignal ) + { +// aSignal->SignalTimeComplex()[index][0] += [...] +// aSignal->SignalTimeComplex()[index][1] += [...] return true; } + bool [name]Generator::DoGenerateFreq( Signal* aSignal ) + { + return true; + } + + } /* namespace locust */ diff --git a/Source/Generators/LMCTemplateGenerator.hh b/Source/Generators/LMCTemplateGenerator.hh index 52cf0de1..1d95d9cd 100644 --- a/Source/Generators/LMCTemplateGenerator.hh +++ b/Source/Generators/LMCTemplateGenerator.hh @@ -38,8 +38,16 @@ namespace locust void Accept( GeneratorVisitor* aVisitor ) const; + Signal::State GetDomain() const; + void SetDomain( Signal::State aDomain ); + + private: - bool DoGenerate( Signal* aSignal ) const; + bool DoGenerate( Signal* aSignal ); + bool DoGenerateTime( Signal* aSignal ); + bool DoGenerateFreq( Signal* aSignal ); + + bool ([name]Generator::*fDoGenerateFunc)( Signal* aSignal ); }; From 1b1eceb9a3f1d2a959d343f5b007dfdc7a97b91e Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Thu, 28 Jan 2021 14:48:34 -0500 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25592fd5..1b51c9d3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ After running Katydid, the processed fft spectra will have a span from 0 to the ### Tutorial -A tutorial with examples is located in the locust-tutorial repository, [here](https://github.com/project8/locust-tutorial). +Tutorials with examples are located in the locust-tutorial repository, [here](https://github.com/project8/locust-tutorial). Issues should be posted via [GitHub](https://github.com/project8/locust_mc/issues). From a2a213ed89c760e576b4879439ada304377c5121 Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Fri, 5 Feb 2021 20:08:12 -0500 Subject: [PATCH 8/9] Moved event-start checks inside lines enclosed by std::lock. --- Source/Generators/LMCArraySignalGenerator.cc | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Source/Generators/LMCArraySignalGenerator.cc b/Source/Generators/LMCArraySignalGenerator.cc index 4412d46d..722f7465 100644 --- a/Source/Generators/LMCArraySignalGenerator.cc +++ b/Source/Generators/LMCArraySignalGenerator.cc @@ -612,7 +612,7 @@ namespace locust } - if (fInterface->fPreEventInProgress) + if (fInterface->fPreEventInProgress) // Locust keeps sampling until Kass event. { PreEventCounter += 1; @@ -622,13 +622,14 @@ namespace locust fInterface->fEventInProgress = true; LPROG( lmclog, "LMC about to WakeBeforeEvent()" ); WakeBeforeEvent(); // trigger Kass event. - std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } - if ((fInterface->fEventInProgress)&&(!fInterface->fKassEventReady)) // fEventInProgress + if (fInterface->fEventInProgress) // fEventInProgress { - std::unique_lock< std::mutex >tLock( fInterface->fMutexDigitizer, std::defer_lock ); + std::unique_lock< std::mutex >tLock( fInterface->fMutexDigitizer, std::defer_lock ); + if (!fInterface->fKassEventReady) // Kass confirms event is underway. + { tLock.lock(); fInterface->fDigitizerCondition.wait( tLock ); if (fInterface->fEventInProgress) @@ -637,6 +638,21 @@ namespace locust PreEventCounter = 0; // reset } tLock.unlock(); + } + else // either Kass thread fell behind, or it has stopped generating events. + { + tLock.lock(); + std::this_thread::sleep_for(std::chrono::milliseconds(10000)); + if (!fInterface->fKassEventReady) // Kass event did start. Continue but skip this sample. + { + tLock.unlock(); + } + else // no Kass event ever started, unlock and break out of signal loop entirely. + { + tLock.unlock(); + break; + } + } } } // for loop From 5d37c099102c6262d46b817ce8a6bb1d71c1b88e Mon Sep 17 00:00:00 2001 From: Penny Slocum Date: Sat, 6 Feb 2021 09:25:49 -0500 Subject: [PATCH 9/9] Bumped version to 2.1.6 --- CMakeLists.txt | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b4875fe..6c8646d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required( VERSION 3.1 ) # Define the project cmake_policy( SET CMP0048 NEW ) # version in project() -project( locust_mc VERSION 2.1.5) +project( locust_mc VERSION 2.1.6) list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake ) include( PackageBuilder ) diff --git a/Dockerfile b/Dockerfile index 16fff4be..d084eb52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM project8/p8compute_dependencies:v0.9.0 as locust_common ARG build_type=Release ENV LOCUST_BUILD_TYPE=$build_type -ENV LOCUST_TAG=v2.1.5 +ENV LOCUST_TAG=v2.1.6 ENV LOCUST_BUILD_PREFIX=/usr/local/p8/locust/$LOCUST_TAG RUN mkdir -p $LOCUST_BUILD_PREFIX &&\