By initializing an object, for instance of type VarCollTIData,
the vectors containing receive and send counts were deleted
when the TI object was deleted. This is unexpected by a 'normal'
user - by accepting shared_ptrs, this can be ameliorated.
The constructor that still accepts vector* should be removed once
all initializations use the constructor accepting the shared_ptr.
#include "xbt/graph.h"
#include <iomanip> /** std::setprecision **/
#include <map>
#include "xbt/graph.h"
#include <iomanip> /** std::setprecision **/
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <set>
#include <sstream>
#include <string>
public:
int endpoint = 0;
int send_size = 0;
public:
int endpoint = 0;
int send_size = 0;
- std::vector<int>* sendcounts = nullptr;
+ std::shared_ptr<std::vector<int>> sendcounts = nullptr;
- std::vector<int>* recvcounts = nullptr;
+ std::shared_ptr<std::vector<int>> recvcounts = nullptr;
std::string send_type = "";
std::string recv_type = "";
std::string send_type = "";
std::string recv_type = "";
// VarCollTI: gatherV, scatterV, allGatherV, allToAllV (+ reduceScatter out of laziness)
explicit TIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
// VarCollTI: gatherV, scatterV, allGatherV, allToAllV (+ reduceScatter out of laziness)
explicit TIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
+ : TIData(name, root, send_size, std::shared_ptr<std::vector<int>>(sendcounts), recv_size,
+ std::shared_ptr<std::vector<int>>(recvcounts), send_type, recv_type){};
+
+ explicit TIData(std::string name, int root, int send_size, std::shared_ptr<std::vector<int>> sendcounts,
+ int recv_size, std::shared_ptr<std::vector<int>> recvcounts, std::string send_type,
+ std::string recv_type)
: name_(name)
, endpoint(root)
, send_size(send_size)
: name_(name)
, endpoint(root)
, send_size(send_size)
, send_type(send_type)
, recv_type(recv_type){};
, send_type(send_type)
, recv_type(recv_type){};
- virtual ~TIData()
- {
- delete sendcounts;
- delete recvcounts;
- }
std::string getName() { return name_; }
double getAmount() { return amount_; }
std::string getName() { return name_; }
double getAmount() { return amount_; }
explicit VarCollTIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
: TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){};
explicit VarCollTIData(std::string name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
std::vector<int>* recvcounts, std::string send_type, std::string recv_type)
: TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){};
+
+ explicit VarCollTIData(std::string name, int root, int send_size, std::shared_ptr<std::vector<int>> sendcounts,
+ int recv_size, std::shared_ptr<std::vector<int>> recvcounts, std::string send_type,
+ std::string recv_type)
+ : TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){};
+
std::string print() override
{
std::stringstream stream;
std::string print() override
{
std::stringstream stream;