From 2fbafc3976ae127d52ce977544b7340c73ca2fd1 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Sun, 6 Apr 2025 23:14:26 -0700 Subject: [PATCH 01/26] modify copyGPUtoCPU() and copyCPUtoGPU() to include neuron info --- Simulator/Core/GPUModel.cpp | 14 ++++++++++---- Simulator/Core/GPUModel.h | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 2085c3928..a0c373eb0 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -362,15 +362,21 @@ __global__ void /// Copy GPU Synapse data to CPU. void GPUModel::copyGPUtoCPU() { - // copy device synapse structs to host memory - connections_->getEdges().copyEdgeDeviceToHost(allEdgesDevice_); + // copy device neuron and synapse structs to host memory + AllVertices &neurons = layout_->getVertices(); + AllEdges &synapses = connections_->getEdges(); + neurons.copyFromDevice(*allVerticesDevice); + synapses.copyEdgeDeviceToHost(*allEdgesDevice); } /// Copy CPU Synapse data to GPU. void GPUModel::copyCPUtoGPU() { - // copy host synapse structs to device memory - connections_->getEdges().copyEdgeHostToDevice(allEdgesDevice_); + // copy host neurons and synapse structs to device memory + AllVertices &neurons = layout_->getVertices(); + AllEdges &synapses = connections_->getEdges(); + neurons.copyToDevice(*allVerticesDevice); + synapses.copyEdgeHostToDevice(*allEdgesDevice); } /// Print out SynapseProps on the GPU. diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index fc5254d68..eb350a441 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -92,10 +92,10 @@ class GPUModel : public Model { /// over the past epoch. Should be called once every epoch. virtual void updateConnections() override; - /// Copy GPU Synapse data to CPU. + /// Copy GPU Neuron and Synapse data to CPU. virtual void copyGPUtoCPU() override; - /// Copy CPU Synapse data to GPU. + /// Copy CPU Neuron and Synapse data to GPU. virtual void copyCPUtoGPU() override; /// Print out SynapseProps on the GPU. From 969407bd24b5c8fd96ff16052e7aad535596cacd Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Tue, 8 Apr 2025 12:06:12 -0700 Subject: [PATCH 02/26] modified deleteDeviceStruct and allocDeviceStruct to use copyToCPu and copyTOGPU --- Simulator/Core/GPUModel.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index a0c373eb0..e9d25df91 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -46,9 +46,7 @@ void GPUModel::allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice HANDLE_ERROR(cudaMalloc((void **)&randNoise_d, randNoise_d_size)); // Copy host neuron and synapse arrays into GPU device - neurons.copyToDevice(*allVerticesDevice); - synapses.copyEdgeHostToDevice(*allEdgesDevice); - + copyCPUtoGPU(); // Allocate synapse inverse map in device memory allocSynapseImap(numVertices); } @@ -63,11 +61,9 @@ void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevic AllEdges &synapses = connections_->getEdges(); // Copy device synapse and neuron structs to host memory - neurons.copyFromDevice(*allVerticesDevice); + copyGPUtoCPU(); // Deallocate device memory neurons.deleteNeuronDeviceStruct(*allVerticesDevice); - // Copy device synapse and neuron structs to host memory - synapses.copyEdgeDeviceToHost(*allEdgesDevice); // Deallocate device memory synapses.deleteEdgeDeviceStruct(*allEdgesDevice); HANDLE_ERROR(cudaFree(randNoise_d)); @@ -77,6 +73,7 @@ void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevic void GPUModel::setupSim() { // Set device ID + std::cout << "gdevice id: " << g_deviceId << std::endl; HANDLE_ERROR(cudaSetDevice(g_deviceId)); // Set DEBUG flag HANDLE_ERROR(cudaMemcpyToSymbol(d_debug_mask, &g_debug_mask, sizeof(int))); @@ -365,8 +362,8 @@ void GPUModel::copyGPUtoCPU() // copy device neuron and synapse structs to host memory AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); - neurons.copyFromDevice(*allVerticesDevice); - synapses.copyEdgeDeviceToHost(*allEdgesDevice); + neurons.copyFromDevice(allVerticesDevice_); + synapses.copyEdgeDeviceToHost(allEdgesDevice_); } /// Copy CPU Synapse data to GPU. @@ -375,8 +372,8 @@ void GPUModel::copyCPUtoGPU() // copy host neurons and synapse structs to device memory AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); - neurons.copyToDevice(*allVerticesDevice); - synapses.copyEdgeHostToDevice(*allEdgesDevice); + neurons.copyToDevice(allVerticesDevice_); + synapses.copyEdgeHostToDevice(allEdgesDevice_); } /// Print out SynapseProps on the GPU. From 6dc96c6b822e60aa566f540fd732dd9cc5073919 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Wed, 9 Apr 2025 12:15:59 -0700 Subject: [PATCH 03/26] seperated the allocation from memory copying --- Simulator/Core/GPUModel.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index e9d25df91..9409832bb 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -45,8 +45,6 @@ void GPUModel::allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice BGSIZE randNoise_d_size = numVertices * sizeof(float); // size of random noise array HANDLE_ERROR(cudaMalloc((void **)&randNoise_d, randNoise_d_size)); - // Copy host neuron and synapse arrays into GPU device - copyCPUtoGPU(); // Allocate synapse inverse map in device memory allocSynapseImap(numVertices); } @@ -60,8 +58,6 @@ void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevic AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); - // Copy device synapse and neuron structs to host memory - copyGPUtoCPU(); // Deallocate device memory neurons.deleteNeuronDeviceStruct(*allVerticesDevice); // Deallocate device memory @@ -73,7 +69,6 @@ void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevic void GPUModel::setupSim() { // Set device ID - std::cout << "gdevice id: " << g_deviceId << std::endl; HANDLE_ERROR(cudaSetDevice(g_deviceId)); // Set DEBUG flag HANDLE_ERROR(cudaMemcpyToSymbol(d_debug_mask, &g_debug_mask, sizeof(int))); @@ -102,7 +97,8 @@ void GPUModel::setupSim() // allocates memories on CUDA device allocDeviceStruct((void **)&allVerticesDevice_, (void **)&allEdgesDevice_); - + // Copy host neuron and synapse arrays into GPU device + copyCPUtoGPU(); // copy inverse map to the device memory copySynapseIndexMapHostToDevice(connections_->getEdgeIndexMap(), Simulator::getInstance().getTotalVertices()); @@ -117,6 +113,8 @@ void GPUModel::setupSim() /// Performs any finalization tasks on network following a simulation. void GPUModel::finish() { + // copy device synapse and neuron structs to host memory + copyGPUtoCPU(); // deallocates memories on CUDA device deleteDeviceStruct((void **)&allVerticesDevice_, (void **)&allEdgesDevice_); deleteSynapseImap(); From 67246ad40d268666f846f65d6efb9dbc6372795a Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Wed, 9 Apr 2025 13:13:27 -0700 Subject: [PATCH 04/26] added the new operation to the operation.h and operationanager.cpp --- Simulator/Core/OperationManager.cpp | 2 ++ Simulator/Core/Operations.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Simulator/Core/OperationManager.cpp b/Simulator/Core/OperationManager.cpp index 66dbdb72a..6dc11b041 100644 --- a/Simulator/Core/OperationManager.cpp +++ b/Simulator/Core/OperationManager.cpp @@ -71,6 +71,8 @@ string OperationManager::operationToString(const Operations::op &operation) cons return "copyToGPU"; case Operations::op::copyFromGPU: return "copyFromGPU"; + case Operations::op::allocateGPU: + return "allocateGPU"; default: return "Operation isn't in OperationManager::operationToString()"; } diff --git a/Simulator/Core/Operations.h b/Simulator/Core/Operations.h index ceb87bc80..62f22059a 100644 --- a/Simulator/Core/Operations.h +++ b/Simulator/Core/Operations.h @@ -22,6 +22,7 @@ class Operations { deallocateGPUMemory, // Make sure deallocate memory isn't called until all GPU memory is copied back. restoreToDefault, // Not sure what this refers to. copyToGPU, - copyFromGPU + copyFromGPU, + allocateGPU }; }; \ No newline at end of file From fbaba9ba82bb0205dfcd586d66ee074781c34b16 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Wed, 9 Apr 2025 22:25:13 -0700 Subject: [PATCH 05/26] added the getter for allVerticesDevice_ and allEdgesDevice_ --- Simulator/Core/GPUModel.cpp | 12 ++++++++++++ Simulator/Core/GPUModel.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 9409832bb..e74fc4c0d 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -379,3 +379,15 @@ void GPUModel::printGPUSynapsesPropsModel() const { connections_->getEdges().printGPUEdgesProps(allEdgesDevice_); } + +/// Getter for neuron structure in device memory +AllSpikingNeuronsDeviceProperties* GPUModel::getAllVerticesDevice() const +{ + return allVerticesDevice_; +} + +/// Getter for synapse structures in device memory +AllSpikingSynapsesDeviceProperties* GPUModel::getAllEdgesDevice() const +{ + return allEdgesDevice_; +} \ No newline at end of file diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index eb350a441..3bdb235ab 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -101,6 +101,12 @@ class GPUModel : public Model { /// Print out SynapseProps on the GPU. void printGPUSynapsesPropsModel() const; + /// Getter for synapse structures in device memory + AllSpikingSynapsesDeviceProperties* getAllEdgesDevice() const; + + /// Getter for neuron structure in device memory + AllSpikingNeuronsDeviceProperties* getAllVerticesDevice() const; + protected: /// Allocates and initializes memories on CUDA device. /// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. From beaac28081e55006dcaa7c6e7233e5b7dd713136 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 10 Apr 2025 11:34:03 -0700 Subject: [PATCH 06/26] modified the function: allocNeuronDeviceStruct so that now it does not take in any parameter --- Simulator/Core/GPUModel.cpp | 2 +- Simulator/Vertices/AllVertices.h | 2 +- Simulator/Vertices/NG911/All911Vertices.h | 2 +- Simulator/Vertices/Neuro/AllIFNeurons.h | 2 +- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 6 +++++- Simulator/Vertices/Neuro/AllIZHNeurons.h | 2 +- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 10 +++++----- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index e74fc4c0d..37a00bbc1 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -37,7 +37,7 @@ void GPUModel::allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice AllEdges &synapses = connections_->getEdges(); // Allocate Neurons and Synapses structs on GPU device memory - neurons.allocNeuronDeviceStruct(allVerticesDevice); + neurons.allocNeuronDeviceStruct(); synapses.allocEdgeDeviceStruct(allEdgesDevice); // Allocate memory for random noise array diff --git a/Simulator/Vertices/AllVertices.h b/Simulator/Vertices/AllVertices.h index b929dbd0b..d205287a4 100644 --- a/Simulator/Vertices/AllVertices.h +++ b/Simulator/Vertices/AllVertices.h @@ -102,7 +102,7 @@ class AllVertices { /// and copy them from host to GPU memory. /// /// @param allVerticesDevice GPU address of the allVertices struct on device memory. - virtual void allocNeuronDeviceStruct(void **allVerticesDevice) = 0; + virtual void allocNeuronDeviceStruct() = 0; /// Delete GPU memories. /// diff --git a/Simulator/Vertices/NG911/All911Vertices.h b/Simulator/Vertices/NG911/All911Vertices.h index 6187b31c8..cd56e6f67 100644 --- a/Simulator/Vertices/NG911/All911Vertices.h +++ b/Simulator/Vertices/NG911/All911Vertices.h @@ -225,7 +225,7 @@ class All911Vertices : public AllVertices { // GPU functionality for 911 simulation is unimplemented. // These signatures are required to make the class non-abstract public: - virtual void allocNeuronDeviceStruct(void **allVerticesDevice) {}; + virtual void allocNeuronDeviceStruct() {}; virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) {}; virtual void copyToDevice(void *allVerticesDevice) {}; virtual void copyFromDevice(void *allVerticesDevice) {}; diff --git a/Simulator/Vertices/Neuro/AllIFNeurons.h b/Simulator/Vertices/Neuro/AllIFNeurons.h index f657fec32..98edf95e2 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons.h +++ b/Simulator/Vertices/Neuro/AllIFNeurons.h @@ -90,7 +90,7 @@ class AllIFNeurons : public AllSpikingNeurons { /// and copy them from host to GPU memory. /// /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void allocNeuronDeviceStruct(void **allVerticesDevice); + virtual void allocNeuronDeviceStruct(); /// Delete GPU memories. /// diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index ec9c1341d..3f9d4a375 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -8,14 +8,18 @@ #include "AllIFNeurons.h" #include "Book.h" +#include "Simulator.h" +#include "GPUModel.h" /// Allocate GPU memories to store all neurons' states, /// and copy them from host to GPU memory. /// /// @param allVerticesDevice GPU address of the AllIFNeuronsDeviceProperties struct on device memory. -void AllIFNeurons::allocNeuronDeviceStruct(void **allVerticesDevice) +void AllIFNeurons::allocNeuronDeviceStruct() { AllIFNeuronsDeviceProperties allNeurons; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allVerticesDevice = reinterpret_cast(gpuModel->getAllVerticesDevice()); allocDeviceStruct(allNeurons); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties))); HANDLE_ERROR(cudaMemcpy(*allVerticesDevice, &allNeurons, sizeof(AllIFNeuronsDeviceProperties), diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons.h b/Simulator/Vertices/Neuro/AllIZHNeurons.h index 8b9a98f30..44d96e0f5 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons.h +++ b/Simulator/Vertices/Neuro/AllIZHNeurons.h @@ -140,7 +140,7 @@ class AllIZHNeurons : public AllIFNeurons { /// and copy them from host to GPU memory. // /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void allocNeuronDeviceStruct(void **allVerticesDevice) override; + virtual void allocNeuronDeviceStruct() override; /// Delete GPU memories. // diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index 8978b592a..236df8a4b 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -10,7 +10,8 @@ #include "AllSpikingSynapses.h" #include "AllVerticesDeviceFuncs.h" #include "Book.h" - +#include "Simulator.h" +#include "GPUModel.h" /// CUDA code for advancing izhikevich neurons /// @@ -36,12 +37,11 @@ __global__ void advanceIZHNeuronsDevice(int totalVertices, int maxEdges, int max /// Allocate GPU memories to store all neurons' states, /// and copy them from host to GPU memory. /// -/// @param allVerticesDevice GPU address of the AllIZHNeuronsDeviceProperties struct -/// on device memory. -void AllIZHNeurons::allocNeuronDeviceStruct(void **allVerticesDevice) +void AllIZHNeurons::allocNeuronDeviceStruct() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allVerticesDevice = reinterpret_cast(gpuModel->getAllVerticesDevice()); allocDeviceStruct(allVerticesDeviceProps); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties))); From 3c4805f63d9a910e84a15d9ef171ddeeb62dca4a Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 10 Apr 2025 12:39:20 -0700 Subject: [PATCH 07/26] fixed the getter for AllSpikingSynapsesDeviceProperties and AllSpikingNeuronsDeviceProperties, now they return by reference so we can use it to intialize the allVerticesDevice_ and allEdgesDevice_ --- Simulator/Core/GPUModel.cpp | 4 ++-- Simulator/Core/GPUModel.h | 4 ++-- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 2 +- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 37a00bbc1..db9b0bc56 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -381,13 +381,13 @@ void GPUModel::printGPUSynapsesPropsModel() const } /// Getter for neuron structure in device memory -AllSpikingNeuronsDeviceProperties* GPUModel::getAllVerticesDevice() const +AllSpikingNeuronsDeviceProperties*& GPUModel::getAllVerticesDevice() { return allVerticesDevice_; } /// Getter for synapse structures in device memory -AllSpikingSynapsesDeviceProperties* GPUModel::getAllEdgesDevice() const +AllSpikingSynapsesDeviceProperties*& GPUModel::getAllEdgesDevice() { return allEdgesDevice_; } \ No newline at end of file diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 3bdb235ab..9f58d8f30 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -102,10 +102,10 @@ class GPUModel : public Model { void printGPUSynapsesPropsModel() const; /// Getter for synapse structures in device memory - AllSpikingSynapsesDeviceProperties* getAllEdgesDevice() const; + AllSpikingSynapsesDeviceProperties*& getAllEdgesDevice(); /// Getter for neuron structure in device memory - AllSpikingNeuronsDeviceProperties* getAllVerticesDevice() const; + AllSpikingNeuronsDeviceProperties*& getAllVerticesDevice(); protected: /// Allocates and initializes memories on CUDA device. diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index 3f9d4a375..4807a07b6 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -19,7 +19,7 @@ void AllIFNeurons::allocNeuronDeviceStruct() { AllIFNeuronsDeviceProperties allNeurons; GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allVerticesDevice = reinterpret_cast(gpuModel->getAllVerticesDevice()); + void** allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); allocDeviceStruct(allNeurons); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties))); HANDLE_ERROR(cudaMemcpy(*allVerticesDevice, &allNeurons, sizeof(AllIFNeuronsDeviceProperties), diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index 236df8a4b..589e4da06 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -41,7 +41,7 @@ void AllIZHNeurons::allocNeuronDeviceStruct() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allVerticesDevice = reinterpret_cast(gpuModel->getAllVerticesDevice()); + void** allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); allocDeviceStruct(allVerticesDeviceProps); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties))); From 09fe39689268e054e9e9382510beb7835bc25c1f Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 10 Apr 2025 13:35:14 -0700 Subject: [PATCH 08/26] modified allocEdgeDeviceStruct and allocNeuronDeviceStruct in multiple files so that it does not take in a parameter. this is the preparation step for the register to operationmanager --- Simulator/Core/GPUModel.cpp | 2 +- Simulator/Edges/AllEdges.h | 4 +--- Simulator/Edges/NG911/All911Edges.h | 2 +- Simulator/Edges/Neuro/AllDSSynapses.h | 4 +--- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h | 6 ++---- Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 8 ++++---- Simulator/Edges/Neuro/AllSTDPSynapses.h | 4 +--- Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllSpikingSynapses.h | 4 +--- Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp | 9 +++++---- 11 files changed, 23 insertions(+), 34 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index db9b0bc56..993a2f0f7 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -38,7 +38,7 @@ void GPUModel::allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice // Allocate Neurons and Synapses structs on GPU device memory neurons.allocNeuronDeviceStruct(); - synapses.allocEdgeDeviceStruct(allEdgesDevice); + synapses.allocEdgeDeviceStruct(); // Allocate memory for random noise array int numVertices = Simulator::getInstance().getTotalVertices(); diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index 9c208e5b7..e67f655ec 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -94,9 +94,7 @@ class AllEdges { public: /// Allocate GPU memories to store all edges' states, /// and copy them from host to GPU memory. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) = 0; + virtual void allocEdgeDeviceStruct() = 0; /// Allocate GPU memories to store all edges' states, /// and copy them from host to GPU memory. diff --git a/Simulator/Edges/NG911/All911Edges.h b/Simulator/Edges/NG911/All911Edges.h index 62b6aec01..061ddcecf 100644 --- a/Simulator/Edges/NG911/All911Edges.h +++ b/Simulator/Edges/NG911/All911Edges.h @@ -65,7 +65,7 @@ class All911Edges : public AllEdges { // GPU functionality for 911 simulation is unimplemented. // These signatures are required to make the class non-abstract public: - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) {}; + virtual void allocEdgeDeviceStruct() {}; virtual void allocEdgeDeviceStruct(void **allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) {}; diff --git a/Simulator/Edges/Neuro/AllDSSynapses.h b/Simulator/Edges/Neuro/AllDSSynapses.h index 47427e679..06d9f2188 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses.h +++ b/Simulator/Edges/Neuro/AllDSSynapses.h @@ -121,9 +121,7 @@ class AllDSSynapses : public AllSpikingSynapses { public: /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) override; + virtual void allocEdgeDeviceStruct() override; /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index fe509445c..204eadb68 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -14,11 +14,10 @@ /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. -/// -/// @param allEdgesDevice GPU address of the AllDSSynapsesDeviceProperties struct -/// on device memory. -void AllDSSynapses::allocEdgeDeviceStruct(void **allEdgesDevice) +void AllDSSynapses::allocEdgeDeviceStruct() { + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h index 482fd759d..64e7ca8a5 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h @@ -124,10 +124,8 @@ class AllDynamicSTDPSynapses : public AllSTDPSynapses { #if defined(USE_GPU) public: /// Allocate GPU memories to store all synapses' states, - /// and copy them from host to GPU memory. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) override; + /// and copy them from host to GPU memory. memory. + virtual void allocEdgeDeviceStruct() override; /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 16da12284..6ad89808b 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -9,15 +9,15 @@ #include "AllDynamicSTDPSynapses.h" #include "AllSynapsesDeviceFuncs.h" #include "Book.h" +#include "GPUModel.h" #include "Simulator.h" /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. -/// -/// @param allEdgesDevice GPU address of the AllDynamicSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllDynamicSTDPSynapses::allocEdgeDeviceStruct(void **allEdgesDevice) +void AllDynamicSTDPSynapses::allocEdgeDeviceStruct() { + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.h b/Simulator/Edges/Neuro/AllSTDPSynapses.h index 1a68979d1..706cf3298 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.h @@ -154,9 +154,7 @@ class AllSTDPSynapses : public AllSpikingSynapses { public: /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) override; + virtual void allocEdgeDeviceStruct() override; /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index a6c1aaa1f..8973af206 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -32,11 +32,10 @@ __global__ void advanceSTDPSynapsesDevice(int totalSynapseCount, int maxSpikes); /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. -/// -/// @param allEdgesDevice GPU address of the AllSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllSTDPSynapses::allocEdgeDeviceStruct(void **allEdgesDevice) +void AllSTDPSynapses::allocEdgeDeviceStruct() { + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.h b/Simulator/Edges/Neuro/AllSpikingSynapses.h index 1d3158388..808414a8d 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.h +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.h @@ -122,9 +122,7 @@ class AllSpikingSynapses : public AllNeuroEdges { public: /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void allocEdgeDeviceStruct(void **allEdgesDevice) override; + virtual void allocEdgeDeviceStruct() override; /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index 0568b0745..b6af756b7 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -11,6 +11,8 @@ #include "AllSynapsesDeviceFuncs.h" #include "Book.h" #include +#include "GPUModel.h" +#include "Simulator.h" /// CUDA code for advancing spiking synapses. /// Perform updating synapses for one time step. @@ -28,11 +30,10 @@ __global__ void advanceSpikingSynapsesDevice(int totalSynapseCount, /// Allocate GPU memories to store all synapses' states, /// and copy them from host to GPU memory. -/// -/// @param allEdgesDevice GPU address of the AllSpikingSynapsesDeviceProperties struct -/// on device memory. -void AllSpikingSynapses::allocEdgeDeviceStruct(void **allEdgesDevice) +void AllSpikingSynapses::allocEdgeDeviceStruct() { + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } From 9cbc980895f476dfe931d9ed387ec2e105787fb6 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 10 Apr 2025 16:52:53 -0700 Subject: [PATCH 09/26] completed the allocateGPU for the operationManager --- Simulator/Core/GPUModel.cpp | 24 ++++++++++-------------- Simulator/Core/GPUModel.h | 5 ++--- Simulator/Edges/AllEdges.cpp | 7 +++++++ Simulator/Vertices/AllVertices.cpp | 7 +++++++ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 993a2f0f7..5c9f209d9 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -13,6 +13,7 @@ #include "AllVertices.h" #include "Connections.h" #include "Global.h" +#include "OperationManager.h" #ifdef PERFORMANCE_METRICS float g_time; @@ -25,21 +26,17 @@ GPUModel::GPUModel() : Model::Model(), synapseIndexMapDevice_(nullptr), randNoise_d(nullptr), allVerticesDevice_(nullptr), allEdgesDevice_(nullptr) { + #if defined(USE_GPU) + // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager + function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, + allocateGPU); + #endif } /// Allocates and initializes memories on CUDA device. -/// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. -/// @param[out] allEdgesDevice Memory location of the pointer to the synapses list on device memory. -void GPUModel::allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice) +void GPUModel::allocDeviceStruct() { - // Get neurons and synapses - AllVertices &neurons = layout_->getVertices(); - AllEdges &synapses = connections_->getEdges(); - - // Allocate Neurons and Synapses structs on GPU device memory - neurons.allocNeuronDeviceStruct(); - synapses.allocEdgeDeviceStruct(); - // Allocate memory for random noise array int numVertices = Simulator::getInstance().getTotalVertices(); BGSIZE randNoise_d_size = numVertices * sizeof(float); // size of random noise array @@ -94,9 +91,8 @@ void GPUModel::setupSim() t_gpu_advanceSynapses = 0.0; t_gpu_calcSummation = 0.0; #endif // PERFORMANCE_METRICS - - // allocates memories on CUDA device - allocDeviceStruct((void **)&allVerticesDevice_, (void **)&allEdgesDevice_); + // Allocate and copy neuron/synapse data structures to GPU memory + OperationManager::getInstance().executeOperation(Operations::allocateGPU); // Copy host neuron and synapse arrays into GPU device copyCPUtoGPU(); // copy inverse map to the device memory diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 9f58d8f30..83ad748fd 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -37,6 +37,7 @@ #include "AllSpikingNeurons.h" #include "AllSpikingSynapses.h" +#include "OperationManager.h" #ifdef __CUDACC__ #include "Book.h" @@ -109,9 +110,7 @@ class GPUModel : public Model { protected: /// Allocates and initializes memories on CUDA device. - /// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. - /// @param[out] allEdgesDevice Memory location of the pointer to the synapses list on device memory. - void allocDeviceStruct(void **allVerticesDevice, void **allEdgesDevice); + void allocDeviceStruct(); /// Copies device memories to host memories and deallocates them. /// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. diff --git a/Simulator/Edges/AllEdges.cpp b/Simulator/Edges/AllEdges.cpp index 2d199af9b..04d66034d 100644 --- a/Simulator/Edges/AllEdges.cpp +++ b/Simulator/Edges/AllEdges.cpp @@ -26,6 +26,13 @@ AllEdges::AllEdges() : totalEdgeCount_(0), maxEdgesPerVertex_(0), countVertices_ OperationManager::getInstance().registerOperation(Operations::printParameters, printParametersFunc); + #if defined(USE_GPU) + // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager + function allocateGPU = bind(static_cast(&AllEdges::allocEdgeDeviceStruct), this); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, + allocateGPU); + #endif + fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); edgeLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("edge")); } diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index db6091852..858cca15d 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -22,6 +22,13 @@ AllVertices::AllVertices() : size_(0) OperationManager::getInstance().registerOperation(Operations::printParameters, printParametersFunc); + #if defined(USE_GPU) + // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager + function allocateGPU = bind(&AllVertices::allocNeuronDeviceStruct, this); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, + allocateGPU); + #endif + // Get a copy of the file and vertex logger to use log4cplus macros to print to debug files fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); vertexLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("vertex")); From 2110b506feefab6d1259bfff04773ea29b4c133c Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Mon, 14 Apr 2025 14:23:09 -0700 Subject: [PATCH 10/26] refactor the function copySynapseIndexMapHostToDevice, so that it does not take in any parameter. This is to prepare the GPUModel::copySynapseIndexMapHostToDevice to be compatible to register to the operationManager --- Simulator/Core/GPUModel.cpp | 10 +++++----- Simulator/Core/GPUModel.h | 2 +- Simulator/Core/Serializer.cpp | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 5c9f209d9..73f99f6b2 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -96,8 +96,7 @@ void GPUModel::setupSim() // Copy host neuron and synapse arrays into GPU device copyCPUtoGPU(); // copy inverse map to the device memory - copySynapseIndexMapHostToDevice(connections_->getEdgeIndexMap(), - Simulator::getInstance().getTotalVertices()); + copySynapseIndexMapHostToDevice(); // set some parameters used for advanceVerticesDevice layout_->getVertices().setAdvanceVerticesDeviceParams(connections_->getEdges()); @@ -201,8 +200,7 @@ void GPUModel::updateConnections() // create synapse index map connections_->createEdgeIndexMap(); // copy index map to the device memory - copySynapseIndexMapHostToDevice(connections_->getEdgeIndexMap(), - Simulator::getInstance().getTotalVertices()); + copySynapseIndexMapHostToDevice(); } } @@ -254,8 +252,10 @@ void GPUModel::deleteSynapseImap() /// Copy EdgeIndexMap in host memory to EdgeIndexMap in device memory. /// @param synapseIndexMapHost Reference to the EdgeIndexMap in host memory. -void GPUModel::copySynapseIndexMapHostToDevice(EdgeIndexMap &synapseIndexMapHost, int numVertices) +void GPUModel::copySynapseIndexMapHostToDevice() { + EdgeIndexMap synapseIndexMapHost = connections_->getEdgeIndexMap(); + int numVertices = Simulator::getInstance().getTotalVertices(); AllEdges &synapses = connections_->getEdges(); int totalSynapseCount = dynamic_cast(synapses).totalEdgeCount_; if (totalSynapseCount == 0) diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 83ad748fd..98164e3ec 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -140,7 +140,7 @@ class GPUModel : public Model { void deleteSynapseImap(); public: //2020/03/14 changed to public for accessing in Core - void copySynapseIndexMapHostToDevice(EdgeIndexMap &synapseIndexMapHost, int numVertices); + void copySynapseIndexMapHostToDevice(); private: void updateHistory(); diff --git a/Simulator/Core/Serializer.cpp b/Simulator/Core/Serializer.cpp index 36cf960da..3a6db2b5a 100644 --- a/Simulator/Core/Serializer.cpp +++ b/Simulator/Core/Serializer.cpp @@ -67,8 +67,7 @@ bool Serializer::deserialize() #if defined(USE_GPU) GPUModel &gpuModel = static_cast(simulator.getModel()); - gpuModel.copySynapseIndexMapHostToDevice(simulator.getModel().getConnections().getEdgeIndexMap(), - simulator.getTotalVertices()); + gpuModel.copySynapseIndexMapHostToDevice(); #endif // USE_GPU return true; From f3f5c799526086ca6bd52daaffe105cfdb078250 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Mon, 14 Apr 2025 15:21:25 -0700 Subject: [PATCH 11/26] refactored the copyToGPU for all the neuron classes, such that they take in no parameter to be compatible with the operationManager --- Simulator/Core/GPUModel.cpp | 2 +- Simulator/Vertices/AllVertices.h | 4 +--- Simulator/Vertices/NG911/All911Vertices.h | 2 +- Simulator/Vertices/Neuro/AllIFNeurons.h | 3 +-- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 8 ++++---- Simulator/Vertices/Neuro/AllIZHNeurons.h | 4 +--- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 9 ++++----- Simulator/Vertices/Neuro/AllSpikingNeurons.h | 2 +- Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp | 6 +++++- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 73f99f6b2..1e5df94c6 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -366,7 +366,7 @@ void GPUModel::copyCPUtoGPU() // copy host neurons and synapse structs to device memory AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); - neurons.copyToDevice(allVerticesDevice_); + neurons.copyToDevice(); synapses.copyEdgeHostToDevice(allEdgesDevice_); } diff --git a/Simulator/Vertices/AllVertices.h b/Simulator/Vertices/AllVertices.h index d205287a4..aee2d2352 100644 --- a/Simulator/Vertices/AllVertices.h +++ b/Simulator/Vertices/AllVertices.h @@ -110,9 +110,7 @@ class AllVertices { virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) = 0; /// Copy all vertices' data from host to device. - /// - /// @param allVerticesDevice GPU address of the allVertices struct on device memory. - virtual void copyToDevice(void *allVerticesDevice) = 0; + virtual void copyToDevice() = 0; /// Copy all vertices' data from device to host. /// diff --git a/Simulator/Vertices/NG911/All911Vertices.h b/Simulator/Vertices/NG911/All911Vertices.h index cd56e6f67..c63dbbd44 100644 --- a/Simulator/Vertices/NG911/All911Vertices.h +++ b/Simulator/Vertices/NG911/All911Vertices.h @@ -227,7 +227,7 @@ class All911Vertices : public AllVertices { public: virtual void allocNeuronDeviceStruct() {}; virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) {}; - virtual void copyToDevice(void *allVerticesDevice) {}; + virtual void copyToDevice() {}; virtual void copyFromDevice(void *allVerticesDevice) {}; virtual void advanceVertices(AllEdges &edges, void *allVerticesDevice, void *allEdgesDevice, float randNoise[], EdgeIndexMapDevice *edgeIndexMapDevice) {}; diff --git a/Simulator/Vertices/Neuro/AllIFNeurons.h b/Simulator/Vertices/Neuro/AllIFNeurons.h index 98edf95e2..26d336101 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons.h +++ b/Simulator/Vertices/Neuro/AllIFNeurons.h @@ -105,8 +105,7 @@ class AllIFNeurons : public AllSpikingNeurons { //@param allVerticesDevice GPU address of the allNeurons struct on device memory. virtual void copyFromDevice(void *deviceAddress) override; //Copy all neurons' data from host to device. - // @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void copyToDevice(void *deviceAddress) override; + virtual void copyToDevice() override; protected: /// Allocate GPU memories to store all neurons' states. diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index 4807a07b6..89fa71d5e 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -115,11 +115,11 @@ void AllIFNeurons::deleteDeviceStruct(AllIFNeuronsDeviceProperties &allVerticesD } /// Copy all neurons' data from host to device. -/// -/// @param allVerticesDevice GPU address of the AllIFNeuronsDeviceProperties struct on device memory. -void AllIFNeurons::copyToDevice(void *allVerticesDevice) +void AllIFNeurons::copyToDevice() { int count = Simulator::getInstance().getTotalVertices(); + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); AllIFNeuronsDeviceProperties allVerticesDeviceProps; HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); @@ -156,7 +156,7 @@ void AllIFNeurons::copyToDevice(void *allVerticesDevice) HANDLE_ERROR(cudaMemcpy(allVerticesDeviceProps.numStepsInRefractoryPeriod_, numStepsInRefractoryPeriod_.data(), count * sizeof(int), cudaMemcpyHostToDevice)); - AllSpikingNeurons::copyToDevice(allVerticesDevice); + AllSpikingNeurons::copyToDevice(); } /// Copy all neurons' data from device to host. diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons.h b/Simulator/Vertices/Neuro/AllIZHNeurons.h index 44d96e0f5..ad487400c 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons.h +++ b/Simulator/Vertices/Neuro/AllIZHNeurons.h @@ -168,9 +168,7 @@ class AllIZHNeurons : public AllIFNeurons { virtual void copyFromDevice(void *deviceAddress) override; // Copy all neurons' data from host to device. - // - /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void copyToDevice(void *deviceAddress) override; + virtual void copyToDevice() override; protected: diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index 589e4da06..2cfbd7358 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -101,18 +101,17 @@ void AllIZHNeurons::deleteDeviceStruct(AllIZHNeuronsDeviceProperties &allVertice /// Copy all neurons' data from host to device. /// -/// @param allVerticesDevice GPU address of the AllIZHNeuronsDeviceProperties struct -/// on device memory. -void AllIZHNeurons::copyToDevice(void *allVerticesDevice) +void AllIZHNeurons::copyToDevice() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); int count = Simulator::getInstance().getTotalVertices(); - AllIFNeurons::copyToDevice(allVerticesDevice); + AllIFNeurons::copyToDevice(); HANDLE_ERROR(cudaMemcpy(allVerticesDeviceProps.Aconst_, Aconst_.data(), count * sizeof(BGFLOAT), cudaMemcpyHostToDevice)); diff --git a/Simulator/Vertices/Neuro/AllSpikingNeurons.h b/Simulator/Vertices/Neuro/AllSpikingNeurons.h index bdb4c8181..c29e074c6 100644 --- a/Simulator/Vertices/Neuro/AllSpikingNeurons.h +++ b/Simulator/Vertices/Neuro/AllSpikingNeurons.h @@ -67,7 +67,7 @@ class AllSpikingNeurons : public AllVertices { /// @param allVerticesDevice GPU address of the allVertices struct on device memory. virtual void clearNeuronSpikeCounts(void *allVerticesDevice) = 0; virtual void copyFromDevice(void *deviceAddress) override; - virtual void copyToDevice(void *deviceAddress) override; + virtual void copyToDevice() override; protected: /// Clear the spike counts out of all neurons in device memory. diff --git a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp index a4bcbfa38..75f7f9e35 100644 --- a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp @@ -9,10 +9,14 @@ #include "AllSpikingNeurons.h" #include "AllSpikingSynapses.h" #include "Book.h" +#include "Simulator.h" +#include "GPUModel.h" -void AllSpikingNeurons::copyToDevice(void *deviceAddress) +void AllSpikingNeurons::copyToDevice() { AllSpikingNeuronsDeviceProperties allVerticesDevice; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDevice, deviceAddress, sizeof(AllSpikingNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); From 8ef565e67708bf80321807ef36fbc36fbff111f0 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Mon, 14 Apr 2025 15:40:31 -0700 Subject: [PATCH 12/26] modified copyToDevice method in AllVertice class and its child class, such that it does not take in any parameter and thus can be registered to te operationManager. Also registered the copySynapseIndexMapHostToDevice In GPUModel.cpp to the OperationManager --- Simulator/Core/GPUModel.cpp | 8 +++++++- Simulator/Edges/AllEdges.h | 6 ++---- Simulator/Edges/NG911/All911Edges.h | 2 +- Simulator/Edges/Neuro/AllDSSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 6 +++--- Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 6 +++--- Simulator/Edges/Neuro/AllSTDPSynapses.h | 4 +--- Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 8 +++----- Simulator/Edges/Neuro/AllSpikingSynapses.h | 3 +-- Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp | 6 +++--- Simulator/Vertices/AllVertices.cpp | 5 +++++ 12 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 1e5df94c6..05b9309d7 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -31,6 +31,12 @@ GPUModel::GPUModel() : function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); + + // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager + function copyCPUtoGPU= bind(&GPUModel::copySynapseIndexMapHostToDevice, this); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, + copyCPUtoGPU); + #endif } @@ -367,7 +373,7 @@ void GPUModel::copyCPUtoGPU() AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); neurons.copyToDevice(); - synapses.copyEdgeHostToDevice(allEdgesDevice_); + synapses.copyEdgeHostToDevice(); } /// Print out SynapseProps on the GPU. diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index e67f655ec..aa34ccdc1 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -110,10 +110,8 @@ class AllEdges { /// @param allEdgesDevice GPU address of the allEdges struct on device memory. virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) = 0; - /// Copy all edges' data from host to device. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeHostToDevice(void *allEdgesDevice) = 0; + /// Copy all edges' data from host to device. + virtual void copyEdgeHostToDevice() = 0; /// Copy all edges' data from host to device. /// diff --git a/Simulator/Edges/NG911/All911Edges.h b/Simulator/Edges/NG911/All911Edges.h index 061ddcecf..00553d3d6 100644 --- a/Simulator/Edges/NG911/All911Edges.h +++ b/Simulator/Edges/NG911/All911Edges.h @@ -69,7 +69,7 @@ class All911Edges : public AllEdges { virtual void allocEdgeDeviceStruct(void **allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) {}; - virtual void copyEdgeHostToDevice(void *allEdgesDevice) {}; + virtual void copyEdgeHostToDevice() {}; virtual void copyEdgeHostToDevice(void *allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; virtual void copyEdgeDeviceToHost(void *allEdgesDevice) {}; diff --git a/Simulator/Edges/Neuro/AllDSSynapses.h b/Simulator/Edges/Neuro/AllDSSynapses.h index 06d9f2188..5a0a8205a 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses.h +++ b/Simulator/Edges/Neuro/AllDSSynapses.h @@ -139,8 +139,7 @@ class AllDSSynapses : public AllSpikingSynapses { /// Copy all synapses' data from host to device. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeHostToDevice(void *allEdgesDevice) override; + virtual void copyEdgeHostToDevice() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index 204eadb68..13d76325f 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -99,10 +99,10 @@ void AllDSSynapses::deleteDeviceStruct(AllDSSynapsesDeviceProperties &allEdgesDe /// Copy all synapses' data from host to device. /// -/// @param allEdgesDevice GPU address of the AllDSSynapsesDeviceProperties struct -/// on device memory. -void AllDSSynapses::copyEdgeHostToDevice(void *allEdgesDevice) +void AllDSSynapses::copyEdgeHostToDevice() { // copy everything necessary + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h index 64e7ca8a5..a3f0aa7cd 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h @@ -142,8 +142,7 @@ class AllDynamicSTDPSynapses : public AllSTDPSynapses { /// Copy all synapses' data from host to device. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeHostToDevice(void *allEdgesDevice) override; + virtual void copyEdgeHostToDevice() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 6ad89808b..94eef493d 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -102,10 +102,10 @@ void AllDynamicSTDPSynapses::deleteDeviceStruct( /// Copy all synapses' data from host to device. /// -/// @param allEdgesDevice GPU address of the AllDynamicSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllDynamicSTDPSynapses::copyEdgeHostToDevice(void *allEdgesDevice) +void AllDynamicSTDPSynapses::copyEdgeHostToDevice() { // copy everything necessary + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.h b/Simulator/Edges/Neuro/AllSTDPSynapses.h index 706cf3298..eadc36a93 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.h @@ -171,9 +171,7 @@ class AllSTDPSynapses : public AllSpikingSynapses { virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) override; /// Copy all synapses' data from host to device. - /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeHostToDevice(void *allEdgesDevice) override; + virtual void copyEdgeHostToDevice() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index 8973af206..212d91c09 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -128,12 +128,10 @@ void AllSTDPSynapses::deleteDeviceStruct(AllSTDPSynapsesDeviceProperties &allEdg /// Copy all synapses' data from host to device. /// -/// @param allEdgesDevice GPU address of the AllSTDPSynapsesDeviceProperties struct -/// on device memory. -/// @param numVertices Number of vertices. -/// @param maxEdgesPerVertex Maximum number of synapses per neuron. -void AllSTDPSynapses::copyEdgeHostToDevice(void *allEdgesDevice) +void AllSTDPSynapses::copyEdgeHostToDevice() { // copy everything necessary + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.h b/Simulator/Edges/Neuro/AllSpikingSynapses.h index 808414a8d..8081798b9 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.h +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.h @@ -140,8 +140,7 @@ class AllSpikingSynapses : public AllNeuroEdges { /// Copy all synapses' data from host to device. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeHostToDevice(void *allEdgesDevice) override; + virtual void copyEdgeHostToDevice() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index b6af756b7..6091b1151 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -128,10 +128,10 @@ void AllSpikingSynapses::deleteDeviceStruct(AllSpikingSynapsesDeviceProperties & /// Copy all synapses' data from host to device. /// -/// @param allEdgesDevice GPU address of the AllSpikingSynapsesDeviceProperties struct -/// on device memory. -void AllSpikingSynapses::copyEdgeHostToDevice(void *allEdgesDevice) +void AllSpikingSynapses::copyEdgeHostToDevice() { // copy everything necessary + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index 858cca15d..db5475a26 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -27,6 +27,11 @@ AllVertices::AllVertices() : size_(0) function allocateGPU = bind(&AllVertices::allocNeuronDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); + + // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager + function copyCPUtoGPU= bind(&GPUModel::copySynapseIndexMapHostToDevice, this); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, + copyCPUtoGPU); #endif // Get a copy of the file and vertex logger to use log4cplus macros to print to debug files From d12e4d7858fe0f8d7d9aa575f173ce4d4ab503a7 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Tue, 15 Apr 2025 13:11:41 -0700 Subject: [PATCH 13/26] done for the documentation and implementation for registering the copyToGPU to the operationManager --- Simulator/Core/GPUModel.cpp | 5 +++-- Simulator/Edges/AllEdges.cpp | 5 +++++ Simulator/Vertices/AllVertices.cpp | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 05b9309d7..29fbfa1f7 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -100,9 +100,10 @@ void GPUModel::setupSim() // Allocate and copy neuron/synapse data structures to GPU memory OperationManager::getInstance().executeOperation(Operations::allocateGPU); // Copy host neuron and synapse arrays into GPU device - copyCPUtoGPU(); // copy inverse map to the device memory - copySynapseIndexMapHostToDevice(); + OperationManager::getInstance().executeOperation(Operations::copyToGPU); + //copyCPUtoGPU(); + //copySynapseIndexMapHostToDevice(); // set some parameters used for advanceVerticesDevice layout_->getVertices().setAdvanceVerticesDeviceParams(connections_->getEdges()); diff --git a/Simulator/Edges/AllEdges.cpp b/Simulator/Edges/AllEdges.cpp index 04d66034d..8fb2bdb6a 100644 --- a/Simulator/Edges/AllEdges.cpp +++ b/Simulator/Edges/AllEdges.cpp @@ -31,6 +31,11 @@ AllEdges::AllEdges() : totalEdgeCount_(0), maxEdgesPerVertex_(0), countVertices_ function allocateGPU = bind(static_cast(&AllEdges::allocEdgeDeviceStruct), this); OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); + + // Register AllEdges::copyEdgeHostToDevice function as a copyToGPU operation in the OperationManager + function copyCPUtoGPU= bind(static_cast(&AllEdges::copyEdgeHostToDevice), this); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, + copyCPUtoGPU); #endif fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index db5475a26..73416b4bc 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -28,8 +28,8 @@ AllVertices::AllVertices() : size_(0) OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); - // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager - function copyCPUtoGPU= bind(&GPUModel::copySynapseIndexMapHostToDevice, this); + // Register AllVertices::copyToDevice function as a copyToGPU operation in the OperationManager + function copyCPUtoGPU= bind(&AllVertices::copyToDevice, this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); #endif From a48604e387294fcd065855edb8439dd90b6ef66a Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Sun, 20 Apr 2025 14:07:36 -0700 Subject: [PATCH 14/26] modified function copyFromDevice for allVertices class as well as the child class, so that it takes in no parameter. Modified functions copyEdgeDeviceToHost for allEdges class for similar functionality. register the copyFromGPU function to the operationMager. Copying simulation results are no longer done by long chain of responsibility of the neurons and synapses but are now through the centralized dispartch: operation Manager --- Simulator/Core/GPUModel.cpp | 9 ++------- Simulator/Edges/AllEdges.cpp | 5 +++++ Simulator/Edges/AllEdges.h | 3 +-- Simulator/Edges/NG911/All911Edges.h | 2 +- Simulator/Edges/Neuro/AllDSSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllSTDPSynapses.h | 3 +-- Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllSpikingSynapses.h | 3 +-- Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp | 6 +++--- Simulator/Vertices/AllVertices.cpp | 5 +++++ Simulator/Vertices/AllVertices.h | 3 +-- Simulator/Vertices/NG911/All911Vertices.h | 2 +- Simulator/Vertices/Neuro/AllIFNeurons.h | 3 +-- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 7 ++++--- Simulator/Vertices/Neuro/AllIZHNeurons.h | 3 +-- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 8 ++++---- Simulator/Vertices/Neuro/AllSpikingNeurons.h | 2 +- Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp | 4 +++- 21 files changed, 46 insertions(+), 49 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 29fbfa1f7..74150e162 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -102,8 +102,6 @@ void GPUModel::setupSim() // Copy host neuron and synapse arrays into GPU device // copy inverse map to the device memory OperationManager::getInstance().executeOperation(Operations::copyToGPU); - //copyCPUtoGPU(); - //copySynapseIndexMapHostToDevice(); // set some parameters used for advanceVerticesDevice layout_->getVertices().setAdvanceVerticesDeviceParams(connections_->getEdges()); @@ -195,7 +193,7 @@ void GPUModel::updateConnections() AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); - dynamic_cast(neurons).copyFromDevice(allVerticesDevice_); + dynamic_cast(neurons).copyFromDevice(); // dynamic_cast(neurons.get()) // ->copyNeuronDeviceSpikeHistoryToHost(allVerticesDevice_); @@ -361,10 +359,7 @@ __global__ void void GPUModel::copyGPUtoCPU() { // copy device neuron and synapse structs to host memory - AllVertices &neurons = layout_->getVertices(); - AllEdges &synapses = connections_->getEdges(); - neurons.copyFromDevice(allVerticesDevice_); - synapses.copyEdgeDeviceToHost(allEdgesDevice_); + OperationManager::getInstance().executeOperation(Operations::copyFromGPU); } /// Copy CPU Synapse data to GPU. diff --git a/Simulator/Edges/AllEdges.cpp b/Simulator/Edges/AllEdges.cpp index 8fb2bdb6a..71cc3e67c 100644 --- a/Simulator/Edges/AllEdges.cpp +++ b/Simulator/Edges/AllEdges.cpp @@ -36,6 +36,11 @@ AllEdges::AllEdges() : totalEdgeCount_(0), maxEdgesPerVertex_(0), countVertices_ function copyCPUtoGPU= bind(static_cast(&AllEdges::copyEdgeHostToDevice), this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); + + // Register copyFromGPU operation for transferring edge data from device to host + function copyFromGPU= bind(&AllEdges::copyEdgeDeviceToHost, this); + OperationManager::getInstance().registerOperation(Operations::copyFromGPU, + copyFromGPU); #endif fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index aa34ccdc1..8eb154afd 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -123,8 +123,7 @@ class AllEdges { /// Copy all edges' data from device to host. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) = 0; + virtual void copyEdgeDeviceToHost() = 0; /// Get edge_counts in AllEdges struct on device memory. /// diff --git a/Simulator/Edges/NG911/All911Edges.h b/Simulator/Edges/NG911/All911Edges.h index 00553d3d6..030a0d7d0 100644 --- a/Simulator/Edges/NG911/All911Edges.h +++ b/Simulator/Edges/NG911/All911Edges.h @@ -72,7 +72,7 @@ class All911Edges : public AllEdges { virtual void copyEdgeHostToDevice() {}; virtual void copyEdgeHostToDevice(void *allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) {}; + virtual void copyEdgeDeviceToHost() {}; virtual void copyDeviceEdgeCountsToHost(void *allEdgesDevice) {}; virtual void copyDeviceEdgeSumIdxToHost(void *allEdgesDevice) {}; virtual void advanceEdges(void *allEdgesDevice, void *allVerticesDevice, diff --git a/Simulator/Edges/Neuro/AllDSSynapses.h b/Simulator/Edges/Neuro/AllDSSynapses.h index 5a0a8205a..de9e74f75 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses.h +++ b/Simulator/Edges/Neuro/AllDSSynapses.h @@ -151,8 +151,7 @@ class AllDSSynapses : public AllSpikingSynapses { /// Copy all synapses' data from device to host. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) override; + virtual void copyEdgeDeviceToHost() override; /// Set synapse class ID defined by enumClassSynapses for the caller's Synapse class. /// The class ID will be set to classSynapses_d in device memory, diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index 13d76325f..6f2222304 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -155,13 +155,12 @@ void AllDSSynapses::copyHostToDevice(void *allEdgesDevice, /// Copy all synapses' data from device to host. /// -/// @param allEdgesDevice GPU address of the AllDSSynapsesDeviceProperties struct -/// on device memory. -void AllDSSynapses::copyEdgeDeviceToHost(void *allEdgesDevice) +void AllDSSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllDSSynapsesDeviceProperties allEdgesDeviceProps; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllDSSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h index a3f0aa7cd..98d87e145 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h @@ -154,8 +154,7 @@ class AllDynamicSTDPSynapses : public AllSTDPSynapses { /// Copy all synapses' data from device to host. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) override; + virtual void copyEdgeDeviceToHost() override; /// Set synapse class ID defined by enumClassSynapses for the caller's Synapse class. /// The class ID will be set to classSynapses_d in device memory, diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 94eef493d..2ce5ec4f3 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -159,13 +159,12 @@ void AllDynamicSTDPSynapses::copyHostToDevice( /// Copy all synapses' data from device to host. /// -/// @param allEdgesDevice GPU address of the AllDynamicSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllDynamicSTDPSynapses::copyEdgeDeviceToHost(void *allEdgesDevice) +void AllDynamicSTDPSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllDynamicSTDPSynapsesDeviceProperties allEdges; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDynamicSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.h b/Simulator/Edges/Neuro/AllSTDPSynapses.h index eadc36a93..b13380cd7 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.h @@ -183,8 +183,7 @@ class AllSTDPSynapses : public AllSpikingSynapses { /// Copy all synapses' data from device to host. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) override; + virtual void copyEdgeDeviceToHost() override; /// Advance all the Synapses in the simulation. /// Update the state of all synapses for a time step. diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index 212d91c09..f95e4ad91 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -197,13 +197,12 @@ void AllSTDPSynapses::copyHostToDevice(void *allEdgesDevice, /// Copy all synapses' data from device to host. /// -/// @param allEdgesDevice GPU address of the AllSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllSTDPSynapses::copyEdgeDeviceToHost(void *allEdgesDevice) +void AllSTDPSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllSTDPSynapsesDeviceProperties allEdgesDeviceProps; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); copyDeviceToHost(allEdgesDeviceProps); diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.h b/Simulator/Edges/Neuro/AllSpikingSynapses.h index 8081798b9..098f94910 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.h +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.h @@ -152,8 +152,7 @@ class AllSpikingSynapses : public AllNeuroEdges { /// Copy all synapses' data from device to host. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void copyEdgeDeviceToHost(void *allEdgesDevice) override; + virtual void copyEdgeDeviceToHost() override; /// Get edge_counts in AllNeuroEdges struct on device memory. /// diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index 6091b1151..404d81823 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -201,12 +201,12 @@ void AllSpikingSynapses::copyHostToDevice(void *allEdgesDevice, /// Copy all synapses' data from device to host. /// -/// @param allEdgesDevice GPU address of the AllSpikingSynapsesDeviceProperties struct -/// on device memory. -void AllSpikingSynapses::copyEdgeDeviceToHost(void *allEdgesDevice) +void AllSpikingSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllSpikingSynapsesDeviceProperties allEdges; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllSpikingSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); copyDeviceToHost(allEdges); diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index 73416b4bc..b736acde3 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -32,6 +32,11 @@ AllVertices::AllVertices() : size_(0) function copyCPUtoGPU= bind(&AllVertices::copyToDevice, this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); + + // Register copyFromGPU operation for transferring edge data from device to host + function copyFromGPU= bind(&AllVertices::copyFromDevice, this); + OperationManager::getInstance().registerOperation(Operations::copyFromGPU, + copyFromGPU); #endif // Get a copy of the file and vertex logger to use log4cplus macros to print to debug files diff --git a/Simulator/Vertices/AllVertices.h b/Simulator/Vertices/AllVertices.h index aee2d2352..7ccc99a7e 100644 --- a/Simulator/Vertices/AllVertices.h +++ b/Simulator/Vertices/AllVertices.h @@ -114,8 +114,7 @@ class AllVertices { /// Copy all vertices' data from device to host. /// - /// @param allVerticesDevice GPU address of the allVertices struct on device memory. - virtual void copyFromDevice(void *allVerticesDevice) = 0; + virtual void copyFromDevice() = 0; /// Update the state of all vertices for a time step /// Notify outgoing synapses if vertex has fired. diff --git a/Simulator/Vertices/NG911/All911Vertices.h b/Simulator/Vertices/NG911/All911Vertices.h index c63dbbd44..6f25f9217 100644 --- a/Simulator/Vertices/NG911/All911Vertices.h +++ b/Simulator/Vertices/NG911/All911Vertices.h @@ -228,7 +228,7 @@ class All911Vertices : public AllVertices { virtual void allocNeuronDeviceStruct() {}; virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) {}; virtual void copyToDevice() {}; - virtual void copyFromDevice(void *allVerticesDevice) {}; + virtual void copyFromDevice() {}; virtual void advanceVertices(AllEdges &edges, void *allVerticesDevice, void *allEdgesDevice, float randNoise[], EdgeIndexMapDevice *edgeIndexMapDevice) {}; virtual void setAdvanceVerticesDeviceParams(AllEdges &edges) {}; diff --git a/Simulator/Vertices/Neuro/AllIFNeurons.h b/Simulator/Vertices/Neuro/AllIFNeurons.h index 26d336101..fa846139c 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons.h +++ b/Simulator/Vertices/Neuro/AllIFNeurons.h @@ -102,8 +102,7 @@ class AllIFNeurons : public AllSpikingNeurons { /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. virtual void clearNeuronSpikeCounts(void *allVerticesDevice) override; //Copy all neurons' data from device to host. - //@param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void copyFromDevice(void *deviceAddress) override; + virtual void copyFromDevice() override; //Copy all neurons' data from host to device. virtual void copyToDevice() override; diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index 89fa71d5e..817c2a35d 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -161,10 +161,11 @@ void AllIFNeurons::copyToDevice() /// Copy all neurons' data from device to host. /// -/// @param allVerticesDevice GPU address of the AllIFNeuronsDeviceProperties struct on device memory. -void AllIFNeurons::copyFromDevice(void *allVerticesDevice) +void AllIFNeurons::copyFromDevice() { - AllSpikingNeurons::copyFromDevice(allVerticesDevice); + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + AllSpikingNeurons::copyFromDevice(); int count = Simulator::getInstance().getTotalVertices(); AllIFNeuronsDeviceProperties allVerticesDeviceProps; HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons.h b/Simulator/Vertices/Neuro/AllIZHNeurons.h index ad487400c..dae64aeae 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons.h +++ b/Simulator/Vertices/Neuro/AllIZHNeurons.h @@ -164,8 +164,7 @@ class AllIZHNeurons : public AllIFNeurons { // Copy all neurons' data from device to host. // - /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void copyFromDevice(void *deviceAddress) override; + virtual void copyFromDevice() override; // Copy all neurons' data from host to device. virtual void copyToDevice() override; diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index 2cfbd7358..3e5f5f131 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -129,11 +129,11 @@ void AllIZHNeurons::copyToDevice() /// Copy all neurons' data from device to host. /// -/// @param allVerticesDevice GPU address of the AllIZHNeuronsDeviceProperties struct -/// on device memory. -void AllIZHNeurons::copyFromDevice(void *allVerticesDevice) +void AllIZHNeurons::copyFromDevice() { - AllIFNeurons::copyFromDevice(allVerticesDevice); + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + AllIFNeurons::copyFromDevice(); AllIZHNeuronsDeviceProperties allVerticesDeviceProps; HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, diff --git a/Simulator/Vertices/Neuro/AllSpikingNeurons.h b/Simulator/Vertices/Neuro/AllSpikingNeurons.h index c29e074c6..d91233876 100644 --- a/Simulator/Vertices/Neuro/AllSpikingNeurons.h +++ b/Simulator/Vertices/Neuro/AllSpikingNeurons.h @@ -66,7 +66,7 @@ class AllSpikingNeurons : public AllVertices { // /// @param allVerticesDevice GPU address of the allVertices struct on device memory. virtual void clearNeuronSpikeCounts(void *allVerticesDevice) = 0; - virtual void copyFromDevice(void *deviceAddress) override; + virtual void copyFromDevice() override; virtual void copyToDevice() override; protected: diff --git a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp index 75f7f9e35..012e0b3ab 100644 --- a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp @@ -67,8 +67,10 @@ void AllSpikingNeurons::copyToDevice() maxSpikes * sizeof(uint64_t), cudaMemcpyHostToDevice)); } } -void AllSpikingNeurons::copyFromDevice(void *deviceAddress) +void AllSpikingNeurons::copyFromDevice() { + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); int numVertices = Simulator::getInstance().getTotalVertices(); AllSpikingNeuronsDeviceProperties allVerticesDevice; From 93aedae144f4a3446d8454c955757ce777d2104e Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Sun, 20 Apr 2025 15:19:41 -0700 Subject: [PATCH 15/26] modified the Refactor deleteNeuronDeviceStruct in AllVertices and all child vertex classes to take no parameters.Refactor deleteEdgeDeviceStruct in AllEdges and all child edge classes to take no parameters.registered the deleteSynapseImap in GPUModel to operationManager --- Simulator/Core/GPUModel.cpp | 9 +++++++-- Simulator/Edges/AllEdges.h | 3 +-- Simulator/Edges/NG911/All911Edges.h | 2 +- Simulator/Edges/Neuro/AllDSSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 7 +++---- Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h | 3 +-- Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 3 ++- Simulator/Edges/Neuro/AllSTDPSynapses.h | 3 +-- Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 6 +++--- Simulator/Edges/Neuro/AllSpikingSynapses.h | 3 +-- Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp | 6 +++--- Simulator/Vertices/AllVertices.h | 3 +-- Simulator/Vertices/NG911/All911Vertices.h | 2 +- Simulator/Vertices/Neuro/AllIFNeurons.h | 3 +-- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 5 +++-- Simulator/Vertices/Neuro/AllIZHNeurons.h | 3 +-- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 7 +++---- 17 files changed, 34 insertions(+), 37 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 74150e162..86f9f7118 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -33,10 +33,15 @@ GPUModel::GPUModel() : allocateGPU); // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager - function copyCPUtoGPU= bind(&GPUModel::copySynapseIndexMapHostToDevice, this); + function copyCPUtoGPU = bind(&GPUModel::copySynapseIndexMapHostToDevice, this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); + // Register deleteSynapseImap function as a deallocateGPUMemory operation in the OperationManager + function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); + OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, + deallocateGPUMemory); + #endif } @@ -366,7 +371,7 @@ void GPUModel::copyGPUtoCPU() void GPUModel::copyCPUtoGPU() { // copy host neurons and synapse structs to device memory - AllVertices &neurons = layout_->getVertices(); + AllVertices &neuroyns = laout_->getVertices(); AllEdges &synapses = connections_->getEdges(); neurons.copyToDevice(); synapses.copyEdgeHostToDevice(); diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index 8eb154afd..db5ae4956 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -107,8 +107,7 @@ class AllEdges { /// Delete GPU memories. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) = 0; + virtual void deleteEdgeDeviceStruct() = 0; /// Copy all edges' data from host to device. virtual void copyEdgeHostToDevice() = 0; diff --git a/Simulator/Edges/NG911/All911Edges.h b/Simulator/Edges/NG911/All911Edges.h index 030a0d7d0..db8d3d896 100644 --- a/Simulator/Edges/NG911/All911Edges.h +++ b/Simulator/Edges/NG911/All911Edges.h @@ -68,7 +68,7 @@ class All911Edges : public AllEdges { virtual void allocEdgeDeviceStruct() {}; virtual void allocEdgeDeviceStruct(void **allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) {}; + virtual void deleteEdgeDeviceStruct() {}; virtual void copyEdgeHostToDevice() {}; virtual void copyEdgeHostToDevice(void *allEdgesDevice, int numVertices, int maxEdgesPerVertex) {}; diff --git a/Simulator/Edges/Neuro/AllDSSynapses.h b/Simulator/Edges/Neuro/AllDSSynapses.h index de9e74f75..9459f3a25 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses.h +++ b/Simulator/Edges/Neuro/AllDSSynapses.h @@ -134,8 +134,7 @@ class AllDSSynapses : public AllSpikingSynapses { /// Delete GPU memories. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) override; + virtual void deleteEdgeDeviceStruct() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index 6f2222304..1032b6d68 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -66,12 +66,11 @@ void AllDSSynapses::allocDeviceStruct(AllDSSynapsesDeviceProperties &allEdges, i /// Delete GPU memories. /// -/// @param allEdgesDevice GPU address of the AllDSSynapsesDeviceProperties struct -/// on device memory. -void AllDSSynapses::deleteEdgeDeviceStruct(void *allEdgesDevice) +void AllDSSynapses::deleteEdgeDeviceStruct() { AllDSSynapsesDeviceProperties allEdges; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDSSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h index 98d87e145..a8fa23d5b 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.h @@ -137,8 +137,7 @@ class AllDynamicSTDPSynapses : public AllSTDPSynapses { /// Delete GPU memories. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) override; + virtual void deleteEdgeDeviceStruct() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 2ce5ec4f3..04a3da5dd 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -73,7 +73,8 @@ void AllDynamicSTDPSynapses::allocDeviceStruct( void AllDynamicSTDPSynapses::deleteEdgeDeviceStruct(void *allEdgesDevice) { AllDynamicSTDPSynapsesDeviceProperties allEdges; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDynamicSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.h b/Simulator/Edges/Neuro/AllSTDPSynapses.h index b13380cd7..f4a64f66e 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.h +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.h @@ -167,8 +167,7 @@ class AllSTDPSynapses : public AllSpikingSynapses { /// Delete GPU memories. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) override; + virtual void deleteEdgeDeviceStruct() override; /// Copy all synapses' data from host to device. virtual void copyEdgeHostToDevice() override; diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index f95e4ad91..5bd97439e 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -92,11 +92,11 @@ void AllSTDPSynapses::allocDeviceStruct(AllSTDPSynapsesDeviceProperties &allEdge /// Delete GPU memories. /// -/// @param allEdgesDevice GPU address of the AllSTDPSynapsesDeviceProperties struct -/// on device memory. -void AllSTDPSynapses::deleteEdgeDeviceStruct(void *allEdgesDevice) +void AllSTDPSynapses::deleteEdgeDeviceStruct() { AllSTDPSynapsesDeviceProperties allEdgesDeviceProps; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allEdgesDeviceProps); diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.h b/Simulator/Edges/Neuro/AllSpikingSynapses.h index 098f94910..9715a46b4 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.h +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.h @@ -135,8 +135,7 @@ class AllSpikingSynapses : public AllNeuroEdges { /// Delete GPU memories. /// - /// @param allEdgesDevice GPU address of the allEdges struct on device memory. - virtual void deleteEdgeDeviceStruct(void *allEdgesDevice) override; + virtual void deleteEdgeDeviceStruct() override; /// Copy all synapses' data from host to device. /// diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index 404d81823..bb7e97d9c 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -90,11 +90,11 @@ void AllSpikingSynapses::allocDeviceStruct(AllSpikingSynapsesDeviceProperties &a /// Delete GPU memories. /// -/// @param allEdgesDevice GPU address of the AllSpikingSynapsesDeviceProperties struct -/// on device memory. -void AllSpikingSynapses::deleteEdgeDeviceStruct(void *allEdgesDevice) +void AllSpikingSynapses::deleteEdgeDeviceStruct() { AllSpikingSynapsesDeviceProperties allEdges; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllSpikingSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allEdges); diff --git a/Simulator/Vertices/AllVertices.h b/Simulator/Vertices/AllVertices.h index 7ccc99a7e..28980713c 100644 --- a/Simulator/Vertices/AllVertices.h +++ b/Simulator/Vertices/AllVertices.h @@ -106,8 +106,7 @@ class AllVertices { /// Delete GPU memories. /// - /// @param allVerticesDevice GPU address of the allVertices struct on device memory. - virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) = 0; + virtual void deleteNeuronDeviceStruct() = 0; /// Copy all vertices' data from host to device. virtual void copyToDevice() = 0; diff --git a/Simulator/Vertices/NG911/All911Vertices.h b/Simulator/Vertices/NG911/All911Vertices.h index 6f25f9217..56e194c45 100644 --- a/Simulator/Vertices/NG911/All911Vertices.h +++ b/Simulator/Vertices/NG911/All911Vertices.h @@ -226,7 +226,7 @@ class All911Vertices : public AllVertices { // These signatures are required to make the class non-abstract public: virtual void allocNeuronDeviceStruct() {}; - virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) {}; + virtual void deleteNeuronDeviceStruct() {}; virtual void copyToDevice() {}; virtual void copyFromDevice() {}; virtual void advanceVertices(AllEdges &edges, void *allVerticesDevice, void *allEdgesDevice, diff --git a/Simulator/Vertices/Neuro/AllIFNeurons.h b/Simulator/Vertices/Neuro/AllIFNeurons.h index fa846139c..324e61b7a 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons.h +++ b/Simulator/Vertices/Neuro/AllIFNeurons.h @@ -94,8 +94,7 @@ class AllIFNeurons : public AllSpikingNeurons { /// Delete GPU memories. /// - /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void deleteNeuronDeviceStruct(void *allVerticesDevice); + virtual void deleteNeuronDeviceStruct(); /// Clear the spike counts out of all neurons. // diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index 817c2a35d..efe30f915 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -70,10 +70,11 @@ void AllIFNeurons::allocDeviceStruct(AllIFNeuronsDeviceProperties &allVerticesDe /// Delete GPU memories. /// -/// @param allVerticesDevice GPU address of the AllIFNeuronsDeviceProperties struct on device memory. -void AllIFNeurons::deleteNeuronDeviceStruct(void *allVerticesDevice) +void AllIFNeurons::deleteNeuronDeviceStruct() { AllIFNeuronsDeviceProperties allVerticesDeviceProps; + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allVerticesDeviceProps); diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons.h b/Simulator/Vertices/Neuro/AllIZHNeurons.h index dae64aeae..5cdebe780 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons.h +++ b/Simulator/Vertices/Neuro/AllIZHNeurons.h @@ -144,8 +144,7 @@ class AllIZHNeurons : public AllIFNeurons { /// Delete GPU memories. // - /// @param allVerticesDevice GPU address of the allNeurons struct on device memory. - virtual void deleteNeuronDeviceStruct(void *allVerticesDevice) override; + virtual void deleteNeuronDeviceStruct() override; /// Copy spike history data stored in device memory to host. // diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index 3e5f5f131..f2f413979 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -69,12 +69,11 @@ void AllIZHNeurons::allocDeviceStruct(AllIZHNeuronsDeviceProperties &allVertices /// Delete GPU memories. /// -/// @param allVerticesDevice GPU address of the AllIZHNeuronsDeviceProperties struct -/// on device memory. -void AllIZHNeurons::deleteNeuronDeviceStruct(void *allVerticesDevice) +void AllIZHNeurons::deleteNeuronDeviceStruct() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - + GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); + void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); From 9c7e1dd87c029b31ceeadd862196a2dd9d6a0315 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Tue, 22 Apr 2025 13:11:25 -0700 Subject: [PATCH 16/26] registered deleteEdgeDeviceStruct in AllEdges class and deleteNeuronDeviceStruct in AllVertices, now the deallocation is done through the operationManager --- Simulator/Core/GPUModel.cpp | 9 ++++----- Simulator/Edges/AllEdges.cpp | 6 ++++++ Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 2 +- Simulator/Vertices/AllVertices.cpp | 5 +++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 86f9f7118..bf13c4311 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -67,9 +67,9 @@ void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevic AllEdges &synapses = connections_->getEdges(); // Deallocate device memory - neurons.deleteNeuronDeviceStruct(*allVerticesDevice); + neurons.deleteNeuronDeviceStruct(); // Deallocate device memory - synapses.deleteEdgeDeviceStruct(*allEdgesDevice); + synapses.deleteEdgeDeviceStruct(); HANDLE_ERROR(cudaFree(randNoise_d)); } @@ -121,8 +121,7 @@ void GPUModel::finish() // copy device synapse and neuron structs to host memory copyGPUtoCPU(); // deallocates memories on CUDA device - deleteDeviceStruct((void **)&allVerticesDevice_, (void **)&allEdgesDevice_); - deleteSynapseImap(); + OperationManager::getInstance().executeOperation(Operations::deallocateGPUMemory); #ifdef PERFORMANCE_METRICS cudaEventDestroy(start); @@ -371,7 +370,7 @@ void GPUModel::copyGPUtoCPU() void GPUModel::copyCPUtoGPU() { // copy host neurons and synapse structs to device memory - AllVertices &neuroyns = laout_->getVertices(); + AllVertices &neurons = layout_->getVertices(); AllEdges &synapses = connections_->getEdges(); neurons.copyToDevice(); synapses.copyEdgeHostToDevice(); diff --git a/Simulator/Edges/AllEdges.cpp b/Simulator/Edges/AllEdges.cpp index 71cc3e67c..e27ceca83 100644 --- a/Simulator/Edges/AllEdges.cpp +++ b/Simulator/Edges/AllEdges.cpp @@ -41,6 +41,12 @@ AllEdges::AllEdges() : totalEdgeCount_(0), maxEdgesPerVertex_(0), countVertices_ function copyFromGPU= bind(&AllEdges::copyEdgeDeviceToHost, this); OperationManager::getInstance().registerOperation(Operations::copyFromGPU, copyFromGPU); + + // Register deleteEdgeDeviceStruct function as a deallocateGPUMemory operation in the OperationManager + function deallocateGPUMemory = bind(&AllEdges::deleteEdgeDeviceStruct, this); + OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, + deallocateGPUMemory); + #endif fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 04a3da5dd..a6af4c900 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -70,7 +70,7 @@ void AllDynamicSTDPSynapses::allocDeviceStruct( /// /// @param allEdgesDevice GPU address of the AllDynamicSTDPSynapsesDeviceProperties struct /// on device memory. -void AllDynamicSTDPSynapses::deleteEdgeDeviceStruct(void *allEdgesDevice) +void AllDynamicSTDPSynapses::deleteEdgeDeviceStruct() { AllDynamicSTDPSynapsesDeviceProperties allEdges; GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index b736acde3..2eacda284 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -37,6 +37,11 @@ AllVertices::AllVertices() : size_(0) function copyFromGPU= bind(&AllVertices::copyFromDevice, this); OperationManager::getInstance().registerOperation(Operations::copyFromGPU, copyFromGPU); + + // Register deleteNeuronDeviceStruct function as a deallocateGPUMemory operation in the OperationManager + function deallocateGPUMemory = bind(&AllVertices::deleteNeuronDeviceStruct, this); + OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, + deallocateGPUMemory); #endif // Get a copy of the file and vertex logger to use log4cplus macros to print to debug files From d5e6d647dde19f92263e755f1a89b6f669da8941 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Tue, 22 Apr 2025 15:24:11 -0700 Subject: [PATCH 17/26] using clang-format to fix the formatting issue --- Simulator/Core/GPUModel.cpp | 18 ++++++------- Simulator/Core/GPUModel.h | 4 +-- Simulator/Edges/AllEdges.cpp | 25 +++++++++---------- Simulator/Edges/AllEdges.h | 2 +- Simulator/Edges/NG911/All911Edges.h | 4 +-- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 16 ++++++------ .../Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 16 ++++++------ Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 16 ++++++------ .../Edges/Neuro/AllSpikingSynapses_d.cpp | 18 ++++++------- Simulator/Vertices/AllVertices.cpp | 21 +++++++--------- Simulator/Vertices/Neuro/AllIFNeurons_d.cpp | 18 ++++++------- Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp | 18 ++++++------- .../Vertices/Neuro/AllSpikingNeurons_d.cpp | 10 ++++---- 13 files changed, 90 insertions(+), 96 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index bf13c4311..f160ef2fb 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -26,23 +26,21 @@ GPUModel::GPUModel() : Model::Model(), synapseIndexMapDevice_(nullptr), randNoise_d(nullptr), allVerticesDevice_(nullptr), allEdgesDevice_(nullptr) { - #if defined(USE_GPU) +#if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); - OperationManager::getInstance().registerOperation(Operations::allocateGPU, - allocateGPU); - + OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); + // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager function copyCPUtoGPU = bind(&GPUModel::copySynapseIndexMapHostToDevice, this); - OperationManager::getInstance().registerOperation(Operations::copyToGPU, - copyCPUtoGPU); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); // Register deleteSynapseImap function as a deallocateGPUMemory operation in the OperationManager function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, - deallocateGPUMemory); + deallocateGPUMemory); - #endif +#endif } /// Allocates and initializes memories on CUDA device. @@ -383,13 +381,13 @@ void GPUModel::printGPUSynapsesPropsModel() const } /// Getter for neuron structure in device memory -AllSpikingNeuronsDeviceProperties*& GPUModel::getAllVerticesDevice() +AllSpikingNeuronsDeviceProperties *&GPUModel::getAllVerticesDevice() { return allVerticesDevice_; } /// Getter for synapse structures in device memory -AllSpikingSynapsesDeviceProperties*& GPUModel::getAllEdgesDevice() +AllSpikingSynapsesDeviceProperties *&GPUModel::getAllEdgesDevice() { return allEdgesDevice_; } \ No newline at end of file diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 98164e3ec..035ec3c64 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -103,10 +103,10 @@ class GPUModel : public Model { void printGPUSynapsesPropsModel() const; /// Getter for synapse structures in device memory - AllSpikingSynapsesDeviceProperties*& getAllEdgesDevice(); + AllSpikingSynapsesDeviceProperties *&getAllEdgesDevice(); /// Getter for neuron structure in device memory - AllSpikingNeuronsDeviceProperties*& getAllVerticesDevice(); + AllSpikingNeuronsDeviceProperties *&getAllVerticesDevice(); protected: /// Allocates and initializes memories on CUDA device. diff --git a/Simulator/Edges/AllEdges.cpp b/Simulator/Edges/AllEdges.cpp index e27ceca83..bc4dce1f3 100644 --- a/Simulator/Edges/AllEdges.cpp +++ b/Simulator/Edges/AllEdges.cpp @@ -26,28 +26,27 @@ AllEdges::AllEdges() : totalEdgeCount_(0), maxEdgesPerVertex_(0), countVertices_ OperationManager::getInstance().registerOperation(Operations::printParameters, printParametersFunc); - #if defined(USE_GPU) +#if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager - function allocateGPU = bind(static_cast(&AllEdges::allocEdgeDeviceStruct), this); - OperationManager::getInstance().registerOperation(Operations::allocateGPU, - allocateGPU); + function allocateGPU + = bind(static_cast(&AllEdges::allocEdgeDeviceStruct), this); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); // Register AllEdges::copyEdgeHostToDevice function as a copyToGPU operation in the OperationManager - function copyCPUtoGPU= bind(static_cast(&AllEdges::copyEdgeHostToDevice), this); - OperationManager::getInstance().registerOperation(Operations::copyToGPU, - copyCPUtoGPU); + function copyCPUtoGPU + = bind(static_cast(&AllEdges::copyEdgeHostToDevice), this); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); - // Register copyFromGPU operation for transferring edge data from device to host - function copyFromGPU= bind(&AllEdges::copyEdgeDeviceToHost, this); - OperationManager::getInstance().registerOperation(Operations::copyFromGPU, - copyFromGPU); + // Register copyFromGPU operation for transferring edge data from device to host + function copyFromGPU = bind(&AllEdges::copyEdgeDeviceToHost, this); + OperationManager::getInstance().registerOperation(Operations::copyFromGPU, copyFromGPU); // Register deleteEdgeDeviceStruct function as a deallocateGPUMemory operation in the OperationManager function deallocateGPUMemory = bind(&AllEdges::deleteEdgeDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, - deallocateGPUMemory); + deallocateGPUMemory); - #endif +#endif fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); edgeLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("edge")); diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index db5ae4956..0bf5d1007 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -109,7 +109,7 @@ class AllEdges { /// virtual void deleteEdgeDeviceStruct() = 0; - /// Copy all edges' data from host to device. + /// Copy all edges' data from host to device. virtual void copyEdgeHostToDevice() = 0; /// Copy all edges' data from host to device. diff --git a/Simulator/Edges/NG911/All911Edges.h b/Simulator/Edges/NG911/All911Edges.h index db8d3d896..c98068d6a 100644 --- a/Simulator/Edges/NG911/All911Edges.h +++ b/Simulator/Edges/NG911/All911Edges.h @@ -70,8 +70,8 @@ class All911Edges : public AllEdges { int maxEdgesPerVertex) {}; virtual void deleteEdgeDeviceStruct() {}; virtual void copyEdgeHostToDevice() {}; - virtual void copyEdgeHostToDevice(void *allEdgesDevice, int numVertices, - int maxEdgesPerVertex) {}; + virtual void copyEdgeHostToDevice(void *allEdgesDevice, int numVertices, int maxEdgesPerVertex) { + }; virtual void copyEdgeDeviceToHost() {}; virtual void copyDeviceEdgeCountsToHost(void *allEdgesDevice) {}; virtual void copyDeviceEdgeSumIdxToHost(void *allEdgesDevice) {}; diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index 1032b6d68..719c8f5e9 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -16,8 +16,8 @@ /// and copy them from host to GPU memory. void AllDSSynapses::allocEdgeDeviceStruct() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -69,8 +69,8 @@ void AllDSSynapses::allocDeviceStruct(AllDSSynapsesDeviceProperties &allEdges, i void AllDSSynapses::deleteEdgeDeviceStruct() { AllDSSynapsesDeviceProperties allEdges; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDSSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); @@ -100,8 +100,8 @@ void AllDSSynapses::deleteDeviceStruct(AllDSSynapsesDeviceProperties &allEdgesDe /// void AllDSSynapses::copyEdgeHostToDevice() { // copy everything necessary - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -158,8 +158,8 @@ void AllDSSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllDSSynapsesDeviceProperties allEdgesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllDSSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index a6af4c900..5dbcda131 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -16,8 +16,8 @@ /// and copy them from host to GPU memory. void AllDynamicSTDPSynapses::allocEdgeDeviceStruct() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -73,8 +73,8 @@ void AllDynamicSTDPSynapses::allocDeviceStruct( void AllDynamicSTDPSynapses::deleteEdgeDeviceStruct() { AllDynamicSTDPSynapsesDeviceProperties allEdges; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDynamicSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); @@ -105,8 +105,8 @@ void AllDynamicSTDPSynapses::deleteDeviceStruct( /// void AllDynamicSTDPSynapses::copyEdgeHostToDevice() { // copy everything necessary - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -164,8 +164,8 @@ void AllDynamicSTDPSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllDynamicSTDPSynapsesDeviceProperties allEdges; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllDynamicSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index 5bd97439e..658d83383 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -34,8 +34,8 @@ __global__ void advanceSTDPSynapsesDevice(int totalSynapseCount, /// and copy them from host to GPU memory. void AllSTDPSynapses::allocEdgeDeviceStruct() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -95,8 +95,8 @@ void AllSTDPSynapses::allocDeviceStruct(AllSTDPSynapsesDeviceProperties &allEdge void AllSTDPSynapses::deleteEdgeDeviceStruct() { AllSTDPSynapsesDeviceProperties allEdgesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allEdgesDeviceProps); @@ -130,8 +130,8 @@ void AllSTDPSynapses::deleteDeviceStruct(AllSTDPSynapsesDeviceProperties &allEdg /// void AllSTDPSynapses::copyEdgeHostToDevice() { // copy everything necessary - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -201,8 +201,8 @@ void AllSTDPSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllSTDPSynapsesDeviceProperties allEdgesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdgesDeviceProps, allEdgesDevice, sizeof(AllSTDPSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); copyDeviceToHost(allEdgesDeviceProps); diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index bb7e97d9c..f000f31e0 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -10,9 +10,9 @@ #include "AllSpikingSynapses.h" #include "AllSynapsesDeviceFuncs.h" #include "Book.h" -#include #include "GPUModel.h" #include "Simulator.h" +#include /// CUDA code for advancing spiking synapses. /// Perform updating synapses for one time step. @@ -32,8 +32,8 @@ __global__ void advanceSpikingSynapsesDevice(int totalSynapseCount, /// and copy them from host to GPU memory. void AllSpikingSynapses::allocEdgeDeviceStruct() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allEdgesDevice = reinterpret_cast(&(gpuModel->getAllEdgesDevice())); allocEdgeDeviceStruct(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -93,8 +93,8 @@ void AllSpikingSynapses::allocDeviceStruct(AllSpikingSynapsesDeviceProperties &a void AllSpikingSynapses::deleteEdgeDeviceStruct() { AllSpikingSynapsesDeviceProperties allEdges; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllSpikingSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allEdges); @@ -130,8 +130,8 @@ void AllSpikingSynapses::deleteDeviceStruct(AllSpikingSynapsesDeviceProperties & /// void AllSpikingSynapses::copyEdgeHostToDevice() { // copy everything necessary - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); copyEdgeHostToDevice(allEdgesDevice, Simulator::getInstance().getTotalVertices(), Simulator::getInstance().getMaxEdgesPerVertex()); } @@ -205,8 +205,8 @@ void AllSpikingSynapses::copyEdgeDeviceToHost() { // copy everything necessary AllSpikingSynapsesDeviceProperties allEdges; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allEdgesDevice = static_cast(gpuModel->getAllEdgesDevice()); HANDLE_ERROR(cudaMemcpy(&allEdges, allEdgesDevice, sizeof(AllSpikingSynapsesDeviceProperties), cudaMemcpyDeviceToHost)); copyDeviceToHost(allEdges); diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index 2eacda284..be530b9d3 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -22,27 +22,24 @@ AllVertices::AllVertices() : size_(0) OperationManager::getInstance().registerOperation(Operations::printParameters, printParametersFunc); - #if defined(USE_GPU) +#if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager function allocateGPU = bind(&AllVertices::allocNeuronDeviceStruct, this); - OperationManager::getInstance().registerOperation(Operations::allocateGPU, - allocateGPU); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); // Register AllVertices::copyToDevice function as a copyToGPU operation in the OperationManager - function copyCPUtoGPU= bind(&AllVertices::copyToDevice, this); - OperationManager::getInstance().registerOperation(Operations::copyToGPU, - copyCPUtoGPU); + function copyCPUtoGPU = bind(&AllVertices::copyToDevice, this); + OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); - // Register copyFromGPU operation for transferring edge data from device to host - function copyFromGPU= bind(&AllVertices::copyFromDevice, this); - OperationManager::getInstance().registerOperation(Operations::copyFromGPU, - copyFromGPU); + // Register copyFromGPU operation for transferring edge data from device to host + function copyFromGPU = bind(&AllVertices::copyFromDevice, this); + OperationManager::getInstance().registerOperation(Operations::copyFromGPU, copyFromGPU); // Register deleteNeuronDeviceStruct function as a deallocateGPUMemory operation in the OperationManager function deallocateGPUMemory = bind(&AllVertices::deleteNeuronDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, - deallocateGPUMemory); - #endif + deallocateGPUMemory); +#endif // Get a copy of the file and vertex logger to use log4cplus macros to print to debug files fileLogger_ = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("file")); diff --git a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp index efe30f915..80110002b 100644 --- a/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIFNeurons_d.cpp @@ -8,8 +8,8 @@ #include "AllIFNeurons.h" #include "Book.h" -#include "Simulator.h" #include "GPUModel.h" +#include "Simulator.h" /// Allocate GPU memories to store all neurons' states, /// and copy them from host to GPU memory. @@ -18,8 +18,8 @@ void AllIFNeurons::allocNeuronDeviceStruct() { AllIFNeuronsDeviceProperties allNeurons; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); allocDeviceStruct(allNeurons); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties))); HANDLE_ERROR(cudaMemcpy(*allVerticesDevice, &allNeurons, sizeof(AllIFNeuronsDeviceProperties), @@ -73,8 +73,8 @@ void AllIFNeurons::allocDeviceStruct(AllIFNeuronsDeviceProperties &allVerticesDe void AllIFNeurons::deleteNeuronDeviceStruct() { AllIFNeuronsDeviceProperties allVerticesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); deleteDeviceStruct(allVerticesDeviceProps); @@ -119,8 +119,8 @@ void AllIFNeurons::deleteDeviceStruct(AllIFNeuronsDeviceProperties &allVerticesD void AllIFNeurons::copyToDevice() { int count = Simulator::getInstance().getTotalVertices(); - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); AllIFNeuronsDeviceProperties allVerticesDeviceProps; HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIFNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); @@ -164,8 +164,8 @@ void AllIFNeurons::copyToDevice() /// void AllIFNeurons::copyFromDevice() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); AllSpikingNeurons::copyFromDevice(); int count = Simulator::getInstance().getTotalVertices(); AllIFNeuronsDeviceProperties allVerticesDeviceProps; diff --git a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp index f2f413979..7d1e71644 100644 --- a/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllIZHNeurons_d.cpp @@ -10,8 +10,8 @@ #include "AllSpikingSynapses.h" #include "AllVerticesDeviceFuncs.h" #include "Book.h" -#include "Simulator.h" #include "GPUModel.h" +#include "Simulator.h" /// CUDA code for advancing izhikevich neurons /// @@ -40,8 +40,8 @@ __global__ void advanceIZHNeuronsDevice(int totalVertices, int maxEdges, int max void AllIZHNeurons::allocNeuronDeviceStruct() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void** allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void **allVerticesDevice = reinterpret_cast(&(gpuModel->getAllVerticesDevice())); allocDeviceStruct(allVerticesDeviceProps); HANDLE_ERROR(cudaMalloc(allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties))); @@ -72,8 +72,8 @@ void AllIZHNeurons::allocDeviceStruct(AllIZHNeuronsDeviceProperties &allVertices void AllIZHNeurons::deleteNeuronDeviceStruct() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); @@ -103,8 +103,8 @@ void AllIZHNeurons::deleteDeviceStruct(AllIZHNeuronsDeviceProperties &allVertice void AllIZHNeurons::copyToDevice() { AllIZHNeuronsDeviceProperties allVerticesDeviceProps; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDeviceProps, allVerticesDevice, sizeof(AllIZHNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); @@ -130,8 +130,8 @@ void AllIZHNeurons::copyToDevice() /// void AllIZHNeurons::copyFromDevice() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *allVerticesDevice = static_cast(gpuModel->getAllVerticesDevice()); AllIFNeurons::copyFromDevice(); AllIZHNeuronsDeviceProperties allVerticesDeviceProps; diff --git a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp index 012e0b3ab..c0096aad5 100644 --- a/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp +++ b/Simulator/Vertices/Neuro/AllSpikingNeurons_d.cpp @@ -9,14 +9,14 @@ #include "AllSpikingNeurons.h" #include "AllSpikingSynapses.h" #include "Book.h" -#include "Simulator.h" #include "GPUModel.h" +#include "Simulator.h" void AllSpikingNeurons::copyToDevice() { AllSpikingNeuronsDeviceProperties allVerticesDevice; - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); HANDLE_ERROR(cudaMemcpy(&allVerticesDevice, deviceAddress, sizeof(AllSpikingNeuronsDeviceProperties), cudaMemcpyDeviceToHost)); @@ -69,8 +69,8 @@ void AllSpikingNeurons::copyToDevice() } void AllSpikingNeurons::copyFromDevice() { - GPUModel* gpuModel = static_cast(&Simulator::getInstance().getModel()); - void* deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); + GPUModel *gpuModel = static_cast(&Simulator::getInstance().getModel()); + void *deviceAddress = static_cast(gpuModel->getAllVerticesDevice()); int numVertices = Simulator::getInstance().getTotalVertices(); AllSpikingNeuronsDeviceProperties allVerticesDevice; From 8efd1f0a44c8557c40eadf4f4fbd6f8a6a449635 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Wed, 23 Apr 2025 17:00:39 -0700 Subject: [PATCH 18/26] registered registerHistoryVariable to the operationManager now instead of having simulator.getModel().getLayout().getVertices().registerHistoryVariables(); we can just use operationManager to invokeit --- Simulator/Core/Core.cpp | 2 +- Simulator/Core/Operations.h | 3 ++- Simulator/Vertices/AllVertices.cpp | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Simulator/Core/Core.cpp b/Simulator/Core/Core.cpp index b32b1837b..07dbda9e6 100644 --- a/Simulator/Core/Core.cpp +++ b/Simulator/Core/Core.cpp @@ -191,7 +191,7 @@ int Core::runSimulation(string executableName, string cmdLineArguments) } // Helper function for recorder to register spike history variables for all neurons. - simulator.getModel().getLayout().getVertices().registerHistoryVariables(); + OperationManager::getInstance().executeOperation(Operations::registerHistoryVariables); // Run simulation LOG4CPLUS_TRACE(consoleLogger, "Starting Simulation"); diff --git a/Simulator/Core/Operations.h b/Simulator/Core/Operations.h index 62f22059a..32936d70b 100644 --- a/Simulator/Core/Operations.h +++ b/Simulator/Core/Operations.h @@ -23,6 +23,7 @@ class Operations { restoreToDefault, // Not sure what this refers to. copyToGPU, copyFromGPU, - allocateGPU + allocateGPU, + registerHistoryVariables }; }; \ No newline at end of file diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index be530b9d3..d770502ba 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -22,6 +22,11 @@ AllVertices::AllVertices() : size_(0) OperationManager::getInstance().registerOperation(Operations::printParameters, printParametersFunc); + // Register registerHistoryVariables function as a registerHistoryVariables operation in the OperationManager + function registerHistory = bind(&AllVertices::registerHistoryVariables, this); + OperationManager::getInstance().registerOperation(Operations::registerHistoryVariables, + registerHistory); + #if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager function allocateGPU = bind(&AllVertices::allocNeuronDeviceStruct, this); From ecaceb11b73832a4c8b58bd234111d73011cf019 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 24 Apr 2025 18:29:56 -0700 Subject: [PATCH 19/26] resolved issues from the pull request#841 --- Simulator/Core/GPUModel.cpp | 36 ++++++------------- Simulator/Core/GPUModel.h | 6 ++-- ...peration(Operations::deallocateGPUMemory); | 21 +++++++++++ 3 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 tance().executeOperation(Operations::deallocateGPUMemory); diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index f160ef2fb..0f87dc3a0 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -26,7 +26,6 @@ GPUModel::GPUModel() : Model::Model(), synapseIndexMapDevice_(nullptr), randNoise_d(nullptr), allVerticesDevice_(nullptr), allEdgesDevice_(nullptr) { -#if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); @@ -39,8 +38,6 @@ GPUModel::GPUModel() : function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, deallocateGPUMemory); - -#endif } /// Allocates and initializes memories on CUDA device. @@ -56,19 +53,10 @@ void GPUModel::allocDeviceStruct() } /// Copies device memories to host memories and deallocates them. -/// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. -/// @param[out] allEdgesDevice Memory location of the pointer to the synapses list on device memory. -void GPUModel::deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevice) +void GPUModel::deleteDeviceStruct() { - // Get neurons and synapses - AllVertices &neurons = layout_->getVertices(); - AllEdges &synapses = connections_->getEdges(); - - // Deallocate device memory - neurons.deleteNeuronDeviceStruct(); // Deallocate device memory - synapses.deleteEdgeDeviceStruct(); - HANDLE_ERROR(cudaFree(randNoise_d)); + OperationManager::getInstance().executeOperation(Operations::deallocateGPUMemory); } /// Sets up the Simulation. @@ -101,10 +89,7 @@ void GPUModel::setupSim() t_gpu_calcSummation = 0.0; #endif // PERFORMANCE_METRICS // Allocate and copy neuron/synapse data structures to GPU memory - OperationManager::getInstance().executeOperation(Operations::allocateGPU); - // Copy host neuron and synapse arrays into GPU device - // copy inverse map to the device memory - OperationManager::getInstance().executeOperation(Operations::copyToGPU); + copyCPUtoGPU(); // set some parameters used for advanceVerticesDevice layout_->getVertices().setAdvanceVerticesDeviceParams(connections_->getEdges()); @@ -119,7 +104,7 @@ void GPUModel::finish() // copy device synapse and neuron structs to host memory copyGPUtoCPU(); // deallocates memories on CUDA device - OperationManager::getInstance().executeOperation(Operations::deallocateGPUMemory); + deleteDeviceStruct(); #ifdef PERFORMANCE_METRICS cudaEventDestroy(start); @@ -255,6 +240,7 @@ void GPUModel::deleteSynapseImap() HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeCount_)); HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeIndexMap_)); HANDLE_ERROR(cudaFree(synapseIndexMapDevice_)); + HANDLE_ERROR(cudaFree(randNoise_d)); } /// Copy EdgeIndexMap in host memory to EdgeIndexMap in device memory. @@ -364,14 +350,14 @@ void GPUModel::copyGPUtoCPU() OperationManager::getInstance().executeOperation(Operations::copyFromGPU); } -/// Copy CPU Synapse data to GPU. +/// Allocate and Copy CPU Synapse data to GPU. void GPUModel::copyCPUtoGPU() { - // copy host neurons and synapse structs to device memory - AllVertices &neurons = layout_->getVertices(); - AllEdges &synapses = connections_->getEdges(); - neurons.copyToDevice(); - synapses.copyEdgeHostToDevice(); + // Allocate and copy neuron/synapse data structures to GPU memory + OperationManager::getInstance().executeOperation(Operations::allocateGPU); + // Copy host neuron and synapse arrays into GPU device + // copy inverse map to the device memory + OperationManager::getInstance().executeOperation(Operations::copyToGPU); } /// Print out SynapseProps on the GPU. diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 035ec3c64..27fc4571a 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -112,10 +112,8 @@ class GPUModel : public Model { /// Allocates and initializes memories on CUDA device. void allocDeviceStruct(); - /// Copies device memories to host memories and deallocates them. - /// @param[out] allVerticesDevice Memory location of the pointer to the neurons list on device memory. - /// @param[out] allEdgesDevice Memory location of the pointer to the synapses list on device memory. - virtual void deleteDeviceStruct(void **allVerticesDevice, void **allEdgesDevice); + /// Deallocates device memories. + virtual void deleteDeviceStruct(); /// Add psr of all incoming synapses to summation points. virtual void calcSummationPoint(); diff --git a/tance().executeOperation(Operations::deallocateGPUMemory); b/tance().executeOperation(Operations::deallocateGPUMemory); new file mode 100644 index 000000000..aa038ae74 --- /dev/null +++ b/tance().executeOperation(Operations::deallocateGPUMemory); @@ -0,0 +1,21 @@ +diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp +index f160ef2f..534c899e 100644 +--- a/Simulator/Core/GPUModel.cpp ++++ b/Simulator/Core/GPUModel.cpp +@@ -26,7 +26,6 @@ GPUModel::GPUModel() : + Model::Model(), synapseIndexMapDevice_(nullptr), randNoise_d(nullptr), + allVerticesDevice_(nullptr), allEdgesDevice_(nullptr) + { +-#if defined(USE_GPU) + // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager + function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); + OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); +@@ -39,8 +38,6 @@ GPUModel::GPUModel() : + function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); + OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, + deallocateGPUMemory); +- +-#endif + } +  + /// Allocates and initializes memories on CUDA device. From 113868296f4510ea0d34f56a7928d04f80c66ab5 Mon Sep 17 00:00:00 2001 From: BenYang2002 <96927991+BenYang2002@users.noreply.github.com> Date: Fri, 2 May 2025 13:36:06 -0700 Subject: [PATCH 20/26] Update format.yml find .clang-format and print the .clang-format out --- .github/workflows/format.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index ce659f902..97e7fddfc 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -26,4 +26,17 @@ jobs: - name: Code format check run: | echo "*** running clang-format to check for style violations" + + # Find and print the .clang-format file + dir="$PWD" + while [ "$dir" != "/" ]; do + if [ -f "$dir/.clang-format" ]; then + echo "Found .clang-format at: $dir/.clang-format" + cat "$dir/.clang-format" + break + fi + dir=$(dirname "$dir") + done + + # Run the style check clang-format --dry-run --Werror --style=file `find . -type f \( -iname "*.cpp" -or -iname "*.h" \) ! -path "./Testing/lib/*" ! -path "./ThirdParty/*" ! -path "./docs/*"` From 7c7c8d4aa75d053f7e14f01ddfbed840e68489ba Mon Sep 17 00:00:00 2001 From: BenYang2002 <96927991+BenYang2002@users.noreply.github.com> Date: Fri, 2 May 2025 13:43:10 -0700 Subject: [PATCH 21/26] Update format.yml confirmed that local and remote's .clang-format is the same --- .github/workflows/format.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 97e7fddfc..ce659f902 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -26,17 +26,4 @@ jobs: - name: Code format check run: | echo "*** running clang-format to check for style violations" - - # Find and print the .clang-format file - dir="$PWD" - while [ "$dir" != "/" ]; do - if [ -f "$dir/.clang-format" ]; then - echo "Found .clang-format at: $dir/.clang-format" - cat "$dir/.clang-format" - break - fi - dir=$(dirname "$dir") - done - - # Run the style check clang-format --dry-run --Werror --style=file `find . -type f \( -iname "*.cpp" -or -iname "*.h" \) ! -path "./Testing/lib/*" ! -path "./ThirdParty/*" ! -path "./docs/*"` From b0b8f26020fa8834459e9e2f114b42a9cd18d01c Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Sun, 4 May 2025 18:45:18 -0700 Subject: [PATCH 22/26] renamed the copySynapseIndexMapHostToDevice into copyCPUtoGPU, now we register the copyCPUtoGPU to operationManager --- Simulator/Core/GPUModel.cpp | 104 ++++++++++++++++-------------------- Simulator/Core/GPUModel.h | 3 -- 2 files changed, 47 insertions(+), 60 deletions(-) diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 0f87dc3a0..cf0d514ca 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -30,8 +30,8 @@ GPUModel::GPUModel() : function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); - // Register copySynapseIndexMapHostToDevice function as a copyCPUtoGPU operation in the OperationManager - function copyCPUtoGPU = bind(&GPUModel::copySynapseIndexMapHostToDevice, this); + // Register copyCPUtoGPU function as a copyCPUtoGPU operation in the OperationManager + function copyCPUtoGPU = bind(&GPUModel::copyCPUtoGPU, this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); // Register deleteSynapseImap function as a deallocateGPUMemory operation in the OperationManager @@ -89,7 +89,8 @@ void GPUModel::setupSim() t_gpu_calcSummation = 0.0; #endif // PERFORMANCE_METRICS // Allocate and copy neuron/synapse data structures to GPU memory - copyCPUtoGPU(); + OperationManager::getInstance().executeOperation(Operations::allocateGPU); + OperationManager::getInstance().executeOperation(Operations::copyToGPU); // set some parameters used for advanceVerticesDevice layout_->getVertices().setAdvanceVerticesDeviceParams(connections_->getEdges()); @@ -192,7 +193,7 @@ void GPUModel::updateConnections() // create synapse index map connections_->createEdgeIndexMap(); // copy index map to the device memory - copySynapseIndexMapHostToDevice(); + copyCPUtoGPU(); } } @@ -243,54 +244,6 @@ void GPUModel::deleteSynapseImap() HANDLE_ERROR(cudaFree(randNoise_d)); } -/// Copy EdgeIndexMap in host memory to EdgeIndexMap in device memory. -/// @param synapseIndexMapHost Reference to the EdgeIndexMap in host memory. -void GPUModel::copySynapseIndexMapHostToDevice() -{ - EdgeIndexMap synapseIndexMapHost = connections_->getEdgeIndexMap(); - int numVertices = Simulator::getInstance().getTotalVertices(); - AllEdges &synapses = connections_->getEdges(); - int totalSynapseCount = dynamic_cast(synapses).totalEdgeCount_; - if (totalSynapseCount == 0) - return; - EdgeIndexMapDevice synapseIMapDevice; - HANDLE_ERROR(cudaMemcpy(&synapseIMapDevice, synapseIndexMapDevice_, sizeof(EdgeIndexMapDevice), - cudaMemcpyDeviceToHost)); - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeBegin_, - synapseIndexMapHost.outgoingEdgeBegin_.data(), - numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeCount_, - synapseIndexMapHost.outgoingEdgeCount_.data(), - numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - if (synapseIMapDevice.outgoingEdgeIndexMap_ != nullptr) { - HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeIndexMap_)); - } - HANDLE_ERROR(cudaMalloc((void **)&synapseIMapDevice.outgoingEdgeIndexMap_, - totalSynapseCount * sizeof(BGSIZE))); - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeIndexMap_, - synapseIndexMapHost.outgoingEdgeIndexMap_.data(), - totalSynapseCount * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - // active synapse map - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeBegin_, - synapseIndexMapHost.incomingEdgeBegin_.data(), - numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeCount_, - synapseIndexMapHost.incomingEdgeCount_.data(), - numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - // the number of synapses may change, so we reallocate the memory - if (synapseIMapDevice.incomingEdgeIndexMap_ != nullptr) { - HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeIndexMap_)); - synapseIMapDevice.incomingEdgeIndexMap_ = nullptr; - } - HANDLE_ERROR(cudaMalloc((void **)&synapseIMapDevice.incomingEdgeIndexMap_, - totalSynapseCount * sizeof(BGSIZE))); - HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeIndexMap_, - synapseIndexMapHost.incomingEdgeIndexMap_.data(), - totalSynapseCount * sizeof(BGSIZE), cudaMemcpyHostToDevice)); - HANDLE_ERROR(cudaMemcpy(synapseIndexMapDevice_, &synapseIMapDevice, sizeof(EdgeIndexMapDevice), - cudaMemcpyHostToDevice)); -} - /// Calculate the sum of synaptic input to each neuron. /// /// Calculate the sum of synaptic input to each neuron. One thread @@ -353,11 +306,48 @@ void GPUModel::copyGPUtoCPU() /// Allocate and Copy CPU Synapse data to GPU. void GPUModel::copyCPUtoGPU() { - // Allocate and copy neuron/synapse data structures to GPU memory - OperationManager::getInstance().executeOperation(Operations::allocateGPU); - // Copy host neuron and synapse arrays into GPU device - // copy inverse map to the device memory - OperationManager::getInstance().executeOperation(Operations::copyToGPU); + EdgeIndexMap synapseIndexMapHost = connections_->getEdgeIndexMap(); + int numVertices = Simulator::getInstance().getTotalVertices(); + AllEdges &synapses = connections_->getEdges(); + int totalSynapseCount = dynamic_cast(synapses).totalEdgeCount_; + if (totalSynapseCount == 0) + return; + EdgeIndexMapDevice synapseIMapDevice; + HANDLE_ERROR(cudaMemcpy(&synapseIMapDevice, synapseIndexMapDevice_, sizeof(EdgeIndexMapDevice), + cudaMemcpyDeviceToHost)); + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeBegin_, + synapseIndexMapHost.outgoingEdgeBegin_.data(), + numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeCount_, + synapseIndexMapHost.outgoingEdgeCount_.data(), + numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + if (synapseIMapDevice.outgoingEdgeIndexMap_ != nullptr) { + HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeIndexMap_)); + } + HANDLE_ERROR(cudaMalloc((void **)&synapseIMapDevice.outgoingEdgeIndexMap_, + totalSynapseCount * sizeof(BGSIZE))); + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.outgoingEdgeIndexMap_, + synapseIndexMapHost.outgoingEdgeIndexMap_.data(), + totalSynapseCount * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + // active synapse map + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeBegin_, + synapseIndexMapHost.incomingEdgeBegin_.data(), + numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeCount_, + synapseIndexMapHost.incomingEdgeCount_.data(), + numVertices * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + // the number of synapses may change, so we reallocate the memory + if (synapseIMapDevice.incomingEdgeIndexMap_ != nullptr) { + HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeIndexMap_)); + synapseIMapDevice.incomingEdgeIndexMap_ = nullptr; + } + HANDLE_ERROR(cudaMalloc((void **)&synapseIMapDevice.incomingEdgeIndexMap_, + totalSynapseCount * sizeof(BGSIZE))); + HANDLE_ERROR(cudaMemcpy(synapseIMapDevice.incomingEdgeIndexMap_, + synapseIndexMapHost.incomingEdgeIndexMap_.data(), + totalSynapseCount * sizeof(BGSIZE), cudaMemcpyHostToDevice)); + HANDLE_ERROR(cudaMemcpy(synapseIndexMapDevice_, &synapseIMapDevice, sizeof(EdgeIndexMapDevice), + cudaMemcpyHostToDevice)); } /// Print out SynapseProps on the GPU. diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 27fc4571a..eb470af01 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -137,9 +137,6 @@ class GPUModel : public Model { void deleteSynapseImap(); -public: //2020/03/14 changed to public for accessing in Core - void copySynapseIndexMapHostToDevice(); - private: void updateHistory(); From e2ad9d1a614ca1e7da5e4ce3ec2924430eceb3a9 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Tue, 6 May 2025 13:14:33 -0700 Subject: [PATCH 23/26] resolved some issues from the pull request into the sharedDevelopment, get rid of the copySynapeseIndMap and replaced with copyCPUToGPU, to make the structure more clear --- Simulator/Core/GPUModel.cpp | 41 +- Simulator/Core/GPUModel.h | 11 +- Simulator/Core/Serializer.cpp | 2 +- Testing/test_output.log | 410 ++++++++++++++++++ ...peration(Operations::deallocateGPUMemory); | 21 - 5 files changed, 430 insertions(+), 55 deletions(-) create mode 100644 Testing/test_output.log delete mode 100644 tance().executeOperation(Operations::deallocateGPUMemory); diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index cf0d514ca..62dcd359f 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -35,7 +35,7 @@ GPUModel::GPUModel() : OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); // Register deleteSynapseImap function as a deallocateGPUMemory operation in the OperationManager - function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); + function deallocateGPUMemory = bind(&GPUModel::deleteDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, deallocateGPUMemory); } @@ -56,7 +56,17 @@ void GPUModel::allocDeviceStruct() void GPUModel::deleteDeviceStruct() { // Deallocate device memory - OperationManager::getInstance().executeOperation(Operations::deallocateGPUMemory); + EdgeIndexMapDevice synapseIMapDevice; + HANDLE_ERROR(cudaMemcpy(&synapseIMapDevice, synapseIndexMapDevice_, sizeof(EdgeIndexMapDevice), + cudaMemcpyDeviceToHost)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeBegin_)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeCount_)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeIndexMap_)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeBegin_)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeCount_)); + HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeIndexMap_)); + HANDLE_ERROR(cudaFree(synapseIndexMapDevice_)); + HANDLE_ERROR(cudaFree(randNoise_d)); } /// Sets up the Simulation. @@ -103,9 +113,9 @@ void GPUModel::setupSim() void GPUModel::finish() { // copy device synapse and neuron structs to host memory - copyGPUtoCPU(); + OperationManager::getInstance().executeOperation(Operations::copyFromGPU); // deallocates memories on CUDA device - deleteDeviceStruct(); + OperationManager::getInstance().executeOperation(Operations::deallocateGPUMemory); #ifdef PERFORMANCE_METRICS cudaEventDestroy(start); @@ -228,22 +238,6 @@ void GPUModel::allocSynapseImap(int count) cudaMemcpyHostToDevice)); } -/// Deallocate device memory for synapse inverse map. -void GPUModel::deleteSynapseImap() -{ - EdgeIndexMapDevice synapseIMapDevice; - HANDLE_ERROR(cudaMemcpy(&synapseIMapDevice, synapseIndexMapDevice_, sizeof(EdgeIndexMapDevice), - cudaMemcpyDeviceToHost)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeBegin_)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeCount_)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.outgoingEdgeIndexMap_)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeBegin_)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeCount_)); - HANDLE_ERROR(cudaFree(synapseIMapDevice.incomingEdgeIndexMap_)); - HANDLE_ERROR(cudaFree(synapseIndexMapDevice_)); - HANDLE_ERROR(cudaFree(randNoise_d)); -} - /// Calculate the sum of synaptic input to each neuron. /// /// Calculate the sum of synaptic input to each neuron. One thread @@ -296,13 +290,6 @@ __global__ void } } -/// Copy GPU Synapse data to CPU. -void GPUModel::copyGPUtoCPU() -{ - // copy device neuron and synapse structs to host memory - OperationManager::getInstance().executeOperation(Operations::copyFromGPU); -} - /// Allocate and Copy CPU Synapse data to GPU. void GPUModel::copyCPUtoGPU() { diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index eb470af01..24a145f64 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -93,12 +93,13 @@ class GPUModel : public Model { /// over the past epoch. Should be called once every epoch. virtual void updateConnections() override; - /// Copy GPU Neuron and Synapse data to CPU. - virtual void copyGPUtoCPU() override; - - /// Copy CPU Neuron and Synapse data to GPU. + /// Copy Synapse Map data to GPU. virtual void copyCPUtoGPU() override; + // GPUModel itself does not have anything to be copied back, this function is a + // dummy function just to make GPUModel non virtual + void copyGPUtoCPU() override {} + /// Print out SynapseProps on the GPU. void printGPUSynapsesPropsModel() const; @@ -135,8 +136,6 @@ class GPUModel : public Model { private: void allocSynapseImap(int count); - void deleteSynapseImap(); - private: void updateHistory(); diff --git a/Simulator/Core/Serializer.cpp b/Simulator/Core/Serializer.cpp index 3a6db2b5a..23b72a7f4 100644 --- a/Simulator/Core/Serializer.cpp +++ b/Simulator/Core/Serializer.cpp @@ -67,7 +67,7 @@ bool Serializer::deserialize() #if defined(USE_GPU) GPUModel &gpuModel = static_cast(simulator.getModel()); - gpuModel.copySynapseIndexMapHostToDevice(); + gpuModel.copyCPUtoGPU(); #endif // USE_GPU return true; diff --git a/Testing/test_output.log b/Testing/test_output.log new file mode 100644 index 000000000..5468f2646 --- /dev/null +++ b/Testing/test_output.log @@ -0,0 +1,410 @@ +nohup: ignoring input +============================================================================ +| GRAPHITTI BUILD | +============================================================================ + +----Generating Makefile for Graphitti GPU version---- +-- HDF5 version 1.10.4 located. HDF5 recorders are available. +-- Setting Optimization flag: O3 +-- Setting Compile Definition: TIMXL_USE_STL +-- Generating build for Log4cplus version 2.0.7 +-- Threads: -lpthread +-- Threads: -lpthread +-- Sources: loggingserver.cxx +-- Compiler: /usr/bin/c++ +-- GNU version 8.3.0 +-- Compiler flags: -O3 +-- System name: Linux +-- System version: 4.19.0-16-amd64 +-- Configuring done +-- Generating done +-- Build files have been written to: /home/NETID/shinjiku/issue828/Graphitti/build +[ 4%] Built target Core +[ 5%] Built target RNG +[ 14%] Built target Edges +[ 20%] Built target Connections +[ 21%] Built target FunctionNodes +[ 30%] Built target Vertices +[ 33%] Built target Matrix +[ 35%] Built target Recorders +[ 38%] Built target Utils +[ 39%] Built target Layouts +[ 40%] Built target paramcontainer +[ 47%] Built target TinyXPath +[ 68%] Built target log4cplus +[ 69%] Built target ggraphitti +[ 70%] Built target gtest +[ 71%] Built target gtest_main +[ 80%] Built target tests +[ 81%] Built target serialFileAccessTest +[ 82%] Built target loggingserver +[ 83%] Built target appender_test +[ 84%] Built target configandwatch_test +[ 85%] Built target customloglevel_test +[ 86%] Built target fileappender_test +[ 87%] Built target filter_test +[ 88%] Built target hierarchy_test +[ 89%] Built target loglog_test +[ 90%] Built target ndc_test +[ 91%] Built target ostream_test +[ 92%] Built target patternlayout_test +[ 92%] Built target performance_test +[ 94%] Built target priority_test +[ 95%] Built target propertyconfig_test +[ 96%] Built target thread_test +[ 97%] Built target timeformat_test +[ 98%] Built target unit_tests +[ 99%] Built target gmock +[100%] Built target gmock_main +============================================================================ +| UNIT TESTS | +============================================================================ +[INFO ][2025-05-06 00:02:48] Running Tests +[==========] Running 112 tests from 19 test suites. +[----------] Global test environment set-up. +[----------] 5 tests from OperationManager +[ RUN ] OperationManager.GetInstanceReturnsInstance +[ OK ] OperationManager.GetInstanceReturnsInstance (0 ms) +[ RUN ] OperationManager.AddingOneOperation +[ OK ] OperationManager.AddingOneOperation (0 ms) +[ RUN ] OperationManager.AddingManyOperations +[ OK ] OperationManager.AddingManyOperations (0 ms) +[ RUN ] OperationManager.OperationExecutionSuccess +[ OK ] OperationManager.OperationExecutionSuccess (0 ms) +[ RUN ] OperationManager.OperationExecutionContainsNoFunctionsOfOperationType +[ OK ] OperationManager.OperationExecutionContainsNoFunctionsOfOperationType (0 ms) +[----------] 5 tests from OperationManager (0 ms total) + +[----------] 3 tests from EdgeIndexMap +[ RUN ] EdgeIndexMap.DefaultConstructor +[ OK ] EdgeIndexMap.DefaultConstructor (0 ms) +[ RUN ] EdgeIndexMap.OverloadedConstructor +[ OK ] EdgeIndexMap.OverloadedConstructor (0 ms) +[ RUN ] EdgeIndexMap.ZeroValueConstructor +[ OK ] EdgeIndexMap.ZeroValueConstructor (0 ms) +[----------] 3 tests from EdgeIndexMap (0 ms total) + +[----------] 6 tests from SynapseIndexMapTestObject +[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseMapInitialiedSuccessfully +[ OK ] SynapseIndexMapTestObject.OutgoingSynapseMapInitialiedSuccessfully (0 ms) +[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseBeginInitialiedSuccessfully +[ OK ] SynapseIndexMapTestObject.OutgoingSynapseBeginInitialiedSuccessfully (0 ms) +[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseCountInitialiedSuccessfully +[ OK ] SynapseIndexMapTestObject.OutgoingSynapseCountInitialiedSuccessfully (0 ms) +[ RUN ] SynapseIndexMapTestObject.IncomingSynapseIndexMapInitialiedSuccessfully +[ OK ] SynapseIndexMapTestObject.IncomingSynapseIndexMapInitialiedSuccessfully (0 ms) +[ RUN ] SynapseIndexMapTestObject.IncomingSynapseBeginInitialiedSuccessfully +[ OK ] SynapseIndexMapTestObject.IncomingSynapseBeginInitialiedSuccessfully (0 ms) +[ RUN ] SynapseIndexMapTestObject.IncomingSynapseCountInitializedSuccessfully +[ OK ] SynapseIndexMapTestObject.IncomingSynapseCountInitializedSuccessfully (0 ms) +[----------] 6 tests from SynapseIndexMapTestObject (0 ms total) + +[----------] 1 test from GenericFunctionNode +[ RUN ] GenericFunctionNode.TemplateFunctionTest +[ OK ] GenericFunctionNode.TemplateFunctionTest (0 ms) +[----------] 1 test from GenericFunctionNode (0 ms total) + +[----------] 3 tests from Simulator +[ RUN ] Simulator.GetInstanceSuccess +[ OK ] Simulator.GetInstanceSuccess (0 ms) +[ RUN ] Simulator.PrintParameters +[ OK ] Simulator.PrintParameters (0 ms) +[ RUN ] Simulator.ParametersInitializedSuccessfully +[ OK ] Simulator.ParametersInitializedSuccessfully (3 ms) +[----------] 3 tests from Simulator (3 ms total) + +[----------] 5 tests from VerticesFactory +[ RUN ] VerticesFactory.GetInstanceReturnsInstance +[ OK ] VerticesFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] VerticesFactory.CreateAllLIFNeuronsInstance +[ OK ] VerticesFactory.CreateAllLIFNeuronsInstance (0 ms) +[ RUN ] VerticesFactory.CreateAllIZNeuronsInstance +[ OK ] VerticesFactory.CreateAllIZNeuronsInstance (0 ms) +[ RUN ] VerticesFactory.CreateAll911VerticesInstance +[ OK ] VerticesFactory.CreateAll911VerticesInstance (0 ms) +[ RUN ] VerticesFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] VerticesFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[----------] 5 tests from VerticesFactory (0 ms total) + +[----------] 5 tests from ConnectionsFactory +[ RUN ] ConnectionsFactory.GetInstanceReturnsInstance +[ OK ] ConnectionsFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] ConnectionsFactory.CreateConnstaticInstance +[ OK ] ConnectionsFactory.CreateConnstaticInstance (0 ms) +[ RUN ] ConnectionsFactory.CreateConnGrowthInstance +[ OK ] ConnectionsFactory.CreateConnGrowthInstance (0 ms) +[ RUN ] ConnectionsFactory.CreateConnections911Instance +[ OK ] ConnectionsFactory.CreateConnections911Instance (0 ms) +[ RUN ] ConnectionsFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] ConnectionsFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[----------] 5 tests from ConnectionsFactory (0 ms total) + +[----------] 7 tests from EdgesFactory +[ RUN ] EdgesFactory.GetInstanceReturnsInstance +[ OK ] EdgesFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] EdgesFactory.CreateAll911EdgesInstance +[ OK ] EdgesFactory.CreateAll911EdgesInstance (0 ms) +[ RUN ] EdgesFactory.CreateAllDSSynapsesInstance +[ OK ] EdgesFactory.CreateAllDSSynapsesInstance (0 ms) +[ RUN ] EdgesFactory.CreateAllDynamicSTDPSynapsesInstance +[ OK ] EdgesFactory.CreateAllDynamicSTDPSynapsesInstance (0 ms) +[ RUN ] EdgesFactory.CreateAllSTDPSynapsesInstance +[ OK ] EdgesFactory.CreateAllSTDPSynapsesInstance (0 ms) +[ RUN ] EdgesFactory.CreateAllSpikingSynapsesInstance +[ OK ] EdgesFactory.CreateAllSpikingSynapsesInstance (1 ms) +[ RUN ] EdgesFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] EdgesFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[----------] 7 tests from EdgesFactory (1 ms total) + +[----------] 4 tests from LayoutFactory +[ RUN ] LayoutFactory.GetInstanceReturnsInstance +[ OK ] LayoutFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] LayoutFactory.CreateLayoutNeuroInstance +[ OK ] LayoutFactory.CreateLayoutNeuroInstance (0 ms) +[ RUN ] LayoutFactory.CreateLayout911Instance +[ OK ] LayoutFactory.CreateLayout911Instance (0 ms) +[ RUN ] LayoutFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] LayoutFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[----------] 4 tests from LayoutFactory (0 ms total) + +[----------] 4 tests from RecorderFactory +[ RUN ] RecorderFactory.GetInstanceReturnsInstance +[ OK ] RecorderFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] RecorderFactory.CreateXml911RecorderInstance +[ OK ] RecorderFactory.CreateXml911RecorderInstance (0 ms) +[ RUN ] RecorderFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] RecorderFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[ RUN ] RecorderFactory.CreateHdf5RecorderInstance +[ OK ] RecorderFactory.CreateHdf5RecorderInstance (0 ms) +[----------] 4 tests from RecorderFactory (0 ms total) + +[----------] 9 tests from InputManagerFixture +[ RUN ] InputManagerFixture.queueFront +[ OK ] InputManagerFixture.queueFront (0 ms) +[ RUN ] InputManagerFixture.queueFrontException +[ OK ] InputManagerFixture.queueFrontException (0 ms) +[ RUN ] InputManagerFixture.getEpochEvents +[ OK ] InputManagerFixture.getEpochEvents (0 ms) +[ RUN ] InputManagerFixture.nonEmptyEventQueue +[ OK ] InputManagerFixture.nonEmptyEventQueue (1 ms) +[ RUN ] InputManagerFixture.emptyQueueAfterGettingEpochEvents +[ OK ] InputManagerFixture.emptyQueueAfterGettingEpochEvents (0 ms) +[ RUN ] InputManagerFixture.emptyQueueForMissingVertex +[ OK ] InputManagerFixture.emptyQueueForMissingVertex (0 ms) +[ RUN ] InputManagerFixture.queuePop +[ OK ] InputManagerFixture.queuePop (0 ms) +[ RUN ] InputManagerFixture.clockTickSize +[ OK ] InputManagerFixture.clockTickSize (0 ms) +[ RUN ] InputManagerFixture.clockTickUnit +[ OK ] InputManagerFixture.clockTickUnit (0 ms) +[----------] 9 tests from InputManagerFixture (1 ms total) + +[----------] 1 test from InputManager +[ RUN ] InputManager.readNeuroInputs +[ OK ] InputManager.readNeuroInputs (0 ms) +[----------] 1 test from InputManager (0 ms total) + +[----------] 4 tests from RNGFactory +[ RUN ] RNGFactory.GetInstanceReturnsInstance +[ OK ] RNGFactory.GetInstanceReturnsInstance (0 ms) +[ RUN ] RNGFactory.CreateMTRandInstance +[ OK ] RNGFactory.CreateMTRandInstance (0 ms) +[ RUN ] RNGFactory.CreateNormInstance +[ OK ] RNGFactory.CreateNormInstance (0 ms) +[ RUN ] RNGFactory.CreateNonExistentClassReturnsNullPtr +[ OK ] RNGFactory.CreateNonExistentClassReturnsNullPtr (0 ms) +[----------] 4 tests from RNGFactory (0 ms total) + +[----------] 10 tests from GraphManager +[ RUN ] GraphManager.GetInstanceReturnsInstance +[ OK ] GraphManager.GetInstanceReturnsInstance (0 ms) +[ RUN ] GraphManager.ReadGraphReturnsTrue +[ OK ] GraphManager.ReadGraphReturnsTrue (1 ms) +[ RUN ] GraphManager.NumVerticesReturnsEleven +[ OK ] GraphManager.NumVerticesReturnsEleven (0 ms) +[ RUN ] GraphManager.NumEdgesReturnsTwenty +[ OK ] GraphManager.NumEdgesReturnsTwenty (0 ms) +[ RUN ] GraphManager.GetVertcies +[ OK ] GraphManager.GetVertcies (0 ms) +[ RUN ] GraphManager.GetEdgesAndSource +[ OK ] GraphManager.GetEdgesAndSource (0 ms) +[ RUN ] GraphManager.GetEdgesAndTarget +[ OK ] GraphManager.GetEdgesAndTarget (0 ms) +[ RUN ] GraphManager.SortEdges +[ OK ] GraphManager.SortEdges (0 ms) +[ RUN ] GraphManager.ReadEmptyGraph +[ OK ] GraphManager.ReadEmptyGraph (0 ms) +[ RUN ] GraphManager.ReadNonExistentGraph +[ OK ] GraphManager.ReadNonExistentGraph (0 ms) +[----------] 10 tests from GraphManager (1 ms total) + +[----------] 16 tests from ParameterManager +[ RUN ] ParameterManager.GetInstanceReturnsInstance +[ OK ] ParameterManager.GetInstanceReturnsInstance (0 ms) +[ RUN ] ParameterManager.LoadingXMLFile +[ OK ] ParameterManager.LoadingXMLFile (0 ms) +[ RUN ] ParameterManager.LoadingMultipleValidXMLFiles +[ OK ] ParameterManager.LoadingMultipleValidXMLFiles (1 ms) +[ RUN ] ParameterManager.LoadingMultipleInvalidFiles +[ OK ] ParameterManager.LoadingMultipleInvalidFiles (0 ms) +[ RUN ] ParameterManager.ValidStringTargeting +[ OK ] ParameterManager.ValidStringTargeting (0 ms) +[ RUN ] ParameterManager.ValidIntTargeting +[ OK ] ParameterManager.ValidIntTargeting (2 ms) +[ RUN ] ParameterManager.InvalidIntTargeting +[ OK ] ParameterManager.InvalidIntTargeting (2 ms) +[ RUN ] ParameterManager.ValidFloatTargeting +[ OK ] ParameterManager.ValidFloatTargeting (1 ms) +[ RUN ] ParameterManager.InvalidFloatTargeting +[ OK ] ParameterManager.InvalidFloatTargeting (0 ms) +[ RUN ] ParameterManager.ValidDoubleTargeting +[ OK ] ParameterManager.ValidDoubleTargeting (0 ms) +[ RUN ] ParameterManager.InvalidDoubleTargeting +[ OK ] ParameterManager.InvalidDoubleTargeting (1 ms) +[ RUN ] ParameterManager.ValidBGFloatTargeting +[ OK ] ParameterManager.ValidBGFloatTargeting (0 ms) +[ RUN ] ParameterManager.InvalidBGFloatTargeting +[ OK ] ParameterManager.InvalidBGFloatTargeting (0 ms) +[ RUN ] ParameterManager.ValidLongTargeting +[ OK ] ParameterManager.ValidLongTargeting (1 ms) +[ RUN ] ParameterManager.InvalidLongTargeting +[ OK ] ParameterManager.InvalidLongTargeting (0 ms) +[ RUN ] ParameterManager.InvalidIntVectorTargeting +[ OK ] ParameterManager.InvalidIntVectorTargeting (0 ms) +[----------] 16 tests from ParameterManager (8 ms total) + +[----------] 10 tests from CircularBuffer +[ RUN ] CircularBuffer.Constructor +[ OK ] CircularBuffer.Constructor (0 ms) +[ RUN ] CircularBuffer.ConstructAndResize +[ OK ] CircularBuffer.ConstructAndResize (0 ms) +[ RUN ] CircularBuffer.Put +[ OK ] CircularBuffer.Put (0 ms) +[ RUN ] CircularBuffer.Get +[ OK ] CircularBuffer.Get (0 ms) +[ RUN ] CircularBuffer.GetWhenEmpty +[ OK ] CircularBuffer.GetWhenEmpty (0 ms) +[ RUN ] CircularBuffer.Clear +[ OK ] CircularBuffer.Clear (0 ms) +[ RUN ] CircularBuffer.IsEmpty +[ OK ] CircularBuffer.IsEmpty (0 ms) +[ RUN ] CircularBuffer.IsFull +[ OK ] CircularBuffer.IsFull (8 ms) +[ RUN ] CircularBuffer.Capacity +[ OK ] CircularBuffer.Capacity (29 ms) +[ RUN ] CircularBuffer.Size +[ OK ] CircularBuffer.Size (0 ms) +[----------] 10 tests from CircularBuffer (38 ms total) + +[----------] 4 tests from EventBufferTest +[ RUN ] EventBufferTest.GetElementFromEmptyBuffer +[ OK ] EventBufferTest.GetElementFromEmptyBuffer (0 ms) +[ RUN ] EventBufferTest.GetPastEventFromEmptyBuffer +[ OK ] EventBufferTest.GetPastEventFromEmptyBuffer (0 ms) +[ RUN ] EventBufferTest.InsertEventEmptyBuffer +[ OK ] EventBufferTest.InsertEventEmptyBuffer (0 ms) +[ RUN ] EventBufferTest.BufferWrapAround +[ OK ] EventBufferTest.BufferWrapAround (0 ms) +[----------] 4 tests from EventBufferTest (0 ms total) + +[----------] 9 tests from XmlRecorderTest +[ RUN ] XmlRecorderTest.CreateInstanceSuccess +[ OK ] XmlRecorderTest.CreateInstanceSuccess (0 ms) +[ RUN ] XmlRecorderTest.InitTest +[ OK ] XmlRecorderTest.InitTest (0 ms) +[ RUN ] XmlRecorderTest.RegisterVariableTest +[ OK ] XmlRecorderTest.RegisterVariableTest (0 ms) +[ RUN ] XmlRecorderTest.RegisterVectorMatrixTest +[ OK ] XmlRecorderTest.RegisterVectorMatrixTest (0 ms) +[ RUN ] XmlRecorderTest.RegisterRecordableVectorTest +[ OK ] XmlRecorderTest.RegisterRecordableVectorTest (1 ms) +[ RUN ] XmlRecorderTest.RegisterVectorVariableTest +[ OK ] XmlRecorderTest.RegisterVectorVariableTest (0 ms) +[ RUN ] XmlRecorderTest.CompileHistoriesTest +[ OK ] XmlRecorderTest.CompileHistoriesTest (0 ms) +[ RUN ] XmlRecorderTest.ToXML +[ OK ] XmlRecorderTest.ToXML (0 ms) +[ RUN ] XmlRecorderTest.SaveSimDataTest +[ OK ] XmlRecorderTest.SaveSimDataTest (0 ms) +[----------] 9 tests from XmlRecorderTest (1 ms total) + +[----------] 6 tests from Hdf5RecorderTest +[ RUN ] Hdf5RecorderTest.CreateInstanceSuccess +[ OK ] Hdf5RecorderTest.CreateInstanceSuccess (0 ms) +[ RUN ] Hdf5RecorderTest.Hdf5InitAndTermTest +[ OK ] Hdf5RecorderTest.Hdf5InitAndTermTest (1 ms) +[ RUN ] Hdf5RecorderTest.RegisterVariableTest +[ OK ] Hdf5RecorderTest.RegisterVariableTest (0 ms) +[ RUN ] Hdf5RecorderTest.RegisterVectorVariableTest +[ OK ] Hdf5RecorderTest.RegisterVectorVariableTest (0 ms) +[ RUN ] Hdf5RecorderTest.SaveSimDataTest +[ OK ] Hdf5RecorderTest.SaveSimDataTest (1 ms) +[ RUN ] Hdf5RecorderTest.CompileHistoriesTest +[ OK ] Hdf5RecorderTest.CompileHistoriesTest (0 ms) +[----------] 6 tests from Hdf5RecorderTest (2 ms total) + +[----------] Global test environment tear-down +[==========] 112 tests from 19 test suites ran. (55 ms total) +[ PASSED ] 112 tests. + +============================================================================ +| REGRESSION TESTS | +============================================================================ +Run simulations in parallel, using: ./ggraphitti +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-tiny.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-long.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected-long.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-long.xml +[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected-long.xml +[ RUN TEST ] Waiting for simulations to finish... +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath //SimParams/deltaT/text() +Failed loading simulation parameter for xpath Failed loading simulation parameter for xpath //SimParams/deltaT/text()//SimParams/deltaT/text() + + +[========] Start verification +[--------]Verifying test-tiny.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-tiny-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-tiny-out.xml +[ PASSED ] Are equal +[--------]Verifying test-small.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-out.xml +[ PASSED ] Are equal +[--------]Verifying test-small-connected.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-connected-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-connected-out.xml +[ PASSED ] Are equal +[--------]Verifying test-small-long.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-long-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-long-out.xml +[ PASSED ] Are equal +[--------]Verifying test-small-connected-long.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-connected-long-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-connected-long-out.xml +[ PASSED ] Are equal +[--------]Verifying test-medium.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-out.xml +[ PASSED ] Are equal +[--------]Verifying test-medium-connected.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-connected-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-connected-out.xml +[ PASSED ] Are equal +[--------]Verifying test-medium-long.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-long-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-long-out.xml +[ PASSED ] Are equal +[--------]Verifying test-medium-connected-long.xml simulation output... +[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-connected-long-out.xml +[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-connected-long-out.xml +[ PASSED ] Are equal diff --git a/tance().executeOperation(Operations::deallocateGPUMemory); b/tance().executeOperation(Operations::deallocateGPUMemory); deleted file mode 100644 index aa038ae74..000000000 --- a/tance().executeOperation(Operations::deallocateGPUMemory); +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp -index f160ef2f..534c899e 100644 ---- a/Simulator/Core/GPUModel.cpp -+++ b/Simulator/Core/GPUModel.cpp -@@ -26,7 +26,6 @@ GPUModel::GPUModel() : - Model::Model(), synapseIndexMapDevice_(nullptr), randNoise_d(nullptr), - allVerticesDevice_(nullptr), allEdgesDevice_(nullptr) - { --#if defined(USE_GPU) - // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager - function allocateGPU = bind(&GPUModel::allocDeviceStruct, this); - OperationManager::getInstance().registerOperation(Operations::allocateGPU, allocateGPU); -@@ -39,8 +38,6 @@ GPUModel::GPUModel() : - function deallocateGPUMemory = bind(&GPUModel::deleteSynapseImap, this); - OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, - deallocateGPUMemory); -- --#endif - } -  - /// Allocates and initializes memories on CUDA device. From 7f485918bc1a47d31d5c95d0b7dd74793969b96b Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 8 May 2025 12:49:44 -0700 Subject: [PATCH 24/26] auto fixing code format with clang format --- Simulator/Core/GPUModel.h | 8 +- Simulator/Core/Operations.h | 32 +- Simulator/Edges/Neuro/AllDSSynapses_d.cpp | 3 +- .../Edges/Neuro/AllDynamicSTDPSynapses_d.cpp | 3 +- Simulator/Edges/Neuro/AllNeuroEdges.cpp | 3 +- Simulator/Edges/Neuro/AllSTDPSynapses.cpp | 35 +- Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp | 3 +- Simulator/Edges/Neuro/AllSpikingSynapses.cpp | 15 +- .../Edges/Neuro/AllSpikingSynapses_d.cpp | 3 +- Simulator/Utils/Inputs/FSInput.cpp | 4 +- Simulator/Utils/Inputs/SInputPoisson.cpp | 3 +- Simulator/Vertices/AllVertices.cpp | 2 +- Testing/UnitTesting/XmlRecorderTests.cpp | 4 +- .../googlemock/include/gmock/gmock-actions.h | 68 +- .../include/gmock/gmock-cardinalities.h | 5 +- .../include/gmock/gmock-function-mocker.h | 7 +- .../include/gmock/gmock-generated-actions.h | 667 ++++++++++-------- .../googlemock/include/gmock/gmock-matchers.h | 351 +++++---- .../include/gmock/gmock-more-actions.h | 44 +- .../include/gmock/gmock-more-matchers.h | 12 +- .../include/gmock/gmock-nice-strict.h | 1 - .../include/gmock/gmock-spec-builders.h | 207 +++--- .../googlemock/include/gmock/gmock.h | 1 - .../gmock/internal/gmock-internal-utils.h | 79 ++- .../include/gmock/internal/gmock-port.h | 25 +- .../googlemock/test/gmock_link_test.h | 34 +- .../include/gtest/gtest-death-test.h | 77 +- .../googletest/include/gtest/gtest-matchers.h | 65 +- .../googletest/include/gtest/gtest-message.h | 20 +- .../include/gtest/gtest-param-test.h | 72 +- .../googletest/include/gtest/gtest-printers.h | 40 +- .../googletest/include/gtest/gtest-spi.h | 111 +-- .../include/gtest/gtest-test-part.h | 2 + .../include/gtest/gtest-typed-test.h | 68 +- .../googletest/include/gtest/gtest.h | 296 ++++---- .../include/gtest/gtest_pred_impl.h | 188 ++--- .../googletest/include/gtest/gtest_prod.h | 8 +- .../internal/gtest-death-test-internal.h | 54 +- .../include/gtest/internal/gtest-filepath.h | 11 +- .../include/gtest/internal/gtest-internal.h | 301 ++++---- .../include/gtest/internal/gtest-param-util.h | 117 ++- .../include/gtest/internal/gtest-port-arch.h | 94 +-- .../include/gtest/internal/gtest-port.h | 610 ++++++++-------- .../include/gtest/internal/gtest-string.h | 10 +- .../include/gtest/internal/gtest-type-util.h | 17 +- .../googletest/samples/prime_tables.h | 8 +- .../googletest/samples/sample2.h | 2 - .../googletest/samples/sample3-inl.h | 9 +- .../googletest/src/gtest-internal-inl.h | 71 +- .../test/googletest-param-test-test.h | 6 +- .../googletest/test/gtest-typed-test_test.h | 12 +- .../googletest/test/production.h | 1 + 52 files changed, 1896 insertions(+), 1993 deletions(-) diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index e4809cce0..460491d67 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -21,11 +21,11 @@ #pragma once -#include "OperationManager.h" #include "AllEdges.h" -#include "AllVertices.h" #include "AllSpikingNeurons.h" #include "AllSpikingSynapses.h" +#include "AllVertices.h" +#include "OperationManager.h" #ifdef VALIDATION_MODE #include @@ -89,7 +89,9 @@ class GPUModel : public Model { // GPUModel itself does not have anything to be copied back, this function is a // dummy function just to make GPUModel non virtual - virtual void copyGPUtoCPU() override {} + virtual void copyGPUtoCPU() override + { + } /// Print out EdgeProps on the GPU. void printGPUEdgesPropsModel() const; diff --git a/Simulator/Core/Operations.h b/Simulator/Core/Operations.h index 78fbf0149..ba3030421 100644 --- a/Simulator/Core/Operations.h +++ b/Simulator/Core/Operations.h @@ -7,20 +7,20 @@ * @ingroup Simulator/Core */ - #pragma once +#pragma once - enum class Operations { - /// Available operations the OperationManager can register and execute. - printParameters, - loadParameters, - registerGraphProperties, - setup, - serialize, - deserialize, - deallocateGPUMemory, // Make sure deallocate memory isn't called until all GPU memory is copied back. - restoreToDefault, // Not sure what this refers to. - copyToGPU, - copyFromGPU, - allocateGPU, - registerHistoryVariables - }; +enum class Operations { + /// Available operations the OperationManager can register and execute. + printParameters, + loadParameters, + registerGraphProperties, + setup, + serialize, + deserialize, + deallocateGPUMemory, // Make sure deallocate memory isn't called until all GPU memory is copied back. + restoreToDefault, // Not sure what this refers to. + copyToGPU, + copyFromGPU, + allocateGPU, + registerHistoryVariables +}; diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index c83ad31b4..535348816 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -325,7 +325,8 @@ void AllDSSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + cout << "GPU edge_counts:" + << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; } cout << "GPU totalSynapseCount:" << totalSynapseCountPrint << endl; diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 1204f34cf..2382ba4b9 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -380,7 +380,8 @@ void AllDynamicSTDPSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + cout << "GPU edge_counts:" + << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; } cout << "GPU totalSynapseCount:" << totalSynapseCountPrint << endl; diff --git a/Simulator/Edges/Neuro/AllNeuroEdges.cpp b/Simulator/Edges/Neuro/AllNeuroEdges.cpp index 5596bb840..e36464d51 100644 --- a/Simulator/Edges/Neuro/AllNeuroEdges.cpp +++ b/Simulator/Edges/Neuro/AllNeuroEdges.cpp @@ -114,7 +114,8 @@ void AllNeuroEdges::printSynapsesProps() const } for (int i = 0; i < countVertices_; i++) { - cout << "edge_counts:" << "vertex[" << i << "]" << edgeCounts_[i] << endl; + cout << "edge_counts:" + << "vertex[" << i << "]" << edgeCounts_[i] << endl; } cout << "totalEdgeCount:" << totalEdgeCount_ << endl; diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses.cpp index 1f227a35a..5c491ec0f 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.cpp @@ -118,18 +118,29 @@ void AllSTDPSynapses::printParameters() const { AllSpikingSynapses::printParameters(); - LOG4CPLUS_DEBUG( - edgeLogger_, - "\n\t---AllSTDPSynapses Parameters---" - << "\n\tEdges type: AllSTDPSynapses \n\n" - << "\tSTDP gap" << defaultSTDPgap_ << "\n\n\tTauspost value: [" << " I: " << tauspost_I_ - << ", " << " E: " << tauspost_E_ << "]" << "\n\n\tTauspre value: [" << " I: " << tauspre_I_ - << ", " << " E: " << tauspre_E_ << "]" << "\n\n\tTaupos value: [" << " I: " << taupos_I_ - << ", " << " E: " << taupos_E_ << "]" << "\n\n\tTau negvalue: [" << " I: " << tauneg_I_ - << ", " << " E: " << tauneg_E_ << "]" << "\n\n\tWex value: [" << " I: " << Wex_I_ << ", " - << " E: " << Wex_E_ << "]" << "\n\n\tAneg value: [" << " I: " << Aneg_I_ << ", " - << " E: " << Aneg_E_ << "]" << "\n\n\tApos value: [" << " I: " << Apos_I_ << ", " - << " E: " << Apos_E_ << "]" << endl); + LOG4CPLUS_DEBUG(edgeLogger_, "\n\t---AllSTDPSynapses Parameters---" + << "\n\tEdges type: AllSTDPSynapses \n\n" + << "\tSTDP gap" << defaultSTDPgap_ << "\n\n\tTauspost value: [" + << " I: " << tauspost_I_ << ", " + << " E: " << tauspost_E_ << "]" + << "\n\n\tTauspre value: [" + << " I: " << tauspre_I_ << ", " + << " E: " << tauspre_E_ << "]" + << "\n\n\tTaupos value: [" + << " I: " << taupos_I_ << ", " + << " E: " << taupos_E_ << "]" + << "\n\n\tTau negvalue: [" + << " I: " << tauneg_I_ << ", " + << " E: " << tauneg_E_ << "]" + << "\n\n\tWex value: [" + << " I: " << Wex_I_ << ", " + << " E: " << Wex_E_ << "]" + << "\n\n\tAneg value: [" + << " I: " << Aneg_I_ << ", " + << " E: " << Aneg_E_ << "]" + << "\n\n\tApos value: [" + << " I: " << Apos_I_ << ", " + << " E: " << Apos_E_ << "]" << endl); } /// Sets the data for Synapse to input's data. diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index 2d91d1f11..0a66875af 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -405,7 +405,8 @@ void AllSTDPSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const } } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + cout << "GPU edge_counts:" + << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; } cout << "GPU totalSynapseCount:" << totalSynapseCountPrint << endl; cout << "GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl; diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses.cpp index 0c7b54bb3..a9cfe63fa 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.cpp @@ -107,14 +107,17 @@ void AllSpikingSynapses::printParameters() const << endl << "\tEdges type: AllSpikingSynapses" << endl << endl); - LOG4CPLUS_DEBUG(edgeLogger_, "\n\tTau values: [" << " II: " << tau_II_ << "," << " IE: " - << tau_IE_ << "," << " EI: " << tau_EI_ << "," - << " EE: " << tau_EE_ << "]" << endl); + LOG4CPLUS_DEBUG(edgeLogger_, "\n\tTau values: [" + << " II: " << tau_II_ << "," + << " IE: " << tau_IE_ << "," + << " EI: " << tau_EI_ << "," + << " EE: " << tau_EE_ << "]" << endl); LOG4CPLUS_DEBUG(edgeLogger_, "\n\tDelay values: [" - << " II: " << delay_II_ << "," << " IE: " << delay_IE_ << "," - << " EI:" << delay_EI_ << "," << " EE: " << delay_EE_ << "]" - << endl); + << " II: " << delay_II_ << "," + << " IE: " << delay_IE_ << "," + << " EI:" << delay_EI_ << "," + << " EE: " << delay_EE_ << "]" << endl); } /// Sets the data for Synapse to input's data. diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index e6bb33be0..23c7c98cb 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -416,7 +416,8 @@ void AllSpikingSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const } } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + cout << "GPU edge_counts:" + << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; } cout << "GPU totalSynapseCount:" << totalSynapseCountPrint << endl; cout << "GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl; diff --git a/Simulator/Utils/Inputs/FSInput.cpp b/Simulator/Utils/Inputs/FSInput.cpp index 41dce1257..7d9e63c45 100644 --- a/Simulator/Utils/Inputs/FSInput.cpp +++ b/Simulator/Utils/Inputs/FSInput.cpp @@ -30,8 +30,8 @@ ISInput *FSInput::CreateInstance() // load stimulus input file TiXmlDocument siDoc(stimulusFileName.c_str()); if (!siDoc.LoadFile()) { - cerr << "Failed loading stimulus input file " << stimulusFileName << ":" << "\n\t" - << siDoc.ErrorDesc() << endl; + cerr << "Failed loading stimulus input file " << stimulusFileName << ":" + << "\n\t" << siDoc.ErrorDesc() << endl; cerr << " error: " << siDoc.ErrorRow() << ", " << siDoc.ErrorCol() << endl; return nullptr; } diff --git a/Simulator/Utils/Inputs/SInputPoisson.cpp b/Simulator/Utils/Inputs/SInputPoisson.cpp index 3878f7352..a9960da7c 100644 --- a/Simulator/Utils/Inputs/SInputPoisson.cpp +++ b/Simulator/Utils/Inputs/SInputPoisson.cpp @@ -67,7 +67,8 @@ SInputPoisson::SInputPoisson(TiXmlElement *parms) : TiXmlDocument simDoc(maskNListFileName.c_str()); if (!simDoc.LoadFile()) { cerr << "Failed loading positions of stimulus input mask neurons list file " - << maskNListFileName << ":" << "\n\t" << simDoc.ErrorDesc() << endl; + << maskNListFileName << ":" + << "\n\t" << simDoc.ErrorDesc() << endl; cerr << " error: " << simDoc.ErrorRow() << ", " << simDoc.ErrorCol() << endl; break; } diff --git a/Simulator/Vertices/AllVertices.cpp b/Simulator/Vertices/AllVertices.cpp index b45b3fcce..fbab0beaa 100644 --- a/Simulator/Vertices/AllVertices.cpp +++ b/Simulator/Vertices/AllVertices.cpp @@ -25,7 +25,7 @@ AllVertices::AllVertices() : size_(0) // Register registerHistoryVariables function as a registerHistoryVariables operation in the OperationManager function registerHistory = bind(&AllVertices::registerHistoryVariables, this); OperationManager::getInstance().registerOperation(Operations::registerHistoryVariables, - registerHistory); + registerHistory); #if defined(USE_GPU) // Register allocNeuronDeviceStruct function as a allocateGPU operation in the OperationManager diff --git a/Testing/UnitTesting/XmlRecorderTests.cpp b/Testing/UnitTesting/XmlRecorderTests.cpp index 1a39bab12..8f9bb1d66 100644 --- a/Testing/UnitTesting/XmlRecorderTests.cpp +++ b/Testing/UnitTesting/XmlRecorderTests.cpp @@ -199,7 +199,9 @@ TEST(XmlRecorderTest, ToXML) // Verify the expected XML output stringstream os; os << "" << endl; os << " "; diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-actions.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-actions.h index 4a154b078..437dc3933 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-actions.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-actions.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // The ACTION* family of macros can be used in a namespace scope to @@ -131,7 +130,7 @@ #define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #ifndef _WIN32_WCE -# include +#include #endif #include @@ -147,8 +146,8 @@ #include "gmock/internal/gmock-pp.h" #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4100) #endif namespace testing { @@ -196,9 +195,7 @@ class BuiltInDefaultValue { public: // This function returns true if and only if type T has a built-in default // value. - static bool Exists() { - return ::std::is_default_constructible::value; - } + static bool Exists() { return ::std::is_default_constructible::value; } static T Get() { return BuiltInDefaultValueGetter< @@ -227,11 +224,11 @@ class BuiltInDefaultValue { // The following specializations define the default values for // specific types we care about. #define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \ - template <> \ - class BuiltInDefaultValue { \ - public: \ - static bool Exists() { return true; } \ - static type Get() { return value; } \ + template <> \ + class BuiltInDefaultValue { \ + public: \ + static bool Exists() { return true; } \ + static type Get() { return value; } \ } GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT @@ -255,10 +252,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0); -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT +GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT +GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long long, 0); // NOLINT -GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0); // NOLINT +GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0); // NOLINT GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0); GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0); @@ -838,7 +835,7 @@ class ReturnRoundRobinAction { template T operator()(Args&&...) const { - return state_->Next(); + return state_->Next(); } private: @@ -861,7 +858,9 @@ class DoDefaultAction { // This template type conversion operator allows DoDefault() to be // used in any function. template - operator Action() const { return Action(); } // NOLINT + operator Action() const { + return Action(); + } // NOLINT }; // Implements the Assign action to set a given pointer referent to a @@ -889,8 +888,7 @@ template class SetErrnoAndReturnAction { public: SetErrnoAndReturnAction(int errno_value, T result) - : errno_(errno_value), - result_(result) {} + : errno_(errno_value), result_(result) {} template Result Perform(const ArgumentTuple& /* args */) const { errno = errno_; @@ -1001,8 +999,8 @@ class IgnoreResultAction { private: // Type OriginalFunction is the same as F except that its return // type is IgnoredValue. - typedef typename internal::Function::MakeResultIgnoredValue - OriginalFunction; + typedef + typename internal::Function::MakeResultIgnoredValue OriginalFunction; const Action action_; }; @@ -1019,12 +1017,12 @@ struct WithArgsAction { template operator Action() const { // NOLINT using TupleType = std::tuple; - Action::type...)> - converted(action); + Action::type...)> converted( + action); return [converted](Args... args) -> R { return converted.Perform(std::forward_as_tuple( - std::get(std::forward_as_tuple(std::forward(args)...))...)); + std::get(std::forward_as_tuple(std::forward(args)...))...)); }; } }; @@ -1106,8 +1104,8 @@ internal::DoAllAction::type...> DoAll( // multiple arguments. For convenience, we also provide // WithArgs(an_action) (defined below) as a synonym. template -internal::WithArgsAction::type, k> -WithArg(InnerAction&& action) { +internal::WithArgsAction::type, k> WithArg( + InnerAction&& action) { return {std::forward(action)}; } @@ -1126,8 +1124,8 @@ WithArgs(InnerAction&& action) { // argument. In other words, it adapts an action accepting no // argument to one that accepts (and ignores) arguments. template -internal::WithArgsAction::type> -WithoutArgs(InnerAction&& action) { +internal::WithArgsAction::type> WithoutArgs( + InnerAction&& action) { return {std::forward(action)}; } @@ -1213,7 +1211,7 @@ internal::SetArgumentPointeeAction SetArgumentPointee(T value) { // Creates an action that sets a pointer referent to a given value. template -PolymorphicAction > Assign(T1* ptr, T2 val) { +PolymorphicAction> Assign(T1* ptr, T2 val) { return MakePolymorphicAction(internal::AssignAction(ptr, val)); } @@ -1221,8 +1219,8 @@ PolymorphicAction > Assign(T1* ptr, T2 val) { // Creates an action that sets errno and returns the appropriate error. template -PolymorphicAction > -SetErrnoAndReturn(int errval, T result) { +PolymorphicAction> SetErrnoAndReturn( + int errval, T result) { return MakePolymorphicAction( internal::SetErrnoAndReturnAction(errval, result)); } @@ -1483,9 +1481,8 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { template \ template \ typename ::testing::internal::Function::Result \ - full_name::gmock_Impl< \ - F>::gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) \ - const + full_name::gmock_Impl< \ + F>::gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const } // namespace internal @@ -1552,8 +1549,7 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { } // namespace testing #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif - #endif // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-cardinalities.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-cardinalities.h index 46e01e102..a076734f7 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-cardinalities.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-cardinalities.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements some commonly used cardinalities. More @@ -40,8 +39,10 @@ #define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #include + #include #include // NOLINT + #include "gmock/internal/gmock-port.h" #include "gtest/gtest.h" @@ -116,7 +117,7 @@ class GTEST_API_ Cardinality { // cardinality, i.e. exceed the maximum number of allowed calls. bool IsOverSaturatedByCallCount(int call_count) const { return impl_->IsSaturatedByCallCount(call_count) && - !impl_->IsSatisfiedByCallCount(call_count); + !impl_->IsSatisfiedByCallCount(call_count); } // Describes self to an ostream diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-function-mocker.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-function-mocker.h index 317d6c2b7..729e54074 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-function-mocker.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-function-mocker.h @@ -136,8 +136,9 @@ using internal::FunctionMocker; _Signature)>::Result \ GMOCK_INTERNAL_EXPAND(_CallType) \ _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \ - GMOCK_PP_IF(_Constness, const, ) _NoexceptSpec \ - GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) { \ + GMOCK_PP_IF(_Constness, const, ) \ + _NoexceptSpec GMOCK_PP_IF(_Override, override, ) \ + GMOCK_PP_IF(_Final, final, ) { \ GMOCK_MOCKER_(_N, _Constness, _MethodName) \ .SetOwnerAndName(this, #_MethodName); \ return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ @@ -160,7 +161,7 @@ using internal::FunctionMocker; GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \ } \ mutable ::testing::FunctionMocker \ - GMOCK_MOCKER_(_N, _Constness, _MethodName) + GMOCK_MOCKER_(_N, _Constness, _MethodName) #define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__ diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-generated-actions.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-generated-actions.h index 7030a98e9..bc63df4a3 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-generated-actions.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-generated-actions.h @@ -31,7 +31,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements some commonly used variadic actions. @@ -47,7 +46,6 @@ #include "gmock/gmock-actions.h" #include "gmock/internal/gmock-port.h" - // Sometimes you want to give an action explicit template parameters // that cannot be inferred from its value parameters. ACTION() and // ACTION_P*() don't support that. ACTION_TEMPLATE() remedies that @@ -131,194 +129,272 @@ // Declares the template parameters. #define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0 -#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) kind0 name0, kind1 name1 +#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, name1) \ + kind0 name0, kind1 name1 #define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) kind0 name0, kind1 name1, kind2 name2 + kind2, name2) \ + kind0 name0, kind1 name1, kind2 name2 #define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3 -#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \ - kind2 name2, kind3 name3, kind4 name4 + kind2, name2, kind3, name3) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3 +#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4 #define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 -#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ - kind5 name5, kind6 name6 -#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \ - kind4 name4, kind5 name5, kind6 name6, kind7 name7 -#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \ - kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \ - kind8 name8 -#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \ - kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \ - kind6 name6, kind7 name7, kind8 name8, kind9 name9 + kind2, name2, kind3, name3, \ + kind4, name4, kind5, name5) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5 +#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ + kind5 name5, kind6 name6 +#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ + kind5 name5, kind6 name6, kind7 name7 +#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7, kind8, name8) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ + kind5 name5, kind6 name6, kind7 name7, kind8 name8 +#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \ + kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \ + kind5 name5, kind6 name6, kind7 name7, kind8 name8, kind9 name9 // Lists the template parameters. #define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0 -#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1) name0, name1 +#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, name1) \ + name0, name1 #define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2) name0, name1, name2 + kind2, name2) \ + name0, name1, name2 #define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3) name0, name1, name2, name3 -#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \ - name4 + kind2, name2, kind3, name3) \ + name0, name1, name2, name3 +#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4) \ + name0, name1, name2, name3, name4 #define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \ - name2, name3, name4, name5 -#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6) name0, name1, name2, name3, name4, name5, name6 -#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7 -#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \ - kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \ - kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \ - name6, name7, name8 -#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \ - name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \ - name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \ - name3, name4, name5, name6, name7, name8, name9 + kind2, name2, kind3, name3, \ + kind4, name4, kind5, name5) \ + name0, name1, name2, name3, name4, name5 +#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6) \ + name0, name1, name2, name3, name4, name5, name6 +#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7) \ + name0, name1, name2, name3, name4, name5, name6, name7 +#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7, kind8, name8) \ + name0, name1, name2, name3, name4, name5, name6, name7, name8 +#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS( \ + kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \ + kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \ + name0, name1, name2, name3, name4, name5, name6, name7, name8, name9 // Declares the types of value parameters. #define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS() #define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \ - typename p0##_type, typename p1##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \ - typename p0##_type, typename p1##_type, typename p2##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type -#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type +#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) \ + , typename p0##_type, typename p1##_type +#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \ + , typename p0##_type, typename p1##_type, typename p2##_type +#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type +#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type +#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type, typename p5##_type #define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type + p6) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type, typename p5##_type, \ + typename p6##_type #define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type + p6, p7) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type, typename p5##_type, \ + typename p6##_type, typename p7##_type #define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \ - typename p3##_type, typename p4##_type, typename p5##_type, \ - typename p6##_type, typename p7##_type, typename p8##_type + p6, p7, p8) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type, typename p5##_type, \ + typename p6##_type, typename p7##_type, typename p8##_type #define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \ - typename p2##_type, typename p3##_type, typename p4##_type, \ - typename p5##_type, typename p6##_type, typename p7##_type, \ - typename p8##_type, typename p9##_type + p6, p7, p8, p9) \ + , typename p0##_type, typename p1##_type, typename p2##_type, \ + typename p3##_type, typename p4##_type, typename p5##_type, \ + typename p6##_type, typename p7##_type, typename p8##_type, \ + typename p9##_type // Initializes the value parameters. -#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\ - () -#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\ - (p0##_type gmock_p0) : p0(::std::move(gmock_p0)) -#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\ - (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)) -#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\ - (p0##_type gmock_p0, p1##_type gmock_p1, \ - p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)) -#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ +#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS() () +#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0) \ + (p0##_type gmock_p0) : p0(::std::move(gmock_p0)) +#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1) \ + (p0##_type gmock_p0, p1##_type gmock_p1) \ + : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)) +#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)) +#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ p3(::std::move(gmock_p3)) -#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)) -#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, \ - p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ +#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)) +#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)), \ p5(::std::move(gmock_p5)) -#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)) -#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ +#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ + p6##_type gmock_p6) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)), \ + p5(::std::move(gmock_p5)), \ + p6(::std::move(gmock_p6)) +#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ + p6##_type gmock_p6, p7##_type gmock_p7) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)), \ + p5(::std::move(gmock_p5)), \ + p6(::std::move(gmock_p6)), \ p7(::std::move(gmock_p7)) -#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, \ - p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)) +#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \ + p8) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ + p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)), \ + p5(::std::move(gmock_p5)), \ + p6(::std::move(gmock_p6)), \ + p7(::std::move(gmock_p7)), \ + p8(::std::move(gmock_p8)) #define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9)\ - (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ - p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ - p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ - p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \ - p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \ - p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \ - p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \ - p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \ + p7, p8, p9) \ + (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \ + p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ + p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ + p9##_type gmock_p9) \ + : p0(::std::move(gmock_p0)), \ + p1(::std::move(gmock_p1)), \ + p2(::std::move(gmock_p2)), \ + p3(::std::move(gmock_p3)), \ + p4(::std::move(gmock_p4)), \ + p5(::std::move(gmock_p5)), \ + p6(::std::move(gmock_p6)), \ + p7(::std::move(gmock_p7)), \ + p8(::std::move(gmock_p8)), \ p9(::std::move(gmock_p9)) // Declares the fields for storing the value parameters. #define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS() #define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0; -#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \ - p1##_type p1; -#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \ - p1##_type p1; p2##_type p2; -#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \ - p1##_type p1; p2##_type p2; p3##_type p3; -#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; -#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; -#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; -#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \ - p5##_type p5; p6##_type p6; p7##_type p7; -#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; +#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) \ + p0##_type p0; \ + p1##_type p1; +#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; +#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; +#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; +#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; \ + p5##_type p5; +#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; \ + p5##_type p5; \ + p6##_type p6; +#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; \ + p5##_type p5; \ + p6##_type p6; \ + p7##_type p7; +#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \ + p8) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; \ + p5##_type p5; \ + p6##_type p6; \ + p7##_type p7; \ + p8##_type p8; #define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \ - p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \ - p9##_type p9; + p7, p8, p9) \ + p0##_type p0; \ + p1##_type p1; \ + p2##_type p2; \ + p3##_type p3; \ + p4##_type p4; \ + p5##_type p5; \ + p6##_type p6; \ + p7##_type p7; \ + p8##_type p8; \ + p9##_type p9; // Lists the value parameters. #define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS() @@ -326,72 +402,78 @@ #define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1 #define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2 #define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3 -#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \ - p2, p3, p4 -#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \ - p1, p2, p3, p4, p5 -#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0, p1, p2, p3, p4, p5, p6 -#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0, p1, p2, p3, p4, p5, p6, p7 -#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8 +#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + p0, p1, p2, p3, p4 +#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + p0, p1, p2, p3, p4, p5 +#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \ + p0, p1, p2, p3, p4, p5, p6 +#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \ + p0, p1, p2, p3, p4, p5, p6, p7 +#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \ + p8) \ + p0, p1, p2, p3, p4, p5, p6, p7, p8 #define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 + p7, p8, p9) \ + p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 // Lists the value parameter types. #define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS() #define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \ - p1##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \ - p1##_type, p2##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \ - p0##_type, p1##_type, p2##_type, p3##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type -#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \ - p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type +#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) \ + , p0##_type, p1##_type +#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \ + , p0##_type, p1##_type, p2##_type +#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \ + , p0##_type, p1##_type, p2##_type, p3##_type +#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type +#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type #define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ - p6##_type + p6) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_type #define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type + p6, p7) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ + p6##_type, p7##_type #define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type + p6, p7, p8) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ + p6##_type, p7##_type, p8##_type #define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \ - p5##_type, p6##_type, p7##_type, p8##_type, p9##_type + p6, p7, p8, p9) \ + , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \ + p6##_type, p7##_type, p8##_type, p9##_type // Declares the value parameters. #define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS() #define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0 -#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \ - p1##_type p1 -#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \ - p1##_type p1, p2##_type p2 -#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \ - p1##_type p1, p2##_type p2, p3##_type p3 -#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \ - p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 -#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \ - p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5 -#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \ - p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6 -#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ - p5##_type p5, p6##_type p6, p7##_type p7 -#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 +#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) \ + p0##_type p0, p1##_type p1 +#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) \ + p0##_type p0, p1##_type p1, p2##_type p2 +#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3 +#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4 +#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ + p5##_type p5 +#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ + p5##_type p5, p6##_type p6 +#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ + p5##_type p5, p6##_type p6, p7##_type p7 +#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \ + p8) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ + p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8 #define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \ - p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \ - p9##_type p9 + p7, p8, p9) \ + p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \ + p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, p9##_type p9 // The suffix of the class template implementing the action template. #define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS() @@ -403,79 +485,81 @@ #define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6 #define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7 #define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7) P8 + p7) \ + P8 #define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8) P9 + p7, p8) \ + P9 #define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \ - p7, p8, p9) P10 + p7, p8, p9) \ + P10 // The name of the class template implementing the action template. -#define GMOCK_ACTION_CLASS_(name, value_params)\ - GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) - -#define ACTION_TEMPLATE(name, template_params, value_params)\ - template \ - class GMOCK_ACTION_CLASS_(name, value_params) {\ - public:\ - explicit GMOCK_ACTION_CLASS_(name, value_params)\ - GMOCK_INTERNAL_INIT_##value_params {}\ - template \ - class gmock_Impl : public ::testing::ActionInterface {\ - public:\ - typedef F function_type;\ - typedef typename ::testing::internal::Function::Result return_type;\ - typedef typename ::testing::internal::Function::ArgumentTuple\ - args_type;\ - explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\ - return_type Perform(const args_type& args) override {\ - return ::testing::internal::ActionHelper::\ - Perform(this, args);\ - }\ - template \ - return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\ - GMOCK_INTERNAL_DEFN_##value_params\ - };\ - template operator ::testing::Action() const {\ - return ::testing::Action(\ - new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params));\ - }\ - GMOCK_INTERNAL_DEFN_##value_params\ - };\ - template \ - inline GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ - GMOCK_INTERNAL_DECL_##value_params) {\ - return GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ - GMOCK_INTERNAL_LIST_##value_params);\ - }\ - template \ - template \ - template \ - typename ::testing::internal::Function::Result\ - GMOCK_ACTION_CLASS_(name, value_params)<\ - GMOCK_INTERNAL_LIST_##template_params\ - GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::\ - gmock_PerformImpl(\ +#define GMOCK_ACTION_CLASS_(name, value_params) \ + GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params) + +#define ACTION_TEMPLATE(name, template_params, value_params) \ + template \ + class GMOCK_ACTION_CLASS_(name, value_params) { \ + public: \ + explicit GMOCK_ACTION_CLASS_(name, value_params) GMOCK_INTERNAL_INIT_ \ + ##value_params {} \ + template \ + class gmock_Impl : public ::testing::ActionInterface { \ + public: \ + typedef F function_type; \ + typedef typename ::testing::internal::Function::Result return_type; \ + typedef \ + typename ::testing::internal::Function::ArgumentTuple args_type; \ + explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {} \ + return_type Perform(const args_type& args) override { \ + return ::testing::internal::ActionHelper::Perform(this, \ + args); \ + } \ + template \ + return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \ + GMOCK_INTERNAL_DEFN_##value_params \ + }; \ + template \ + operator ::testing::Action() const { \ + return ::testing::Action( \ + new gmock_Impl(GMOCK_INTERNAL_LIST_##value_params)); \ + } \ + GMOCK_INTERNAL_DEFN_##value_params \ + }; \ + template \ + inline GMOCK_ACTION_CLASS_( \ + name, value_params) \ + name(GMOCK_INTERNAL_DECL_##value_params) { \ + return GMOCK_ACTION_CLASS_( \ + name, value_params)( \ + GMOCK_INTERNAL_LIST_##value_params); \ + } \ + template \ + template \ + template \ + typename ::testing::internal::Function::Result GMOCK_ACTION_CLASS_( \ + name, value_params):: \ + gmock_Impl::gmock_PerformImpl( \ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const - namespace testing { - // The ACTION*() macros trigger warning C4100 (unreferenced formal // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in // the macro definition, as the warnings are generated when the macro // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4100) #endif // Various overloads for InvokeArgument(). @@ -508,98 +592,87 @@ namespace testing { // InvokeArgument action from temporary values and have it performed // later. -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS()) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args)); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(p0)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_2_VALUE_PARAMS(p0, p1)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_3_VALUE_PARAMS(p0, p1, p2)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4, p5); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4, p5, p6); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7, - p8); + p8); } -ACTION_TEMPLATE(InvokeArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(InvokeArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { using internal::invoke_argument::InvokeArgumentAdl; return InvokeArgumentAdl(internal::invoke_argument::AdlTag(), ::std::get(args), p0, p1, p2, p3, p4, p5, p6, p7, - p8, p9); + p8, p9); } #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif } // namespace testing diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-matchers.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-matchers.h index dd59cc94d..5ee98e439 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-matchers.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-matchers.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // The MATCHER* family of macros can be used in a namespace scope to @@ -396,7 +395,7 @@ class MatcherCastImpl { // is already a Matcher. This only compiles when type T can be // statically converted to type U. template -class MatcherCastImpl > { +class MatcherCastImpl> { public: static Matcher Cast(const Matcher& source_matcher) { return Matcher(new Impl(source_matcher)); @@ -450,7 +449,7 @@ class MatcherCastImpl > { // This even more specialized version is used for efficiently casting // a matcher to its own type. template -class MatcherCastImpl > { +class MatcherCastImpl> { public: static Matcher Cast(const Matcher& matcher) { return matcher; } }; @@ -544,7 +543,7 @@ inline Matcher SafeMatcherCast(const Matcher& matcher) { constexpr bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther; GTEST_COMPILE_ASSERT_( kTIsOther || kUIsOther || - (internal::LosslessArithmeticConvertible::value), + (internal::LosslessArithmeticConvertible::value), conversion_of_arithmetic_types_must_be_lossless); return MatcherCast(matcher); } @@ -689,8 +688,7 @@ bool TupleMatches(const MatcherTuple& matcher_tuple, // is no failure, nothing will be streamed to os. template void ExplainMatchFailureTupleTo(const MatcherTuple& matchers, - const ValueTuple& values, - ::std::ostream* os) { + const ValueTuple& values, ::std::ostream* os) { TuplePrefix::value>::ExplainMatchFailuresTo( matchers, values, os); } @@ -714,14 +712,14 @@ class TransformTupleValuesHelper { private: template struct IterateOverTuple { - OutIter operator() (Func f, const Tup& t, OutIter out) const { + OutIter operator()(Func f, const Tup& t, OutIter out) const { *out++ = f(::std::get(t)); return IterateOverTuple()(f, t, out); } }; template struct IterateOverTuple { - OutIter operator() (Func /* f */, const Tup& /* t */, OutIter out) const { + OutIter operator()(Func /* f */, const Tup& /* t */, OutIter out) const { return out; } }; @@ -759,7 +757,9 @@ class AnyMatcherImpl : public MatcherInterface { class AnythingMatcher { public: template - operator Matcher() const { return A(); } + operator Matcher() const { + return A(); + } }; // Implements the polymorphic IsNull() matcher, which matches any raw or smart @@ -773,9 +773,7 @@ class IsNullMatcher { } void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "isn't NULL"; - } + void DescribeNegationTo(::std::ostream* os) const { *os << "isn't NULL"; } }; // Implements the polymorphic NotNull() matcher, which matches any raw or smart @@ -789,9 +787,7 @@ class NotNullMatcher { } void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "is NULL"; - } + void DescribeNegationTo(::std::ostream* os) const { *os << "is NULL"; } }; // Ref(variable) matches any argument that is a reference to @@ -877,8 +873,7 @@ inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs, // String comparison for narrow or wide strings that can have embedded NUL // characters. template -bool CaseInsensitiveStringEquals(const StringType& s1, - const StringType& s2) { +bool CaseInsensitiveStringEquals(const StringType& s1, const StringType& s2) { // Are the heads equal? if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) { return false; @@ -939,8 +934,8 @@ class StrEqualityMatcher { bool MatchAndExplain(const MatcheeStringType& s, MatchResultListener* /* listener */) const { const StringType s2(s); - const bool eq = case_sensitive_ ? s2 == string_ : - CaseInsensitiveStringEquals(s2, string_); + const bool eq = case_sensitive_ ? s2 == string_ + : CaseInsensitiveStringEquals(s2, string_); return expect_eq_ == eq; } @@ -1027,8 +1022,7 @@ class HasSubstrMatcher { template class StartsWithMatcher { public: - explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) { - } + explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {} #if GTEST_INTERNAL_HAS_STRING_VIEW bool MatchAndExplain(const internal::StringView& s, @@ -1059,7 +1053,7 @@ class StartsWithMatcher { MatchResultListener* /* listener */) const { const StringType& s2(s); return s2.length() >= prefix_.length() && - s2.substr(0, prefix_.length()) == prefix_; + s2.substr(0, prefix_.length()) == prefix_; } void DescribeTo(::std::ostream* os) const { @@ -1113,7 +1107,7 @@ class EndsWithMatcher { MatchResultListener* /* listener */) const { const StringType& s2(s); return s2.length() >= suffix_.length() && - s2.substr(s2.length() - suffix_.length()) == suffix_; + s2.substr(s2.length() - suffix_.length()) == suffix_; } void DescribeTo(::std::ostream* os) const { @@ -1203,8 +1197,7 @@ class Ge2Matcher : public PairMatchBase { template class NotMatcherImpl : public MatcherInterface { public: - explicit NotMatcherImpl(const Matcher& matcher) - : matcher_(matcher) {} + explicit NotMatcherImpl(const Matcher& matcher) : matcher_(matcher) {} bool MatchAndExplain(const T& x, MatchResultListener* listener) const override { @@ -1248,7 +1241,7 @@ class NotMatcher { template class AllOfMatcherImpl : public MatcherInterface { public: - explicit AllOfMatcherImpl(std::vector > matchers) + explicit AllOfMatcherImpl(std::vector> matchers) : matchers_(std::move(matchers)) {} void DescribeTo(::std::ostream* os) const override { @@ -1299,7 +1292,7 @@ class AllOfMatcherImpl : public MatcherInterface { } private: - const std::vector > matchers_; + const std::vector> matchers_; }; // VariadicMatcher is used for the variadic implementation of @@ -1322,14 +1315,14 @@ class VariadicMatcher { // all of the provided matchers (Matcher1, Matcher2, ...) can match. template operator Matcher() const { - std::vector > values; + std::vector> values; CreateVariadicMatcher(&values, std::integral_constant()); return Matcher(new CombiningMatcher(std::move(values))); } private: template - void CreateVariadicMatcher(std::vector >* values, + void CreateVariadicMatcher(std::vector>* values, std::integral_constant) const { values->push_back(SafeMatcherCast(std::get(matchers_))); CreateVariadicMatcher(values, std::integral_constant()); @@ -1337,7 +1330,7 @@ class VariadicMatcher { template void CreateVariadicMatcher( - std::vector >*, + std::vector>*, std::integral_constant) const {} std::tuple matchers_; @@ -1353,7 +1346,7 @@ using AllOfMatcher = VariadicMatcher; template class AnyOfMatcherImpl : public MatcherInterface { public: - explicit AnyOfMatcherImpl(std::vector > matchers) + explicit AnyOfMatcherImpl(std::vector> matchers) : matchers_(std::move(matchers)) {} void DescribeTo(::std::ostream* os) const override { @@ -1404,7 +1397,7 @@ class AnyOfMatcherImpl : public MatcherInterface { } private: - const std::vector > matchers_; + const std::vector> matchers_; }; // AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...). @@ -1460,8 +1453,7 @@ class TrulyMatcher { // We cannot write 'return !!predicate_(x);' as that doesn't work // when predicate_(x) returns a class convertible to bool but // having no operator!(). - if (predicate_(x)) - return true; + if (predicate_(x)) return true; return false; } @@ -1568,8 +1560,8 @@ class PredicateFormatterFromMatcher { // used for implementing ASSERT_THAT() and EXPECT_THAT(). // Implementation detail: 'matcher' is received by-value to force decaying. template -inline PredicateFormatterFromMatcher -MakePredicateFormatterFromMatcher(M matcher) { +inline PredicateFormatterFromMatcher MakePredicateFormatterFromMatcher( + M matcher) { return PredicateFormatterFromMatcher(std::move(matcher)); } @@ -1584,9 +1576,7 @@ class IsNanMatcher { } void DescribeTo(::std::ostream* os) const { *os << "is NaN"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "isn't NaN"; - } + void DescribeNegationTo(::std::ostream* os) const { *os << "isn't NaN"; } }; // Implements the polymorphic floating point equality matcher, which matches @@ -1602,9 +1592,8 @@ class FloatingEqMatcher { // equality comparisons between NANs will always return false. We specify a // negative max_abs_error_ term to indicate that ULP-based approximation will // be used for comparison. - FloatingEqMatcher(FloatType expected, bool nan_eq_nan) : - expected_(expected), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) { - } + FloatingEqMatcher(FloatType expected, bool nan_eq_nan) + : expected_(expected), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {} // Constructor that supports a user-specified max_abs_error that will be used // for comparison instead of ULP-based approximation. The max absolute @@ -1666,8 +1655,8 @@ class FloatingEqMatcher { // os->precision() returns the previously set precision, which we // store to restore the ostream to its original configuration // after outputting. - const ::std::streamsize old_precision = os->precision( - ::std::numeric_limits::digits10 + 2); + const ::std::streamsize old_precision = + os->precision(::std::numeric_limits::digits10 + 2); if (FloatingPoint(expected_).is_nan()) { if (nan_eq_nan_) { *os << "is NaN"; @@ -1685,8 +1674,8 @@ class FloatingEqMatcher { void DescribeNegationTo(::std::ostream* os) const override { // As before, get original precision. - const ::std::streamsize old_precision = os->precision( - ::std::numeric_limits::digits10 + 2); + const ::std::streamsize old_precision = + os->precision(::std::numeric_limits::digits10 + 2); if (FloatingPoint(expected_).is_nan()) { if (nan_eq_nan_) { *os << "isn't NaN"; @@ -1704,9 +1693,7 @@ class FloatingEqMatcher { } private: - bool HasMaxAbsError() const { - return max_abs_error_ >= 0; - } + bool HasMaxAbsError() const { return max_abs_error_ >= 0; } const FloatType expected_; const bool nan_eq_nan_; @@ -1781,9 +1768,8 @@ class FloatingEq2Matcher { template class Impl : public MatcherInterface { public: - Impl(FloatType max_abs_error, bool nan_eq_nan) : - max_abs_error_(max_abs_error), - nan_eq_nan_(nan_eq_nan) {} + Impl(FloatType max_abs_error, bool nan_eq_nan) + : max_abs_error_(max_abs_error), nan_eq_nan_(nan_eq_nan) {} bool MatchAndExplain(Tuple args, MatchResultListener* listener) const override { @@ -1900,9 +1886,7 @@ class WhenDynamicCastToMatcherBase { protected: const Matcher matcher_; - static std::string GetToName() { - return GetTypeName(); - } + static std::string GetToName() { return GetTypeName(); } private: static void GetCastTypeDescription(::std::ostream* os) { @@ -2039,7 +2023,7 @@ class PropertyMatcher { } template - bool MatchAndExplain(const T&value, MatchResultListener* listener) const { + bool MatchAndExplain(const T& value, MatchResultListener* listener) const { return MatchAndExplainImpl( typename std::is_pointer::type>::type(), value, listener); @@ -2091,16 +2075,16 @@ struct CallableTraits { // Specialization for function pointers. template -struct CallableTraits { +struct CallableTraits { typedef ResType ResultType; - typedef ResType(*StorageType)(ArgType); + typedef ResType (*StorageType)(ArgType); - static void CheckIsValid(ResType(*f)(ArgType)) { + static void CheckIsValid(ResType (*f)(ArgType)) { GTEST_CHECK_(f != nullptr) << "NULL function pointer is passed into ResultOf()."; } template - static ResType Invoke(ResType(*f)(ArgType), T arg) { + static ResType Invoke(ResType (*f)(ArgType), T arg) { return (*f)(arg); } }; @@ -2173,8 +2157,7 @@ template class SizeIsMatcher { public: explicit SizeIsMatcher(const SizeMatcher& size_matcher) - : size_matcher_(size_matcher) { - } + : size_matcher_(size_matcher) {} template operator Matcher() const { @@ -2202,8 +2185,8 @@ class SizeIsMatcher { SizeType size = container.size(); StringMatchResultListener size_listener; const bool result = size_matcher_.MatchAndExplain(size, &size_listener); - *listener - << "whose size " << size << (result ? " matches" : " doesn't match"); + *listener << "whose size " << size + << (result ? " matches" : " doesn't match"); PrintIfNotEmpty(size_listener.str(), listener->stream()); return result; } @@ -2232,8 +2215,9 @@ class BeginEndDistanceIsMatcher { template class Impl : public MatcherInterface { public: - typedef internal::StlContainerView< - GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView; + typedef internal::StlContainerView + ContainerView; typedef typename std::iterator_traits< typename ContainerView::type::const_iterator>::difference_type DistanceType; @@ -2315,8 +2299,7 @@ class ContainerEqMatcher { LhsView; typedef typename LhsView::type LhsStlContainer; StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); - if (lhs_stl_container == expected_) - return true; + if (lhs_stl_container == expected_) return true; ::std::ostream* const os = listener->stream(); if (os != nullptr) { @@ -2341,9 +2324,9 @@ class ContainerEqMatcher { bool printed_header2 = false; for (typename StlContainer::const_iterator it = expected_.begin(); it != expected_.end(); ++it) { - if (internal::ArrayAwareFind( - lhs_stl_container.begin(), lhs_stl_container.end(), *it) == - lhs_stl_container.end()) { + if (internal::ArrayAwareFind(lhs_stl_container.begin(), + lhs_stl_container.end(), + *it) == lhs_stl_container.end()) { if (printed_header2) { *os << ", "; } else { @@ -2366,7 +2349,9 @@ class ContainerEqMatcher { // A comparator functor that uses the < operator to compare two values. struct LessComparator { template - bool operator()(const T& lhs, const U& rhs) const { return lhs < rhs; } + bool operator()(const T& lhs, const U& rhs) const { + return lhs < rhs; + } }; // Implements WhenSortedBy(comparator, container_matcher). @@ -2385,14 +2370,16 @@ class WhenSortedByMatcher { template class Impl : public MatcherInterface { public: - typedef internal::StlContainerView< - GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView; + typedef internal::StlContainerView + LhsView; typedef typename LhsView::type LhsStlContainer; typedef typename LhsView::const_reference LhsStlContainerReference; // Transforms std::pair into std::pair // so that we can match associative containers. - typedef typename RemoveConstFromKey< - typename LhsStlContainer::value_type>::type LhsValue; + typedef + typename RemoveConstFromKey::type + LhsValue; Impl(const Comparator& comparator, const ContainerMatcher& matcher) : comparator_(comparator), matcher_(matcher) {} @@ -2412,8 +2399,8 @@ class WhenSortedByMatcher { LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); ::std::vector sorted_container(lhs_stl_container.begin(), lhs_stl_container.end()); - ::std::sort( - sorted_container.begin(), sorted_container.end(), comparator_); + ::std::sort(sorted_container.begin(), sorted_container.end(), + comparator_); if (!listener->IsInterested()) { // If the listener is not interested, we do not need to @@ -2426,8 +2413,8 @@ class WhenSortedByMatcher { *listener << " when sorted"; StringMatchResultListener inner_listener; - const bool match = matcher_.MatchAndExplain(sorted_container, - &inner_listener); + const bool match = + matcher_.MatchAndExplain(sorted_container, &inner_listener); PrintIfNotEmpty(inner_listener.str(), listener->stream()); return match; } @@ -2482,8 +2469,9 @@ class PointwiseMatcher { template class Impl : public MatcherInterface { public: - typedef internal::StlContainerView< - GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView; + typedef internal::StlContainerView + LhsView; typedef typename LhsView::type LhsStlContainer; typedef typename LhsView::const_reference LhsStlContainerReference; typedef typename LhsStlContainer::value_type LhsValue; @@ -2577,13 +2565,12 @@ class QuantifierMatcherImpl : public MatcherInterface { template explicit QuantifierMatcherImpl(InnerMatcher inner_matcher) : inner_matcher_( - testing::SafeMatcherCast(inner_matcher)) {} + testing::SafeMatcherCast(inner_matcher)) {} // Checks whether: // * All elements in the container match, if all_elements_should_match. // * Any element in the container matches, if !all_elements_should_match. - bool MatchAndExplainImpl(bool all_elements_should_match, - Container container, + bool MatchAndExplainImpl(bool all_elements_should_match, Container container, MatchResultListener* listener) const { StlContainerReference stl_container = View::ConstReference(container); size_t i = 0; @@ -2727,8 +2714,7 @@ class KeyMatcherImpl : public MatcherInterface { template explicit KeyMatcherImpl(InnerMatcher inner_matcher) : inner_matcher_( - testing::SafeMatcherCast(inner_matcher)) { - } + testing::SafeMatcherCast(inner_matcher)) {} // Returns true if and only if 'key_value.first' (the key) matches the inner // matcher. @@ -2790,8 +2776,7 @@ class PairMatcherImpl : public MatcherInterface { : first_matcher_( testing::SafeMatcherCast(first_matcher)), second_matcher_( - testing::SafeMatcherCast(second_matcher)) { - } + testing::SafeMatcherCast(second_matcher)) {} // Describes what this matcher does. void DescribeTo(::std::ostream* os) const override { @@ -2869,7 +2854,7 @@ class PairMatcher { : first_matcher_(first_matcher), second_matcher_(second_matcher) {} template - operator Matcher () const { + operator Matcher() const { return Matcher( new PairMatcherImpl(first_matcher_, second_matcher_)); } @@ -3021,7 +3006,7 @@ class ElementsAreMatcherImpl : public MatcherInterface { size_t count() const { return matchers_.size(); } - ::std::vector > matchers_; + ::std::vector> matchers_; }; // Connectivity matrix of (elements X matchers), in element-major order. @@ -3033,8 +3018,7 @@ class GTEST_API_ MatchMatrix { MatchMatrix(size_t num_elements, size_t num_matchers) : num_elements_(num_elements), num_matchers_(num_matchers), - matched_(num_elements_* num_matchers_, 0) { - } + matched_(num_elements_ * num_matchers_, 0) {} size_t LhsSize() const { return num_elements_; } size_t RhsSize() const { return num_matchers_; } @@ -3073,8 +3057,7 @@ typedef ::std::vector ElementMatcherPairs; // Returns a maximum bipartite matching for the specified graph 'g'. // The matching is represented as a vector of {element, matcher} pairs. -GTEST_API_ ElementMatcherPairs -FindMaxBipartiteMatching(const MatchMatrix& g); +GTEST_API_ ElementMatcherPairs FindMaxBipartiteMatching(const MatchMatrix& g); struct UnorderedMatcherRequire { enum Flags { @@ -3111,9 +3094,7 @@ class GTEST_API_ UnorderedElementsAreMatcherImplBase { bool FindPairing(const MatchMatrix& matrix, MatchResultListener* listener) const; - MatcherDescriberVec& matcher_describers() { - return matcher_describers_; - } + MatcherDescriberVec& matcher_describers() { return matcher_describers_; } static Message Elements(size_t n) { return Message() << n << " element" << (n == 1 ? "" : "s"); @@ -3218,7 +3199,7 @@ class UnorderedElementsAreMatcherImpl return matrix; } - ::std::vector > matchers_; + ::std::vector> matchers_; }; // Functor for use in TransformTuple. @@ -3243,7 +3224,7 @@ class UnorderedElementsAreMatcher { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView::type View; typedef typename View::value_type Element; - typedef ::std::vector > MatcherVec; + typedef ::std::vector> MatcherVec; MatcherVec matchers; matchers.reserve(::std::tuple_size::value); TransformTupleValues(CastAndAppendTransform(), matchers_, @@ -3274,7 +3255,7 @@ class ElementsAreMatcher { typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer; typedef typename internal::StlContainerView::type View; typedef typename View::value_type Element; - typedef ::std::vector > MatcherVec; + typedef ::std::vector> MatcherVec; MatcherVec matchers; matchers.reserve(::std::tuple_size::value); TransformTupleValues(CastAndAppendTransform(), matchers_, @@ -3688,8 +3669,8 @@ ElementsAreArray(Iter first, Iter last) { } template -inline internal::ElementsAreArrayMatcher ElementsAreArray( - const T* pointer, size_t count) { +inline internal::ElementsAreArrayMatcher ElementsAreArray(const T* pointer, + size_t count) { return ElementsAreArray(pointer, pointer + count); } @@ -3706,8 +3687,8 @@ ElementsAreArray(const Container& container) { } template -inline internal::ElementsAreArrayMatcher -ElementsAreArray(::std::initializer_list xs) { +inline internal::ElementsAreArrayMatcher ElementsAreArray( + ::std::initializer_list xs) { return ElementsAreArray(xs.begin(), xs.end()); } @@ -3734,14 +3715,14 @@ UnorderedElementsAreArray(Iter first, Iter last) { } template -inline internal::UnorderedElementsAreArrayMatcher -UnorderedElementsAreArray(const T* pointer, size_t count) { +inline internal::UnorderedElementsAreArrayMatcher UnorderedElementsAreArray( + const T* pointer, size_t count) { return UnorderedElementsAreArray(pointer, pointer + count); } template -inline internal::UnorderedElementsAreArrayMatcher -UnorderedElementsAreArray(const T (&array)[N]) { +inline internal::UnorderedElementsAreArrayMatcher UnorderedElementsAreArray( + const T (&array)[N]) { return UnorderedElementsAreArray(array, N); } @@ -3753,8 +3734,8 @@ UnorderedElementsAreArray(const Container& container) { } template -inline internal::UnorderedElementsAreArrayMatcher -UnorderedElementsAreArray(::std::initializer_list xs) { +inline internal::UnorderedElementsAreArrayMatcher UnorderedElementsAreArray( + ::std::initializer_list xs) { return UnorderedElementsAreArray(xs.begin(), xs.end()); } @@ -3776,7 +3757,9 @@ inline Matcher A() { // Creates a matcher that matches any value of the given type T. template -inline Matcher An() { return A(); } +inline Matcher An() { + return A(); +} template Matcher internal::MatcherCastImpl::CastImpl( @@ -3786,14 +3769,14 @@ Matcher internal::MatcherCastImpl::CastImpl( } // Creates a polymorphic matcher that matches any NULL pointer. -inline PolymorphicMatcher IsNull() { +inline PolymorphicMatcher IsNull() { return MakePolymorphicMatcher(internal::IsNullMatcher()); } // Creates a polymorphic matcher that matches any non-NULL pointer. // This is convenient as Not(NULL) doesn't compile (the compiler // thinks that that expression is comparing a pointer with an integer). -inline PolymorphicMatcher NotNull() { +inline PolymorphicMatcher NotNull() { return MakePolymorphicMatcher(internal::NotNullMatcher()); } @@ -3824,8 +3807,8 @@ inline internal::FloatingEqMatcher NanSensitiveDoubleEq(double rhs) { // Creates a matcher that matches any double argument approximately equal to // rhs, up to the specified max absolute error bound, where two NANs are // considered unequal. The max absolute error bound must be non-negative. -inline internal::FloatingEqMatcher DoubleNear( - double rhs, double max_abs_error) { +inline internal::FloatingEqMatcher DoubleNear(double rhs, + double max_abs_error) { return internal::FloatingEqMatcher(rhs, false, max_abs_error); } @@ -3852,8 +3835,8 @@ inline internal::FloatingEqMatcher NanSensitiveFloatEq(float rhs) { // Creates a matcher that matches any float argument approximately equal to // rhs, up to the specified max absolute error bound, where two NANs are // considered unequal. The max absolute error bound must be non-negative. -inline internal::FloatingEqMatcher FloatNear( - float rhs, float max_abs_error) { +inline internal::FloatingEqMatcher FloatNear(float rhs, + float max_abs_error) { return internal::FloatingEqMatcher(rhs, false, max_abs_error); } @@ -3881,7 +3864,7 @@ inline internal::PointeeMatcher Pointee( // If To is a reference and the cast fails, this matcher returns false // immediately. template -inline PolymorphicMatcher > +inline PolymorphicMatcher> WhenDynamicCastTo(const Matcher& inner_matcher) { return MakePolymorphicMatcher( internal::WhenDynamicCastToMatcher(inner_matcher)); @@ -3893,12 +3876,10 @@ WhenDynamicCastTo(const Matcher& inner_matcher) { // Field(&Foo::number, Ge(5)) // matches a Foo object x if and only if x.number >= 5. template -inline PolymorphicMatcher< - internal::FieldMatcher > Field( +inline PolymorphicMatcher> Field( FieldType Class::*field, const FieldMatcher& matcher) { - return MakePolymorphicMatcher( - internal::FieldMatcher( - field, MatcherCast(matcher))); + return MakePolymorphicMatcher(internal::FieldMatcher( + field, MatcherCast(matcher))); // The call to MatcherCast() is required for supporting inner // matchers of compatible types. For example, it allows // Field(&Foo::bar, m) @@ -3908,7 +3889,7 @@ inline PolymorphicMatcher< // Same as Field() but also takes the name of the field to provide better error // messages. template -inline PolymorphicMatcher > Field( +inline PolymorphicMatcher> Field( const std::string& field_name, FieldType Class::*field, const FieldMatcher& matcher) { return MakePolymorphicMatcher(internal::FieldMatcher( @@ -3921,7 +3902,7 @@ inline PolymorphicMatcher > Field( // matches a Foo object x if and only if x.str() starts with "hi". template inline PolymorphicMatcher > + Class, PropertyType, PropertyType (Class::*)() const>> Property(PropertyType (Class::*property)() const, const PropertyMatcher& matcher) { return MakePolymorphicMatcher( @@ -3938,7 +3919,7 @@ Property(PropertyType (Class::*property)() const, // better error messages. template inline PolymorphicMatcher > + Class, PropertyType, PropertyType (Class::*)() const>> Property(const std::string& property_name, PropertyType (Class::*property)() const, const PropertyMatcher& matcher) { @@ -3951,8 +3932,8 @@ Property(const std::string& property_name, // The same as above but for reference-qualified member functions. template inline PolymorphicMatcher > -Property(PropertyType (Class::*property)() const &, + Class, PropertyType, PropertyType (Class::*)() const&>> +Property(PropertyType (Class::*property)() const&, const PropertyMatcher& matcher) { return MakePolymorphicMatcher( internal::PropertyMatcher inline PolymorphicMatcher > + Class, PropertyType, PropertyType (Class::*)() const&>> Property(const std::string& property_name, - PropertyType (Class::*property)() const &, + PropertyType (Class::*property)() const&, const PropertyMatcher& matcher) { return MakePolymorphicMatcher( internal::PropertyMatcher internal::ResultOfMatcher ResultOf( Callable callable, InnerMatcher matcher) { - return internal::ResultOfMatcher( - std::move(callable), std::move(matcher)); + return internal::ResultOfMatcher(std::move(callable), + std::move(matcher)); } // String matchers. // Matches a string equal to str. template -PolymorphicMatcher > StrEq( +PolymorphicMatcher> StrEq( const internal::StringLike& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(std::string(str), true, true)); @@ -4000,7 +3981,7 @@ PolymorphicMatcher > StrEq( // Matches a string not equal to str. template -PolymorphicMatcher > StrNe( +PolymorphicMatcher> StrNe( const internal::StringLike& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(std::string(str), false, true)); @@ -4008,7 +3989,7 @@ PolymorphicMatcher > StrNe( // Matches a string equal to str, ignoring case. template -PolymorphicMatcher > StrCaseEq( +PolymorphicMatcher> StrCaseEq( const internal::StringLike& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(std::string(str), true, false)); @@ -4016,7 +3997,7 @@ PolymorphicMatcher > StrCaseEq( // Matches a string not equal to str, ignoring case. template -PolymorphicMatcher > StrCaseNe( +PolymorphicMatcher> StrCaseNe( const internal::StringLike& str) { return MakePolymorphicMatcher(internal::StrEqualityMatcher( std::string(str), false, false)); @@ -4025,7 +4006,7 @@ PolymorphicMatcher > StrCaseNe( // Creates a matcher that matches any string, std::string, or C string // that contains the given substring. template -PolymorphicMatcher > HasSubstr( +PolymorphicMatcher> HasSubstr( const internal::StringLike& substring) { return MakePolymorphicMatcher( internal::HasSubstrMatcher(std::string(substring))); @@ -4033,7 +4014,7 @@ PolymorphicMatcher > HasSubstr( // Matches a string that starts with 'prefix' (case-sensitive). template -PolymorphicMatcher > StartsWith( +PolymorphicMatcher> StartsWith( const internal::StringLike& prefix) { return MakePolymorphicMatcher( internal::StartsWithMatcher(std::string(prefix))); @@ -4041,7 +4022,7 @@ PolymorphicMatcher > StartsWith( // Matches a string that ends with 'suffix' (case-sensitive). template -PolymorphicMatcher > EndsWith( +PolymorphicMatcher> EndsWith( const internal::StringLike& suffix) { return MakePolymorphicMatcher( internal::EndsWithMatcher(std::string(suffix))); @@ -4051,50 +4032,50 @@ PolymorphicMatcher > EndsWith( // Wide string matchers. // Matches a string equal to str. -inline PolymorphicMatcher > StrEq( +inline PolymorphicMatcher> StrEq( const std::wstring& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(str, true, true)); } // Matches a string not equal to str. -inline PolymorphicMatcher > StrNe( +inline PolymorphicMatcher> StrNe( const std::wstring& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(str, false, true)); } // Matches a string equal to str, ignoring case. -inline PolymorphicMatcher > -StrCaseEq(const std::wstring& str) { +inline PolymorphicMatcher> StrCaseEq( + const std::wstring& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(str, true, false)); } // Matches a string not equal to str, ignoring case. -inline PolymorphicMatcher > -StrCaseNe(const std::wstring& str) { +inline PolymorphicMatcher> StrCaseNe( + const std::wstring& str) { return MakePolymorphicMatcher( internal::StrEqualityMatcher(str, false, false)); } // Creates a matcher that matches any ::wstring, std::wstring, or C wide string // that contains the given substring. -inline PolymorphicMatcher > HasSubstr( +inline PolymorphicMatcher> HasSubstr( const std::wstring& substring) { return MakePolymorphicMatcher( internal::HasSubstrMatcher(substring)); } // Matches a string that starts with 'prefix' (case-sensitive). -inline PolymorphicMatcher > -StartsWith(const std::wstring& prefix) { +inline PolymorphicMatcher> StartsWith( + const std::wstring& prefix) { return MakePolymorphicMatcher( internal::StartsWithMatcher(prefix)); } // Matches a string that ends with 'suffix' (case-sensitive). -inline PolymorphicMatcher > EndsWith( +inline PolymorphicMatcher> EndsWith( const std::wstring& suffix) { return MakePolymorphicMatcher( internal::EndsWithMatcher(suffix)); @@ -4189,8 +4170,8 @@ inline internal::NotMatcher Not(InnerMatcher m) { // predicate. The predicate can be any unary function or functor // whose return type can be implicitly converted to bool. template -inline PolymorphicMatcher > -Truly(Predicate pred) { +inline PolymorphicMatcher> Truly( + Predicate pred) { return MakePolymorphicMatcher(internal::TrulyMatcher(pred)); } @@ -4201,8 +4182,8 @@ Truly(Predicate pred) { // EXPECT_THAT(container, SizeIs(2)); // Checks container has 2 elements. // EXPECT_THAT(container, SizeIs(Le(2)); // Checks container has at most 2. template -inline internal::SizeIsMatcher -SizeIs(const SizeMatcher& size_matcher) { +inline internal::SizeIsMatcher SizeIs( + const SizeMatcher& size_matcher) { return internal::SizeIsMatcher(size_matcher); } @@ -4212,8 +4193,8 @@ SizeIs(const SizeMatcher& size_matcher) { // do not implement size(). The container must provide const_iterator (with // valid iterator_traits), begin() and end(). template -inline internal::BeginEndDistanceIsMatcher -BeginEndDistanceIs(const DistanceMatcher& distance_matcher) { +inline internal::BeginEndDistanceIsMatcher BeginEndDistanceIs( + const DistanceMatcher& distance_matcher) { return internal::BeginEndDistanceIsMatcher(distance_matcher); } @@ -4222,8 +4203,8 @@ BeginEndDistanceIs(const DistanceMatcher& distance_matcher) { // values that are included in one container but not the other. (Duplicate // values and order differences are not explained.) template -inline PolymorphicMatcher::type>> +inline PolymorphicMatcher< + internal::ContainerEqMatcher::type>> ContainerEq(const Container& rhs) { return MakePolymorphicMatcher(internal::ContainerEqMatcher(rhs)); } @@ -4231,9 +4212,8 @@ ContainerEq(const Container& rhs) { // Returns a matcher that matches a container that, when sorted using // the given comparator, matches container_matcher. template -inline internal::WhenSortedByMatcher -WhenSortedBy(const Comparator& comparator, - const ContainerMatcher& container_matcher) { +inline internal::WhenSortedByMatcher WhenSortedBy( + const Comparator& comparator, const ContainerMatcher& container_matcher) { return internal::WhenSortedByMatcher( comparator, container_matcher); } @@ -4243,9 +4223,9 @@ WhenSortedBy(const Comparator& comparator, template inline internal::WhenSortedByMatcher WhenSorted(const ContainerMatcher& container_matcher) { - return - internal::WhenSortedByMatcher( - internal::LessComparator(), container_matcher); + return internal::WhenSortedByMatcher( + internal::LessComparator(), container_matcher); } // Matches an STL-style container or a native array that contains the @@ -4262,15 +4242,13 @@ Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) { rhs); } - // Supports the Pointwise(m, {a, b, c}) syntax. template -inline internal::PointwiseMatcher > Pointwise( +inline internal::PointwiseMatcher> Pointwise( const TupleMatcher& tuple_matcher, std::initializer_list rhs) { return Pointwise(tuple_matcher, std::vector(rhs)); } - // UnorderedPointwise(pair_matcher, rhs) matches an STL-style // container or a native array that contains the same number of // elements as in rhs, where in some permutation of the container, its @@ -4299,28 +4277,25 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher, RhsView::ConstReference(rhs_container); // Create a matcher for each element in rhs_container. - ::std::vector > matchers; + ::std::vector> matchers; for (typename RhsStlContainer::const_iterator it = rhs_stl_container.begin(); it != rhs_stl_container.end(); ++it) { - matchers.push_back( - internal::MatcherBindSecond(tuple2_matcher, *it)); + matchers.push_back(internal::MatcherBindSecond(tuple2_matcher, *it)); } // Delegate the work to UnorderedElementsAreArray(). return UnorderedElementsAreArray(matchers); } - // Supports the UnorderedPointwise(m, {a, b, c}) syntax. template inline internal::UnorderedElementsAreArrayMatcher< - typename internal::BoundSecondMatcher > + typename internal::BoundSecondMatcher> UnorderedPointwise(const Tuple2Matcher& tuple2_matcher, std::initializer_list rhs) { return UnorderedPointwise(tuple2_matcher, std::vector(rhs)); } - // Matches an STL-style container or a native array that contains at // least one element matching the given value or matcher. // @@ -4508,10 +4483,10 @@ inline internal::KeyMatcher Key(M inner_matcher) { // to match a std::map that contains exactly one element whose key // is >= 5 and whose value equals "foo". template -inline internal::PairMatcher -Pair(FirstMatcher first_matcher, SecondMatcher second_matcher) { - return internal::PairMatcher( - first_matcher, second_matcher); +inline internal::PairMatcher Pair( + FirstMatcher first_matcher, SecondMatcher second_matcher) { + return internal::PairMatcher(first_matcher, + second_matcher); } // Returns a predicate that is satisfied by anything that matches the @@ -4530,8 +4505,8 @@ inline bool Value(const T& value, M matcher) { // Matches the value against the given matcher and explains the match // result to listener. template -inline bool ExplainMatchResult( - M matcher, const T& value, MatchResultListener* listener) { +inline bool ExplainMatchResult(M matcher, const T& value, + MatchResultListener* listener) { return SafeMatcherCast(matcher).MatchAndExplain(value, listener); } @@ -4690,7 +4665,9 @@ internal::ArgsMatcher::type, k...> Args( // // EXPECT_CALL(foo, Bar(_, _)).With(Eq()); template -inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; } +inline InnerMatcher AllArgs(const InnerMatcher& matcher) { + return matcher; +} // Returns a matcher that matches the value of an optional<> type variable. // The matcher implementation only uses '!arg' and requires that the optional<> @@ -4708,7 +4685,7 @@ inline internal::OptionalMatcher Optional( // Returns a matcher that matches the value of a absl::any type variable. template -PolymorphicMatcher > AnyWith( +PolymorphicMatcher> AnyWith( const Matcher& matcher) { return MakePolymorphicMatcher( internal::any_cast_matcher::AnyCastMatcher(matcher)); @@ -4719,7 +4696,7 @@ PolymorphicMatcher > AnyWith( // functions. // It is compatible with std::variant. template -PolymorphicMatcher > VariantWith( +PolymorphicMatcher> VariantWith( const Matcher& matcher) { return MakePolymorphicMatcher( internal::variant_matcher::VariantMatcher(matcher)); @@ -4729,10 +4706,12 @@ PolymorphicMatcher > VariantWith( // tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher) // succeed if and only if the value matches the matcher. If the assertion // fails, the value and the description of the matcher will be printed. -#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\ - ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) -#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\ - ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) +#define ASSERT_THAT(value, matcher) \ + ASSERT_PRED_FORMAT1( \ + ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) +#define EXPECT_THAT(value, matcher) \ + EXPECT_PRED_FORMAT1( \ + ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) // MATCHER* macroses itself are listed below. #define MATCHER(name, description) \ diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-actions.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-actions.h index 55c2b5743..ca7fac966 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-actions.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-actions.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements some actions that depend on gmock-generated-actions.h. @@ -49,9 +48,8 @@ namespace internal { // necessary because Visual Studio deprecates ::std::copy, issuing warning 4996. // However Visual Studio 2010 and later do not honor #pragmas which disable that // warning. -template -inline OutputIterator CopyElements(InputIterator first, - InputIterator last, +template +inline OutputIterator CopyElements(InputIterator first, InputIterator last, OutputIterator output) { for (; first != last; ++first, ++output) { *output = *first; @@ -69,37 +67,33 @@ inline OutputIterator CopyElements(InputIterator first, // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4100) #endif // Action ReturnArg() returns the k-th argument of the mock function. -ACTION_TEMPLATE(ReturnArg, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(ReturnArg, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS()) { return ::std::get(args); } // Action SaveArg(pointer) saves the k-th (0-based) argument of the // mock function to *pointer. -ACTION_TEMPLATE(SaveArg, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(SaveArg, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(pointer)) { *pointer = ::std::get(args); } // Action SaveArgPointee(pointer) saves the value pointed to // by the k-th (0-based) argument of the mock function to *pointer. -ACTION_TEMPLATE(SaveArgPointee, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(SaveArgPointee, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(pointer)) { *pointer = *::std::get(args); } // Action SetArgReferee(value) assigns 'value' to the variable // referenced by the k-th (0-based) argument of the mock function. -ACTION_TEMPLATE(SetArgReferee, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(SetArgReferee, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(value)) { typedef typename ::std::tuple_element::type argk_type; // Ensures that argument #k is a reference. If you get a compiler @@ -115,8 +109,7 @@ ACTION_TEMPLATE(SetArgReferee, // (0-based) argument, which can be either a pointer or an // iterator. The action does not take ownership of the elements in the // source range. -ACTION_TEMPLATE(SetArrayArgument, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(SetArrayArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_2_VALUE_PARAMS(first, last)) { // Visual Studio deprecates ::std::copy, so we use our own copy in that case. #ifdef _MSC_VER @@ -128,8 +121,7 @@ ACTION_TEMPLATE(SetArrayArgument, // Action DeleteArg() deletes the k-th (0-based) argument of the mock // function. -ACTION_TEMPLATE(DeleteArg, - HAS_1_TEMPLATE_PARAMS(int, k), +ACTION_TEMPLATE(DeleteArg, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS()) { delete ::std::get(args); } @@ -142,19 +134,19 @@ ACTION_P(ReturnPointee, pointer) { return *pointer; } #if GTEST_HAS_EXCEPTIONS // Suppresses the 'unreachable code' warning that VC generates in opt modes. -# ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4702) // Temporarily disables warning 4702. -# endif +#ifdef _MSC_VER +#pragma warning(push) // Saves the current warning state. +#pragma warning(disable : 4702) // Temporarily disables warning 4702. +#endif ACTION_P(Throw, exception) { throw exception; } -# ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. -# endif +#ifdef _MSC_VER +#pragma warning(pop) // Restores the warning state. +#endif #endif // GTEST_HAS_EXCEPTIONS #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif } // namespace testing diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-matchers.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-matchers.h index b306dd603..1d7053a34 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-matchers.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-more-matchers.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements some matchers that depend on gmock-matchers.h. @@ -47,13 +46,13 @@ namespace testing { // Silence C4100 (unreferenced formal // parameter) for MSVC #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4100) #if (_MSC_VER == 1900) // and silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14 -# pragma warning(disable:4800) - #endif +#pragma warning(disable : 4800) +#endif #endif // Defines a matcher that matches an empty container. The container must @@ -83,10 +82,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") { } #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif - } // namespace testing #endif // GMOCK_INCLUDE_GMOCK_MORE_MATCHERS_H_ diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-nice-strict.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-nice-strict.h index 5495a9805..efecf43b7 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-nice-strict.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-nice-strict.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Implements class templates NiceMock, NaggyMock, and StrictMock. // // Given a mock class MockFoo that is created using Google Mock, diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-spec-builders.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-spec-builders.h index c6a74ae79..3c2196149 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock-spec-builders.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock-spec-builders.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file implements the ON_CALL() and EXPECT_CALL() macros. @@ -70,6 +69,7 @@ #include #include #include + #include "gmock/gmock-actions.h" #include "gmock/gmock-cardinalities.h" #include "gmock/gmock-matchers.h" @@ -78,7 +78,7 @@ #include "gtest/gtest.h" #if GTEST_HAS_EXCEPTIONS -# include // NOLINT +#include // NOLINT #endif GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ @@ -97,13 +97,15 @@ class ExpectationSet; namespace internal { // Implements a mock function. -template class FunctionMocker; +template +class FunctionMocker; // Base class for expectations. class ExpectationBase; // Implements an expectation. -template class TypedExpectation; +template +class TypedExpectation; // Helper class for testing the Expectation class template. class ExpectationTester; @@ -163,10 +165,9 @@ class GTEST_API_ UntypedFunctionMockerBase { // Writes a message that the call is uninteresting (i.e. neither // explicitly expected nor explicitly unexpected) to the given // ostream. - virtual void UntypedDescribeUninterestingCall( - const void* untyped_args, - ::std::ostream* os) const - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; + virtual void UntypedDescribeUninterestingCall(const void* untyped_args, + ::std::ostream* os) const + GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; // Returns the expectation that matches the given function arguments // (or NULL is there's no match); when a match is found, @@ -175,10 +176,9 @@ class GTEST_API_ UntypedFunctionMockerBase { // is_excessive is modified to indicate whether the call exceeds the // expected number. virtual const ExpectationBase* UntypedFindMatchingExpectation( - const void* untyped_args, - const void** untyped_action, bool* is_excessive, + const void* untyped_args, const void** untyped_action, bool* is_excessive, ::std::ostream* what, ::std::ostream* why) - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; + GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0; // Prints the given function arguments to the ostream. virtual void UntypedPrintArgs(const void* untyped_args, @@ -188,8 +188,7 @@ class GTEST_API_ UntypedFunctionMockerBase { // this information in the global mock registry. Will be called // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock // method. - void RegisterOwner(const void* mock_obj) - GTEST_LOCK_EXCLUDED_(g_gmock_mutex); + void RegisterOwner(const void* mock_obj) GTEST_LOCK_EXCLUDED_(g_gmock_mutex); // Sets the mock object this mock method belongs to, and sets the // name of the mock function. Will be called upon each invocation @@ -200,13 +199,11 @@ class GTEST_API_ UntypedFunctionMockerBase { // Returns the mock object this mock method belongs to. Must be // called after RegisterOwner() or SetOwnerAndName() has been // called. - const void* MockObject() const - GTEST_LOCK_EXCLUDED_(g_gmock_mutex); + const void* MockObject() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex); // Returns the name of this mock method. Must be called after // SetOwnerAndName() has been called. - const char* Name() const - GTEST_LOCK_EXCLUDED_(g_gmock_mutex); + const char* Name() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex); // Returns the result of invoking this mock function with the given // arguments. This function can be safely called from multiple @@ -445,8 +442,7 @@ class GTEST_API_ Mock { // Returns the reaction Google Mock will have on uninteresting calls // made on the given mock object. static internal::CallReaction GetReactionOnUninterestingCalls( - const void* mock_obj) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); + const void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); // Verifies that all expectations on the given mock object have been // satisfied. Reports one or more Google Test non-fatal failures @@ -459,17 +455,16 @@ class GTEST_API_ Mock { GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex); // Registers a mock object and a mock method it owns. - static void Register( - const void* mock_obj, - internal::UntypedFunctionMockerBase* mocker) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); + static void Register(const void* mock_obj, + internal::UntypedFunctionMockerBase* mocker) + GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); // Tells Google Mock where in the source code mock_obj is used in an // ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this // information helps the user identify which object it is. - static void RegisterUseByOnCallOrExpectCall( - const void* mock_obj, const char* file, int line) - GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); + static void RegisterUseByOnCallOrExpectCall(const void* mock_obj, + const char* file, int line) + GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); // Unregisters a mock method; removes the owning mock object from // the registry when the last mock method associated with it has @@ -626,7 +621,6 @@ class ExpectationSet { Expectation::Set expectations_; }; - // Sequence objects are used by a user to specify the relative order // in which the expectations should match. They are copyable (we rely // on the compiler-defined copy constructor and assignment operator). @@ -672,6 +666,7 @@ class GTEST_API_ InSequence { public: InSequence(); ~InSequence(); + private: bool sequence_created_; @@ -778,40 +773,34 @@ class GTEST_API_ ExpectationBase { // the current thread. // Retires all pre-requisites of this expectation. - void RetireAllPreRequisites() - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); + void RetireAllPreRequisites() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); // Returns true if and only if this expectation is retired. - bool is_retired() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + bool is_retired() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); return retired_; } // Retires this expectation. - void Retire() - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + void Retire() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); retired_ = true; } // Returns true if and only if this expectation is satisfied. - bool IsSatisfied() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); return cardinality().IsSatisfiedByCallCount(call_count_); } // Returns true if and only if this expectation is saturated. - bool IsSaturated() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + bool IsSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); return cardinality().IsSaturatedByCallCount(call_count_); } // Returns true if and only if this expectation is over-saturated. - bool IsOverSaturated() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + bool IsOverSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); return cardinality().IsOverSaturatedByCallCount(call_count_); } @@ -826,15 +815,13 @@ class GTEST_API_ ExpectationBase { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); // Returns the number this expectation has been invoked. - int call_count() const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + int call_count() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); return call_count_; } // Increments the number this expectation has been invoked. - void IncrementCallCount() - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + void IncrementCallCount() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); call_count_++; } @@ -843,8 +830,7 @@ class GTEST_API_ ExpectationBase { // WillRepeatedly() clauses) against the cardinality if this hasn't // been done before. Prints a warning if there are too many or too // few actions. - void CheckActionCountIfNotDone() const - GTEST_LOCK_EXCLUDED_(mutex_); + void CheckActionCountIfNotDone() const GTEST_LOCK_EXCLUDED_(mutex_); friend class ::testing::Sequence; friend class ::testing::internal::ExpectationTester; @@ -857,12 +843,12 @@ class GTEST_API_ ExpectationBase { // This group of fields are part of the spec and won't change after // an EXPECT_CALL() statement finishes. - const char* file_; // The file that contains the expectation. - int line_; // The line number of the expectation. + const char* file_; // The file that contains the expectation. + int line_; // The line number of the expectation. const std::string source_text_; // The EXPECT_CALL(...) source text. // True if and only if the cardinality is specified explicitly. bool cardinality_specified_; - Cardinality cardinality_; // The cardinality of the expectation. + Cardinality cardinality_; // The cardinality of the expectation. // The immediate pre-requisites (i.e. expectations that must be // satisfied before this expectation can be matched) of this // expectation. We use std::shared_ptr in the set because we want an @@ -881,7 +867,7 @@ class GTEST_API_ ExpectationBase { bool retires_on_saturation_; Clause last_clause_; mutable bool action_count_checked_; // Under mutex_. - mutable Mutex mutex_; // Protects action_count_checked_. + mutable Mutex mutex_; // Protects action_count_checked_. }; // class ExpectationBase // Impements an expectation for the given function type. @@ -939,9 +925,7 @@ class TypedExpectation : public ExpectationBase { } // Implements the .Times() clause. - TypedExpectation& Times(int n) { - return Times(Exactly(n)); - } + TypedExpectation& Times(int n) { return Times(Exactly(n)); } // Implements the .InSequence() clause. TypedExpectation& InSequence(const Sequence& s) { @@ -1056,9 +1040,7 @@ class TypedExpectation : public ExpectationBase { // Returns the matchers for the arguments as specified inside the // EXPECT_CALL() macro. - const ArgumentMatcherTuple& matchers() const { - return matchers_; - } + const ArgumentMatcherTuple& matchers() const { return matchers_; } // Returns the matcher specified by the .With() clause. const Matcher& extra_matcher() const { @@ -1113,10 +1095,8 @@ class TypedExpectation : public ExpectationBase { // Describes the result of matching the arguments against this // expectation to the given ostream. - void ExplainMatchResultTo( - const ArgumentTuple& args, - ::std::ostream* os) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + void ExplainMatchResultTo(const ArgumentTuple& args, ::std::ostream* os) const + GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); if (is_retired()) { @@ -1175,9 +1155,9 @@ class TypedExpectation : public ExpectationBase { ::std::stringstream ss; DescribeLocationTo(&ss); ss << "Actions ran out in " << source_text() << "...\n" - << "Called " << count << " times, but only " - << action_count << " WillOnce()" - << (action_count == 1 ? " is" : "s are") << " specified - "; + << "Called " << count << " times, but only " << action_count + << " WillOnce()" << (action_count == 1 ? " is" : "s are") + << " specified - "; mocker->DescribeDefaultActionTo(args, &ss); Log(kWarning, ss.str(), 1); } @@ -1219,7 +1199,7 @@ class TypedExpectation : public ExpectationBase { } // Must be done after IncrementCount()! - *what << "Mock function call matches " << source_text() <<"...\n"; + *what << "Mock function call matches " << source_text() << "...\n"; return &(GetCurrentAction(mocker, args)); } @@ -1252,8 +1232,8 @@ template class MockSpec { public: typedef typename internal::Function::ArgumentTuple ArgumentTuple; - typedef typename internal::Function::ArgumentMatcherTuple - ArgumentMatcherTuple; + typedef + typename internal::Function::ArgumentMatcherTuple ArgumentMatcherTuple; // Constructs a MockSpec object, given the function mocker object // that the spec is associated with. @@ -1263,8 +1243,9 @@ class MockSpec { // Adds a new default action spec to the function mocker and returns // the newly created spec. - internal::OnCallSpec& InternalDefaultActionSetAt( - const char* file, int line, const char* obj, const char* call) { + internal::OnCallSpec& InternalDefaultActionSetAt(const char* file, + int line, const char* obj, + const char* call) { LogWithLocation(internal::kInfo, file, line, std::string("ON_CALL(") + obj + ", " + call + ") invoked"); return function_mocker_->AddNewOnCallSpec(file, line, matchers_); @@ -1272,13 +1253,14 @@ class MockSpec { // Adds a new expectation spec to the function mocker and returns // the newly created spec. - internal::TypedExpectation& InternalExpectedAt( - const char* file, int line, const char* obj, const char* call) { + internal::TypedExpectation& InternalExpectedAt(const char* file, int line, + const char* obj, + const char* call) { const std::string source_text(std::string("EXPECT_CALL(") + obj + ", " + call + ")"); LogWithLocation(internal::kInfo, file, line, source_text + " invoked"); - return function_mocker_->AddNewExpectation( - file, line, source_text, matchers_); + return function_mocker_->AddNewExpectation(file, line, source_text, + matchers_); } // This operator overload is used to swallow the superfluous parameter list @@ -1311,9 +1293,7 @@ template class ReferenceOrValueWrapper { public: // Constructs a wrapper from the given value/reference. - explicit ReferenceOrValueWrapper(T value) - : value_(std::move(value)) { - } + explicit ReferenceOrValueWrapper(T value) : value_(std::move(value)) {} // Unwraps and returns the underlying value/reference, exactly as // originally passed. The behavior of calling this more than once on @@ -1324,9 +1304,7 @@ class ReferenceOrValueWrapper { // Always returns a const reference (more precisely, // const std::add_lvalue_reference::type). The behavior of calling this // after calling Unwrap on the same object is unspecified. - const T& Peek() const { - return value_; - } + const T& Peek() const { return value_; } private: T value_; @@ -1340,8 +1318,7 @@ class ReferenceOrValueWrapper { // Workaround for debatable pass-by-reference lint warning (c-library-team // policy precludes NOLINT in this context) typedef T& reference; - explicit ReferenceOrValueWrapper(reference ref) - : value_ptr_(&ref) {} + explicit ReferenceOrValueWrapper(reference ref) : value_ptr_(&ref) {} T& Unwrap() { return *value_ptr_; } const T& Peek() const { return *value_ptr_; } @@ -1371,9 +1348,7 @@ template class ActionResultHolder : public UntypedActionResultHolderBase { public: // Returns the held value. Must not be called more than once. - T Unwrap() { - return result_.Unwrap(); - } + T Unwrap() { return result_.Unwrap(); } // Prints the held value as an action's result to os. void PrintAsActionResult(::std::ostream* os) const override { @@ -1389,8 +1364,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase { const FunctionMocker* func_mocker, typename Function::ArgumentTuple&& args, const std::string& call_description) { - return new ActionResultHolder(Wrapper(func_mocker->PerformDefaultAction( - std::move(args), call_description))); + return new ActionResultHolder(Wrapper( + func_mocker->PerformDefaultAction(std::move(args), call_description))); } // Performs the given action and returns the result in a new-ed @@ -1398,16 +1373,13 @@ class ActionResultHolder : public UntypedActionResultHolderBase { template static ActionResultHolder* PerformAction( const Action& action, typename Function::ArgumentTuple&& args) { - return new ActionResultHolder( - Wrapper(action.Perform(std::move(args)))); + return new ActionResultHolder(Wrapper(action.Perform(std::move(args)))); } private: typedef ReferenceOrValueWrapper Wrapper; - explicit ActionResultHolder(Wrapper result) - : result_(std::move(result)) { - } + explicit ActionResultHolder(Wrapper result) : result_(std::move(result)) {} Wrapper result_; @@ -1418,7 +1390,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase { template <> class ActionResultHolder : public UntypedActionResultHolderBase { public: - void Unwrap() { } + void Unwrap() {} void PrintAsActionResult(::std::ostream* /* os */) const override {} @@ -1489,14 +1461,12 @@ class FunctionMocker final : public UntypedFunctionMockerBase { // Returns the ON_CALL spec that matches this mock function with the // given arguments; returns NULL if no matching ON_CALL is found. // L = * - const OnCallSpec* FindOnCallSpec( - const ArgumentTuple& args) const { - for (UntypedOnCallSpecs::const_reverse_iterator it - = untyped_on_call_specs_.rbegin(); + const OnCallSpec* FindOnCallSpec(const ArgumentTuple& args) const { + for (UntypedOnCallSpecs::const_reverse_iterator it = + untyped_on_call_specs_.rbegin(); it != untyped_on_call_specs_.rend(); ++it) { const OnCallSpec* spec = static_cast*>(*it); - if (spec->Matches(args)) - return spec; + if (spec->Matches(args)) return spec; } return nullptr; @@ -1511,8 +1481,7 @@ class FunctionMocker final : public UntypedFunctionMockerBase { // L = * Result PerformDefaultAction(ArgumentTuple&& args, const std::string& call_description) const { - const OnCallSpec* const spec = - this->FindOnCallSpec(args); + const OnCallSpec* const spec = this->FindOnCallSpec(args); if (spec != nullptr) { return spec->GetAction().Perform(std::move(args)); } @@ -1573,8 +1542,7 @@ class FunctionMocker final : public UntypedFunctionMockerBase { untyped_on_call_specs_.swap(specs_to_delete); g_gmock_mutex.Unlock(); - for (UntypedOnCallSpecs::const_iterator it = - specs_to_delete.begin(); + for (UntypedOnCallSpecs::const_iterator it = specs_to_delete.begin(); it != specs_to_delete.end(); ++it) { delete static_cast*>(*it); } @@ -1605,10 +1573,9 @@ class FunctionMocker final : public UntypedFunctionMockerBase { typedef ActionResultHolder ResultHolder; // Adds and returns a default action spec for this mock function. - OnCallSpec& AddNewOnCallSpec( - const char* file, int line, - const ArgumentMatcherTuple& m) - GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { + OnCallSpec& AddNewOnCallSpec(const char* file, int line, + const ArgumentMatcherTuple& m) + GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); OnCallSpec* const on_call_spec = new OnCallSpec(file, line, m); untyped_on_call_specs_.push_back(on_call_spec); @@ -1638,7 +1605,8 @@ class FunctionMocker final : public UntypedFunctionMockerBase { } private: - template friend class TypedExpectation; + template + friend class TypedExpectation; // Some utilities needed for implementing UntypedInvokeWith(). @@ -1722,9 +1690,8 @@ class FunctionMocker final : public UntypedFunctionMockerBase { // Returns the expectation that matches the arguments, or NULL if no // expectation matches them. - TypedExpectation* FindMatchingExpectationLocked( - const ArgumentTuple& args) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + TypedExpectation* FindMatchingExpectationLocked(const ArgumentTuple& args) + const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); // See the definition of untyped_expectations_ for why access to // it is unprotected here. @@ -1741,11 +1708,10 @@ class FunctionMocker final : public UntypedFunctionMockerBase { } // Returns a message that the arguments don't match any expectation. - void FormatUnexpectedCallMessageLocked( - const ArgumentTuple& args, - ::std::ostream* os, - ::std::ostream* why) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args, + ::std::ostream* os, + ::std::ostream* why) const + GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); *os << "\nUnexpected mock function call - "; DescribeDefaultActionTo(args, os); @@ -1754,15 +1720,14 @@ class FunctionMocker final : public UntypedFunctionMockerBase { // Prints a list of expectations that have been tried against the // current mock function call. - void PrintTriedExpectationsLocked( - const ArgumentTuple& args, - ::std::ostream* why) const - GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { + void PrintTriedExpectationsLocked(const ArgumentTuple& args, + ::std::ostream* why) const + GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); const size_t count = untyped_expectations_.size(); *why << "Google Mock tried the following " << count << " " - << (count == 1 ? "expectation, but it didn't match" : - "expectations, but none matched") + << (count == 1 ? "expectation, but it didn't match" + : "expectations, but none matched") << ":\n"; for (size_t i = 0; i < count; i++) { TypedExpectation* const expectation = @@ -1944,7 +1909,9 @@ using internal::MockSpec; // // Expects a call to const MockFoo::Bar(). // EXPECT_CALL(Const(foo), Bar()); template -inline const T& Const(const T& x) { return x; } +inline const T& Const(const T& x) { + return x; +} // Constructs an Expectation object that references and co-owns exp. inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/gmock.h b/Testing/lib/googletest-master/googlemock/include/gmock/gmock.h index 3c317b6d4..47a0267a3 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/gmock.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/gmock.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This is the main header file a user should include. diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-internal-utils.h b/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-internal-utils.h index 5580dcb38..0a20c2cf9 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file defines some utilities useful for implementing Google @@ -40,9 +39,11 @@ #define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_ #include + #include // NOLINT #include #include + #include "gmock/internal/gmock-port.h" #include "gtest/gtest.h" @@ -56,9 +57,9 @@ namespace internal { // Silence MSVC C4100 (unreferenced formal parameter) and // C4805('==': unsafe mix of type 'const int' and type 'const bool') #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) -# pragma warning(disable:4805) +#pragma warning(push) +#pragma warning(disable : 4100) +#pragma warning(disable : 4805) #endif // Joins a vector of strings as if they are fields of a tuple; returns @@ -83,7 +84,9 @@ struct PointeeOf { }; // This specialization is for the raw pointer case. template -struct PointeeOf { typedef T type; }; // NOLINT +struct PointeeOf { + typedef T type; +}; // NOLINT // GetRawPointer(p) returns the raw pointer underlying p when p is a // smart pointer, or returns p itself when p is already a raw pointer. @@ -94,7 +97,9 @@ inline const typename Pointer::element_type* GetRawPointer(const Pointer& p) { } // This overloaded version is for the raw pointer case. template -inline Element* GetRawPointer(Element* p) { return p; } +inline Element* GetRawPointer(Element* p) { + return p; +} // MSVC treats wchar_t as a native type usually, but treats it as the // same as unsigned short when the compiler option /Zc:wchar_t- is @@ -103,7 +108,7 @@ inline Element* GetRawPointer(Element* p) { return p; } #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) // wchar_t is a typedef. #else -# define GMOCK_WCHAR_T_IS_NATIVE_ 1 +#define GMOCK_WCHAR_T_IS_NATIVE_ 1 #endif // In what follows, we use the term "kind" to indicate whether a type @@ -111,18 +116,20 @@ inline Element* GetRawPointer(Element* p) { return p; } // or none of them. This categorization is useful for determining // when a matcher argument type can be safely converted to another // type in the implementation of SafeMatcherCast. -enum TypeKind { - kBool, kInteger, kFloatingPoint, kOther -}; +enum TypeKind { kBool, kInteger, kFloatingPoint, kOther }; // KindOf::value is the kind of type T. -template struct KindOf { +template +struct KindOf { enum { value = kOther }; // The default kind. }; // This macro declares that the kind of 'type' is 'kind'. #define GMOCK_DECLARE_KIND_(type, kind) \ - template <> struct KindOf { enum { value = kind }; } + template <> \ + struct KindOf { \ + enum { value = kind }; \ + } GMOCK_DECLARE_KIND_(bool, kBool); @@ -130,13 +137,13 @@ GMOCK_DECLARE_KIND_(bool, kBool); GMOCK_DECLARE_KIND_(char, kInteger); GMOCK_DECLARE_KIND_(signed char, kInteger); GMOCK_DECLARE_KIND_(unsigned char, kInteger); -GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT +GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT GMOCK_DECLARE_KIND_(int, kInteger); GMOCK_DECLARE_KIND_(unsigned int, kInteger); -GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT -GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT -GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT +GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT +GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT +GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT GMOCK_DECLARE_KIND_(unsigned long long, kInteger); // NOLINT #if GMOCK_WCHAR_T_IS_NATIVE_ @@ -151,7 +158,7 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint); #undef GMOCK_DECLARE_KIND_ // Evaluates to the kind of 'type'. -#define GMOCK_KIND_OF_(type) \ +#define GMOCK_KIND_OF_(type) \ static_cast< ::testing::internal::TypeKind>( \ ::testing::internal::KindOf::value) @@ -207,9 +214,7 @@ using LosslessArithmeticConvertible = class FailureReporterInterface { public: // The type of a failure (either non-fatal or fatal). - enum FailureType { - kNonfatal, kFatal - }; + enum FailureType { kNonfatal, kFatal }; virtual ~FailureReporterInterface() {} @@ -229,8 +234,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter(); inline void Assert(bool condition, const char* file, int line, const std::string& msg) { if (!condition) { - GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, - file, line, msg); + GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, file, + line, msg); } } inline void Assert(bool condition, const char* file, int line) { @@ -251,10 +256,7 @@ inline void Expect(bool condition, const char* file, int line) { } // Severity level of a log. -enum LogSeverity { - kInfo = 0, - kWarning = 1 -}; +enum LogSeverity { kInfo = 0, kWarning = 1 }; // Valid values for the --gmock_verbose flag. @@ -297,8 +299,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); // Disable MSVC warnings for infinite recursion, since in this case the // the recursion is unreachable. #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4717) +#pragma warning(push) +#pragma warning(disable : 4717) #endif // Invalid() is usable as an expression of type T, but will terminate @@ -316,7 +318,7 @@ inline T Invalid() { } #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif // Given a raw type (i.e. having no top-level reference or const @@ -394,7 +396,8 @@ class StlContainerView< ::std::tuple > { // The following specialization prevents the user from instantiating // StlContainer with a reference type. -template class StlContainerView; +template +class StlContainerView; // A type transform to remove constness from the first part of a pair. // Pairs like that are used as the value_type of associative containers, @@ -415,17 +418,19 @@ struct RemoveConstFromKey > { GTEST_API_ void IllegalDoDefault(const char* file, int line); template -auto ApplyImpl(F&& f, Tuple&& args, IndexSequence) -> decltype( - std::forward(f)(std::get(std::forward(args))...)) { +auto ApplyImpl(F&& f, Tuple&& args, IndexSequence) + -> decltype(std::forward(f)( + std::get(std::forward(args))...)) { return std::forward(f)(std::get(std::forward(args))...); } // Apply the function to a tuple of arguments. template -auto Apply(F&& f, Tuple&& args) -> decltype( - ApplyImpl(std::forward(f), std::forward(args), - MakeIndexSequence::type>::value>())) { +auto Apply(F&& f, Tuple&& args) + -> decltype(ApplyImpl( + std::forward(f), std::forward(args), + MakeIndexSequence::type>::value>())) { return ApplyImpl(std::forward(f), std::forward(args), MakeIndexSequence::type>::value>()); @@ -463,7 +468,7 @@ template constexpr size_t Function::ArgumentCount; #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif } // namespace internal diff --git a/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-port.h b/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-port.h index 70872ef39..d0262780e 100644 --- a/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-port.h +++ b/Testing/lib/googletest-master/googlemock/include/gmock/internal/gmock-port.h @@ -42,6 +42,7 @@ #include #include + #include #include @@ -53,13 +54,13 @@ // here, as Google Mock depends on Google Test. Only add a utility // here if it's truly specific to Google Mock. -#include "gtest/internal/gtest-port.h" #include "gmock/internal/custom/gmock-port.h" +#include "gtest/internal/gtest-port.h" // For MS Visual C++, check the compiler version. At least VS 2015 is // required to compile Google Mock. #if defined(_MSC_VER) && _MSC_VER < 1900 -# error "At least Visual C++ 2015 (14.0) is required to compile Google Mock." +#error "At least Visual C++ 2015 (14.0) is required to compile Google Mock." #endif // Macro for referencing flags. This is public as we want the user to @@ -69,18 +70,18 @@ #if !defined(GMOCK_DECLARE_bool_) // Macros for declaring flags. -# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name) -# define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name) -# define GMOCK_DECLARE_string_(name) \ - extern GTEST_API_ ::std::string GMOCK_FLAG(name) +#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name) +#define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name) +#define GMOCK_DECLARE_string_(name) \ + extern GTEST_API_ ::std::string GMOCK_FLAG(name) // Macros for defining flags. -# define GMOCK_DEFINE_bool_(name, default_val, doc) \ - GTEST_API_ bool GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_int32_(name, default_val, doc) \ - GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val) -# define GMOCK_DEFINE_string_(name, default_val, doc) \ - GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val) +#define GMOCK_DEFINE_bool_(name, default_val, doc) \ + GTEST_API_ bool GMOCK_FLAG(name) = (default_val) +#define GMOCK_DEFINE_int32_(name, default_val, doc) \ + GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val) +#define GMOCK_DEFINE_string_(name, default_val, doc) \ + GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val) #endif // !defined(GMOCK_DECLARE_bool_) diff --git a/Testing/lib/googletest-master/googlemock/test/gmock_link_test.h b/Testing/lib/googletest-master/googlemock/test/gmock_link_test.h index 175d2bdd1..69ac0f47c 100644 --- a/Testing/lib/googletest-master/googlemock/test/gmock_link_test.h +++ b/Testing/lib/googletest-master/googlemock/test/gmock_link_test.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Mock - a framework for writing C++ mock classes. // // This file tests that: @@ -118,7 +117,7 @@ #include "gmock/gmock.h" #if !GTEST_OS_WINDOWS_MOBILE -# include +#include #endif #include @@ -200,14 +199,14 @@ class Interface { virtual char* StringFromString(char* str) = 0; virtual int IntFromString(char* str) = 0; virtual int& IntRefFromString(char* str) = 0; - virtual void VoidFromFunc(void(*func)(char* str)) = 0; + virtual void VoidFromFunc(void (*func)(char* str)) = 0; virtual void VoidFromIntRef(int& n) = 0; // NOLINT virtual void VoidFromFloat(float n) = 0; virtual void VoidFromDouble(double n) = 0; virtual void VoidFromVector(const std::vector& v) = 0; }; -class Mock: public Interface { +class Mock : public Interface { public: Mock() {} @@ -215,7 +214,7 @@ class Mock: public Interface { MOCK_METHOD1(StringFromString, char*(char* str)); MOCK_METHOD1(IntFromString, int(char* str)); MOCK_METHOD1(IntRefFromString, int&(char* str)); - MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str))); + MOCK_METHOD1(VoidFromFunc, void(void (*func)(char* str))); MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT MOCK_METHOD1(VoidFromFloat, void(float n)); MOCK_METHOD1(VoidFromDouble, void(double n)); @@ -301,8 +300,8 @@ TEST(LinkTest, TestSetArrayArgument) { char ch = 'x'; char ch2 = 'y'; - EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2, - &ch2 + 1)); + EXPECT_CALL(mock, VoidFromString(_)) + .WillOnce(SetArrayArgument<0>(&ch2, &ch2 + 1)); mock.VoidFromString(&ch); } @@ -339,8 +338,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) { EXPECT_CALL(mock, VoidFromString(_)) .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid)) - .WillOnce(InvokeWithoutArgs(&test_invoke_helper, - &InvokeHelper::VoidFromVoid)); + .WillOnce( + InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid)); mock.VoidFromString(nullptr); mock.VoidFromString(nullptr); } @@ -424,14 +423,14 @@ TEST(LinkTest, TestThrow) { // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4100) #endif // Tests the linkage of actions created using ACTION macro. namespace { ACTION(Return1) { return 1; } -} +} // namespace TEST(LinkTest, TestActionMacro) { Mock mock; @@ -443,7 +442,7 @@ TEST(LinkTest, TestActionMacro) { // Tests the linkage of actions created using ACTION_P macro. namespace { ACTION_P(ReturnArgument, ret_value) { return ret_value; } -} +} // namespace TEST(LinkTest, TestActionPMacro) { Mock mock; @@ -457,10 +456,10 @@ namespace { ACTION_P2(ReturnEqualsEitherOf, first, second) { return arg0 == first || arg0 == second; } -} +} // namespace #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif TEST(LinkTest, TestActionP2Macro) { @@ -492,8 +491,7 @@ TEST(LinkTest, TestMatchersEq) { const char* p = "x"; ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return()); - ON_CALL(mock, VoidFromString(const_cast("y"))) - .WillByDefault(Return()); + ON_CALL(mock, VoidFromString(const_cast("y"))).WillByDefault(Return()); } // Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers. @@ -592,7 +590,7 @@ TEST(LinkTest, TestMatcherElementsAre) { // Tests the linkage of the ElementsAreArray matcher. TEST(LinkTest, TestMatcherElementsAreArray) { Mock mock; - char arr[] = { 'a', 'b' }; + char arr[] = {'a', 'b'}; ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return()); } diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-death-test.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-death-test.h index 2bd41cf38..d6a9e152d 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-death-test.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-death-test.h @@ -165,24 +165,24 @@ GTEST_API_ bool InDeathTestChild(); // Asserts that a given statement causes the program to exit, with an // integer exit status that satisfies predicate, and emitting error output // that matches regex. -# define ASSERT_EXIT(statement, predicate, regex) \ - GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) +#define ASSERT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) // Like ASSERT_EXIT, but continues on to successive tests in the // test suite, if any: -# define EXPECT_EXIT(statement, predicate, regex) \ - GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) +#define EXPECT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) // Asserts that a given statement causes the program to exit, either by // explicitly exiting with a nonzero exit code or being killed by a // signal, and emitting error output that matches regex. -# define ASSERT_DEATH(statement, regex) \ - ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) +#define ASSERT_DEATH(statement, regex) \ + ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) // Like ASSERT_DEATH, but continues on to successive tests in the // test suite, if any: -# define EXPECT_DEATH(statement, regex) \ - EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) +#define EXPECT_DEATH(statement, regex) \ + EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) // Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: @@ -193,11 +193,12 @@ class GTEST_API_ ExitedWithCode { ExitedWithCode(const ExitedWithCode&) = default; void operator=(const ExitedWithCode& other) = delete; bool operator()(int exit_status) const; + private: const int exit_code_; }; -# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Tests that an exit code describes an exit due to termination by a // given signal. // GOOGLETEST_CM0006 DO NOT DELETE @@ -205,10 +206,11 @@ class GTEST_API_ KilledBySignal { public: explicit KilledBySignal(int signum); bool operator()(int exit_status) const; + private: const int signum_; }; -# endif // !GTEST_OS_WINDOWS +#endif // !GTEST_OS_WINDOWS // EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. // The death testing framework causes this to have interesting semantics, @@ -253,23 +255,21 @@ class GTEST_API_ KilledBySignal { // EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); // }, "death"); // -# ifdef NDEBUG +#ifdef NDEBUG -# define EXPECT_DEBUG_DEATH(statement, regex) \ +#define EXPECT_DEBUG_DEATH(statement, regex) \ GTEST_EXECUTE_STATEMENT_(statement, regex) -# define ASSERT_DEBUG_DEATH(statement, regex) \ +#define ASSERT_DEBUG_DEATH(statement, regex) \ GTEST_EXECUTE_STATEMENT_(statement, regex) -# else +#else -# define EXPECT_DEBUG_DEATH(statement, regex) \ - EXPECT_DEATH(statement, regex) +#define EXPECT_DEBUG_DEATH(statement, regex) EXPECT_DEATH(statement, regex) -# define ASSERT_DEBUG_DEATH(statement, regex) \ - ASSERT_DEATH(statement, regex) +#define ASSERT_DEBUG_DEATH(statement, regex) ASSERT_DEATH(statement, regex) -# endif // NDEBUG for EXPECT_DEBUG_DEATH +#endif // NDEBUG for EXPECT_DEBUG_DEATH #endif // GTEST_HAS_DEATH_TEST // This macro is used for implementing macros such as @@ -307,18 +307,17 @@ class GTEST_API_ KilledBySignal { // statement unconditionally returns or throws. The Message constructor at // the end allows the syntax of streaming additional messages into the // macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. -# define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - GTEST_LOG_(WARNING) \ - << "Death tests are not supported on this platform.\n" \ - << "Statement '" #statement "' cannot be verified."; \ - } else if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::RE::PartialMatch(".*", (regex)); \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - terminator; \ - } else \ - ::testing::Message() +#define GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, terminator) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_LOG_(WARNING) << "Death tests are not supported on this platform.\n" \ + << "Statement '" #statement "' cannot be verified."; \ + } else if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::RE::PartialMatch(".*", (regex)); \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + terminator; \ + } else \ + ::testing::Message() // EXPECT_DEATH_IF_SUPPORTED(statement, regex) and // ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if @@ -326,15 +325,15 @@ class GTEST_API_ KilledBySignal { // useful when you are combining death test assertions with normal test // assertions in one test. #if GTEST_HAS_DEATH_TEST -# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ - EXPECT_DEATH(statement, regex) -# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ - ASSERT_DEATH(statement, regex) +#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + EXPECT_DEATH(statement, regex) +#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + ASSERT_DEATH(statement, regex) #else -# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ - GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, ) -# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ - GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return) +#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, ) +#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST(statement, regex, return) #endif } // namespace testing diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-matchers.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-matchers.h index 3b2d0f501..53d076efe 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-matchers.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-matchers.h @@ -108,8 +108,7 @@ class MatchResultListener { GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener); }; -inline MatchResultListener::~MatchResultListener() { -} +inline MatchResultListener::~MatchResultListener() {} // An instance of a subclass of this knows how to describe itself as a // matcher. @@ -208,27 +207,39 @@ class MatcherInterfaceAdapter : public MatcherInterface { struct AnyEq { template - bool operator()(const A& a, const B& b) const { return a == b; } + bool operator()(const A& a, const B& b) const { + return a == b; + } }; struct AnyNe { template - bool operator()(const A& a, const B& b) const { return a != b; } + bool operator()(const A& a, const B& b) const { + return a != b; + } }; struct AnyLt { template - bool operator()(const A& a, const B& b) const { return a < b; } + bool operator()(const A& a, const B& b) const { + return a < b; + } }; struct AnyGt { template - bool operator()(const A& a, const B& b) const { return a > b; } + bool operator()(const A& a, const B& b) const { + return a > b; + } }; struct AnyLe { template - bool operator()(const A& a, const B& b) const { return a <= b; } + bool operator()(const A& a, const B& b) const { + return a <= b; + } }; struct AnyGe { template - bool operator()(const A& a, const B& b) const { return a >= b; } + bool operator()(const A& a, const B& b) const { + return a >= b; + } }; // A match result listener that ignores the explanation. @@ -287,9 +298,7 @@ class MatcherBase { // Returns the describer for this matcher object; retains ownership // of the describer, which is only guaranteed to be alive when // this matcher object is alive. - const MatcherDescriberInterface* GetDescriber() const { - return impl_.get(); - } + const MatcherDescriberInterface* GetDescriber() const { return impl_.get(); } protected: MatcherBase() {} @@ -536,9 +545,13 @@ class ComparisonBase { private: template - static const T& Unwrap(const T& v) { return v; } + static const T& Unwrap(const T& v) { + return v; + } template - static const T& Unwrap(std::reference_wrapper v) { return v; } + static const T& Unwrap(std::reference_wrapper v) { + return v; + } template class Impl : public MatcherInterface { @@ -553,7 +566,7 @@ class ComparisonBase { UniversalPrint(Unwrap(rhs_), os); } void DescribeNegationTo(::std::ostream* os) const override { - *os << D::NegatedDesc() << " "; + *os << D::NegatedDesc() << " "; UniversalPrint(Unwrap(rhs_), os); } @@ -567,7 +580,7 @@ template class EqMatcher : public ComparisonBase, Rhs, AnyEq> { public: explicit EqMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyEq>(rhs) { } + : ComparisonBase, Rhs, AnyEq>(rhs) {} static const char* Desc() { return "is equal to"; } static const char* NegatedDesc() { return "isn't equal to"; } }; @@ -575,7 +588,7 @@ template class NeMatcher : public ComparisonBase, Rhs, AnyNe> { public: explicit NeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyNe>(rhs) { } + : ComparisonBase, Rhs, AnyNe>(rhs) {} static const char* Desc() { return "isn't equal to"; } static const char* NegatedDesc() { return "is equal to"; } }; @@ -583,7 +596,7 @@ template class LtMatcher : public ComparisonBase, Rhs, AnyLt> { public: explicit LtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLt>(rhs) { } + : ComparisonBase, Rhs, AnyLt>(rhs) {} static const char* Desc() { return "is <"; } static const char* NegatedDesc() { return "isn't <"; } }; @@ -591,7 +604,7 @@ template class GtMatcher : public ComparisonBase, Rhs, AnyGt> { public: explicit GtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGt>(rhs) { } + : ComparisonBase, Rhs, AnyGt>(rhs) {} static const char* Desc() { return "is >"; } static const char* NegatedDesc() { return "isn't >"; } }; @@ -599,7 +612,7 @@ template class LeMatcher : public ComparisonBase, Rhs, AnyLe> { public: explicit LeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLe>(rhs) { } + : ComparisonBase, Rhs, AnyLe>(rhs) {} static const char* Desc() { return "is <="; } static const char* NegatedDesc() { return "isn't <="; } }; @@ -607,7 +620,7 @@ template class GeMatcher : public ComparisonBase, Rhs, AnyGe> { public: explicit GeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGe>(rhs) { } + : ComparisonBase, Rhs, AnyGe>(rhs) {} static const char* Desc() { return "is >="; } static const char* NegatedDesc() { return "isn't >="; } }; @@ -698,12 +711,16 @@ PolymorphicMatcher ContainsRegex( // Note: if the parameter of Eq() were declared as const T&, Eq("foo") // wouldn't compile. template -inline internal::EqMatcher Eq(T x) { return internal::EqMatcher(x); } +inline internal::EqMatcher Eq(T x) { + return internal::EqMatcher(x); +} // Constructs a Matcher from a 'value' of type T. The constructed // matcher matches any value that's equal to 'value'. template -Matcher::Matcher(T value) { *this = Eq(value); } +Matcher::Matcher(T value) { + *this = Eq(value); +} // Creates a monomorphic matcher that matches anything with type Lhs // and equal to rhs. A user may need to use this instead of Eq(...) @@ -718,7 +735,9 @@ Matcher::Matcher(T value) { *this = Eq(value); } // can always write Matcher(Lt(5)) to be explicit about the type, // for example. template -inline Matcher TypedEq(const Rhs& rhs) { return Eq(rhs); } +inline Matcher TypedEq(const Rhs& rhs) { + return Eq(rhs); +} // Creates a polymorphic matcher that matches anything >= x. template diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-message.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-message.h index 21899232a..dcf1dc79c 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-message.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-message.h @@ -110,7 +110,7 @@ class GTEST_API_ Message { // Streams a non-pointer value to this object. template - inline Message& operator <<(const T& val) { + inline Message& operator<<(const T& val) { // Some libraries overload << for STL containers. These // overloads are defined in the global namespace instead of ::std. // @@ -125,7 +125,7 @@ class GTEST_API_ Message { // from the global namespace. With this using declaration, // overloads of << defined in the global namespace and those // visible via Koenig lookup are both exposed in this function. - using ::operator <<; + using ::operator<<; *ss_ << val; return *this; } @@ -144,7 +144,7 @@ class GTEST_API_ Message { // ensure consistent result across compilers, we always treat NULL // as "(null)". template - inline Message& operator <<(T* const& pointer) { // NOLINT + inline Message& operator<<(T* const& pointer) { // NOLINT if (pointer == nullptr) { *ss_ << "(null)"; } else { @@ -159,25 +159,23 @@ class GTEST_API_ Message { // templatized version above. Without this definition, streaming // endl or other basic IO manipulators to Message will confuse the // compiler. - Message& operator <<(BasicNarrowIoManip val) { + Message& operator<<(BasicNarrowIoManip val) { *ss_ << val; return *this; } // Instead of 1/0, we want to see true/false for bool values. - Message& operator <<(bool b) { - return *this << (b ? "true" : "false"); - } + Message& operator<<(bool b) { return *this << (b ? "true" : "false"); } // These two overloads allow streaming a wide C string to a Message // using the UTF-8 encoding. - Message& operator <<(const wchar_t* wide_c_str); - Message& operator <<(wchar_t* wide_c_str); + Message& operator<<(const wchar_t* wide_c_str); + Message& operator<<(wchar_t* wide_c_str); #if GTEST_HAS_STD_WSTRING // Converts the given wide string to a narrow string using the UTF-8 // encoding, and streams the result to this Message object. - Message& operator <<(const ::std::wstring& wstr); + Message& operator<<(const ::std::wstring& wstr); #endif // GTEST_HAS_STD_WSTRING // Gets the text streamed to this object so far as an std::string. @@ -196,7 +194,7 @@ class GTEST_API_ Message { }; // Streams a Message to an ostream. -inline std::ostream& operator <<(std::ostream& os, const Message& sb) { +inline std::ostream& operator<<(std::ostream& os, const Message& sb) { return os << sb.GetString(); } diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-param-test.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-param-test.h index 5b039df9f..c8db1e81a 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-param-test.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-param-test.h @@ -36,7 +36,6 @@ #ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ #define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ - // Value-parameterized tests allow you to test your code with different // parameters without writing multiple copies of the same test. // @@ -356,9 +355,7 @@ internal::ValueArray Values(T... v) { // } // INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool()); // -inline internal::ParamGenerator Bool() { - return Values(false, true); -} +inline internal::ParamGenerator Bool() { return Values(false, true); } // Combine() allows the user to combine two or more sequences to produce // values of a Cartesian product of those sequences' elements. @@ -457,43 +454,42 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define GTEST_GET_FIRST_(first, ...) first #define GTEST_GET_SECOND_(first, second, ...) second -#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \ - static ::testing::internal::ParamGenerator \ - gtest_##prefix##test_suite_name##_EvalGenerator_() { \ - return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ - } \ - static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ - const ::testing::TestParamInfo& info) { \ - if (::testing::internal::AlwaysFalse()) { \ - ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \ - __VA_ARGS__, \ - ::testing::internal::DefaultParamName, \ - DUMMY_PARAM_))); \ - auto t = std::make_tuple(__VA_ARGS__); \ - static_assert(std::tuple_size::value <= 2, \ - "Too Many Args!"); \ - } \ - return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \ - __VA_ARGS__, \ - ::testing::internal::DefaultParamName, \ - DUMMY_PARAM_))))(info); \ - } \ - static int gtest_##prefix##test_suite_name##_dummy_ \ - GTEST_ATTRIBUTE_UNUSED_ = \ - ::testing::UnitTest::GetInstance() \ - ->parameterized_test_registry() \ - .GetTestSuitePatternHolder( \ - GTEST_STRINGIFY_(test_suite_name), \ - ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ - ->AddTestSuiteInstantiation( \ - GTEST_STRINGIFY_(prefix), \ - >est_##prefix##test_suite_name##_EvalGenerator_, \ - >est_##prefix##test_suite_name##_EvalGenerateName_, \ +#define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \ + static ::testing::internal::ParamGenerator \ + gtest_##prefix##test_suite_name##_EvalGenerator_() { \ + return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \ + } \ + static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \ + const ::testing::TestParamInfo& info) { \ + if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))); \ + auto t = std::make_tuple(__VA_ARGS__); \ + static_assert(std::tuple_size::value <= 2, \ + "Too Many Args!"); \ + } \ + return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \ + __VA_ARGS__, \ + ::testing::internal::DefaultParamName, \ + DUMMY_PARAM_))))(info); \ + } \ + static int gtest_##prefix##test_suite_name##_dummy_ \ + GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::UnitTest::GetInstance() \ + ->parameterized_test_registry() \ + .GetTestSuitePatternHolder( \ + GTEST_STRINGIFY_(test_suite_name), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__)) \ + ->AddTestSuiteInstantiation( \ + GTEST_STRINGIFY_(prefix), \ + >est_##prefix##test_suite_name##_EvalGenerator_, \ + >est_##prefix##test_suite_name##_EvalGenerateName_, \ __FILE__, __LINE__) - // Allow Marking a Parameterized test class as not needing to be instantiated. -#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \ +#define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \ namespace gtest_do_not_use_outside_namespace_scope {} \ static const ::testing::internal::MarkAsIgnored gtest_allow_ignore_##T( \ GTEST_STRINGIFY_(T)) diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-printers.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-printers.h index f24512a9f..1ef3c2aa6 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-printers.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-printers.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Google Test - The Google C++ Testing and Mocking Framework // // This file implements a universal value printer that can print a @@ -108,6 +107,7 @@ #include #include #include + #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-port.h" @@ -267,12 +267,10 @@ struct ConvertibleToStringViewPrinter { #endif }; - // Prints the given number of bytes in the given object to the given // ostream. GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes, - size_t count, - ::std::ostream* os); + size_t count, ::std::ostream* os); struct FallbackPrinter { template static void PrintValue(const T& value, ::std::ostream* os) { @@ -375,12 +373,12 @@ GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char32_t); // to point to a NUL-terminated string, and thus can print it as a string. #define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ - template <> \ - class FormatForComparison { \ - public: \ - static ::std::string Format(CharType* value) { \ - return ::testing::PrintToString(value); \ - } \ + template <> \ + class FormatForComparison { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(value); \ + } \ } GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); @@ -410,8 +408,8 @@ GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. template -std::string FormatForComparisonFailureMessage( - const T1& value, const T2& /* other_operand */) { +std::string FormatForComparisonFailureMessage(const T1& value, + const T2& /* other_operand */) { return FormatForComparison::Format(value); } @@ -548,14 +546,14 @@ void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { } // Overloads for ::std::string. -GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os); +GTEST_API_ void PrintStringTo(const ::std::string& s, ::std::ostream* os); inline void PrintTo(const ::std::string& s, ::std::ostream* os) { PrintStringTo(s, os); } // Overloads for ::std::wstring. #if GTEST_HAS_STD_WSTRING -GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os); +GTEST_API_ void PrintWideStringTo(const ::std::wstring& s, ::std::ostream* os); inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { PrintWideStringTo(s, os); } @@ -744,12 +742,12 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { } } // This overload prints a (const) char array compactly. -GTEST_API_ void UniversalPrintArray( - const char* begin, size_t len, ::std::ostream* os); +GTEST_API_ void UniversalPrintArray(const char* begin, size_t len, + ::std::ostream* os); // This overload prints a (const) wchar_t array compactly. -GTEST_API_ void UniversalPrintArray( - const wchar_t* begin, size_t len, ::std::ostream* os); +GTEST_API_ void UniversalPrintArray(const wchar_t* begin, size_t len, + ::std::ostream* os); // Implements printing an array type T[N]. template @@ -865,10 +863,10 @@ void UniversalPrint(const T& value, ::std::ostream* os) { UniversalPrinter::Print(value, os); } -typedef ::std::vector< ::std::string> Strings; +typedef ::std::vector<::std::string> Strings; - // Tersely prints the first N fields of a tuple to a string vector, - // one element for each field. +// Tersely prints the first N fields of a tuple to a string vector, +// one element for each field. template void TersePrintPrefixToStrings(const Tuple&, std::integral_constant, Strings*) {} diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-spi.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-spi.h index aa38870e8..71318312d 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-spi.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-spi.h @@ -104,6 +104,7 @@ class GTEST_API_ SingleFailureChecker { SingleFailureChecker(const TestPartResultArray* results, TestPartResult::Type type, const std::string& substr); ~SingleFailureChecker(); + private: const TestPartResultArray* const results_; const TestPartResult::Type type_; @@ -141,38 +142,39 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // helper macro, due to some peculiarity in how the preprocessor // works. The AcceptsMacroThatExpandsToUnprotectedComma test in // gtest_unittest.cc will fail to compile if we do that. -#define EXPECT_FATAL_FAILURE(statement, substr) \ - do { \ - class GTestExpectFatalFailureHelper {\ - public:\ - static void Execute() { statement; }\ - };\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ - GTestExpectFatalFailureHelper::Execute();\ - }\ +#define EXPECT_FATAL_FAILURE(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper { \ + public: \ + static void Execute() { statement; } \ + }; \ + ::testing::TestPartResultArray gtest_failures; \ + ::testing::internal::SingleFailureChecker gtest_checker( \ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr)); \ + { \ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, \ + >est_failures); \ + GTestExpectFatalFailureHelper::Execute(); \ + } \ } while (::testing::internal::AlwaysFalse()) -#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ - do { \ - class GTestExpectFatalFailureHelper {\ - public:\ - static void Execute() { statement; }\ - };\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ALL_THREADS, >est_failures);\ - GTestExpectFatalFailureHelper::Execute();\ - }\ +#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper { \ + public: \ + static void Execute() { statement; } \ + }; \ + ::testing::TestPartResultArray gtest_failures; \ + ::testing::internal::SingleFailureChecker gtest_checker( \ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr)); \ + { \ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \ + ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ + >est_failures); \ + GTestExpectFatalFailureHelper::Execute(); \ + } \ } while (::testing::internal::AlwaysFalse()) // A macro for testing Google Test assertions or code that's expected to @@ -207,32 +209,37 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // instead of // GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) // to avoid an MSVC warning on unreachable code. -#define EXPECT_NONFATAL_FAILURE(statement, substr) \ - do {\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ +#define EXPECT_NONFATAL_FAILURE(statement, substr) \ + do { \ + ::testing::TestPartResultArray gtest_failures; \ + ::testing::internal::SingleFailureChecker gtest_checker( \ >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ - (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ - ::testing::ScopedFakeTestPartResultReporter:: \ - INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ - if (::testing::internal::AlwaysTrue()) { statement; }\ - }\ + (substr)); \ + { \ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, \ + >est_failures); \ + if (::testing::internal::AlwaysTrue()) { \ + statement; \ + } \ + } \ } while (::testing::internal::AlwaysFalse()) -#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ - do {\ - ::testing::TestPartResultArray gtest_failures;\ - ::testing::internal::SingleFailureChecker gtest_checker(\ - >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ - (substr));\ - {\ - ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ +#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do { \ + ::testing::TestPartResultArray gtest_failures; \ + ::testing::internal::SingleFailureChecker gtest_checker( \ + >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ + (substr)); \ + { \ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter( \ ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ - >est_failures);\ - if (::testing::internal::AlwaysTrue()) { statement; }\ - }\ + >est_failures); \ + if (::testing::internal::AlwaysTrue()) { \ + statement; \ + } \ + } \ } while (::testing::internal::AlwaysFalse()) #endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-test-part.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-test-part.h index 05a798535..b405d7b7b 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-test-part.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-test-part.h @@ -34,6 +34,7 @@ #include #include + #include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-string.h" @@ -168,6 +169,7 @@ class GTEST_API_ HasNewFatalFailureHelper ~HasNewFatalFailureHelper() override; void ReportTestPartResult(const TestPartResult& result) override; bool has_new_fatal_failure() const { return has_new_fatal_failure_; } + private: bool has_new_fatal_failure_; TestPartResultReporterInterface* original_reporter_; diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest-typed-test.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest-typed-test.h index 3ffa50b73..230cc1111 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest-typed-test.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest-typed-test.h @@ -192,7 +192,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); typedef ::testing::internal::GenerateTypeList::type \ GTEST_TYPE_PARAMS_(CaseName); \ typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \ - GTEST_NAME_GENERATOR_(CaseName) + GTEST_NAME_GENERATOR_(CaseName) #define TYPED_TEST(CaseName, TestName) \ static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \ @@ -262,7 +262,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); // #included in multiple translation units linked together. #define TYPED_TEST_SUITE_P(SuiteName) \ static ::testing::internal::TypedTestSuitePState \ - GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName) + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName) // Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ @@ -271,28 +271,28 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define TYPED_TEST_P(SuiteName, TestName) \ - namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - template \ - class TestName : public SuiteName { \ - private: \ - typedef SuiteName TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - void TestBody() override; \ - }; \ - static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ - GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ - __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ - GTEST_STRINGIFY_(TestName)); \ - } \ - template \ - void GTEST_SUITE_NAMESPACE_( \ +#define TYPED_TEST_P(SuiteName, TestName) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + template \ + class TestName : public SuiteName { \ + private: \ + typedef SuiteName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + void TestBody() override; \ + }; \ + static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ + __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ + GTEST_STRINGIFY_(TestName)); \ + } \ + template \ + void GTEST_SUITE_NAMESPACE_( \ SuiteName)::TestName::TestBody() // Note: this won't work correctly if the trailing arguments are macros. #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \ namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ + typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ } \ static const char* const GTEST_REGISTERED_TEST_NAMES_( \ SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \ @@ -307,21 +307,21 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); REGISTER_TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ - static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \ - "test-suit-prefix must not be empty"); \ - static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \ - ::testing::internal::TypeParameterizedTestSuite< \ - SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ - ::testing::internal::GenerateTypeList::type>:: \ - Register(GTEST_STRINGIFY_(Prefix), \ - ::testing::internal::CodeLocation(__FILE__, __LINE__), \ - >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \ - GTEST_STRINGIFY_(SuiteName), \ - GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ - ::testing::internal::GenerateNames< \ - ::testing::internal::NameGeneratorSelector< \ - __VA_ARGS__>::type, \ +#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ + static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \ + "test-suit-prefix must not be empty"); \ + static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTestSuite< \ + SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ + ::testing::internal::GenerateTypeList::type>:: \ + Register(GTEST_STRINGIFY_(Prefix), \ + ::testing::internal::CodeLocation(__FILE__, __LINE__), \ + >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \ + GTEST_STRINGIFY_(SuiteName), \ + GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ + ::testing::internal::GenerateNames< \ + ::testing::internal::NameGeneratorSelector< \ + __VA_ARGS__>::type, \ ::testing::internal::GenerateTypeList::type>()) // Legacy API is deprecated but still available diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest.h index 75ccc8bce..a54efb50e 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest.h @@ -59,16 +59,16 @@ #include #include -#include "gtest/internal/gtest-internal.h" -#include "gtest/internal/gtest-string.h" #include "gtest/gtest-death-test.h" #include "gtest/gtest-matchers.h" #include "gtest/gtest-message.h" #include "gtest/gtest-param-test.h" #include "gtest/gtest-printers.h" -#include "gtest/gtest_prod.h" #include "gtest/gtest-test-part.h" #include "gtest/gtest-typed-test.h" +#include "gtest/gtest_prod.h" +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) @@ -78,12 +78,11 @@ namespace testing { // Silence C4100 (unreferenced formal parameter) and 4805 // unsafe mix of type 'const int' and type 'const bool' #ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable:4805) -# pragma warning(disable:4100) +#pragma warning(push) +#pragma warning(disable : 4805) +#pragma warning(disable : 4100) #endif - // Declares the flags. // This flag temporary enables the disabled tests. @@ -337,7 +336,8 @@ class GTEST_API_ AssertionResult { const char* failure_message() const { return message(); } // Streams a custom failure message into this object. - template AssertionResult& operator<<(const T& value) { + template + AssertionResult& operator<<(const T& value) { AppendMessage(Message() << value); return *this; } @@ -535,24 +535,17 @@ class TestProperty { // C'tor. TestProperty does NOT have a default constructor. // Always use this constructor (with parameters) to create a // TestProperty object. - TestProperty(const std::string& a_key, const std::string& a_value) : - key_(a_key), value_(a_value) { - } + TestProperty(const std::string& a_key, const std::string& a_value) + : key_(a_key), value_(a_value) {} // Gets the user supplied key. - const char* key() const { - return key_.c_str(); - } + const char* key() const { return key_.c_str(); } // Gets the user supplied value. - const char* value() const { - return value_.c_str(); - } + const char* value() const { return value_.c_str(); } // Sets a new value, overriding the one supplied in the constructor. - void SetValue(const std::string& new_value) { - value_ = new_value; - } + void SetValue(const std::string& new_value) { value_ = new_value; } private: // The key supplied by the user. @@ -810,8 +803,8 @@ class GTEST_API_ TestInfo { } // These fields are immutable properties of the test. - const std::string test_suite_name_; // test suite name - const std::string name_; // Test name + const std::string test_suite_name_; // test suite name + const std::string name_; // Test name // Name of the parameter type, or NULL if this is not a typed or a // type-parameterized test. const std::unique_ptr type_param_; @@ -940,7 +933,7 @@ class GTEST_API_ TestSuite { // Adds a TestInfo to this test suite. Will delete the TestInfo upon // destruction of the TestSuite object. - void AddTestInfo(TestInfo * test_info); + void AddTestInfo(TestInfo* test_info); // Clears the results of all tests in this test suite. void ClearResult(); @@ -1068,6 +1061,7 @@ class Environment { // Override this to define how to tear down the environment. virtual void TearDown() {} + private: // If you see an error about overriding the following function or // about it being private, you have mis-spelled SetUp() as Setup(). @@ -1120,8 +1114,9 @@ class TestEventListener { virtual void OnTestStart(const TestInfo& test_info) = 0; // Fired after a failed assertion or a SUCCEED() invocation. - // If you want to throw an exception from this function to skip to the nextNode - // TEST, it must be AssertionException defined above, or inherited from it. + // If you want to throw an exception from this function to skip to the + // nextNode TEST, it must be AssertionException defined above, or inherited + // from it. virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0; // Fired after the test ends. @@ -1142,8 +1137,7 @@ class TestEventListener { virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0; // Fired after each iteration of tests finishes. - virtual void OnTestIterationEnd(const UnitTest& unit_test, - int iteration) = 0; + virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration) = 0; // Fired after all test activities have ended. virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0; @@ -1300,8 +1294,7 @@ class GTEST_API_ UnitTest { // Returns the TestInfo object for the test that's currently running, // or NULL if no test is running. - const TestInfo* current_test_info() const - GTEST_LOCK_EXCLUDED_(mutex_); + const TestInfo* current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_); // Returns the random seed used at the start of the current test run. int random_seed() const; @@ -1407,8 +1400,7 @@ class GTEST_API_ UnitTest { // eventually call this to report their results. The user code // should use the assertion macros instead of calling this directly. void AddTestPartResult(TestPartResult::Type result_type, - const char* file_name, - int line_number, + const char* file_name, int line_number, const std::string& message, const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_); @@ -1439,8 +1431,7 @@ class GTEST_API_ UnitTest { friend std::set* internal::GetIgnoredParameterizedTestSuites(); friend internal::UnitTestImpl* internal::GetUnitTestImpl(); friend void internal::ReportFailureInUnknownLocation( - TestPartResult::Type result_type, - const std::string& message); + TestPartResult::Type result_type, const std::string& message); // Creates an empty UnitTest. UnitTest(); @@ -1454,8 +1445,7 @@ class GTEST_API_ UnitTest { GTEST_LOCK_EXCLUDED_(mutex_); // Pops a trace from the per-thread Google Test trace stack. - void PopGTestTrace() - GTEST_LOCK_EXCLUDED_(mutex_); + void PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_); // Protects mutable state in *impl_. This is mutable as some const // methods need to lock it too. @@ -1519,13 +1509,11 @@ namespace internal { // when calling EXPECT_* in a tight loop. template AssertionResult CmpHelperEQFailure(const char* lhs_expression, - const char* rhs_expression, - const T1& lhs, const T2& rhs) { - return EqFailure(lhs_expression, - rhs_expression, + const char* rhs_expression, const T1& lhs, + const T2& rhs) { + return EqFailure(lhs_expression, rhs_expression, FormatForComparisonFailureMessage(lhs, rhs), - FormatForComparisonFailureMessage(rhs, lhs), - false); + FormatForComparisonFailureMessage(rhs, lhs), false); } // This block of code defines operator==/!= @@ -1538,8 +1526,7 @@ inline bool operator!=(faketype, faketype) { return false; } // The helper function for {ASSERT|EXPECT}_EQ. template AssertionResult CmpHelperEQ(const char* lhs_expression, - const char* rhs_expression, - const T1& lhs, + const char* rhs_expression, const T1& lhs, const T2& rhs) { if (lhs == rhs) { return AssertionSuccess(); @@ -1553,8 +1540,7 @@ AssertionResult CmpHelperEQ(const char* lhs_expression, // can be implicitly cast to BiggestInt. GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression, const char* rhs_expression, - BiggestInt lhs, - BiggestInt rhs); + BiggestInt lhs, BiggestInt rhs); class EqHelper { public: @@ -1578,8 +1564,7 @@ class EqHelper { // Even though its body looks the same as the above version, we // cannot merge the two, as it will make anonymous enums unhappy. static AssertionResult Compare(const char* lhs_expression, - const char* rhs_expression, - BiggestInt lhs, + const char* rhs_expression, BiggestInt lhs, BiggestInt rhs) { return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); } @@ -1619,18 +1604,18 @@ AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. -#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ -template \ -AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ - const T1& val1, const T2& val2) {\ - if (val1 op val2) {\ - return AssertionSuccess();\ - } else {\ - return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\ - }\ -}\ -GTEST_API_ AssertionResult CmpHelper##op_name(\ - const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) +#define GTEST_IMPL_CMP_HELPER_(op_name, op) \ + template \ + AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ + const T1& val1, const T2& val2) { \ + if (val1 op val2) { \ + return AssertionSuccess(); \ + } else { \ + return CmpHelperOpFailure(expr1, expr2, val1, val2, #op); \ + } \ + } \ + GTEST_API_ AssertionResult CmpHelper##op_name( \ + const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. @@ -1652,49 +1637,42 @@ GTEST_IMPL_CMP_HELPER_(GT, >); // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, const char* s2_expression, - const char* s1, - const char* s2); + const char* s1, const char* s2); // The helper function for {ASSERT|EXPECT}_STRCASEEQ. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* s1_expression, const char* s2_expression, - const char* s1, - const char* s2); + const char* s1, const char* s2); // The helper function for {ASSERT|EXPECT}_STRNE. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, const char* s2_expression, - const char* s1, - const char* s2); + const char* s1, const char* s2); // The helper function for {ASSERT|EXPECT}_STRCASENE. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression, const char* s2_expression, - const char* s1, - const char* s2); - + const char* s1, const char* s2); // Helper function for *_STREQ on wide strings. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, const char* s2_expression, - const wchar_t* s1, - const wchar_t* s2); + const wchar_t* s1, const wchar_t* s2); // Helper function for *_STRNE on wide strings. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, const char* s2_expression, - const wchar_t* s1, - const wchar_t* s2); + const wchar_t* s1, const wchar_t* s2); } // namespace internal @@ -1706,32 +1684,40 @@ GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, // // The {needle,haystack}_expr arguments are the stringified // expressions that generated the two real arguments. -GTEST_API_ AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const char* needle, const char* haystack); -GTEST_API_ AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const wchar_t* needle, const wchar_t* haystack); -GTEST_API_ AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const char* needle, const char* haystack); -GTEST_API_ AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const wchar_t* needle, const wchar_t* haystack); -GTEST_API_ AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::string& needle, const ::std::string& haystack); -GTEST_API_ AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::string& needle, const ::std::string& haystack); +GTEST_API_ AssertionResult IsSubstring(const char* needle_expr, + const char* haystack_expr, + const char* needle, + const char* haystack); +GTEST_API_ AssertionResult IsSubstring(const char* needle_expr, + const char* haystack_expr, + const wchar_t* needle, + const wchar_t* haystack); +GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr, + const char* haystack_expr, + const char* needle, + const char* haystack); +GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr, + const char* haystack_expr, + const wchar_t* needle, + const wchar_t* haystack); +GTEST_API_ AssertionResult IsSubstring(const char* needle_expr, + const char* haystack_expr, + const ::std::string& needle, + const ::std::string& haystack); +GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr, + const char* haystack_expr, + const ::std::string& needle, + const ::std::string& haystack); #if GTEST_HAS_STD_WSTRING -GTEST_API_ AssertionResult IsSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::wstring& needle, const ::std::wstring& haystack); -GTEST_API_ AssertionResult IsNotSubstring( - const char* needle_expr, const char* haystack_expr, - const ::std::wstring& needle, const ::std::wstring& haystack); +GTEST_API_ AssertionResult IsSubstring(const char* needle_expr, + const char* haystack_expr, + const ::std::wstring& needle, + const ::std::wstring& haystack); +GTEST_API_ AssertionResult IsNotSubstring(const char* needle_expr, + const char* haystack_expr, + const ::std::wstring& needle, + const ::std::wstring& haystack); #endif // GTEST_HAS_STD_WSTRING namespace internal { @@ -1746,8 +1732,7 @@ namespace internal { template AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, const char* rhs_expression, - RawType lhs_value, - RawType rhs_value) { + RawType lhs_value, RawType rhs_value) { const FloatingPoint lhs(lhs_value), rhs(rhs_value); if (lhs.AlmostEquals(rhs)) { @@ -1762,10 +1747,8 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, rhs_ss << std::setprecision(std::numeric_limits::digits10 + 2) << rhs_value; - return EqFailure(lhs_expression, - rhs_expression, - StringStreamToString(&lhs_ss), - StringStreamToString(&rhs_ss), + return EqFailure(lhs_expression, rhs_expression, + StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss), false); } @@ -1775,8 +1758,7 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression, GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, const char* expr2, const char* abs_error_expr, - double val1, - double val2, + double val1, double val2, double abs_error); // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. @@ -1784,9 +1766,7 @@ GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, class GTEST_API_ AssertHelper { public: // Constructor. - AssertHelper(TestPartResult::Type type, - const char* file, - int line, + AssertHelper(TestPartResult::Type type, const char* file, int line, const char* message); ~AssertHelper(); @@ -1800,11 +1780,9 @@ class GTEST_API_ AssertHelper { // re-using stack space even for temporary variables, so every EXPECT_EQ // reserves stack space for another AssertHelper. struct AssertHelperData { - AssertHelperData(TestPartResult::Type t, - const char* srcfile, - int line_num, + AssertHelperData(TestPartResult::Type t, const char* srcfile, int line_num, const char* msg) - : type(t), file(srcfile), line(line_num), message(msg) { } + : type(t), file(srcfile), line(line_num), message(msg) {} TestPartResult::Type const type; const char* const file; @@ -1874,15 +1852,14 @@ class WithParamInterface { private: // Sets parameter value. The caller is responsible for making sure the value // remains alive and unchanged throughout the current test. - static void SetParam(const ParamType* parameter) { - parameter_ = parameter; - } + static void SetParam(const ParamType* parameter) { parameter_ = parameter; } // Static value used for accessing parameter during a test lifetime. static const ParamType* parameter_; // TestClass must be a subclass of WithParamInterface and Test. - template friend class internal::ParameterizedTestFactory; + template + friend class internal::ParameterizedTestFactory; }; template @@ -1892,8 +1869,7 @@ const T* WithParamInterface::parameter_ = nullptr; // WithParamInterface, and can just inherit from ::testing::TestWithParam. template -class TestWithParam : public Test, public WithParamInterface { -}; +class TestWithParam : public Test, public WithParamInterface {}; // Macros for indicating success/failure in test code. @@ -1924,7 +1900,7 @@ class TestWithParam : public Test, public WithParamInterface { // Generates a nonfatal failure at the given source file location with // a generic message. -#define ADD_FAILURE_AT(file, line) \ +#define ADD_FAILURE_AT(file, line) \ GTEST_MESSAGE_AT_(file, line, "Failed", \ ::testing::TestPartResult::kNonFatalFailure) @@ -1939,7 +1915,7 @@ class TestWithParam : public Test, public WithParamInterface { // Define this macro to 1 to omit the definition of FAIL(), which is a // generic name and clashes with some other libraries. #if !GTEST_DONT_DEFINE_FAIL -# define FAIL() GTEST_FAIL() +#define FAIL() GTEST_FAIL() #endif // Generates a success with a generic message. @@ -1948,7 +1924,7 @@ class TestWithParam : public Test, public WithParamInterface { // Define this macro to 1 to omit the definition of SUCCEED(), which // is a generic name and clashes with some other libraries. #if !GTEST_DONT_DEFINE_SUCCEED -# define SUCCEED() GTEST_SUCCEED() +#define SUCCEED() GTEST_SUCCEED() #endif // Macros for testing exceptions. @@ -1976,16 +1952,15 @@ class TestWithParam : public Test, public WithParamInterface { // Boolean assertions. Condition can be either a Boolean expression or an // AssertionResult. For more information on how to use AssertionResult with // these macros see comments on that class. -#define EXPECT_TRUE(condition) \ +#define EXPECT_TRUE(condition) \ GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_NONFATAL_FAILURE_) -#define EXPECT_FALSE(condition) \ +#define EXPECT_FALSE(condition) \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_NONFATAL_FAILURE_) #define ASSERT_TRUE(condition) \ - GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ - GTEST_FATAL_FAILURE_) -#define ASSERT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_) +#define ASSERT_FALSE(condition) \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_FATAL_FAILURE_) @@ -2065,27 +2040,27 @@ class TestWithParam : public Test, public WithParamInterface { // ASSERT_XY(), which clashes with some users' own code. #if !GTEST_DONT_DEFINE_ASSERT_EQ -# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) +#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) #endif #if !GTEST_DONT_DEFINE_ASSERT_NE -# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) +#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) #endif #if !GTEST_DONT_DEFINE_ASSERT_LE -# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) +#define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) #endif #if !GTEST_DONT_DEFINE_ASSERT_LT -# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) +#define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) #endif #if !GTEST_DONT_DEFINE_ASSERT_GE -# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) +#define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) #endif #if !GTEST_DONT_DEFINE_ASSERT_GT -# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) +#define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) #endif // C-string Comparisons. All tests treat NULL and any non-NULL string @@ -2110,7 +2085,7 @@ class TestWithParam : public Test, public WithParamInterface { EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) #define EXPECT_STRCASEEQ(s1, s2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) -#define EXPECT_STRCASENE(s1, s2)\ +#define EXPECT_STRCASENE(s1, s2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) #define ASSERT_STREQ(s1, s2) \ @@ -2119,7 +2094,7 @@ class TestWithParam : public Test, public WithParamInterface { ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) #define ASSERT_STRCASEEQ(s1, s2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) -#define ASSERT_STRCASENE(s1, s2)\ +#define ASSERT_STRCASENE(s1, s2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) // Macros for comparing floating-point numbers. @@ -2136,29 +2111,29 @@ class TestWithParam : public Test, public WithParamInterface { // FloatingPoint template class in gtest-internal.h if you are // interested in the implementation details. -#define EXPECT_FLOAT_EQ(val1, val2)\ +#define EXPECT_FLOAT_EQ(val1, val2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ val1, val2) -#define EXPECT_DOUBLE_EQ(val1, val2)\ +#define EXPECT_DOUBLE_EQ(val1, val2) \ EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ val1, val2) -#define ASSERT_FLOAT_EQ(val1, val2)\ +#define ASSERT_FLOAT_EQ(val1, val2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ val1, val2) -#define ASSERT_DOUBLE_EQ(val1, val2)\ +#define ASSERT_DOUBLE_EQ(val1, val2) \ ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ val1, val2) -#define EXPECT_NEAR(val1, val2, abs_error)\ - EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ - val1, val2, abs_error) +#define EXPECT_NEAR(val1, val2, abs_error) \ + EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, val1, val2, \ + abs_error) -#define ASSERT_NEAR(val1, val2, abs_error)\ - ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ - val1, val2, abs_error) +#define ASSERT_NEAR(val1, val2, abs_error) \ + ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, val1, val2, \ + abs_error) // These predicate format functions work on floating-point values, and // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. @@ -2172,7 +2147,6 @@ GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2, GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, double val1, double val2); - #if GTEST_OS_WINDOWS // Macros that test for HRESULT failure and success, these are only useful @@ -2184,17 +2158,17 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // expected result and the actual result with both a human-readable // string representation of the error, if available, as well as the // hex result code. -# define EXPECT_HRESULT_SUCCEEDED(expr) \ - EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) +#define EXPECT_HRESULT_SUCCEEDED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) -# define ASSERT_HRESULT_SUCCEEDED(expr) \ - ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) +#define ASSERT_HRESULT_SUCCEEDED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) -# define EXPECT_HRESULT_FAILED(expr) \ - EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) +#define EXPECT_HRESULT_FAILED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) -# define ASSERT_HRESULT_FAILED(expr) \ - ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) +#define ASSERT_HRESULT_FAILED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) #endif // GTEST_OS_WINDOWS @@ -2209,9 +2183,9 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, // ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed"; // #define ASSERT_NO_FATAL_FAILURE(statement) \ - GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_) + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_) #define EXPECT_NO_FATAL_FAILURE(statement) \ - GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) // Causes a trace (including the given source file path and line number, // and the given message) to be included in every test failure message generated @@ -2273,9 +2247,9 @@ class GTEST_API_ ScopedTrace { // Assuming that each thread maintains its own stack of traces. // Therefore, a SCOPED_TRACE() would (correctly) only affect the // assertions in its own thread. -#define SCOPED_TRACE(message) \ - ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ - __FILE__, __LINE__, (message)) +#define SCOPED_TRACE(message) \ + ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)( \ + __FILE__, __LINE__, (message)) // Compile-time assertion for type equality. // StaticAssertTypeEq() compiles if and only if type1 and type2 @@ -2376,7 +2350,7 @@ constexpr bool StaticAssertTypeEq() noexcept { // // GOOGLETEST_CM0011 DO NOT DELETE #if !GTEST_DONT_DEFINE_TEST -#define TEST_F(test_fixture, test_name)\ +#define TEST_F(test_fixture, test_name) \ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId()) #endif // !GTEST_DONT_DEFINE_TEST @@ -2386,7 +2360,7 @@ constexpr bool StaticAssertTypeEq() noexcept { GTEST_API_ std::string TempDir(); #ifdef _MSC_VER -# pragma warning(pop) +#pragma warning(pop) #endif // Dynamically registers a test with the framework. @@ -2481,9 +2455,7 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name, // namespace and has an all-caps name. int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_; -inline int RUN_ALL_TESTS() { - return ::testing::UnitTest::GetInstance()->Run(); -} +inline int RUN_ALL_TESTS() { return ::testing::UnitTest::GetInstance()->Run(); } GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest_pred_impl.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest_pred_impl.h index d514255c7..96a57b21a 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest_pred_impl.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest_pred_impl.h @@ -72,22 +72,18 @@ namespace testing { // GTEST_ASSERT_ is the basic statement to which all of the assertions // in this file reduce. Don't use this in your code. -#define GTEST_ASSERT_(expression, on_failure) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ +#define GTEST_ASSERT_(expression, on_failure) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ if (const ::testing::AssertionResult gtest_ar = (expression)) \ - ; \ - else \ + ; \ + else \ on_failure(gtest_ar.failure_message()) - // Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use // this in your code. -template -AssertionResult AssertPred1Helper(const char* pred_text, - const char* e1, - Pred pred, - const T1& v1) { +template +AssertionResult AssertPred1Helper(const char* pred_text, const char* e1, + Pred pred, const T1& v1) { if (pred(v1)) return AssertionSuccess(); return AssertionFailure() @@ -98,40 +94,27 @@ AssertionResult AssertPred1Helper(const char* pred_text, // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1. // Don't use this in your code. -#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\ - GTEST_ASSERT_(pred_format(#v1, v1), \ - on_failure) +#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure) \ + GTEST_ASSERT_(pred_format(#v1, v1), on_failure) // Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use // this in your code. -#define GTEST_PRED1_(pred, v1, on_failure)\ - GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \ - #v1, \ - pred, \ - v1), on_failure) +#define GTEST_PRED1_(pred, v1, on_failure) \ + GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, #v1, pred, v1), on_failure) // Unary predicate assertion macros. #define EXPECT_PRED_FORMAT1(pred_format, v1) \ GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_) -#define EXPECT_PRED1(pred, v1) \ - GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED1(pred, v1) GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_) #define ASSERT_PRED_FORMAT1(pred_format, v1) \ GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_) -#define ASSERT_PRED1(pred, v1) \ - GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_) - - +#define ASSERT_PRED1(pred, v1) GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_) // Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use // this in your code. -template -AssertionResult AssertPred2Helper(const char* pred_text, - const char* e1, - const char* e2, - Pred pred, - const T1& v1, +template +AssertionResult AssertPred2Helper(const char* pred_text, const char* e1, + const char* e2, Pred pred, const T1& v1, const T2& v2) { if (pred(v1, v2)) return AssertionSuccess(); @@ -145,19 +128,14 @@ AssertionResult AssertPred2Helper(const char* pred_text, // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2. // Don't use this in your code. -#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\ - GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \ - on_failure) +#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure) \ + GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure) // Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use // this in your code. -#define GTEST_PRED2_(pred, v1, v2, on_failure)\ - GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \ - #v1, \ - #v2, \ - pred, \ - v1, \ - v2), on_failure) +#define GTEST_PRED2_(pred, v1, v2, on_failure) \ + GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, #v1, #v2, pred, v1, v2), \ + on_failure) // Binary predicate assertion macros. #define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \ @@ -169,22 +147,12 @@ AssertionResult AssertPred2Helper(const char* pred_text, #define ASSERT_PRED2(pred, v1, v2) \ GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_) - - // Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use // this in your code. -template -AssertionResult AssertPred3Helper(const char* pred_text, - const char* e1, - const char* e2, - const char* e3, - Pred pred, - const T1& v1, - const T2& v2, - const T3& v3) { +template +AssertionResult AssertPred3Helper(const char* pred_text, const char* e1, + const char* e2, const char* e3, Pred pred, + const T1& v1, const T2& v2, const T3& v3) { if (pred(v1, v2, v3)) return AssertionSuccess(); return AssertionFailure() @@ -198,21 +166,15 @@ AssertionResult AssertPred3Helper(const char* pred_text, // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3. // Don't use this in your code. -#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\ - GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \ - on_failure) +#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure) \ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), on_failure) // Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use // this in your code. -#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\ - GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \ - #v1, \ - #v2, \ - #v3, \ - pred, \ - v1, \ - v2, \ - v3), on_failure) +#define GTEST_PRED3_(pred, v1, v2, v3, on_failure) \ + GTEST_ASSERT_( \ + ::testing::AssertPred3Helper(#pred, #v1, #v2, #v3, pred, v1, v2, v3), \ + on_failure) // Ternary predicate assertion macros. #define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \ @@ -224,25 +186,13 @@ AssertionResult AssertPred3Helper(const char* pred_text, #define ASSERT_PRED3(pred, v1, v2, v3) \ GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_) - - // Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use // this in your code. -template -AssertionResult AssertPred4Helper(const char* pred_text, - const char* e1, - const char* e2, - const char* e3, - const char* e4, - Pred pred, - const T1& v1, - const T2& v2, - const T3& v3, - const T4& v4) { +template +AssertionResult AssertPred4Helper(const char* pred_text, const char* e1, + const char* e2, const char* e3, + const char* e4, Pred pred, const T1& v1, + const T2& v2, const T3& v3, const T4& v4) { if (pred(v1, v2, v3, v4)) return AssertionSuccess(); return AssertionFailure() @@ -257,23 +207,15 @@ AssertionResult AssertPred4Helper(const char* pred_text, // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4. // Don't use this in your code. -#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\ - GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \ - on_failure) +#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure) \ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), on_failure) // Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use // this in your code. -#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\ - GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \ - #v1, \ - #v2, \ - #v3, \ - #v4, \ - pred, \ - v1, \ - v2, \ - v3, \ - v4), on_failure) +#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure) \ + GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, #v1, #v2, #v3, #v4, pred, \ + v1, v2, v3, v4), \ + on_failure) // 4-ary predicate assertion macros. #define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \ @@ -285,28 +227,15 @@ AssertionResult AssertPred4Helper(const char* pred_text, #define ASSERT_PRED4(pred, v1, v2, v3, v4) \ GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_) - - // Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use // this in your code. -template -AssertionResult AssertPred5Helper(const char* pred_text, - const char* e1, - const char* e2, - const char* e3, - const char* e4, - const char* e5, - Pred pred, - const T1& v1, - const T2& v2, - const T3& v3, - const T4& v4, - const T5& v5) { +AssertionResult AssertPred5Helper(const char* pred_text, const char* e1, + const char* e2, const char* e3, + const char* e4, const char* e5, Pred pred, + const T1& v1, const T2& v2, const T3& v3, + const T4& v4, const T5& v5) { if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess(); return AssertionFailure() @@ -322,25 +251,16 @@ AssertionResult AssertPred5Helper(const char* pred_text, // Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5. // Don't use this in your code. -#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\ +#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure) \ GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \ on_failure) // Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use // this in your code. -#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\ - GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \ - #v1, \ - #v2, \ - #v3, \ - #v4, \ - #v5, \ - pred, \ - v1, \ - v2, \ - v3, \ - v4, \ - v5), on_failure) +#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure) \ + GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, #v1, #v2, #v3, #v4, #v5, \ + pred, v1, v2, v3, v4, v5), \ + on_failure) // 5-ary predicate assertion macros. #define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \ @@ -352,8 +272,6 @@ AssertionResult AssertPred5Helper(const char* pred_text, #define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \ GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_) - - } // namespace testing #endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ diff --git a/Testing/lib/googletest-master/googletest/include/gtest/gtest_prod.h b/Testing/lib/googletest-master/googletest/include/gtest/gtest_prod.h index e651671eb..3dc5b2386 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/gtest_prod.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/gtest_prod.h @@ -28,8 +28,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Google C++ Testing and Mocking Framework definitions useful in production code. -// GOOGLETEST_CM0003 DO NOT DELETE +// Google C++ Testing and Mocking Framework definitions useful in production +// code. GOOGLETEST_CM0003 DO NOT DELETE #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ @@ -55,7 +55,7 @@ // Note: The test class must be in the same namespace as the class being tested. // For example, putting MyClassTest in an anonymous namespace will not work. -#define FRIEND_TEST(test_case_name, test_name)\ -friend class test_case_name##_##test_name##_Test +#define FRIEND_TEST(test_case_name, test_name) \ + friend class test_case_name##_##test_name##_Test #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-death-test-internal.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-death-test-internal.h index 68bd35306..e2f21437d 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -36,12 +36,13 @@ #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ -#include "gtest/gtest-matchers.h" -#include "gtest/internal/gtest-internal.h" - #include + #include +#include "gtest/gtest-matchers.h" +#include "gtest/internal/gtest-internal.h" + namespace testing { namespace internal { @@ -83,13 +84,14 @@ class GTEST_API_ DeathTest { static bool Create(const char* statement, Matcher matcher, const char* file, int line, DeathTest** test); DeathTest(); - virtual ~DeathTest() { } + virtual ~DeathTest() {} // A helper class that aborts a death test when it's deleted. class ReturnSentinel { public: - explicit ReturnSentinel(DeathTest* test) : test_(test) { } + explicit ReturnSentinel(DeathTest* test) : test_(test) {} ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); } + private: DeathTest* const test_; GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel); @@ -145,7 +147,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // Factory interface for death tests. May be mocked out for testing. class DeathTestFactory { public: - virtual ~DeathTestFactory() { } + virtual ~DeathTestFactory() {} virtual bool Create(const char* statement, Matcher matcher, const char* file, int line, DeathTest** test) = 0; @@ -186,28 +188,28 @@ inline Matcher MakeDeathTestMatcher( // Traps C++ exceptions escaping statement and reports them as test // failures. Note that trapping SEH exceptions is not implemented here. -# if GTEST_HAS_EXCEPTIONS -# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ - try { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } catch (const ::std::exception& gtest_exception) { \ - fprintf(\ - stderr, \ - "\n%s: Caught std::exception-derived exception escaping the " \ - "death test statement. Exception message: %s\n", \ +#if GTEST_HAS_EXCEPTIONS +#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } catch (const ::std::exception& gtest_exception) { \ + fprintf( \ + stderr, \ + "\n%s: Caught std::exception-derived exception escaping the " \ + "death test statement. Exception message: %s\n", \ ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \ - gtest_exception.what()); \ - fflush(stderr); \ + gtest_exception.what()); \ + fflush(stderr); \ death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ - } catch (...) { \ + } catch (...) { \ death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ } -# else -# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ +#else +#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) -# endif +#endif // This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*, // ASSERT_EXIT*, and EXPECT_EXIT*. @@ -265,16 +267,12 @@ inline Matcher MakeDeathTestMatcher( // RUN_ALL_TESTS was called. class InternalRunDeathTestFlag { public: - InternalRunDeathTestFlag(const std::string& a_file, - int a_line, - int an_index, + InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index, int a_write_fd) - : file_(a_file), line_(a_line), index_(an_index), - write_fd_(a_write_fd) {} + : file_(a_file), line_(a_line), index_(an_index), write_fd_(a_write_fd) {} ~InternalRunDeathTestFlag() { - if (write_fd_ >= 0) - posix::Close(write_fd_); + if (write_fd_ >= 0) posix::Close(write_fd_); } const std::string& file() const { return file_; } diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-filepath.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-filepath.h index c11b10151..328edb4f1 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-filepath.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-filepath.h @@ -61,8 +61,8 @@ namespace internal { class GTEST_API_ FilePath { public: - FilePath() : pathname_("") { } - FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { } + FilePath() : pathname_("") {} + FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {} explicit FilePath(const std::string& pathname) : pathname_(pathname) { Normalize(); @@ -73,9 +73,7 @@ class GTEST_API_ FilePath { return *this; } - void Set(const FilePath& rhs) { - pathname_ = rhs.pathname_; - } + void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; } const std::string& string() const { return pathname_; } const char* c_str() const { return pathname_.c_str(); } @@ -88,8 +86,7 @@ class GTEST_API_ FilePath { // than zero (e.g., 12), returns "dir/test_12.xml". // On Windows platform, uses \ as the separator rather than /. static FilePath MakeFileName(const FilePath& directory, - const FilePath& base_name, - int number, + const FilePath& base_name, int number, const char* extension); // Given directory = "dir", relative_path = "test.xml", diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-internal.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-internal.h index 028f21eb5..33113f666 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-internal.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-internal.h @@ -40,19 +40,20 @@ #include "gtest/internal/gtest-port.h" #if GTEST_OS_LINUX -# include -# include -# include -# include +#include +#include +#include +#include #endif // GTEST_OS_LINUX #if GTEST_HAS_EXCEPTIONS -# include +#include #endif #include #include #include + #include #include #include @@ -76,7 +77,7 @@ // the current line number. For more details, see // http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar) -#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar +#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo##bar // Stringifies its argument. // Work around a bug in visual studio which doesn't accept code like this: @@ -98,21 +99,21 @@ namespace testing { // Forward declarations. -class AssertionResult; // Result of an assertion. -class Message; // Represents a failure message. -class Test; // Represents a test. -class TestInfo; // Information about a test. -class TestPartResult; // Result of a test part. -class UnitTest; // A collection of test suites. +class AssertionResult; // Result of an assertion. +class Message; // Represents a failure message. +class Test; // Represents a test. +class TestInfo; // Information about a test. +class TestPartResult; // Result of a test part. +class UnitTest; // A collection of test suites. template ::std::string PrintToString(const T& value); namespace internal { -struct TraceInfo; // Information about a trace point. -class TestInfoImpl; // Opaque implementation of TestInfo -class UnitTestImpl; // Opaque implementation of UnitTest +struct TraceInfo; // Information about a trace point. +class TestInfoImpl; // Opaque implementation of TestInfo +class UnitTestImpl; // Opaque implementation of UnitTest // The text used in failure messages to indicate the start of the // stack trace. @@ -121,6 +122,7 @@ GTEST_API_ extern const char kStackTraceMarker[]; // An IgnoredValue object can be implicitly constructed from ANY value. class IgnoredValue { struct Sink {}; + public: // This constructor template allows any value to be implicitly // converted to IgnoredValue. The object has no data member and @@ -136,13 +138,13 @@ class IgnoredValue { }; // Appends the user-supplied message to the Google-Test-generated message. -GTEST_API_ std::string AppendUserMessage( - const std::string& gtest_msg, const Message& user_msg); +GTEST_API_ std::string AppendUserMessage(const std::string& gtest_msg, + const Message& user_msg); #if GTEST_HAS_EXCEPTIONS -GTEST_DISABLE_MSC_WARNINGS_PUSH_(4275 \ -/* an exported class was derived from a class that was not exported */) +GTEST_DISABLE_MSC_WARNINGS_PUSH_( + 4275 /* an exported class was derived from a class that was not exported */) // This exception is thrown by (and only by) a failed Google Test // assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions @@ -212,10 +214,8 @@ GTEST_API_ AssertionResult EqFailure(const char* expected_expression, // Constructs a failure message for Boolean assertions such as EXPECT_TRUE. GTEST_API_ std::string GetBoolAssertionFailureMessage( - const AssertionResult& assertion_result, - const char* expression_text, - const char* actual_predicate_value, - const char* expected_predicate_value); + const AssertionResult& assertion_result, const char* expression_text, + const char* actual_predicate_value, const char* expected_predicate_value); // This template class represents an IEEE floating-point number // (either single-precision or double-precision, depending on the @@ -256,11 +256,11 @@ class FloatingPoint { // Constants. // # of bits in a number. - static const size_t kBitCount = 8*sizeof(RawType); + static const size_t kBitCount = 8 * sizeof(RawType); // # of fraction bits in a number. static const size_t kFractionBitCount = - std::numeric_limits::digits - 1; + std::numeric_limits::digits - 1; // # of exponent bits in a number. static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount; @@ -269,8 +269,8 @@ class FloatingPoint { static const Bits kSignBitMask = static_cast(1) << (kBitCount - 1); // The mask for the fraction bits. - static const Bits kFractionBitMask = - ~static_cast(0) >> (kExponentBitCount + 1); + static const Bits kFractionBitMask = ~static_cast(0) >> + (kExponentBitCount + 1); // The mask for the exponent bits. static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask); @@ -309,9 +309,7 @@ class FloatingPoint { } // Returns the floating-point number that represent positive infinity. - static RawType Infinity() { - return ReinterpretBits(kExponentBitMask); - } + static RawType Infinity() { return ReinterpretBits(kExponentBitMask); } // Returns the maximum representable finite floating-point number. static RawType Max(); @@ -319,7 +317,7 @@ class FloatingPoint { // Non-static methods // Returns the bits that represents this number. - const Bits &bits() const { return u_.bits_; } + const Bits& bits() const { return u_.bits_; } // Returns the exponent bits of this number. Bits exponent_bits() const { return kExponentBitMask & u_.bits_; } @@ -348,8 +346,8 @@ class FloatingPoint { // a NAN must return false. if (is_nan() || rhs.is_nan()) return false; - return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) - <= kMaxUlps; + return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) <= + kMaxUlps; } private: @@ -374,7 +372,7 @@ class FloatingPoint { // // Read http://en.wikipedia.org/wiki/Signed_number_representations // for more details on signed number representations. - static Bits SignAndMagnitudeToBiased(const Bits &sam) { + static Bits SignAndMagnitudeToBiased(const Bits& sam) { if (kSignBitMask & sam) { // sam represents a negative number. return ~sam + 1; @@ -386,8 +384,8 @@ class FloatingPoint { // Given two numbers in the sign-and-magnitude representation, // returns the distance between them as an unsigned number. - static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1, - const Bits &sam2) { + static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits& sam1, + const Bits& sam2) { const Bits biased1 = SignAndMagnitudeToBiased(sam1); const Bits biased2 = SignAndMagnitudeToBiased(sam2); return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1); @@ -399,9 +397,13 @@ class FloatingPoint { // We cannot use std::numeric_limits::max() as it clashes with the max() // macro defined by . template <> -inline float FloatingPoint::Max() { return FLT_MAX; } +inline float FloatingPoint::Max() { + return FLT_MAX; +} template <> -inline double FloatingPoint::Max() { return DBL_MAX; } +inline double FloatingPoint::Max() { + return DBL_MAX; +} // Typedefs the instances of the FloatingPoint template class that we // care to use. @@ -644,7 +646,8 @@ inline const char* SkipComma(const char* str) { if (comma == nullptr) { return nullptr; } - while (IsSpace(*(++comma))) {} + while (IsSpace(*(++comma))) { + } return comma; } @@ -658,7 +661,7 @@ inline std::string GetPrefixUntilComma(const char* str) { // Splits a given string on a given delimiter, populating a given // vector with the fields. void SplitString(const ::std::string& str, char delimiter, - ::std::vector< ::std::string>* dest); + ::std::vector<::std::string>* dest); // The default argument to the template below for the case when the user does // not provide a name generator. @@ -771,13 +774,13 @@ class TypeParameterizedTestSuite { const std::vector& type_names = GenerateNames()) { RegisterTypeParameterizedTestSuiteInstantiation(case_name); - std::string test_name = StripTrailingSpaces( - GetPrefixUntilComma(test_names)); + std::string test_name = + StripTrailingSpaces(GetPrefixUntilComma(test_names)); if (!state->TestExists(test_name)) { fprintf(stderr, "Failed to get code location for test %s.%s at %s.", case_name, test_name.c_str(), - FormatFileLocation(code_location.file.c_str(), - code_location.line).c_str()); + FormatFileLocation(code_location.file.c_str(), code_location.line) + .c_str()); fflush(stderr); posix::Abort(); } @@ -823,8 +826,8 @@ class TypeParameterizedTestSuite { // For example, if Foo() calls Bar(), which in turn calls // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. -GTEST_API_ std::string GetCurrentOsStackTraceExceptTop( - UnitTest* unit_test, int skip_count); +GTEST_API_ std::string GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, + int skip_count); // Helpers for suppressing warnings on unreachable code or constant // condition. @@ -923,7 +926,9 @@ IsContainer IsContainerTest(int /* dummy */) { typedef char IsNotContainer; template -IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; } +IsNotContainer IsContainerTest(long /* dummy */) { + return '\0'; +} // Trait to detect whether a type T is a hash table. // The heuristic used is that the type contains an inner type `hasher` and does @@ -986,11 +991,13 @@ bool ArrayEq(const T* lhs, size_t size, const U* rhs); // This generic version is used when k is 0. template -inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; } +inline bool ArrayEq(const T& lhs, const U& rhs) { + return lhs == rhs; +} // This overload is used when k >= 1. template -inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) { +inline bool ArrayEq(const T (&lhs)[N], const U (&rhs)[N]) { return internal::ArrayEq(lhs, N, rhs); } @@ -1000,8 +1007,7 @@ inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) { template bool ArrayEq(const T* lhs, size_t size, const U* rhs) { for (size_t i = 0; i != size; i++) { - if (!internal::ArrayEq(lhs[i], rhs[i])) - return false; + if (!internal::ArrayEq(lhs[i], rhs[i])) return false; } return true; } @@ -1011,8 +1017,7 @@ bool ArrayEq(const T* lhs, size_t size, const U* rhs) { template Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) { for (Iter it = begin; it != end; ++it) { - if (internal::ArrayEq(*it, elem)) - return it; + if (internal::ArrayEq(*it, elem)) return it; } return end; } @@ -1026,11 +1031,13 @@ void CopyArray(const T* from, size_t size, U* to); // This generic version is used when k is 0. template -inline void CopyArray(const T& from, U* to) { *to = from; } +inline void CopyArray(const T& from, U* to) { + *to = from; +} // This overload is used when k >= 1. template -inline void CopyArray(const T(&from)[N], U(*to)[N]) { +inline void CopyArray(const T (&from)[N], U (*to)[N]) { internal::CopyArray(from, N, *to); } @@ -1083,8 +1090,7 @@ class NativeArray { } ~NativeArray() { - if (clone_ != &NativeArray::InitRef) - delete[] array_; + if (clone_ != &NativeArray::InitRef) delete[] array_; } // STL-style container methods. @@ -1092,8 +1098,7 @@ class NativeArray { const_iterator begin() const { return array_; } const_iterator end() const { return array_ + size_; } bool operator==(const NativeArray& rhs) const { - return size() == rhs.size() && - ArrayEq(begin(), size(), rhs.begin()); + return size() == rhs.size() && ArrayEq(begin(), size(), rhs.begin()); } private: @@ -1261,9 +1266,9 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } } // namespace internal } // namespace testing -#define GTEST_MESSAGE_AT_(file, line, message, result_type) \ - ::testing::internal::AssertHelper(result_type, file, line, message) \ - = ::testing::Message() +#define GTEST_MESSAGE_AT_(file, line, message, result_type) \ + ::testing::internal::AssertHelper(result_type, file, line, message) = \ + ::testing::Message() #define GTEST_MESSAGE_(message, result_type) \ GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type) @@ -1291,42 +1296,39 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } } else /* NOLINT */ \ static_assert(true, "") // User must have a semicolon after expansion. -#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::ConstCharPtr gtest_msg = "") { \ - bool gtest_caught_expected = false; \ - try { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } \ - catch (expected_exception const&) { \ - gtest_caught_expected = true; \ - } \ - catch (...) { \ - gtest_msg.value = \ - "Expected: " #statement " throws an exception of type " \ - #expected_exception ".\n Actual: it throws a different type."; \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ - } \ - if (!gtest_caught_expected) { \ - gtest_msg.value = \ - "Expected: " #statement " throws an exception of type " \ - #expected_exception ".\n Actual: it throws nothing."; \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ - } \ - } else \ - GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ - fail(gtest_msg.value) +#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::ConstCharPtr gtest_msg = "") { \ + bool gtest_caught_expected = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } catch (expected_exception const&) { \ + gtest_caught_expected = true; \ + } catch (...) { \ + gtest_msg.value = "Expected: " #statement \ + " throws an exception of type " #expected_exception \ + ".\n Actual: it throws a different type."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + if (!gtest_caught_expected) { \ + gtest_msg.value = "Expected: " #statement \ + " throws an exception of type " #expected_exception \ + ".\n Actual: it throws nothing."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \ + : fail(gtest_msg.value) #if GTEST_HAS_EXCEPTIONS -#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ - catch (std::exception const& e) { \ - gtest_msg.value = ( \ - "it throws std::exception-derived exception with description: \"" \ - ); \ - gtest_msg.value += e.what(); \ - gtest_msg.value += "\"."; \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ +#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ + catch (std::exception const& e) { \ + gtest_msg.value = \ + ("it throws std::exception-derived exception with description: \""); \ + gtest_msg.value += e.what(); \ + gtest_msg.value += "\"."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ } #else // GTEST_HAS_EXCEPTIONS @@ -1335,66 +1337,69 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } #endif // GTEST_HAS_EXCEPTIONS -#define GTEST_TEST_NO_THROW_(statement, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::TrueWithString gtest_msg{}) { \ - try { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } \ - GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ - catch (...) { \ - gtest_msg.value = "it throws."; \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ - } \ - } else \ - GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ - fail(("Expected: " #statement " doesn't throw an exception.\n" \ - " Actual: " + gtest_msg.value).c_str()) - -#define GTEST_TEST_ANY_THROW_(statement, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ - bool gtest_caught_any = false; \ - try { \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - } \ - catch (...) { \ - gtest_caught_any = true; \ - } \ - if (!gtest_caught_any) { \ +#define GTEST_TEST_NO_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::TrueWithString gtest_msg{}) { \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ + catch (...) { \ + gtest_msg.value = "it throws."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__) \ + : fail(("Expected: " #statement " doesn't throw an exception.\n" \ + " Actual: " + \ + gtest_msg.value) \ + .c_str()) + +#define GTEST_TEST_ANY_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + bool gtest_caught_any = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } catch (...) { \ + gtest_caught_any = true; \ + } \ + if (!gtest_caught_any) { \ goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ - } \ - } else \ - GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \ - fail("Expected: " #statement " throws an exception.\n" \ - " Actual: it doesn't.") - + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__) \ + : fail("Expected: " #statement \ + " throws an exception.\n" \ + " Actual: it doesn't.") // Implements Boolean test assertions such as EXPECT_TRUE. expression can be // either a boolean expression or an AssertionResult. text is a textual // represenation of expression as it was passed into the EXPECT_TRUE. #define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (const ::testing::AssertionResult gtest_ar_ = \ - ::testing::AssertionResult(expression)) \ - ; \ - else \ - fail(::testing::internal::GetBoolAssertionFailureMessage(\ - gtest_ar_, text, #actual, #expected).c_str()) - -#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::AlwaysTrue()) { \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar_ = \ + ::testing::AssertionResult(expression)) \ + ; \ + else \ + fail(::testing::internal::GetBoolAssertionFailureMessage( \ + gtest_ar_, text, #actual, #expected) \ + .c_str()) + +#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \ - GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ - if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ - } \ - } else \ - GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ - fail("Expected: " #statement " doesn't generate new fatal " \ - "failures in the current thread.\n" \ - " Actual: it does.") + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__) \ + : fail("Expected: " #statement \ + " doesn't generate new fatal " \ + "failures in the current thread.\n" \ + " Actual: it does.") // Expands to the name of the class that implements the given test. #define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-param-util.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-param-util.h index 14ce2dd8c..cfc694d90 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-param-util.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-param-util.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Type and function utilities for implementing parameterized tests. // GOOGLETEST_CM0001 DO NOT DELETE @@ -46,19 +45,18 @@ #include #include -#include "gtest/internal/gtest-internal.h" -#include "gtest/internal/gtest-port.h" #include "gtest/gtest-printers.h" #include "gtest/gtest-test-part.h" +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-port.h" namespace testing { // Input to a parameterized test name generator, describing a test parameter. // Consists of the parameter value and the integer parameter index. template struct TestParamInfo { - TestParamInfo(const ParamType& a_param, size_t an_index) : - param(a_param), - index(an_index) {} + TestParamInfo(const ParamType& a_param, size_t an_index) + : param(a_param), index(an_index) {} ParamType param; size_t index; }; @@ -84,8 +82,10 @@ namespace internal { GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name, CodeLocation code_location); -template class ParamGeneratorInterface; -template class ParamGenerator; +template +class ParamGeneratorInterface; +template +class ParamGenerator; // Interface for iterating over elements provided by an implementation // of ParamGeneratorInterface. @@ -129,8 +129,7 @@ class ParamIterator { // ParamIterator assumes ownership of the impl_ pointer. ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {} ParamIterator& operator=(const ParamIterator& other) { - if (this != &other) - impl_.reset(other.impl_->Clone()); + if (this != &other) impl_.reset(other.impl_->Clone()); return *this; } @@ -157,7 +156,7 @@ class ParamIterator { private: friend class ParamGenerator; explicit ParamIterator(ParamIteratorInterface* impl) : impl_(impl) {} - std::unique_ptr > impl_; + std::unique_ptr> impl_; }; // ParamGeneratorInterface is the binary interface to access generators @@ -179,7 +178,7 @@ class ParamGeneratorInterface { // This class implements copy initialization semantics and the contained // ParamGeneratorInterface instance is shared among all copies // of the original object. This is possible because that instance is immutable. -template +template class ParamGenerator { public: typedef ParamIterator iterator; @@ -196,7 +195,7 @@ class ParamGenerator { iterator end() const { return iterator(impl_->End()); } private: - std::shared_ptr > impl_; + std::shared_ptr> impl_; }; // Generates values from a range of two comparable values. Can be used to @@ -207,8 +206,10 @@ template class RangeGenerator : public ParamGeneratorInterface { public: RangeGenerator(T begin, T end, IncrementT step) - : begin_(begin), end_(end), - step_(step), end_index_(CalculateEndIndex(begin, end, step)) {} + : begin_(begin), + end_(end), + step_(step), + end_index_(CalculateEndIndex(begin, end, step)) {} ~RangeGenerator() override {} ParamIteratorInterface* Begin() const override { @@ -251,7 +252,9 @@ class RangeGenerator : public ParamGeneratorInterface { private: Iterator(const Iterator& other) : ParamIteratorInterface(), - base_(other.base_), value_(other.value_), index_(other.index_), + base_(other.base_), + value_(other.value_), + index_(other.index_), step_(other.step_) {} // No implementation - assignment is unsupported. @@ -263,12 +266,10 @@ class RangeGenerator : public ParamGeneratorInterface { const IncrementT step_; }; // class RangeGenerator::Iterator - static int CalculateEndIndex(const T& begin, - const T& end, + static int CalculateEndIndex(const T& begin, const T& end, const IncrementT& step) { int end_index = 0; - for (T i = begin; i < end; i = static_cast(i + step)) - end_index++; + for (T i = begin; i < end; i = static_cast(i + step)) end_index++; return end_index; } @@ -283,7 +284,6 @@ class RangeGenerator : public ParamGeneratorInterface { const int end_index_; }; // class RangeGenerator - // Generates values from a pair of STL-style iterators. Used in the // ValuesIn() function. The elements are copied from the source range // since the source can be located on the stack, and the generator @@ -341,13 +341,13 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface { << "The program attempted to compare iterators " << "from different generators." << std::endl; return iterator_ == - CheckedDowncastToActualType(&other)->iterator_; + CheckedDowncastToActualType(&other)->iterator_; } private: Iterator(const Iterator& other) - // The explicit constructor call suppresses a false warning - // emitted by gcc when supplied with the -Wextra option. + // The explicit constructor call suppresses a false warning + // emitted by gcc when supplied with the -Wextra option. : ParamIteratorInterface(), base_(other.base_), iterator_(other.iterator_) {} @@ -394,8 +394,8 @@ template class ParameterizedTestFactory : public TestFactoryBase { public: typedef typename TestClass::ParamType ParamType; - explicit ParameterizedTestFactory(ParamType parameter) : - parameter_(parameter) {} + explicit ParameterizedTestFactory(ParamType parameter) + : parameter_(parameter) {} Test* CreateTest() override { TestClass::SetParam(¶meter_); return new TestClass(); @@ -546,8 +546,8 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { test_it != tests_.end(); ++test_it) { std::shared_ptr test_info = *test_it; for (typename InstantiationContainer::iterator gen_it = - instantiations_.begin(); gen_it != instantiations_.end(); - ++gen_it) { + instantiations_.begin(); + gen_it != instantiations_.end(); ++gen_it) { const std::string& instantiation_name = gen_it->name; ParamGenerator generator((*gen_it->generator)()); ParamNameGeneratorFunc* name_func = gen_it->name_func; @@ -555,7 +555,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { int line = gen_it->line; std::string test_suite_name; - if ( !instantiation_name.empty() ) + if (!instantiation_name.empty()) test_suite_name = instantiation_name + "/"; test_suite_name += test_info->test_suite_base_name; @@ -568,17 +568,16 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { Message test_name_stream; - std::string param_name = name_func( - TestParamInfo(*param_it, i)); + std::string param_name = + name_func(TestParamInfo(*param_it, i)); GTEST_CHECK_(IsValidParamName(param_name)) << "Parameterized test name '" << param_name - << "' is invalid, in " << file - << " line " << line << std::endl; + << "' is invalid, in " << file << " line " << line << std::endl; GTEST_CHECK_(test_param_names.count(param_name) == 0) - << "Duplicate parameterized test name '" << param_name - << "', in " << file << " line " << line << std::endl; + << "Duplicate parameterized test name '" << param_name << "', in " + << file << " line " << line << std::endl; test_param_names.insert(param_name); @@ -603,7 +602,7 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { InsertSyntheticTestCase(GetTestSuiteName(), code_location_, !tests_.empty()); } - } // RegisterTests + } // RegisterTests private: // LocalTestInfo structure keeps information about a single test registered @@ -617,41 +616,38 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase { const std::string test_suite_base_name; const std::string test_base_name; - const std::unique_ptr > test_meta_factory; + const std::unique_ptr> test_meta_factory; }; - using TestInfoContainer = ::std::vector >; + using TestInfoContainer = ::std::vector>; // Records data received from INSTANTIATE_TEST_SUITE_P macros: // struct InstantiationInfo { - InstantiationInfo(const std::string &name_in, - GeneratorCreationFunc* generator_in, - ParamNameGeneratorFunc* name_func_in, - const char* file_in, - int line_in) - : name(name_in), - generator(generator_in), - name_func(name_func_in), - file(file_in), - line(line_in) {} - - std::string name; - GeneratorCreationFunc* generator; - ParamNameGeneratorFunc* name_func; - const char* file; - int line; + InstantiationInfo(const std::string& name_in, + GeneratorCreationFunc* generator_in, + ParamNameGeneratorFunc* name_func_in, const char* file_in, + int line_in) + : name(name_in), + generator(generator_in), + name_func(name_func_in), + file(file_in), + line(line_in) {} + + std::string name; + GeneratorCreationFunc* generator; + ParamNameGeneratorFunc* name_func; + const char* file; + int line; }; typedef ::std::vector InstantiationContainer; static bool IsValidParamName(const std::string& name) { // Check for empty string - if (name.empty()) - return false; + if (name.empty()) return false; // Check for invalid characters for (std::string::size_type index = 0; index < name.size(); ++index) { - if (!isalnum(name[index]) && name[index] != '_') - return false; + if (!isalnum(name[index]) && name[index] != '_') return false; } return true; @@ -705,7 +701,7 @@ class ParameterizedTestSuiteRegistry { // type we are looking for, so we downcast it to that type // without further checks. typed_test_info = CheckedDowncastToActualType< - ParameterizedTestSuiteInfo >(test_suite_info); + ParameterizedTestSuiteInfo>(test_suite_info); } break; } @@ -823,7 +819,8 @@ class CartesianProductGenerator : public ParamIteratorInterface { public: IteratorImpl(const ParamGeneratorInterface* base, - const std::tuple...>& generators, bool is_end) + const std::tuple...>& generators, + bool is_end) : base_(base), begin_(std::get(generators).begin()...), end_(std::get(generators).end()...), diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port-arch.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port-arch.h index d3239b25b..f803a19be 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port-arch.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port-arch.h @@ -37,69 +37,69 @@ // Determines the platform on which Google Test is compiled. #ifdef __CYGWIN__ -# define GTEST_OS_CYGWIN 1 -# elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__) -# define GTEST_OS_WINDOWS_MINGW 1 -# define GTEST_OS_WINDOWS 1 +#define GTEST_OS_CYGWIN 1 +#elif defined(__MINGW__) || defined(__MINGW32__) || defined(__MINGW64__) +#define GTEST_OS_WINDOWS_MINGW 1 +#define GTEST_OS_WINDOWS 1 #elif defined _WIN32 -# define GTEST_OS_WINDOWS 1 -# ifdef _WIN32_WCE -# define GTEST_OS_WINDOWS_MOBILE 1 -# elif defined(WINAPI_FAMILY) -# include -# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) -# define GTEST_OS_WINDOWS_DESKTOP 1 -# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) -# define GTEST_OS_WINDOWS_PHONE 1 -# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) -# define GTEST_OS_WINDOWS_RT 1 -# elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE) -# define GTEST_OS_WINDOWS_PHONE 1 -# define GTEST_OS_WINDOWS_TV_TITLE 1 -# else - // WINAPI_FAMILY defined but no known partition matched. - // Default to desktop. -# define GTEST_OS_WINDOWS_DESKTOP 1 -# endif -# else -# define GTEST_OS_WINDOWS_DESKTOP 1 -# endif // _WIN32_WCE +#define GTEST_OS_WINDOWS 1 +#ifdef _WIN32_WCE +#define GTEST_OS_WINDOWS_MOBILE 1 +#elif defined(WINAPI_FAMILY) +#include +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +#define GTEST_OS_WINDOWS_DESKTOP 1 +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +#define GTEST_OS_WINDOWS_PHONE 1 +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#define GTEST_OS_WINDOWS_RT 1 +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE) +#define GTEST_OS_WINDOWS_PHONE 1 +#define GTEST_OS_WINDOWS_TV_TITLE 1 +#else +// WINAPI_FAMILY defined but no known partition matched. +// Default to desktop. +#define GTEST_OS_WINDOWS_DESKTOP 1 +#endif +#else +#define GTEST_OS_WINDOWS_DESKTOP 1 +#endif // _WIN32_WCE #elif defined __OS2__ -# define GTEST_OS_OS2 1 +#define GTEST_OS_OS2 1 #elif defined __APPLE__ -# define GTEST_OS_MAC 1 -# if TARGET_OS_IPHONE -# define GTEST_OS_IOS 1 -# endif +#define GTEST_OS_MAC 1 +#if TARGET_OS_IPHONE +#define GTEST_OS_IOS 1 +#endif #elif defined __DragonFly__ -# define GTEST_OS_DRAGONFLY 1 +#define GTEST_OS_DRAGONFLY 1 #elif defined __FreeBSD__ -# define GTEST_OS_FREEBSD 1 +#define GTEST_OS_FREEBSD 1 #elif defined __Fuchsia__ -# define GTEST_OS_FUCHSIA 1 +#define GTEST_OS_FUCHSIA 1 #elif defined(__GLIBC__) && defined(__FreeBSD_kernel__) -# define GTEST_OS_GNU_KFREEBSD 1 +#define GTEST_OS_GNU_KFREEBSD 1 #elif defined __linux__ -# define GTEST_OS_LINUX 1 -# if defined __ANDROID__ -# define GTEST_OS_LINUX_ANDROID 1 -# endif +#define GTEST_OS_LINUX 1 +#if defined __ANDROID__ +#define GTEST_OS_LINUX_ANDROID 1 +#endif #elif defined __MVS__ -# define GTEST_OS_ZOS 1 +#define GTEST_OS_ZOS 1 #elif defined(__sun) && defined(__SVR4) -# define GTEST_OS_SOLARIS 1 +#define GTEST_OS_SOLARIS 1 #elif defined(_AIX) -# define GTEST_OS_AIX 1 +#define GTEST_OS_AIX 1 #elif defined(__hpux) -# define GTEST_OS_HPUX 1 +#define GTEST_OS_HPUX 1 #elif defined __native_client__ -# define GTEST_OS_NACL 1 +#define GTEST_OS_NACL 1 #elif defined __NetBSD__ -# define GTEST_OS_NETBSD 1 +#define GTEST_OS_NETBSD 1 #elif defined __OpenBSD__ -# define GTEST_OS_OPENBSD 1 +#define GTEST_OS_OPENBSD 1 #elif defined __QNX__ -# define GTEST_OS_QNX 1 +#define GTEST_OS_QNX 1 #elif defined(__HAIKU__) #define GTEST_OS_HAIKU 1 #elif defined ESP8266 diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port.h index 2c92a34b4..221cecba8 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-port.h @@ -268,13 +268,13 @@ #include #ifndef _WIN32_WCE -# include -# include +#include +#include #endif // !_WIN32_WCE #if defined __APPLE__ -# include -# include +#include +#include #endif #include // NOLINT @@ -288,23 +288,23 @@ #include "gtest/internal/gtest-port-arch.h" #if !defined(GTEST_DEV_EMAIL_) -# define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" -# define GTEST_FLAG_PREFIX_ "gtest_" -# define GTEST_FLAG_PREFIX_DASH_ "gtest-" -# define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" -# define GTEST_NAME_ "Google Test" -# define GTEST_PROJECT_URL_ "https://github.com/google/googletest/" +#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" +#define GTEST_FLAG_PREFIX_ "gtest_" +#define GTEST_FLAG_PREFIX_DASH_ "gtest-" +#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" +#define GTEST_NAME_ "Google Test" +#define GTEST_PROJECT_URL_ "https://github.com/google/googletest/" #endif // !defined(GTEST_DEV_EMAIL_) #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_) -# define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest" +#define GTEST_INIT_GOOGLE_TEST_NAME_ "testing::InitGoogleTest" #endif // !defined(GTEST_INIT_GOOGLE_TEST_NAME_) // Determines the version of gcc that is used to compile this. #ifdef __GNUC__ // 40302 means version 4.3.2. -# define GTEST_GCC_VER_ \ - (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) +#define GTEST_GCC_VER_ \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif // __GNUC__ // Macros for disabling Microsoft Visual C++ warnings. @@ -313,41 +313,37 @@ // /* code that triggers warnings C4800 and C4385 */ // GTEST_DISABLE_MSC_WARNINGS_POP_() #if defined(_MSC_VER) -# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ - __pragma(warning(push)) \ - __pragma(warning(disable: warnings)) -# define GTEST_DISABLE_MSC_WARNINGS_POP_() \ - __pragma(warning(pop)) +#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) \ + __pragma(warning(push)) __pragma(warning(disable : warnings)) +#define GTEST_DISABLE_MSC_WARNINGS_POP_() __pragma(warning(pop)) #else // Not all compilers are MSVC -# define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) -# define GTEST_DISABLE_MSC_WARNINGS_POP_() +#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings) +#define GTEST_DISABLE_MSC_WARNINGS_POP_() #endif // Clang on Windows does not understand MSVC's pragma warning. // We need clang-specific way to disable function deprecation warning. #ifdef __clang__ -# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ - _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") -#define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ - _Pragma("clang diagnostic pop") +#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"") +#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop") #else -# define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) -# define GTEST_DISABLE_MSC_DEPRECATED_POP_() \ - GTEST_DISABLE_MSC_WARNINGS_POP_() +#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996) +#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() #endif // Brings in definitions for functions used in the testing::internal::posix // namespace (read, write, close, chdir, isatty, stat). We do not currently // use them on Windows Mobile. #if GTEST_OS_WINDOWS -# if !GTEST_OS_WINDOWS_MOBILE -# include -# include -# endif +#if !GTEST_OS_WINDOWS_MOBILE +#include +#include +#endif // In order to avoid having to include , use forward declaration #if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two @@ -363,24 +359,24 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // This assumes that non-Windows OSes provide unistd.h. For OSes where this // is not the case, we need to include headers that provide the functions // mentioned above. -# include -# include +#include +#include #endif // GTEST_OS_WINDOWS #if GTEST_OS_LINUX_ANDROID // Used to define __ANDROID_API__ matching the target NDK API level. -# include // NOLINT +#include // NOLINT #endif // Defines this to true if and only if Google Test can use POSIX regular // expressions. #ifndef GTEST_HAS_POSIX_RE -# if GTEST_OS_LINUX_ANDROID +#if GTEST_OS_LINUX_ANDROID // On Android, is only available starting with Gingerbread. -# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) -# else -# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) -# endif +#define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) +#else +#define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) +#endif #endif #if GTEST_USES_PCRE @@ -392,39 +388,39 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // won't compile otherwise. We can #include it here as we already // included , which is guaranteed to define size_t through // . -# include // NOLINT +#include // NOLINT -# define GTEST_USES_POSIX_RE 1 +#define GTEST_USES_POSIX_RE 1 #elif GTEST_OS_WINDOWS // is not available on Windows. Use our own simple regex // implementation instead. -# define GTEST_USES_SIMPLE_RE 1 +#define GTEST_USES_SIMPLE_RE 1 #else // may not be available on this platform. Use our own // simple regex implementation instead. -# define GTEST_USES_SIMPLE_RE 1 +#define GTEST_USES_SIMPLE_RE 1 #endif // GTEST_USES_PCRE #ifndef GTEST_HAS_EXCEPTIONS // The user didn't tell us whether exceptions are enabled, so we need // to figure it out. -# if defined(_MSC_VER) && defined(_CPPUNWIND) +#if defined(_MSC_VER) && defined(_CPPUNWIND) // MSVC defines _CPPUNWIND to 1 if and only if exceptions are enabled. -# define GTEST_HAS_EXCEPTIONS 1 -# elif defined(__BORLANDC__) +#define GTEST_HAS_EXCEPTIONS 1 +#elif defined(__BORLANDC__) // C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS // macro to enable exceptions, so we'll do the same. // Assumes that exceptions are enabled by default. -# ifndef _HAS_EXCEPTIONS -# define _HAS_EXCEPTIONS 1 -# endif // _HAS_EXCEPTIONS -# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS -# elif defined(__clang__) +#ifndef _HAS_EXCEPTIONS +#define _HAS_EXCEPTIONS 1 +#endif // _HAS_EXCEPTIONS +#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS +#elif defined(__clang__) // clang defines __EXCEPTIONS if and only if exceptions are enabled before clang // 220714, but if and only if cleanups are enabled after that. In Obj-C++ files, // there can be cleanups for ObjC exceptions which also need cleanups, even if @@ -433,27 +429,27 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // cleanups prior to that. To reliably check for C++ exception availability with // clang, check for // __EXCEPTIONS && __has_feature(cxx_exceptions). -# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) -# elif defined(__GNUC__) && __EXCEPTIONS +#define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) +#elif defined(__GNUC__) && __EXCEPTIONS // gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled. -# define GTEST_HAS_EXCEPTIONS 1 -# elif defined(__SUNPRO_CC) +#define GTEST_HAS_EXCEPTIONS 1 +#elif defined(__SUNPRO_CC) // Sun Pro CC supports exceptions. However, there is no compile-time way of // detecting whether they are enabled or not. Therefore, we assume that // they are enabled unless the user tells us otherwise. -# define GTEST_HAS_EXCEPTIONS 1 -# elif defined(__IBMCPP__) && __EXCEPTIONS +#define GTEST_HAS_EXCEPTIONS 1 +#elif defined(__IBMCPP__) && __EXCEPTIONS // xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled. -# define GTEST_HAS_EXCEPTIONS 1 -# elif defined(__HP_aCC) +#define GTEST_HAS_EXCEPTIONS 1 +#elif defined(__HP_aCC) // Exception handling is in effect by default in HP aCC compiler. It has to // be turned of by +noeh compiler option if desired. -# define GTEST_HAS_EXCEPTIONS 1 -# else +#define GTEST_HAS_EXCEPTIONS 1 +#else // For other compilers, we assume exceptions are disabled to be // conservative. -# define GTEST_HAS_EXCEPTIONS 0 -# endif // defined(_MSC_VER) || defined(__BORLANDC__) +#define GTEST_HAS_EXCEPTIONS 0 +#endif // defined(_MSC_VER) || defined(__BORLANDC__) #endif // GTEST_HAS_EXCEPTIONS #ifndef GTEST_HAS_STD_WSTRING @@ -473,63 +469,62 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // The user didn't tell us whether RTTI is enabled, so we need to // figure it out. -# ifdef _MSC_VER +#ifdef _MSC_VER #ifdef _CPPRTTI // MSVC defines this macro if and only if RTTI is enabled. -# define GTEST_HAS_RTTI 1 -# else -# define GTEST_HAS_RTTI 0 -# endif +#define GTEST_HAS_RTTI 1 +#else +#define GTEST_HAS_RTTI 0 +#endif // Starting with version 4.3.2, gcc defines __GXX_RTTI if and only if RTTI is // enabled. -# elif defined(__GNUC__) +#elif defined(__GNUC__) -# ifdef __GXX_RTTI +#ifdef __GXX_RTTI // When building against STLport with the Android NDK and with // -frtti -fno-exceptions, the build fails at link time with undefined // references to __cxa_bad_typeid. Note sure if STL or toolchain bug, // so disable RTTI when detected. -# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \ - !defined(__EXCEPTIONS) -# define GTEST_HAS_RTTI 0 -# else -# define GTEST_HAS_RTTI 1 -# endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS -# else -# define GTEST_HAS_RTTI 0 -# endif // __GXX_RTTI +#if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && !defined(__EXCEPTIONS) +#define GTEST_HAS_RTTI 0 +#else +#define GTEST_HAS_RTTI 1 +#endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS +#else +#define GTEST_HAS_RTTI 0 +#endif // __GXX_RTTI // Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends // using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the // first version with C++ support. -# elif defined(__clang__) +#elif defined(__clang__) -# define GTEST_HAS_RTTI __has_feature(cxx_rtti) +#define GTEST_HAS_RTTI __has_feature(cxx_rtti) // Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if // both the typeid and dynamic_cast features are present. -# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900) +#elif defined(__IBMCPP__) && (__IBMCPP__ >= 900) -# ifdef __RTTI_ALL__ -# define GTEST_HAS_RTTI 1 -# else -# define GTEST_HAS_RTTI 0 -# endif +#ifdef __RTTI_ALL__ +#define GTEST_HAS_RTTI 1 +#else +#define GTEST_HAS_RTTI 0 +#endif -# else +#else // For all other compilers, we assume RTTI is enabled. -# define GTEST_HAS_RTTI 1 +#define GTEST_HAS_RTTI 1 -# endif // _MSC_VER +#endif // _MSC_VER #endif // GTEST_HAS_RTTI // It's this header's responsibility to #include when RTTI // is enabled. #if GTEST_HAS_RTTI -# include +#include #endif // Determines whether Google Test can use the pthreads library. @@ -549,10 +544,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #if GTEST_HAS_PTHREAD // gtest-port.h guarantees to #include when GTEST_HAS_PTHREAD is // true. -# include // NOLINT +#include // NOLINT // For timespec and nanosleep, used below. -# include // NOLINT +#include // NOLINT #endif // Determines whether clone(2) is supported. @@ -562,24 +557,23 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_HAS_CLONE // The user didn't tell us, so we need to figure it out. -# if GTEST_OS_LINUX && !defined(__ia64__) -# if GTEST_OS_LINUX_ANDROID +#if GTEST_OS_LINUX && !defined(__ia64__) +#if GTEST_OS_LINUX_ANDROID // On Android, clone() became available at different API levels for each 32-bit // architecture. -# if defined(__LP64__) || \ - (defined(__arm__) && __ANDROID_API__ >= 9) || \ - (defined(__mips__) && __ANDROID_API__ >= 12) || \ - (defined(__i386__) && __ANDROID_API__ >= 17) -# define GTEST_HAS_CLONE 1 -# else -# define GTEST_HAS_CLONE 0 -# endif -# else -# define GTEST_HAS_CLONE 1 -# endif -# else -# define GTEST_HAS_CLONE 0 -# endif // GTEST_OS_LINUX && !defined(__ia64__) +#if defined(__LP64__) || (defined(__arm__) && __ANDROID_API__ >= 9) || \ + (defined(__mips__) && __ANDROID_API__ >= 12) || \ + (defined(__i386__) && __ANDROID_API__ >= 17) +#define GTEST_HAS_CLONE 1 +#else +#define GTEST_HAS_CLONE 0 +#endif +#else +#define GTEST_HAS_CLONE 1 +#endif +#else +#define GTEST_HAS_CLONE 0 +#endif // GTEST_OS_LINUX && !defined(__ia64__) #endif // GTEST_HAS_CLONE @@ -590,10 +584,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // platforms except known mobile ones. #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 -# define GTEST_HAS_STREAM_REDIRECTION 0 -# else -# define GTEST_HAS_STREAM_REDIRECTION 1 -# endif // !GTEST_OS_WINDOWS_MOBILE +#define GTEST_HAS_STREAM_REDIRECTION 0 +#else +#define GTEST_HAS_STREAM_REDIRECTION 1 +#endif // !GTEST_OS_WINDOWS_MOBILE #endif // GTEST_HAS_STREAM_REDIRECTION // Determines whether to support death tests. @@ -604,7 +598,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \ GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU) -# define GTEST_HAS_DEATH_TEST 1 +#define GTEST_HAS_DEATH_TEST 1 #endif // Determines whether to support type-driven tests. @@ -613,8 +607,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Sun Pro CC, IBM Visual Age, and HP aCC support. #if defined(__GNUC__) || defined(_MSC_VER) || defined(__SUNPRO_CC) || \ defined(__IBMCPP__) || defined(__HP_aCC) -# define GTEST_HAS_TYPED_TEST 1 -# define GTEST_HAS_TYPED_TEST_P 1 +#define GTEST_HAS_TYPED_TEST 1 +#define GTEST_HAS_TYPED_TEST_P 1 #endif // Determines whether the system compiler uses UTF-16 for encoding wide strings. @@ -624,7 +618,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Determines whether test results can be streamed to a socket. #if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \ GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD -# define GTEST_CAN_STREAM_RESULTS_ 1 +#define GTEST_CAN_STREAM_RESULTS_ 1 #endif // Defines some utility macros. @@ -638,9 +632,12 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // // The "switch (0) case 0:" idiom is used to suppress this. #ifdef __INTEL_COMPILER -# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ +#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ #else -# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT +#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + switch (0) \ + case 0: \ + default: // NOLINT #endif // Use this annotation at the end of a struct/class definition to @@ -655,38 +652,36 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Also use it after a variable or parameter declaration to tell the // compiler the variable/parameter does not have to be used. #if defined(__GNUC__) && !defined(COMPILER_ICC) -# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +#define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused)) #elif defined(__clang__) -# if __has_attribute(unused) -# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) -# endif +#if __has_attribute(unused) +#define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused)) +#endif #endif #ifndef GTEST_ATTRIBUTE_UNUSED_ -# define GTEST_ATTRIBUTE_UNUSED_ +#define GTEST_ATTRIBUTE_UNUSED_ #endif // Use this annotation before a function that takes a printf format string. #if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC) -# if defined(__MINGW_PRINTF_FORMAT) +#if defined(__MINGW_PRINTF_FORMAT) // MinGW has two different printf implementations. Ensure the format macro // matches the selected implementation. See // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. -# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ - __attribute__((__format__(__MINGW_PRINTF_FORMAT, string_index, \ - first_to_check))) -# else -# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ - __attribute__((__format__(__printf__, string_index, first_to_check))) -# endif +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__(( \ + __format__(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) #else -# define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((__format__(__printf__, string_index, first_to_check))) +#endif +#else +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) #endif - // A macro to disallow copy operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_ASSIGN_(type) \ - type& operator=(type const &) = delete +#define GTEST_DISALLOW_ASSIGN_(type) type& operator=(type const&) = delete // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. @@ -697,7 +692,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // A macro to disallow move operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_MOVE_ASSIGN_(type) \ - type& operator=(type &&) noexcept = delete + type& operator=(type&&) noexcept = delete // A macro to disallow move constructor and operator= // This should be used in the private: declarations for a class. @@ -711,9 +706,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // // Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; #if defined(__GNUC__) && !defined(COMPILER_ICC) -# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result)) +#define GTEST_MUST_USE_RESULT_ __attribute__((warn_unused_result)) #else -# define GTEST_MUST_USE_RESULT_ +#define GTEST_MUST_USE_RESULT_ #endif // __GNUC__ && !COMPILER_ICC // MS C++ compiler emits warning when a conditional expression is compile time @@ -724,10 +719,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // while (true) { // GTEST_INTENTIONAL_CONST_COND_POP_() // } -# define GTEST_INTENTIONAL_CONST_COND_PUSH_() \ - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127) -# define GTEST_INTENTIONAL_CONST_COND_POP_() \ - GTEST_DISABLE_MSC_WARNINGS_POP_() +#define GTEST_INTENTIONAL_CONST_COND_PUSH_() \ + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127) +#define GTEST_INTENTIONAL_CONST_COND_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_() // Determine whether the compiler supports Microsoft's Structured Exception // Handling. This is supported by several Windows compilers but generally @@ -735,13 +729,13 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_HAS_SEH // The user didn't tell us, so we need to figure it out. -# if defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(_MSC_VER) || defined(__BORLANDC__) // These two compilers are known to support SEH. -# define GTEST_HAS_SEH 1 -# else +#define GTEST_HAS_SEH 1 +#else // Assume no SEH. -# define GTEST_HAS_SEH 0 -# endif +#define GTEST_HAS_SEH 0 +#endif #endif // GTEST_HAS_SEH @@ -760,88 +754,86 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_API_ #ifdef _MSC_VER -# if GTEST_LINKED_AS_SHARED_LIBRARY -# define GTEST_API_ __declspec(dllimport) -# elif GTEST_CREATE_SHARED_LIBRARY -# define GTEST_API_ __declspec(dllexport) -# endif +#if GTEST_LINKED_AS_SHARED_LIBRARY +#define GTEST_API_ __declspec(dllimport) +#elif GTEST_CREATE_SHARED_LIBRARY +#define GTEST_API_ __declspec(dllexport) +#endif #elif __GNUC__ >= 4 || defined(__clang__) -# define GTEST_API_ __attribute__((visibility ("default"))) +#define GTEST_API_ __attribute__((visibility("default"))) #endif // _MSC_VER #endif // GTEST_API_ #ifndef GTEST_API_ -# define GTEST_API_ +#define GTEST_API_ #endif // GTEST_API_ #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE -# define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" +#define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" #endif // GTEST_DEFAULT_DEATH_TEST_STYLE #ifdef __GNUC__ // Ask the compiler to never inline a given function. -# define GTEST_NO_INLINE_ __attribute__((noinline)) +#define GTEST_NO_INLINE_ __attribute__((noinline)) #else -# define GTEST_NO_INLINE_ +#define GTEST_NO_INLINE_ #endif // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project. #if !defined(GTEST_HAS_CXXABI_H_) -# if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) -# define GTEST_HAS_CXXABI_H_ 1 -# else -# define GTEST_HAS_CXXABI_H_ 0 -# endif +#if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) +#define GTEST_HAS_CXXABI_H_ 1 +#else +#define GTEST_HAS_CXXABI_H_ 0 +#endif #endif // A function level attribute to disable checking for use of uninitialized // memory when built with MemorySanitizer. #if defined(__clang__) -# if __has_feature(memory_sanitizer) -# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ \ - __attribute__((no_sanitize_memory)) -# else -# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -# endif // __has_feature(memory_sanitizer) +#if __has_feature(memory_sanitizer) +#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ __attribute__((no_sanitize_memory)) +#else +#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +#endif // __has_feature(memory_sanitizer) #else -# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ +#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ #endif // __clang__ // A function level attribute to disable AddressSanitizer instrumentation. #if defined(__clang__) -# if __has_feature(address_sanitizer) -# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \ - __attribute__((no_sanitize_address)) -# else -# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -# endif // __has_feature(address_sanitizer) +#if __has_feature(address_sanitizer) +#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \ + __attribute__((no_sanitize_address)) #else -# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ +#endif // __has_feature(address_sanitizer) +#else +#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ #endif // __clang__ // A function level attribute to disable HWAddressSanitizer instrumentation. #if defined(__clang__) -# if __has_feature(hwaddress_sanitizer) -# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \ - __attribute__((no_sanitize("hwaddress"))) -# else -# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ -# endif // __has_feature(hwaddress_sanitizer) +#if __has_feature(hwaddress_sanitizer) +#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \ + __attribute__((no_sanitize("hwaddress"))) +#else +#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ +#endif // __has_feature(hwaddress_sanitizer) #else -# define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ +#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ #endif // __clang__ // A function level attribute to disable ThreadSanitizer instrumentation. #if defined(__clang__) -# if __has_feature(thread_sanitizer) -# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ \ - __attribute__((no_sanitize_thread)) -# else -# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -# endif // __has_feature(thread_sanitizer) +#if __has_feature(thread_sanitizer) +#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ __attribute__((no_sanitize_thread)) #else -# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ +#endif // __has_feature(thread_sanitizer) +#else +#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ #endif // __clang__ namespace testing { @@ -920,16 +912,16 @@ class GTEST_API_ RE { const char* pattern_; bool is_valid_; -# if GTEST_USES_POSIX_RE +#if GTEST_USES_POSIX_RE regex_t full_regex_; // For FullMatch(). regex_t partial_regex_; // For PartialMatch(). -# else // GTEST_USES_SIMPLE_RE +#else // GTEST_USES_SIMPLE_RE const char* full_pattern_; // For FullMatch(); -# endif +#endif }; #endif // GTEST_USES_PCRE @@ -950,12 +942,7 @@ GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file, // LogToStderr() - directs all log messages to stderr. // FlushInfoLog() - flushes informational log messages. -enum GTestLogSeverity { - GTEST_INFO, - GTEST_WARNING, - GTEST_ERROR, - GTEST_FATAL -}; +enum GTestLogSeverity { GTEST_INFO, GTEST_WARNING, GTEST_ERROR, GTEST_FATAL }; // Formats log entry severity, provides a stream object for streaming the // log message, and terminates the message with a newline when going out of @@ -977,9 +964,10 @@ class GTEST_API_ GTestLog { #if !defined(GTEST_LOG_) -# define GTEST_LOG_(severity) \ - ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \ - __FILE__, __LINE__).GetStream() +#define GTEST_LOG_(severity) \ + ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \ + __FILE__, __LINE__) \ + .GetStream() inline void LogToStderr() {} inline void FlushInfoLog() { fflush(nullptr); } @@ -1001,12 +989,12 @@ inline void FlushInfoLog() { fflush(nullptr); } // condition itself, plus additional message streamed into it, if any, // and then it aborts the program. It aborts the program irrespective of // whether it is built in the debug mode or not. -# define GTEST_CHECK_(condition) \ - GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::IsTrue(condition)) \ - ; \ - else \ - GTEST_LOG_(FATAL) << "Condition " #condition " failed. " +#define GTEST_CHECK_(condition) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::IsTrue(condition)) \ + ; \ + else \ + GTEST_LOG_(FATAL) << "Condition " #condition " failed. " #endif // !defined(GTEST_CHECK_) // An all-mode assert to verify that the given POSIX-style function @@ -1015,9 +1003,8 @@ inline void FlushInfoLog() { fflush(nullptr); } // in {} if you need to use it as the only statement in an 'if' // branch. #define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \ - if (const int gtest_error = (posix_call)) \ - GTEST_LOG_(FATAL) << #posix_call << "failed with error " \ - << gtest_error + if (const int gtest_error = (posix_call)) \ + GTEST_LOG_(FATAL) << #posix_call << "failed with error " << gtest_error // Transforms "T" into "const T&" according to standard reference collapsing // rules (this is only needed as a backport for C++98 compilers that do not @@ -1031,9 +1018,13 @@ inline void FlushInfoLog() { fflush(nullptr); } // Note that the non-const reference will not have "const" added. This is // standard, and necessary so that "T" can always bind to "const T&". template -struct ConstRef { typedef const T& type; }; +struct ConstRef { + typedef const T& type; +}; template -struct ConstRef { typedef T& type; }; +struct ConstRef { + typedef T& type; +}; // The argument T must depend on some template parameters. #define GTEST_REFERENCE_TO_CONST_(T) \ @@ -1059,8 +1050,10 @@ struct ConstRef { typedef T& type; }; // This relatively ugly name is intentional. It prevents clashes with // similar functions users may have (e.g., implicit_cast). The internal // namespace alone is not enough because the function can be found by ADL. -template -inline To ImplicitCast_(To x) { return x; } +template +inline To ImplicitCast_(To x) { + return x; +} // When you upcast (that is, cast a pointer from type Foo to type // SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts @@ -1083,17 +1076,17 @@ inline To ImplicitCast_(To x) { return x; } // This relatively ugly name is intentional. It prevents clashes with // similar functions users may have (e.g., down_cast). The internal // namespace alone is not enough because the function can be found by ADL. -template // use like this: DownCast_(foo); -inline To DownCast_(From* f) { // so we only accept pointers +template // use like this: DownCast_(foo); +inline To DownCast_(From* f) { // so we only accept pointers // Ensures that To is a sub-type of From *. This test is here only // for compile-time type checking, and has no overhead in an // optimized build at run-time, as it will be optimized away // completely. GTEST_INTENTIONAL_CONST_COND_PUSH_() if (false) { - GTEST_INTENTIONAL_CONST_COND_POP_() - const To to = nullptr; - ::testing::internal::ImplicitCast_(to); + GTEST_INTENTIONAL_CONST_COND_POP_() + const To to = nullptr; + ::testing::internal::ImplicitCast_(to); } #if GTEST_HAS_RTTI @@ -1158,24 +1151,24 @@ void ClearInjectableArgvs(); // Defines synchronization primitives. #if GTEST_IS_THREADSAFE -# if GTEST_HAS_PTHREAD +#if GTEST_HAS_PTHREAD // Sleeps for (roughly) n milliseconds. This function is only for testing // Google Test's own constructs. Don't use it in user tests, either // directly or indirectly. inline void SleepMilliseconds(int n) { const timespec time = { - 0, // 0 seconds. - n * 1000L * 1000L, // And n ms. + 0, // 0 seconds. + n * 1000L * 1000L, // And n ms. }; nanosleep(&time, nullptr); } -# endif // GTEST_HAS_PTHREAD +#endif // GTEST_HAS_PTHREAD -# if GTEST_HAS_NOTIFICATION_ +#if GTEST_HAS_NOTIFICATION_ // Notification has already been imported into the namespace. // Nothing to do here. -# elif GTEST_HAS_PTHREAD +#elif GTEST_HAS_PTHREAD // Allows a controller thread to pause execution of newly created // threads until notified. Instances of this class must be created // and destroyed in the controller thread. @@ -1187,9 +1180,7 @@ class Notification { Notification() : notified_(false) { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); } - ~Notification() { - pthread_mutex_destroy(&mutex_); - } + ~Notification() { pthread_mutex_destroy(&mutex_); } // Notifies all threads created with this notification to start. Must // be called from the controller thread. @@ -1206,8 +1197,7 @@ class Notification { pthread_mutex_lock(&mutex_); const bool notified = notified_; pthread_mutex_unlock(&mutex_); - if (notified) - break; + if (notified) break; SleepMilliseconds(10); } } @@ -1219,7 +1209,7 @@ class Notification { GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); }; -# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +#elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT GTEST_API_ void SleepMilliseconds(int n); @@ -1269,12 +1259,12 @@ class GTEST_API_ Notification { GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); }; -# endif // GTEST_HAS_NOTIFICATION_ +#endif // GTEST_HAS_NOTIFICATION_ // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD // defined, but we don't want to use MinGW's pthreads implementation, which // has conformance problems with some versions of the POSIX standard. -# if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW +#if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW // As a C-function, ThreadFuncWithCLinkage cannot be templated itself. // Consequently, it cannot select a correct instantiation of ThreadWithParam @@ -1352,14 +1342,14 @@ class ThreadWithParam : public ThreadWithParamBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); }; -# endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || - // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +#endif // !GTEST_OS_WINDOWS && GTEST_HAS_PTHREAD || + // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ -# if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +#if GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ // Mutex and ThreadLocal have already been imported into the namespace. // Nothing to do here. -# elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +#elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT // Mutex implements mutex on Windows platforms. It is used in conjunction // with class MutexLock: @@ -1416,11 +1406,11 @@ class GTEST_API_ Mutex { GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); }; -# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ - extern ::testing::internal::Mutex mutex +#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::Mutex mutex -# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ - ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex) +#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::Mutex mutex(::testing::internal::Mutex::kStaticMutex) // We cannot name this class MutexLock because the ctor declaration would // conflict with a macro named MutexLock, which is defined on some @@ -1429,8 +1419,7 @@ class GTEST_API_ Mutex { // "MutexLock l(&mu)". Hence the typedef trick below. class GTestMutexLock { public: - explicit GTestMutexLock(Mutex* mutex) - : mutex_(mutex) { mutex_->Lock(); } + explicit GTestMutexLock(Mutex* mutex) : mutex_(mutex) { mutex_->Lock(); } ~GTestMutexLock() { mutex_->Unlock(); } @@ -1493,7 +1482,7 @@ class GTEST_API_ ThreadWithParamBase { virtual void Run() = 0; }; - ThreadWithParamBase(Runnable *runnable, Notification* thread_can_start); + ThreadWithParamBase(Runnable* runnable, Notification* thread_can_start); virtual ~ThreadWithParamBase(); private: @@ -1507,21 +1496,15 @@ class ThreadWithParam : public ThreadWithParamBase { typedef void UserThreadFunc(T); ThreadWithParam(UserThreadFunc* func, T param, Notification* thread_can_start) - : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) { - } + : ThreadWithParamBase(new RunnableImpl(func, param), thread_can_start) {} virtual ~ThreadWithParam() {} private: class RunnableImpl : public Runnable { public: - RunnableImpl(UserThreadFunc* func, T param) - : func_(func), - param_(param) { - } + RunnableImpl(UserThreadFunc* func, T param) : func_(func), param_(param) {} virtual ~RunnableImpl() {} - virtual void Run() { - func_(param_); - } + virtual void Run() { func_(param_); } private: UserThreadFunc* const func_; @@ -1589,10 +1572,10 @@ class ThreadLocal : public ThreadLocalBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); }; - T* GetOrCreateValue() const { return static_cast( - ThreadLocalRegistry::GetValueOnCurrentThread(this))->pointer(); + ThreadLocalRegistry::GetValueOnCurrentThread(this)) + ->pointer(); } virtual ThreadLocalValueHolderBase* NewValueForCurrentThread() const { @@ -1636,7 +1619,7 @@ class ThreadLocal : public ThreadLocalBase { GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); }; -# elif GTEST_HAS_PTHREAD +#elif GTEST_HAS_PTHREAD // MutexBase and Mutex implement mutex on pthreads-based platforms. class MutexBase { @@ -1683,8 +1666,8 @@ class MutexBase { }; // Forward-declares a static mutex. -# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ - extern ::testing::internal::MutexBase mutex +#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::MutexBase mutex // Defines and statically (i.e. at link time) initializes a static mutex. // The initialization list here does not explicitly initialize each field, @@ -1703,9 +1686,7 @@ class Mutex : public MutexBase { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, nullptr)); has_owner_ = false; } - ~Mutex() { - GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); - } + ~Mutex() { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); } private: GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); @@ -1718,8 +1699,7 @@ class Mutex : public MutexBase { // "MutexLock l(&mu)". Hence the typedef trick below. class GTestMutexLock { public: - explicit GTestMutexLock(MutexBase* mutex) - : mutex_(mutex) { mutex_->Lock(); } + explicit GTestMutexLock(MutexBase* mutex) : mutex_(mutex) { mutex_->Lock(); } ~GTestMutexLock() { mutex_->Unlock(); } @@ -1847,7 +1827,7 @@ class GTEST_API_ ThreadLocal { GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); }; -# endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +#endif // GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ #else // GTEST_IS_THREADSAFE @@ -1864,10 +1844,10 @@ class Mutex { void AssertHeld() const {} }; -# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ +#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ extern ::testing::internal::Mutex mutex -# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex +#define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex // We cannot name this class MutexLock because the ctor declaration would // conflict with a macro named MutexLock, which is defined on some @@ -1890,6 +1870,7 @@ class GTEST_API_ ThreadLocal { const T* pointer() const { return &value_; } const T& get() const { return value_; } void set(const T& value) { value_ = value; } + private: T value_; }; @@ -1901,11 +1882,11 @@ class GTEST_API_ ThreadLocal { GTEST_API_ size_t GetThreadCount(); #if GTEST_OS_WINDOWS -# define GTEST_PATH_SEP_ "\\" -# define GTEST_HAS_ALT_PATH_SEP_ 1 +#define GTEST_PATH_SEP_ "\\" +#define GTEST_HAS_ALT_PATH_SEP_ 1 #else -# define GTEST_PATH_SEP_ "/" -# define GTEST_HAS_ALT_PATH_SEP_ 0 +#define GTEST_PATH_SEP_ "/" +#define GTEST_HAS_ALT_PATH_SEP_ 0 #endif // GTEST_OS_WINDOWS // Utilities for char. @@ -1950,8 +1931,7 @@ inline char ToUpper(char ch) { inline std::string StripTrailingSpaces(std::string str) { std::string::iterator it = str.end(); - while (it != str.begin() && IsSpace(*--it)) - it = str.erase(it); + while (it != str.begin() && IsSpace(*--it)) it = str.erase(it); return str; } @@ -1969,36 +1949,34 @@ namespace posix { typedef struct _stat StatStruct; -# ifdef __BORLANDC__ +#ifdef __BORLANDC__ inline int DoIsATTY(int fd) { return isatty(fd); } inline int StrCaseCmp(const char* s1, const char* s2) { return stricmp(s1, s2); } inline char* StrDup(const char* src) { return strdup(src); } -# else // !__BORLANDC__ -# if GTEST_OS_WINDOWS_MOBILE +#else // !__BORLANDC__ +#if GTEST_OS_WINDOWS_MOBILE inline int DoIsATTY(int /* fd */) { return 0; } -# else +#else inline int DoIsATTY(int fd) { return _isatty(fd); } -# endif // GTEST_OS_WINDOWS_MOBILE +#endif // GTEST_OS_WINDOWS_MOBILE inline int StrCaseCmp(const char* s1, const char* s2) { return _stricmp(s1, s2); } inline char* StrDup(const char* src) { return _strdup(src); } -# endif // __BORLANDC__ +#endif // __BORLANDC__ -# if GTEST_OS_WINDOWS_MOBILE +#if GTEST_OS_WINDOWS_MOBILE inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this // time and thus not defined there. -# else +#else inline int FileNo(FILE* file) { return _fileno(file); } inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); } inline int RmDir(const char* dir) { return _rmdir(dir); } -inline bool IsDir(const StatStruct& st) { - return (_S_IFDIR & st.st_mode) != 0; -} -# endif // GTEST_OS_WINDOWS_MOBILE +inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; } +#endif // GTEST_OS_WINDOWS_MOBILE #elif GTEST_OS_ESP8266 typedef struct stat StatStruct; @@ -2066,7 +2044,7 @@ inline FILE* FOpen(const char* path, const char* mode) { #endif // GTEST_OS_WINDOWS } #if !GTEST_OS_WINDOWS_MOBILE -inline FILE *FReopen(const char* path, const char* mode, FILE* stream) { +inline FILE* FReopen(const char* path, const char* mode, FILE* stream) { return freopen(path, mode, stream); } inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } @@ -2118,13 +2096,13 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_() // snprintf is a variadic function. #if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE // MSVC 2005 and above support variadic macros. -# define GTEST_SNPRINTF_(buffer, size, format, ...) \ - _snprintf_s(buffer, size, size, format, __VA_ARGS__) +#define GTEST_SNPRINTF_(buffer, size, format, ...) \ + _snprintf_s(buffer, size, size, format, __VA_ARGS__) #elif defined(_MSC_VER) // Windows CE does not define _snprintf_s -# define GTEST_SNPRINTF_ _snprintf +#define GTEST_SNPRINTF_ _snprintf #else -# define GTEST_SNPRINTF_ snprintf +#define GTEST_SNPRINTF_ snprintf #endif // The biggest signed integer type the compiler supports. @@ -2184,37 +2162,37 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. // Macro for referencing flags. #if !defined(GTEST_FLAG) -# define GTEST_FLAG(name) FLAGS_gtest_##name +#define GTEST_FLAG(name) FLAGS_gtest_##name #endif // !defined(GTEST_FLAG) #if !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) -# define GTEST_USE_OWN_FLAGFILE_FLAG_ 1 +#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1 #endif // !defined(GTEST_USE_OWN_FLAGFILE_FLAG_) #if !defined(GTEST_DECLARE_bool_) -# define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver +#define GTEST_FLAG_SAVER_ ::testing::internal::GTestFlagSaver // Macros for declaring flags. -# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) -# define GTEST_DECLARE_int32_(name) \ - GTEST_API_ extern std::int32_t GTEST_FLAG(name) -# define GTEST_DECLARE_string_(name) \ - GTEST_API_ extern ::std::string GTEST_FLAG(name) +#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) +#define GTEST_DECLARE_int32_(name) \ + GTEST_API_ extern std::int32_t GTEST_FLAG(name) +#define GTEST_DECLARE_string_(name) \ + GTEST_API_ extern ::std::string GTEST_FLAG(name) // Macros for defining flags. -# define GTEST_DEFINE_bool_(name, default_val, doc) \ - GTEST_API_ bool GTEST_FLAG(name) = (default_val) -# define GTEST_DEFINE_int32_(name, default_val, doc) \ - GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val) -# define GTEST_DEFINE_string_(name, default_val, doc) \ - GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_bool_(name, default_val, doc) \ + GTEST_API_ bool GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_int32_(name, default_val, doc) \ + GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_string_(name, default_val, doc) \ + GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) #endif // !defined(GTEST_DECLARE_bool_) // Thread annotations #if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) -# define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) -# define GTEST_LOCK_EXCLUDED_(locks) +#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) +#define GTEST_LOCK_EXCLUDED_(locks) #endif // !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_) // Parses 'str' for a 32-bit signed integer. If successful, writes the result @@ -2314,7 +2292,7 @@ using Optional = ::std::optional; #if GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. -# define GTEST_INTERNAL_HAS_STRING_VIEW 1 +#define GTEST_INTERNAL_HAS_STRING_VIEW 1 #include "absl/strings/string_view.h" namespace testing { namespace internal { @@ -2322,11 +2300,11 @@ using StringView = ::absl::string_view; } // namespace internal } // namespace testing #else -# ifdef __has_include -# if __has_include() && __cplusplus >= 201703L +#ifdef __has_include +#if __has_include() && __cplusplus >= 201703L // Otherwise for C++17 and higher use std::string_view for Matcher<> // specializations. -# define GTEST_INTERNAL_HAS_STRING_VIEW 1 +#define GTEST_INTERNAL_HAS_STRING_VIEW 1 #include namespace testing { namespace internal { @@ -2335,8 +2313,8 @@ using StringView = ::std::string_view; } // namespace testing // The case where absl is configured NOT to alias std::string_view is not // supported. -# endif // __has_include() && __cplusplus >= 201703L -# endif // __has_include +#endif // __has_include() && __cplusplus >= 201703L +#endif // __has_include #endif // GTEST_HAS_ABSL #if GTEST_HAS_ABSL diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-string.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-string.h index 0b2a91a5d..5ee059e5b 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-string.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-string.h @@ -43,10 +43,11 @@ #ifdef __BORLANDC__ // string.h is not guaranteed to provide strcpy on C++ Builder. -# include +#include #endif #include + #include #include @@ -123,8 +124,7 @@ class GTEST_API_ String { // Unlike strcasecmp(), this function can handle NULL argument(s). // A NULL C string is considered different to any non-NULL C string, // including the empty string. - static bool CaseInsensitiveCStringEquals(const char* lhs, - const char* rhs); + static bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs); // Compares two wide C strings, ignoring case. Returns true if and only if // they have the same content. @@ -143,8 +143,8 @@ class GTEST_API_ String { // Returns true if and only if the given string ends with the given suffix, // ignoring case. Any string is considered to end with an empty suffix. - static bool EndsWithCaseInsensitive( - const std::string& str, const std::string& suffix); + static bool EndsWithCaseInsensitive(const std::string& str, + const std::string& suffix); // Formats an int value as "%02d". static std::string FormatIntWidth2(int value); // "%02d" for width == 2 diff --git a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-type-util.h b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-type-util.h index c3326f2c5..77d390d8a 100644 --- a/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-type-util.h +++ b/Testing/lib/googletest-master/googletest/include/gtest/internal/gtest-type-util.h @@ -39,11 +39,11 @@ // #ifdef __GNUC__ is too general here. It is possible to use gcc without using // libstdc++ (which is where cxxabi.h comes from). -# if GTEST_HAS_CXXABI_H_ -# include -# elif defined(__HP_aCC) -# include -# endif // GTEST_HASH_CXXABI_H_ +#if GTEST_HAS_CXXABI_H_ +#include +#elif defined(__HP_aCC) +#include +#endif // GTEST_HASH_CXXABI_H_ namespace testing { namespace internal { @@ -103,7 +103,9 @@ std::string GetTypeName() { // A unique type indicating an empty node struct None {}; -# define GTEST_TEMPLATE_ template class +#define GTEST_TEMPLATE_ \ + template \ + class // The template "selector" struct TemplateSel is used to // represent Tmpl, which must be a class template with one type @@ -121,8 +123,7 @@ struct TemplateSel { }; }; -# define GTEST_BIND_(TmplSel, T) \ - TmplSel::template Bind::type +#define GTEST_BIND_(TmplSel, T) TmplSel::template Bind::type template struct Templates { diff --git a/Testing/lib/googletest-master/googletest/samples/prime_tables.h b/Testing/lib/googletest-master/googletest/samples/prime_tables.h index 34002f3d6..2645a0424 100644 --- a/Testing/lib/googletest-master/googletest/samples/prime_tables.h +++ b/Testing/lib/googletest-master/googletest/samples/prime_tables.h @@ -27,8 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - // This provides interface PrimeTable that determines whether a number is a // prime and determines a next prime number. This interface is used // in Google Test samples demonstrating use of parameterized tests. @@ -57,7 +55,7 @@ class OnTheFlyPrimeTable : public PrimeTable { bool IsPrime(int n) const override { if (n <= 1) return false; - for (int i = 2; i*i <= n; i++) { + for (int i = 2; i * i <= n; i++) { // n is divisible by an integer other than 1 and itself. if ((n % i) == 0) return false; } @@ -104,13 +102,13 @@ class PreCalculatedPrimeTable : public PrimeTable { // Checks every candidate for prime number (we know that 2 is the only even // prime). - for (int i = 2; i*i <= max; i += i%2+1) { + for (int i = 2; i * i <= max; i += i % 2 + 1) { if (!is_prime_[i]) continue; // Marks all multiples of i (except i itself) as non-prime. // We are starting here from i-th multiplier, because all smaller // complex numbers were already marked. - for (int j = i*i; j <= max; j += i) { + for (int j = i * i; j <= max; j += i) { is_prime_[j] = false; } } diff --git a/Testing/lib/googletest-master/googletest/samples/sample2.h b/Testing/lib/googletest-master/googletest/samples/sample2.h index e9a5a7050..b6d97461e 100644 --- a/Testing/lib/googletest-master/googletest/samples/sample2.h +++ b/Testing/lib/googletest-master/googletest/samples/sample2.h @@ -34,7 +34,6 @@ #include - // A simple string class. class MyString { private: @@ -77,5 +76,4 @@ class MyString { void Set(const char* c_string); }; - #endif // GTEST_SAMPLES_SAMPLE2_H_ diff --git a/Testing/lib/googletest-master/googletest/samples/sample3-inl.h b/Testing/lib/googletest-master/googletest/samples/sample3-inl.h index 80ba6b923..43c39bc5e 100644 --- a/Testing/lib/googletest-master/googletest/samples/sample3-inl.h +++ b/Testing/lib/googletest-master/googletest/samples/sample3-inl.h @@ -34,7 +34,6 @@ #include - // Queue is a simple queue implemented as a singled-linked list. // // The element type must support copy constructor. @@ -62,7 +61,7 @@ class QueueNode { : element_(an_element), next_(nullptr) {} // We disable the default assignment operator and copy c'tor. - const QueueNode& operator = (const QueueNode&); + const QueueNode& operator=(const QueueNode&); QueueNode(const QueueNode&); E element_; @@ -84,7 +83,7 @@ class Queue { // 1. Deletes every node. QueueNode* node = head_; QueueNode* next = node->next(); - for (; ;) { + for (;;) { delete node; node = next; if (node == nullptr) break; @@ -162,11 +161,11 @@ class Queue { private: QueueNode* head_; // The first node of the queue. QueueNode* last_; // The last node of the queue. - size_t size_; // The number of elements in the queue. + size_t size_; // The number of elements in the queue. // We disallow copying a queue. Queue(const Queue&); - const Queue& operator = (const Queue&); + const Queue& operator=(const Queue&); }; #endif // GTEST_SAMPLES_SAMPLE3_INL_H_ diff --git a/Testing/lib/googletest-master/googletest/src/gtest-internal-inl.h b/Testing/lib/googletest-master/googletest/src/gtest-internal-inl.h index aef5571c1..ca5c8b13a 100644 --- a/Testing/lib/googletest-master/googletest/src/gtest-internal-inl.h +++ b/Testing/lib/googletest-master/googletest/src/gtest-internal-inl.h @@ -35,7 +35,7 @@ #define GTEST_SRC_GTEST_INTERNAL_INL_H_ #ifndef _WIN32_WCE -# include +#include #endif // !_WIN32_WCE #include #include // For strtoll/_strtoul64/malloc/free. @@ -50,16 +50,16 @@ #include "gtest/internal/gtest-port.h" #if GTEST_CAN_STREAM_RESULTS_ -# include // NOLINT -# include // NOLINT +#include // NOLINT +#include // NOLINT #endif #if GTEST_OS_WINDOWS -# include // NOLINT -#endif // GTEST_OS_WINDOWS +#include // NOLINT +#endif // GTEST_OS_WINDOWS -#include "gtest/gtest.h" #include "gtest/gtest-spi.h" +#include "gtest/gtest.h" GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) @@ -125,21 +125,22 @@ GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms); // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. -GTEST_API_ bool ParseInt32Flag( - const char* str, const char* flag, int32_t* value); +GTEST_API_ bool ParseInt32Flag(const char* str, const char* flag, + int32_t* value); // Returns a random seed in range [1, kMaxRandomSeed] based on the // given --gtest_random_seed flag value. inline int GetRandomSeedFromFlag(int32_t random_seed_flag) { - const unsigned int raw_seed = (random_seed_flag == 0) ? - static_cast(GetTimeInMillis()) : - static_cast(random_seed_flag); + const unsigned int raw_seed = + (random_seed_flag == 0) ? static_cast(GetTimeInMillis()) + : static_cast(random_seed_flag); // Normalizes the actual seed to range [1, kMaxRandomSeed] such that // it's easy to type. const int normalized_seed = static_cast((raw_seed - 1U) % - static_cast(kMaxRandomSeed)) + 1; + static_cast(kMaxRandomSeed)) + + 1; return normalized_seed; } @@ -278,8 +279,8 @@ GTEST_API_ int32_t Int32FromEnvOrDie(const char* env_var, int32_t default_val); // returns true if and only if the test should be run on this shard. The test id // is some arbitrary but unique non-negative integer assigned to each test // method. Assumes that 0 <= shard_index < total_shards. -GTEST_API_ bool ShouldRunTestOnShard( - int total_shards, int shard_index, int test_id); +GTEST_API_ bool ShouldRunTestOnShard(int total_shards, int shard_index, + int test_id); // STL container utilities. @@ -291,8 +292,7 @@ inline int CountIf(const Container& c, Predicate predicate) { // Solaris has a non-standard signature. int count = 0; for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) { - if (predicate(*it)) - ++count; + if (predicate(*it)) ++count; } return count; } @@ -399,7 +399,7 @@ class GTEST_API_ UnitTestOptions { // // This recursive algorithm isn't very efficient, but is clear and // works well enough for matching test names, which are short. - static bool PatternMatchesString(const char *pattern, const char *str); + static bool PatternMatchesString(const char* pattern, const char* str); // Returns true if and only if the user-specified filter matches the test // suite name and the test name. @@ -483,7 +483,7 @@ struct TraceInfo { // This is the default global test part result reporter used in UnitTestImpl. // This class should only be used by UnitTestImpl. class DefaultGlobalTestPartResultReporter - : public TestPartResultReporterInterface { + : public TestPartResultReporterInterface { public: explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test); // Implements the TestPartResultReporterInterface. Reports the test part @@ -749,9 +749,7 @@ class GTEST_API_ UnitTestImpl { } // Clears the results of ad-hoc test assertions. - void ClearAdHocTestResult() { - ad_hoc_test_result_.Clear(); - } + void ClearAdHocTestResult() { ad_hoc_test_result_.Clear(); } // Adds a TestProperty to the current TestResult object when invoked in a // context of a test or a test suite, or to the global property set. If the @@ -759,10 +757,7 @@ class GTEST_API_ UnitTestImpl { // updated. void RecordProperty(const TestProperty& test_property); - enum ReactionToSharding { - HONOR_SHARDING_PROTOCOL, - IGNORE_SHARDING_PROTOCOL - }; + enum ReactionToSharding { HONOR_SHARDING_PROTOCOL, IGNORE_SHARDING_PROTOCOL }; // Matches the full name of each test against the user-specified // filter to decide whether the test should run, then records the @@ -991,8 +986,9 @@ GTEST_API_ bool IsValidEscape(char ch); GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); GTEST_API_ bool ValidateRegex(const char* regex); GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); -GTEST_API_ bool MatchRepetitionAndRegexAtHead( - bool escaped, char ch, char repeat, const char* regex, const char* str); +GTEST_API_ bool MatchRepetitionAndRegexAtHead(bool escaped, char ch, + char repeat, const char* regex, + const char* str); GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); #endif // GTEST_USES_SIMPLE_RE @@ -1094,8 +1090,7 @@ class StreamingListener : public EmptyTestEventListener { } ~SocketWriter() override { - if (sockfd_ != -1) - CloseConnection(); + if (sockfd_ != -1) CloseConnection(); } // Sends a string to the socket. @@ -1105,9 +1100,8 @@ class StreamingListener : public EmptyTestEventListener { const auto len = static_cast(message.length()); if (write(sockfd_, message.c_str(), len) != static_cast(len)) { - GTEST_LOG_(WARNING) - << "stream_result_to: failed to stream to " - << host_name_ << ":" << port_num_; + GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to " + << host_name_ << ":" << port_num_; } } @@ -1140,7 +1134,9 @@ class StreamingListener : public EmptyTestEventListener { } explicit StreamingListener(AbstractSocketWriter* socket_writer) - : socket_writer_(socket_writer) { Start(); } + : socket_writer_(socket_writer) { + Start(); + } void OnTestProgramStart(const UnitTest& /* unit_test */) override { SendLn("event=TestProgramStart"); @@ -1163,9 +1159,9 @@ class StreamingListener : public EmptyTestEventListener { void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) override { - SendLn("event=TestIterationEnd&passed=" + - FormatBool(unit_test.Passed()) + "&elapsed_time=" + - StreamableToString(unit_test.elapsed_time()) + "ms"); + SendLn("event=TestIterationEnd&passed=" + FormatBool(unit_test.Passed()) + + "&elapsed_time=" + StreamableToString(unit_test.elapsed_time()) + + "ms"); } // Note that "event=TestCaseStart" is a wire format and has to remain @@ -1188,8 +1184,7 @@ class StreamingListener : public EmptyTestEventListener { void OnTestEnd(const TestInfo& test_info) override { SendLn("event=TestEnd&passed=" + - FormatBool((test_info.result())->Passed()) + - "&elapsed_time=" + + FormatBool((test_info.result())->Passed()) + "&elapsed_time=" + StreamableToString((test_info.result())->elapsed_time()) + "ms"); } diff --git a/Testing/lib/googletest-master/googletest/test/googletest-param-test-test.h b/Testing/lib/googletest-master/googletest/test/googletest-param-test-test.h index 648057017..652df538c 100644 --- a/Testing/lib/googletest-master/googletest/test/googletest-param-test-test.h +++ b/Testing/lib/googletest-master/googletest/test/googletest-param-test-test.h @@ -39,13 +39,11 @@ // Test fixture for testing definition and instantiation of a test // in separate translation units. -class ExternalInstantiationTest : public ::testing::TestWithParam { -}; +class ExternalInstantiationTest : public ::testing::TestWithParam {}; // Test fixture for testing instantiation of a test in multiple // translation units. class InstantiationInMultipleTranslationUnitsTest - : public ::testing::TestWithParam { -}; + : public ::testing::TestWithParam {}; #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ diff --git a/Testing/lib/googletest-master/googletest/test/gtest-typed-test_test.h b/Testing/lib/googletest-master/googletest/test/gtest-typed-test_test.h index 23137b7ef..120cf229b 100644 --- a/Testing/lib/googletest-master/googletest/test/gtest-typed-test_test.h +++ b/Testing/lib/googletest-master/googletest/test/gtest-typed-test_test.h @@ -27,7 +27,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - #ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ #define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_ @@ -43,22 +42,19 @@ using testing::Test; // and gtest-typed-test2_test.cc. template -class ContainerTest : public Test { -}; +class ContainerTest : public Test {}; TYPED_TEST_SUITE_P(ContainerTest); -TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { - TypeParam container; -} +TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { TypeParam container; } TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { TypeParam container; EXPECT_EQ(0U, container.size()); } -REGISTER_TYPED_TEST_SUITE_P(ContainerTest, - CanBeDefaultConstructed, InitialSizeIsZero); +REGISTER_TYPED_TEST_SUITE_P(ContainerTest, CanBeDefaultConstructed, + InitialSizeIsZero); #endif // GTEST_HAS_TYPED_TEST_P diff --git a/Testing/lib/googletest-master/googletest/test/production.h b/Testing/lib/googletest-master/googletest/test/production.h index 542723b70..09adb397a 100644 --- a/Testing/lib/googletest-master/googletest/test/production.h +++ b/Testing/lib/googletest-master/googletest/test/production.h @@ -46,6 +46,7 @@ class PrivateCode { PrivateCode(); int x() const { return x_; } + private: void set_x(int an_x) { x_ = an_x; } int x_; From b93c10f29c71bb4a5580b04f3df61fd7e4970ed2 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Fri, 9 May 2025 15:53:37 -0700 Subject: [PATCH 25/26] resolved more issue from the pull request --- Simulator/Core/GPUModel.cpp | 5 + Simulator/Core/GPUModel.h | 11 +- Testing/test_output.log | 410 ------------------------------------ 3 files changed, 13 insertions(+), 413 deletions(-) delete mode 100644 Testing/test_output.log diff --git a/Simulator/Core/GPUModel.cpp b/Simulator/Core/GPUModel.cpp index 896abae14..da7b9cbbd 100644 --- a/Simulator/Core/GPUModel.cpp +++ b/Simulator/Core/GPUModel.cpp @@ -37,6 +37,11 @@ GPUModel::GPUModel() : function copyCPUtoGPU = bind(&GPUModel::copyCPUtoGPU, this); OperationManager::getInstance().registerOperation(Operations::copyToGPU, copyCPUtoGPU); + // Note: We do not register a corresponding copyFromGPU operation here because + // we are only copying the synapseIndexMap to the GPU. This map is a read-only lookup table + // that gets recreated from scratch on each update. As a result, we only need to allocate, + // copy to GPU, and deallocate — there is no meaningful data to copy back from the GPU. + // Register deleteSynapseImap function as a deallocateGPUMemory operation in the OperationManager function deallocateGPUMemory = bind(&GPUModel::deleteDeviceStruct, this); OperationManager::getInstance().registerOperation(Operations::deallocateGPUMemory, diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index 460491d67..fc0756aac 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -84,7 +84,12 @@ class GPUModel : public Model { /// over the past epoch. Should be called once every epoch. virtual void updateConnections() override; - /// Copy Synapse Map data to GPU. + /// Copies neuron and synapse data from CPU to GPU memory. + /// TODO: Refactor this. Currently, GPUModel handles low-level memory transfer for vertices and edges. + /// Consider moving this responsibility to a more appropriate class, such as a dedicated memory manager + /// or the OperationManager, to better separate concerns and keep the model focused on high-level coordination. + virtual void copyCPUtoGPU() override; + virtual void copyCPUtoGPU() override; // GPUModel itself does not have anything to be copied back, this function is a @@ -96,10 +101,10 @@ class GPUModel : public Model { /// Print out EdgeProps on the GPU. void printGPUEdgesPropsModel() const; - /// Getter for synapse structures in device memory + /// Getter for edge (synapse) structures in device memory AllEdgesDeviceProperties *&getAllEdgesDevice(); - /// Getter for neuron structure in device memory + /// Getter for vertex (neuron) structures in device memory AllVerticesDeviceProperties *&getAllVerticesDevice(); protected: diff --git a/Testing/test_output.log b/Testing/test_output.log deleted file mode 100644 index 5468f2646..000000000 --- a/Testing/test_output.log +++ /dev/null @@ -1,410 +0,0 @@ -nohup: ignoring input -============================================================================ -| GRAPHITTI BUILD | -============================================================================ - -----Generating Makefile for Graphitti GPU version---- --- HDF5 version 1.10.4 located. HDF5 recorders are available. --- Setting Optimization flag: O3 --- Setting Compile Definition: TIMXL_USE_STL --- Generating build for Log4cplus version 2.0.7 --- Threads: -lpthread --- Threads: -lpthread --- Sources: loggingserver.cxx --- Compiler: /usr/bin/c++ --- GNU version 8.3.0 --- Compiler flags: -O3 --- System name: Linux --- System version: 4.19.0-16-amd64 --- Configuring done --- Generating done --- Build files have been written to: /home/NETID/shinjiku/issue828/Graphitti/build -[ 4%] Built target Core -[ 5%] Built target RNG -[ 14%] Built target Edges -[ 20%] Built target Connections -[ 21%] Built target FunctionNodes -[ 30%] Built target Vertices -[ 33%] Built target Matrix -[ 35%] Built target Recorders -[ 38%] Built target Utils -[ 39%] Built target Layouts -[ 40%] Built target paramcontainer -[ 47%] Built target TinyXPath -[ 68%] Built target log4cplus -[ 69%] Built target ggraphitti -[ 70%] Built target gtest -[ 71%] Built target gtest_main -[ 80%] Built target tests -[ 81%] Built target serialFileAccessTest -[ 82%] Built target loggingserver -[ 83%] Built target appender_test -[ 84%] Built target configandwatch_test -[ 85%] Built target customloglevel_test -[ 86%] Built target fileappender_test -[ 87%] Built target filter_test -[ 88%] Built target hierarchy_test -[ 89%] Built target loglog_test -[ 90%] Built target ndc_test -[ 91%] Built target ostream_test -[ 92%] Built target patternlayout_test -[ 92%] Built target performance_test -[ 94%] Built target priority_test -[ 95%] Built target propertyconfig_test -[ 96%] Built target thread_test -[ 97%] Built target timeformat_test -[ 98%] Built target unit_tests -[ 99%] Built target gmock -[100%] Built target gmock_main -============================================================================ -| UNIT TESTS | -============================================================================ -[INFO ][2025-05-06 00:02:48] Running Tests -[==========] Running 112 tests from 19 test suites. -[----------] Global test environment set-up. -[----------] 5 tests from OperationManager -[ RUN ] OperationManager.GetInstanceReturnsInstance -[ OK ] OperationManager.GetInstanceReturnsInstance (0 ms) -[ RUN ] OperationManager.AddingOneOperation -[ OK ] OperationManager.AddingOneOperation (0 ms) -[ RUN ] OperationManager.AddingManyOperations -[ OK ] OperationManager.AddingManyOperations (0 ms) -[ RUN ] OperationManager.OperationExecutionSuccess -[ OK ] OperationManager.OperationExecutionSuccess (0 ms) -[ RUN ] OperationManager.OperationExecutionContainsNoFunctionsOfOperationType -[ OK ] OperationManager.OperationExecutionContainsNoFunctionsOfOperationType (0 ms) -[----------] 5 tests from OperationManager (0 ms total) - -[----------] 3 tests from EdgeIndexMap -[ RUN ] EdgeIndexMap.DefaultConstructor -[ OK ] EdgeIndexMap.DefaultConstructor (0 ms) -[ RUN ] EdgeIndexMap.OverloadedConstructor -[ OK ] EdgeIndexMap.OverloadedConstructor (0 ms) -[ RUN ] EdgeIndexMap.ZeroValueConstructor -[ OK ] EdgeIndexMap.ZeroValueConstructor (0 ms) -[----------] 3 tests from EdgeIndexMap (0 ms total) - -[----------] 6 tests from SynapseIndexMapTestObject -[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseMapInitialiedSuccessfully -[ OK ] SynapseIndexMapTestObject.OutgoingSynapseMapInitialiedSuccessfully (0 ms) -[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseBeginInitialiedSuccessfully -[ OK ] SynapseIndexMapTestObject.OutgoingSynapseBeginInitialiedSuccessfully (0 ms) -[ RUN ] SynapseIndexMapTestObject.OutgoingSynapseCountInitialiedSuccessfully -[ OK ] SynapseIndexMapTestObject.OutgoingSynapseCountInitialiedSuccessfully (0 ms) -[ RUN ] SynapseIndexMapTestObject.IncomingSynapseIndexMapInitialiedSuccessfully -[ OK ] SynapseIndexMapTestObject.IncomingSynapseIndexMapInitialiedSuccessfully (0 ms) -[ RUN ] SynapseIndexMapTestObject.IncomingSynapseBeginInitialiedSuccessfully -[ OK ] SynapseIndexMapTestObject.IncomingSynapseBeginInitialiedSuccessfully (0 ms) -[ RUN ] SynapseIndexMapTestObject.IncomingSynapseCountInitializedSuccessfully -[ OK ] SynapseIndexMapTestObject.IncomingSynapseCountInitializedSuccessfully (0 ms) -[----------] 6 tests from SynapseIndexMapTestObject (0 ms total) - -[----------] 1 test from GenericFunctionNode -[ RUN ] GenericFunctionNode.TemplateFunctionTest -[ OK ] GenericFunctionNode.TemplateFunctionTest (0 ms) -[----------] 1 test from GenericFunctionNode (0 ms total) - -[----------] 3 tests from Simulator -[ RUN ] Simulator.GetInstanceSuccess -[ OK ] Simulator.GetInstanceSuccess (0 ms) -[ RUN ] Simulator.PrintParameters -[ OK ] Simulator.PrintParameters (0 ms) -[ RUN ] Simulator.ParametersInitializedSuccessfully -[ OK ] Simulator.ParametersInitializedSuccessfully (3 ms) -[----------] 3 tests from Simulator (3 ms total) - -[----------] 5 tests from VerticesFactory -[ RUN ] VerticesFactory.GetInstanceReturnsInstance -[ OK ] VerticesFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] VerticesFactory.CreateAllLIFNeuronsInstance -[ OK ] VerticesFactory.CreateAllLIFNeuronsInstance (0 ms) -[ RUN ] VerticesFactory.CreateAllIZNeuronsInstance -[ OK ] VerticesFactory.CreateAllIZNeuronsInstance (0 ms) -[ RUN ] VerticesFactory.CreateAll911VerticesInstance -[ OK ] VerticesFactory.CreateAll911VerticesInstance (0 ms) -[ RUN ] VerticesFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] VerticesFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[----------] 5 tests from VerticesFactory (0 ms total) - -[----------] 5 tests from ConnectionsFactory -[ RUN ] ConnectionsFactory.GetInstanceReturnsInstance -[ OK ] ConnectionsFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] ConnectionsFactory.CreateConnstaticInstance -[ OK ] ConnectionsFactory.CreateConnstaticInstance (0 ms) -[ RUN ] ConnectionsFactory.CreateConnGrowthInstance -[ OK ] ConnectionsFactory.CreateConnGrowthInstance (0 ms) -[ RUN ] ConnectionsFactory.CreateConnections911Instance -[ OK ] ConnectionsFactory.CreateConnections911Instance (0 ms) -[ RUN ] ConnectionsFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] ConnectionsFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[----------] 5 tests from ConnectionsFactory (0 ms total) - -[----------] 7 tests from EdgesFactory -[ RUN ] EdgesFactory.GetInstanceReturnsInstance -[ OK ] EdgesFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] EdgesFactory.CreateAll911EdgesInstance -[ OK ] EdgesFactory.CreateAll911EdgesInstance (0 ms) -[ RUN ] EdgesFactory.CreateAllDSSynapsesInstance -[ OK ] EdgesFactory.CreateAllDSSynapsesInstance (0 ms) -[ RUN ] EdgesFactory.CreateAllDynamicSTDPSynapsesInstance -[ OK ] EdgesFactory.CreateAllDynamicSTDPSynapsesInstance (0 ms) -[ RUN ] EdgesFactory.CreateAllSTDPSynapsesInstance -[ OK ] EdgesFactory.CreateAllSTDPSynapsesInstance (0 ms) -[ RUN ] EdgesFactory.CreateAllSpikingSynapsesInstance -[ OK ] EdgesFactory.CreateAllSpikingSynapsesInstance (1 ms) -[ RUN ] EdgesFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] EdgesFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[----------] 7 tests from EdgesFactory (1 ms total) - -[----------] 4 tests from LayoutFactory -[ RUN ] LayoutFactory.GetInstanceReturnsInstance -[ OK ] LayoutFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] LayoutFactory.CreateLayoutNeuroInstance -[ OK ] LayoutFactory.CreateLayoutNeuroInstance (0 ms) -[ RUN ] LayoutFactory.CreateLayout911Instance -[ OK ] LayoutFactory.CreateLayout911Instance (0 ms) -[ RUN ] LayoutFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] LayoutFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[----------] 4 tests from LayoutFactory (0 ms total) - -[----------] 4 tests from RecorderFactory -[ RUN ] RecorderFactory.GetInstanceReturnsInstance -[ OK ] RecorderFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] RecorderFactory.CreateXml911RecorderInstance -[ OK ] RecorderFactory.CreateXml911RecorderInstance (0 ms) -[ RUN ] RecorderFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] RecorderFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[ RUN ] RecorderFactory.CreateHdf5RecorderInstance -[ OK ] RecorderFactory.CreateHdf5RecorderInstance (0 ms) -[----------] 4 tests from RecorderFactory (0 ms total) - -[----------] 9 tests from InputManagerFixture -[ RUN ] InputManagerFixture.queueFront -[ OK ] InputManagerFixture.queueFront (0 ms) -[ RUN ] InputManagerFixture.queueFrontException -[ OK ] InputManagerFixture.queueFrontException (0 ms) -[ RUN ] InputManagerFixture.getEpochEvents -[ OK ] InputManagerFixture.getEpochEvents (0 ms) -[ RUN ] InputManagerFixture.nonEmptyEventQueue -[ OK ] InputManagerFixture.nonEmptyEventQueue (1 ms) -[ RUN ] InputManagerFixture.emptyQueueAfterGettingEpochEvents -[ OK ] InputManagerFixture.emptyQueueAfterGettingEpochEvents (0 ms) -[ RUN ] InputManagerFixture.emptyQueueForMissingVertex -[ OK ] InputManagerFixture.emptyQueueForMissingVertex (0 ms) -[ RUN ] InputManagerFixture.queuePop -[ OK ] InputManagerFixture.queuePop (0 ms) -[ RUN ] InputManagerFixture.clockTickSize -[ OK ] InputManagerFixture.clockTickSize (0 ms) -[ RUN ] InputManagerFixture.clockTickUnit -[ OK ] InputManagerFixture.clockTickUnit (0 ms) -[----------] 9 tests from InputManagerFixture (1 ms total) - -[----------] 1 test from InputManager -[ RUN ] InputManager.readNeuroInputs -[ OK ] InputManager.readNeuroInputs (0 ms) -[----------] 1 test from InputManager (0 ms total) - -[----------] 4 tests from RNGFactory -[ RUN ] RNGFactory.GetInstanceReturnsInstance -[ OK ] RNGFactory.GetInstanceReturnsInstance (0 ms) -[ RUN ] RNGFactory.CreateMTRandInstance -[ OK ] RNGFactory.CreateMTRandInstance (0 ms) -[ RUN ] RNGFactory.CreateNormInstance -[ OK ] RNGFactory.CreateNormInstance (0 ms) -[ RUN ] RNGFactory.CreateNonExistentClassReturnsNullPtr -[ OK ] RNGFactory.CreateNonExistentClassReturnsNullPtr (0 ms) -[----------] 4 tests from RNGFactory (0 ms total) - -[----------] 10 tests from GraphManager -[ RUN ] GraphManager.GetInstanceReturnsInstance -[ OK ] GraphManager.GetInstanceReturnsInstance (0 ms) -[ RUN ] GraphManager.ReadGraphReturnsTrue -[ OK ] GraphManager.ReadGraphReturnsTrue (1 ms) -[ RUN ] GraphManager.NumVerticesReturnsEleven -[ OK ] GraphManager.NumVerticesReturnsEleven (0 ms) -[ RUN ] GraphManager.NumEdgesReturnsTwenty -[ OK ] GraphManager.NumEdgesReturnsTwenty (0 ms) -[ RUN ] GraphManager.GetVertcies -[ OK ] GraphManager.GetVertcies (0 ms) -[ RUN ] GraphManager.GetEdgesAndSource -[ OK ] GraphManager.GetEdgesAndSource (0 ms) -[ RUN ] GraphManager.GetEdgesAndTarget -[ OK ] GraphManager.GetEdgesAndTarget (0 ms) -[ RUN ] GraphManager.SortEdges -[ OK ] GraphManager.SortEdges (0 ms) -[ RUN ] GraphManager.ReadEmptyGraph -[ OK ] GraphManager.ReadEmptyGraph (0 ms) -[ RUN ] GraphManager.ReadNonExistentGraph -[ OK ] GraphManager.ReadNonExistentGraph (0 ms) -[----------] 10 tests from GraphManager (1 ms total) - -[----------] 16 tests from ParameterManager -[ RUN ] ParameterManager.GetInstanceReturnsInstance -[ OK ] ParameterManager.GetInstanceReturnsInstance (0 ms) -[ RUN ] ParameterManager.LoadingXMLFile -[ OK ] ParameterManager.LoadingXMLFile (0 ms) -[ RUN ] ParameterManager.LoadingMultipleValidXMLFiles -[ OK ] ParameterManager.LoadingMultipleValidXMLFiles (1 ms) -[ RUN ] ParameterManager.LoadingMultipleInvalidFiles -[ OK ] ParameterManager.LoadingMultipleInvalidFiles (0 ms) -[ RUN ] ParameterManager.ValidStringTargeting -[ OK ] ParameterManager.ValidStringTargeting (0 ms) -[ RUN ] ParameterManager.ValidIntTargeting -[ OK ] ParameterManager.ValidIntTargeting (2 ms) -[ RUN ] ParameterManager.InvalidIntTargeting -[ OK ] ParameterManager.InvalidIntTargeting (2 ms) -[ RUN ] ParameterManager.ValidFloatTargeting -[ OK ] ParameterManager.ValidFloatTargeting (1 ms) -[ RUN ] ParameterManager.InvalidFloatTargeting -[ OK ] ParameterManager.InvalidFloatTargeting (0 ms) -[ RUN ] ParameterManager.ValidDoubleTargeting -[ OK ] ParameterManager.ValidDoubleTargeting (0 ms) -[ RUN ] ParameterManager.InvalidDoubleTargeting -[ OK ] ParameterManager.InvalidDoubleTargeting (1 ms) -[ RUN ] ParameterManager.ValidBGFloatTargeting -[ OK ] ParameterManager.ValidBGFloatTargeting (0 ms) -[ RUN ] ParameterManager.InvalidBGFloatTargeting -[ OK ] ParameterManager.InvalidBGFloatTargeting (0 ms) -[ RUN ] ParameterManager.ValidLongTargeting -[ OK ] ParameterManager.ValidLongTargeting (1 ms) -[ RUN ] ParameterManager.InvalidLongTargeting -[ OK ] ParameterManager.InvalidLongTargeting (0 ms) -[ RUN ] ParameterManager.InvalidIntVectorTargeting -[ OK ] ParameterManager.InvalidIntVectorTargeting (0 ms) -[----------] 16 tests from ParameterManager (8 ms total) - -[----------] 10 tests from CircularBuffer -[ RUN ] CircularBuffer.Constructor -[ OK ] CircularBuffer.Constructor (0 ms) -[ RUN ] CircularBuffer.ConstructAndResize -[ OK ] CircularBuffer.ConstructAndResize (0 ms) -[ RUN ] CircularBuffer.Put -[ OK ] CircularBuffer.Put (0 ms) -[ RUN ] CircularBuffer.Get -[ OK ] CircularBuffer.Get (0 ms) -[ RUN ] CircularBuffer.GetWhenEmpty -[ OK ] CircularBuffer.GetWhenEmpty (0 ms) -[ RUN ] CircularBuffer.Clear -[ OK ] CircularBuffer.Clear (0 ms) -[ RUN ] CircularBuffer.IsEmpty -[ OK ] CircularBuffer.IsEmpty (0 ms) -[ RUN ] CircularBuffer.IsFull -[ OK ] CircularBuffer.IsFull (8 ms) -[ RUN ] CircularBuffer.Capacity -[ OK ] CircularBuffer.Capacity (29 ms) -[ RUN ] CircularBuffer.Size -[ OK ] CircularBuffer.Size (0 ms) -[----------] 10 tests from CircularBuffer (38 ms total) - -[----------] 4 tests from EventBufferTest -[ RUN ] EventBufferTest.GetElementFromEmptyBuffer -[ OK ] EventBufferTest.GetElementFromEmptyBuffer (0 ms) -[ RUN ] EventBufferTest.GetPastEventFromEmptyBuffer -[ OK ] EventBufferTest.GetPastEventFromEmptyBuffer (0 ms) -[ RUN ] EventBufferTest.InsertEventEmptyBuffer -[ OK ] EventBufferTest.InsertEventEmptyBuffer (0 ms) -[ RUN ] EventBufferTest.BufferWrapAround -[ OK ] EventBufferTest.BufferWrapAround (0 ms) -[----------] 4 tests from EventBufferTest (0 ms total) - -[----------] 9 tests from XmlRecorderTest -[ RUN ] XmlRecorderTest.CreateInstanceSuccess -[ OK ] XmlRecorderTest.CreateInstanceSuccess (0 ms) -[ RUN ] XmlRecorderTest.InitTest -[ OK ] XmlRecorderTest.InitTest (0 ms) -[ RUN ] XmlRecorderTest.RegisterVariableTest -[ OK ] XmlRecorderTest.RegisterVariableTest (0 ms) -[ RUN ] XmlRecorderTest.RegisterVectorMatrixTest -[ OK ] XmlRecorderTest.RegisterVectorMatrixTest (0 ms) -[ RUN ] XmlRecorderTest.RegisterRecordableVectorTest -[ OK ] XmlRecorderTest.RegisterRecordableVectorTest (1 ms) -[ RUN ] XmlRecorderTest.RegisterVectorVariableTest -[ OK ] XmlRecorderTest.RegisterVectorVariableTest (0 ms) -[ RUN ] XmlRecorderTest.CompileHistoriesTest -[ OK ] XmlRecorderTest.CompileHistoriesTest (0 ms) -[ RUN ] XmlRecorderTest.ToXML -[ OK ] XmlRecorderTest.ToXML (0 ms) -[ RUN ] XmlRecorderTest.SaveSimDataTest -[ OK ] XmlRecorderTest.SaveSimDataTest (0 ms) -[----------] 9 tests from XmlRecorderTest (1 ms total) - -[----------] 6 tests from Hdf5RecorderTest -[ RUN ] Hdf5RecorderTest.CreateInstanceSuccess -[ OK ] Hdf5RecorderTest.CreateInstanceSuccess (0 ms) -[ RUN ] Hdf5RecorderTest.Hdf5InitAndTermTest -[ OK ] Hdf5RecorderTest.Hdf5InitAndTermTest (1 ms) -[ RUN ] Hdf5RecorderTest.RegisterVariableTest -[ OK ] Hdf5RecorderTest.RegisterVariableTest (0 ms) -[ RUN ] Hdf5RecorderTest.RegisterVectorVariableTest -[ OK ] Hdf5RecorderTest.RegisterVectorVariableTest (0 ms) -[ RUN ] Hdf5RecorderTest.SaveSimDataTest -[ OK ] Hdf5RecorderTest.SaveSimDataTest (1 ms) -[ RUN ] Hdf5RecorderTest.CompileHistoriesTest -[ OK ] Hdf5RecorderTest.CompileHistoriesTest (0 ms) -[----------] 6 tests from Hdf5RecorderTest (2 ms total) - -[----------] Global test environment tear-down -[==========] 112 tests from 19 test suites ran. (55 ms total) -[ PASSED ] 112 tests. - -============================================================================ -| REGRESSION TESTS | -============================================================================ -Run simulations in parallel, using: ./ggraphitti -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-tiny.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-long.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-small-connected-long.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-long.xml -[ RUN TEST ] ./ggraphitti -c ../Testing/RegressionTesting/configfiles/test-medium-connected-long.xml -[ RUN TEST ] Waiting for simulations to finish... -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath //SimParams/deltaT/text() -Failed loading simulation parameter for xpath Failed loading simulation parameter for xpath //SimParams/deltaT/text()//SimParams/deltaT/text() - - -[========] Start verification -[--------]Verifying test-tiny.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-tiny-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-tiny-out.xml -[ PASSED ] Are equal -[--------]Verifying test-small.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-out.xml -[ PASSED ] Are equal -[--------]Verifying test-small-connected.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-connected-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-connected-out.xml -[ PASSED ] Are equal -[--------]Verifying test-small-long.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-long-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-long-out.xml -[ PASSED ] Are equal -[--------]Verifying test-small-connected-long.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-small-connected-long-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-small-connected-long-out.xml -[ PASSED ] Are equal -[--------]Verifying test-medium.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-out.xml -[ PASSED ] Are equal -[--------]Verifying test-medium-connected.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-connected-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-connected-out.xml -[ PASSED ] Are equal -[--------]Verifying test-medium-long.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-long-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-long-out.xml -[ PASSED ] Are equal -[--------]Verifying test-medium-connected-long.xml simulation output... -[ ] Output file: ../Testing/RegressionTesting/TestOutput/test-medium-connected-long-out.xml -[ AND ] Good output: ../Testing/RegressionTesting/GoodOutput/Gpu/test-medium-connected-long-out.xml -[ PASSED ] Are equal From 08f9e614ff5f18fda2c34c138442d2e5ed9d29f2 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Sat, 10 May 2025 14:48:45 -0700 Subject: [PATCH 26/26] fixed some bug --- Simulator/Core/GPUModel.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Simulator/Core/GPUModel.h b/Simulator/Core/GPUModel.h index fc0756aac..52da5187d 100644 --- a/Simulator/Core/GPUModel.h +++ b/Simulator/Core/GPUModel.h @@ -90,8 +90,6 @@ class GPUModel : public Model { /// or the OperationManager, to better separate concerns and keep the model focused on high-level coordination. virtual void copyCPUtoGPU() override; - virtual void copyCPUtoGPU() override; - // GPUModel itself does not have anything to be copied back, this function is a // dummy function just to make GPUModel non virtual virtual void copyGPUtoCPU() override