Commit 50a864e2 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

vtkPVView: support min/sum reduction operations

vtkSpreadSheetView (and vtkPVRenderView) needed `sum` reduction across
all participating ranks for certain use-cases. Earlier code erroneously
replaced all with `max`. Fixed that.

Fixes #19121.
parent bde94c1f
......@@ -903,6 +903,14 @@ if (PARAVIEW_USE_MPI)
#UseDataPartitions.xml
)
list(APPEND TESTS_WITH_INLINE_COMPARES
# needs parallel server for the columns to match those in the test.
SpreadSheetParallelData.xml)
# test only checks for spreadsheet columns correctly in
# parallel client-server mode.
set (SpreadSheetParallelData_DISABLE_C TRUE)
# DistributePoints is only tested in non-built-in mode.
paraview_add_client_server_tests(
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
......
<?xml version="1.0" ?>
<pqevents>
<!-- tests paraview/paraview#19121 -->
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources/Alphabetical" command="activate" arguments="SphereSource" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ThetaResolution/LineEdit0" command="key" arguments="16777219" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ThetaResolution/LineEdit0" command="set_string" arguments="3" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PhiResolution/LineEdit0" command="key" arguments="16777219" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PhiResolution/LineEdit0" command="set_string" arguments="3" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/Close" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/EmptyView/scrollArea/qt_scrollarea_viewport/widgetFoo/ConvertActionsFrame/SpreadSheetView" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/pqSpreadSheetViewDecorator/Attribute" command="activated" arguments="Cell Data" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="1.1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="2.1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="3.1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="4.1" />
<pqevent object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" command="setCurrent" arguments="5.1" />
<!-- this index only works for client-server hence we run this test only in client-server -->
<pqcheck object="pqClientMainWindow/centralwidget/MultiViewWidget/CoreWidget/qt_tabwidget_stackedwidget/MultiViewWidget1/Container/Frame.0/CentralWidgetFrame/Viewport/1pqSpreadSheetViewWidget0" property="modelItemData" arguments="5.2,Triangle" />
</pqevents>
......@@ -24,6 +24,7 @@
#include "vtkCamera.h"
#include "vtkCollection.h"
#include "vtkCommand.h"
#include "vtkCommunicator.h"
#include "vtkCuller.h"
#include "vtkDataRepresentation.h"
#include "vtkFXAAOptions.h"
......@@ -1258,7 +1259,7 @@ void vtkPVRenderView::Update()
// Gather information about geometry sizes from all representations.
const vtkTypeUInt64 lsize = this->GetDeliveryManager()->GetVisibleDataSize(/*low_res*/ false);
vtkTypeUInt64 gsize;
this->AllReduceMAX(lsize, gsize);
this->AllReduce(lsize, gsize, vtkCommunicator::SUM_OP);
const double geometry_size = gsize / 1024;
// cout << "Full Geometry size: " << geometry_size << endl;
......@@ -1327,7 +1328,7 @@ void vtkPVRenderView::UpdateLOD()
const vtkTypeUInt64 lsize = this->GetDeliveryManager()->GetVisibleDataSize(/*low_res*/ true);
vtkTypeUInt64 gsize;
this->AllReduceMAX(lsize, gsize);
this->AllReduce(lsize, gsize, vtkCommunicator::SUM_OP);
const double geometry_size = gsize / 1024;
// cout << "LOD Geometry size: " << geometry_size << endl;
......@@ -3401,8 +3402,8 @@ void vtkPVRenderView::SynchronizeMaximumIds(vtkIdType* maxPointId, vtkIdType* ma
// skip data server since this method is only called on processes involved
// in rendering.
this->AllReduceMAX(ptid, ptid, /*skip_data_server=*/true);
this->AllReduceMAX(cellid, cellid, /*skip_data_server=*/true);
this->AllReduce(ptid, ptid, vtkCommunicator::MAX_OP, /*skip_data_server=*/true);
this->AllReduce(cellid, cellid, vtkCommunicator::MAX_OP, /*skip_data_server=*/true);
*maxPointId = static_cast<vtkIdType>(ptid);
*maxCellId = static_cast<vtkIdType>(cellid);
......
......@@ -434,7 +434,7 @@ void vtkPVView::Update()
{
cache_full = 1;
}
this->AllReduceMAX(cache_full, cache_full);
this->AllReduce(cache_full, cache_full, vtkCommunicator::MAX_OP);
cacheSizeKeeper->SetCacheFull(cache_full > 0);
}
......@@ -641,17 +641,31 @@ void vtkPVView::AllReduce(const vtkBoundingBox& arg_source, vtkBoundingBox& dest
}
//-----------------------------------------------------------------------------
void vtkPVView::AllReduceMAX(
const vtkTypeUInt64 arg_source, vtkTypeUInt64& dest, bool skip_data_server)
void vtkPVView::AllReduce(
const vtkTypeUInt64 arg_source, vtkTypeUInt64& dest, int operation, bool skip_data_server)
{
assert(this->Session);
vtkVLogScopeF(PARAVIEW_LOG_RENDERING_VERBOSITY(), "all-reduce-max");
vtkVLogScopeF(PARAVIEW_LOG_RENDERING_VERBOSITY(), "all-reduce (op=%d)", operation);
auto evaluator = [operation](vtkTypeUInt64 a, vtkTypeUInt64 b) {
switch (operation)
{
case vtkCommunicator::MAX_OP:
return std::max(a, b);
case vtkCommunicator::MIN_OP:
return std::min(a, b);
case vtkCommunicator::SUM_OP:
return a + b;
default:
abort();
}
};
vtkTypeUInt64 source = arg_source;
auto pController = vtkMultiProcessController::GetGlobalController();
if (pController)
{
pController->Reduce(&source, &dest, 1, vtkCommunicator::MAX_OP, 0);
pController->Reduce(&source, &dest, 1, operation, 0);
source = dest;
}
......@@ -674,14 +688,14 @@ void vtkPVView::AllReduceMAX(
{
vtkTypeUInt64 val;
crController->Receive(&val, 1, 1, 41234);
source = std::max(source, val);
source = evaluator(source, val);
}
if (cdController)
{
vtkTypeUInt64 val;
cdController->Receive(&val, 1, 1, 41234);
source = std::max(source, val);
source = evaluator(source, val);
}
if (crController)
......
......@@ -266,9 +266,13 @@ protected:
void AllReduce(const vtkBoundingBox& source, vtkBoundingBox& dest);
/**
* Reduce the max value between all participating processes.
* Reduce between all participating processes using the operation
* (vtkCommunicator::StandardOperations) specified. Currently only
* vtkCommunicator::MIN_OP, vtkCommunicator::MAX_OP, and
* vtkCommunicator::SUM_OP are supported.
*/
void AllReduceMAX(const vtkTypeUInt64 source, vtkTypeUInt64& dest, bool skip_data_server = false);
void AllReduce(
const vtkTypeUInt64 source, vtkTypeUInt64& dest, int operation, bool skip_data_server = false);
/**
* Overridden to check that the representation has View setup properly. Older
......
......@@ -18,6 +18,7 @@
#include "vtkCSVExporter.h"
#include "vtkCharArray.h"
#include "vtkClientServerMoveData.h"
#include "vtkCommunicator.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSet.h"
#include "vtkDataSetAttributes.h"
......@@ -644,7 +645,7 @@ int vtkSpreadSheetView::StreamToClient()
this->DeliveryFilter->RemoveAllInputs();
}
this->AllReduceMAX(num_rows, num_rows);
this->AllReduce(num_rows, num_rows, vtkCommunicator::SUM_OP);
if (this->NumberOfRows != static_cast<vtkIdType>(num_rows))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment