From 28aa7278f7c56cf970a0c9a7649a84f32232e7ea Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt <mikael@djurfeldt.com> Date: Wed, 10 Nov 2021 06:14:07 +0100 Subject: [PATCH] Fix POSTPONE:d initialization (used by the PyNN-MUSIC interface) --- src/configuration.cc | 8 ++++---- src/music/setup.hh | 3 ++- src/setup.cc | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/configuration.cc b/src/configuration.cc index f7cd18a..a28064e 100644 --- a/src/configuration.cc +++ b/src/configuration.cc @@ -1,6 +1,6 @@ /* * This file is part of MUSIC. - * Copyright (C) 2007, 2008, 2009, 2012 INCF + * Copyright (C) 2007, 2008, 2009, 2012, 2021 INCF * * MUSIC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -123,11 +123,11 @@ namespace MUSIC { { std::istringstream env (configStr); setName (IOUtils::read (env)); - env.ignore (); + env.ignore (); // delim // do not need color information, // but we can use for error check - env.ignore (); - env.ignore (); + IOUtils::read (env); + env.ignore (); // delim applications_->read (env); env.ignore (); std::map<int, int> leaders = applications_->assignLeaders( Name ()); diff --git a/src/music/setup.hh b/src/music/setup.hh index 6b58b3e..ed0262a 100644 --- a/src/music/setup.hh +++ b/src/music/setup.hh @@ -1,6 +1,6 @@ /* * This file is part of MUSIC. - * Copyright (C) 2007, 2008, 2009 INCF + * Copyright (C) 2007, 2008, 2009, 2021 INCF * * MUSIC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,6 +94,7 @@ namespace MUSIC { bool launchedByMusic_; bool postponeSetup_; + int color_; // Since we don't want to expose this internal interface to the // user we put the member functions in the private part and give diff --git a/src/setup.cc b/src/setup.cc index 5f2895a..3d2c473 100644 --- a/src/setup.cc +++ b/src/setup.cc @@ -23,6 +23,7 @@ #include "music/parse.hh" #include "music/error.hh" #include "music/application_mapper.hh" +#include "music/ioutils.hh" #include <strings.h> #include <fstream> @@ -101,8 +102,17 @@ namespace MUSIC { assert(config.length() > 0); launchedByMusic_ = true; if (!config.compare (0, 8, "POSTPONE")) - postponeSetup_ = true; - config_ = new Configuration (config); + { + postponeSetup_ = true; + // *fixme* Error checking + std::istringstream in (config); + IOUtils::read (in); // POSTPONE + in.ignore (); // delim + std::string colorString = IOUtils::read (in); + color_ = atoi (colorString.c_str ()); + } + else + config_ = new Configuration (config); } else if (launchedMPMD (argc, argv, config)) { @@ -141,7 +151,7 @@ namespace MUSIC { argc = argc_; argv = argv_; } - comm = MPI::COMM_WORLD.Split (config_->Color (), myRank); + comm = MPI::COMM_WORLD.Split (postponeSetup_ ? color_ : config_->Color (), myRank); } else { -- GitLab