From 4830e201d53af82a0d2722defd50a17363073785 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Tue, 13 Mar 2018 18:19:21 +0100 Subject: [PATCH] [INSTR] Move vector* to shared_ptr. 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. --- src/instr/instr_private.hpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 57413b0999..0004fa948b 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -19,6 +19,7 @@ #include "xbt/graph.h" #include /** std::setprecision **/ #include +#include #include #include #include @@ -42,9 +43,9 @@ class TIData { public: int endpoint = 0; int send_size = 0; - std::vector* sendcounts = nullptr; + std::shared_ptr> sendcounts = nullptr; int recv_size = 0; - std::vector* recvcounts = nullptr; + std::shared_ptr> recvcounts = nullptr; std::string send_type = ""; std::string recv_type = ""; @@ -68,6 +69,12 @@ public: // VarCollTI: gatherV, scatterV, allGatherV, allToAllV (+ reduceScatter out of laziness) explicit TIData(std::string name, int root, int send_size, std::vector* sendcounts, int recv_size, std::vector* recvcounts, std::string send_type, std::string recv_type) + : TIData(name, root, send_size, std::shared_ptr>(sendcounts), recv_size, + std::shared_ptr>(recvcounts), send_type, recv_type){}; + + explicit TIData(std::string name, int root, int send_size, std::shared_ptr> sendcounts, + int recv_size, std::shared_ptr> recvcounts, std::string send_type, + std::string recv_type) : name_(name) , endpoint(root) , send_size(send_size) @@ -77,11 +84,7 @@ public: , send_type(send_type) , recv_type(recv_type){}; - virtual ~TIData() - { - delete sendcounts; - delete recvcounts; - } + virtual ~TIData() {} std::string getName() { return name_; } double getAmount() { return amount_; } @@ -151,6 +154,12 @@ public: explicit VarCollTIData(std::string name, int root, int send_size, std::vector* sendcounts, int recv_size, std::vector* 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> sendcounts, + int recv_size, std::shared_ptr> 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; -- 2.20.1