Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
Merged
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
22 changes: 22 additions & 0 deletions CMake/GitRevision.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# For now use simple approach to get version information as git is
# often avaialble on the machine where we are building from source

find_package(Git)

if(GIT_FOUND)
# get last commit sha1
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
# get last commit date
execute_process(
COMMAND ${GIT_EXECUTABLE} show -s --format=%ci
WORKING_DIRECTORY ${CORENEURON_PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION_DATE
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CN_GIT_REVISION "${GIT_REVISION_SHA1} (${GIT_REVISION_DATE})")
else()
set(CN_GIT_REVISION "unknown")
endif()
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ include(SetRpath)
include(CTest)
include(AddRandom123Submodule)
include(AddCLI11Submodule)
include(GitRevision)

add_subdirectory(${CORENEURON_PROJECT_SOURCE_DIR}/external/CLI11)

Expand Down Expand Up @@ -104,6 +105,15 @@ if(CORENEURON_AS_SUBPROJECT)
set(CORENRN_ENABLE_UNIT_TESTS OFF)
endif()

# =============================================================================
# Project version from git and project directories
# =============================================================================
set(CN_PROJECT_VERSION ${PROJECT_VERSION})

# generate file with version number from git and nrnunits.lib file path
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/coreneuron/config/config.cpp.in
${PROJECT_BINARY_DIR}/coreneuron/config/config.cpp @ONLY)

# =============================================================================
# Include cmake modules after cmake options
# =============================================================================
Expand Down
1 change: 1 addition & 0 deletions coreneuron/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ file(GLOB_RECURSE CORENEURON_CUDA_FILES "*.cu")
file(GLOB SCOPMATH_CODE_FILES "sim/scopmath/*.cpp")
file(COPY ${CORENEURON_PROJECT_SOURCE_DIR}/external/Random123/include/Random123
DESTINATION ${CMAKE_BINARY_DIR}/include)
list(APPEND CORENEURON_CODE_FILES ${PROJECT_BINARY_DIR}/coreneuron/config/config.cpp)

set(DIMPLIC_CODE_FILE "mechanism/mech/dimplic.cpp")
set(ENGINEMECH_CODE_FILE "mechanism/mech/enginemech.cpp")
Expand Down
18 changes: 16 additions & 2 deletions coreneuron/apps/corenrn_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ THE POSSIBILITY OF SUCH DAMAGE.

#include "coreneuron/apps/corenrn_parameters.hpp"


namespace coreneuron {

extern std::string cnrn_version();

corenrn_parameters::corenrn_parameters(){

app.set_config("--read-config", "", "Read parameters from ini file", false)
Expand Down Expand Up @@ -100,6 +104,8 @@ corenrn_parameters::corenrn_parameters(){
sub_output -> add_option("-o, --outpath", this->outpath, "Path to place output data files.", true);
sub_output -> add_option("--checkpoint", this->checkpointpath, "Enable checkpoint and specify directory to store related files.");

app.add_flag("-v, --version", this->show_version, "Show version information and quit.");

CLI::retire_option(app, "--show");
};

Expand All @@ -111,13 +117,21 @@ void corenrn_parameters::parse (int argc, char** argv) {
nrn_nobanner_ = 1;
}
} catch (const CLI::ExtrasError &e) {
std::cerr << "Single-dash arguments such as -mpi are deleted, please check ./coreneuron_exec --help for more information. \n" << std::endl;
// in case of parsing errors, show message with exception
std::cerr << "CLI parsing error, see nrniv-core --help for more information. \n" << std::endl;
app.exit(e);
throw e;

} catch (const CLI::ParseError &e) {
// use --help is also ParseError; in this case exit by showing all options
app.exit(e);
throw e;
exit(0);
}

// is user has asked for version info, print it and exit
if (show_version) {
std::cout << "CoreNEURON Version : " << cnrn_version() << std::endl;
exit(0);
}
};

Expand Down
2 changes: 2 additions & 0 deletions coreneuron/apps/corenrn_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct corenrn_parameters {
bool gpu=false; /// Enable GPU computation.
bool binqueue=false; /// Use bin queue.

bool show_version=false; /// Print version and exit.

verbose_level verbose{verbose_level::DEFAULT}; /// Verbosity-level

double tstop=100; /// Stop time of simulation in msec
Expand Down
14 changes: 5 additions & 9 deletions coreneuron/apps/main1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <vector>

#include "coreneuron/config/config.h"
#include "coreneuron/engine.h"
#include "coreneuron/utils/randoms/nrnran123.h"
#include "coreneuron/nrnconf.h"
Expand Down Expand Up @@ -339,12 +340,12 @@ void handle_forward_skip(double forwardskip, int prcellgid) {
t = savet;
dt2thread(-1.);

// clear spikes generated during forward skip (with negative time)
// clear spikes generated during forward skip (with negative time)
clear_spike_vectors();
}

const char* nrn_version(int) {
return "version id unimplemented";
std::string cnrn_version() {
return coreneuron::version::to_string();
}

// bsize = 0 then per step transfer
Expand Down Expand Up @@ -428,12 +429,7 @@ using namespace coreneuron;

extern "C" void mk_mech_init(int argc, char** argv) {
// read command line parameters and parameter config files
try {
corenrn_param.parse(argc, argv);
}
catch (...) {
nrn_abort(1);
}
corenrn_param.parse(argc, argv);

#if NRNMPI
if (corenrn_param.mpi_enable) {
Expand Down
7 changes: 7 additions & 0 deletions coreneuron/config/config.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "coreneuron/config/config.h"

/// Git version of the project
const std::string coreneuron::version::GIT_REVISION = "@CN_GIT_REVISION@";

/// CoreNEURON version
const std::string coreneuron::version::CORENEURON_VERSION = "@CN_PROJECT_VERSION@";
31 changes: 31 additions & 0 deletions coreneuron/config/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

/**
* \dir
* \brief Global project configurations
*
* \file
* \brief Version information
*/

#include <string>

namespace coreneuron {

/**
* \brief Project version information
*/
struct version {
/// git revision id
static const std::string GIT_REVISION;

/// project tagged version in the cmake
static const std::string CORENEURON_VERSION;

/// return version string (version + git id) as a string
static std::string to_string() {
return CORENEURON_VERSION + " " + GIT_REVISION;
}
};

} // namespace coreneuron
4 changes: 2 additions & 2 deletions coreneuron/io/mk_mech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace coreneuron {
extern int nrn_nobanner_;

// NB: this should go away
extern const char* nrn_version(int);
extern std::string cnrn_version();
std::map<std::string, int> mech2type;

extern "C" {
Expand Down Expand Up @@ -140,7 +140,7 @@ static void mk_mech(std::istream& s) {
if (nrnmpi_myid < 1 && nrn_nobanner_ == 0) {
fprintf(stderr, " \n");
fprintf(stderr, " %s\n", banner);
fprintf(stderr, " %s\n", nrn_version(1));
fprintf(stderr, " Version : %s\n", cnrn_version().c_str());
fprintf(stderr, " \n");
fflush(stderr);
}
Expand Down
2 changes: 1 addition & 1 deletion coreneuron/network/netpar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ double set_mindelay(double maxdelay) {
}
PreSyn* ps;
InputPreSyn* psi;
netpar_tid_gid2ps(ith, gid, &ps, &psi);
netpar_tid_gid2ps(tid, gid, &ps, &psi);
if (psi) {
chk = true;
} else if (all) {
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipeline {
agent {
label 'bb5'
label 'bb5 && !bb5-07'
}
parameters {
string(name: 'sha1', defaultValue: 'master',
Expand Down