Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit 5804f3b

Browse files
authored
Merge pull request #6 from Alpine-DAV/vpartial_testing
mpi partials test
2 parents e2561a6 + c7a30c7 commit 5804f3b

File tree

9 files changed

+311
-16
lines changed

9 files changed

+311
-16
lines changed

src/apcomp/internal/apcomp_diy_partial_redistribute.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ struct Redistribute
7878

7979
for(int i = 0; i < size; ++i)
8080
{
81-
apcompdiy::DynamicPoint<int,DIY_MAX_DIM> point(block->m_partials[i].m_pixel_id);
82-
//apcompdiy::DynamicPoint<int,DIY_MAX_DIM> point;
83-
//point[0] = block->m_partials[i].m_pixel_id;
81+
//apcompdiy::DynamicPoint<int,DIY_MAX_DIM> point(block->m_partials[i].m_pixel_id);
82+
apcompdiy::DynamicPoint<int,DIY_MAX_DIM> point(1);
83+
point[0] = block->m_partials[i].m_pixel_id;
8484
int dest_gid = m_decomposer.point_to_gid(point);
8585
apcompdiy::BlockID dest = proxy.out_link().target(dest_gid);
8686
outgoing[dest].push_back(block->m_partials[i]);

src/apcomp/partial_compositor.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
//
4141
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
4242
#include "partial_compositor.hpp"
43+
#include <apcomp/apcomp.hpp>
4344
#include <algorithm>
4445
#include <assert.h>
4546
#include <limits>
@@ -308,7 +309,7 @@ PartialCompositor<PartialType>::merge(const std::vector<std::vector<PartialType>
308309
global_max_pixel = max_pixel;
309310

310311
#ifdef APCOMP_PARALLEL
311-
MPI_Comm comm_handle = MPI_Comm_f2c(m_mpi_comm_id);
312+
MPI_Comm comm_handle = MPI_Comm_f2c(mpi_comm());
312313
int rank_min = global_min_pixel;
313314
int rank_max = global_max_pixel;
314315
int mpi_min;
@@ -496,7 +497,7 @@ PartialCompositor<PartialType>::composite(std::vector<std::vector<PartialType>>
496497
{
497498
int global_partial_images = partial_images.size();
498499
#ifdef APCOMP_PARALLEL
499-
MPI_Comm comm_handle = MPI_Comm_f2c(m_mpi_comm_id);
500+
MPI_Comm comm_handle = MPI_Comm_f2c(mpi_comm());
500501
int local_partials = global_partial_images;
501502
MPI_Allreduce(&local_partials, &global_partial_images, 1, MPI_INT, MPI_SUM, comm_handle);
502503
#endif
@@ -564,13 +565,6 @@ PartialCompositor<PartialType>::set_background(std::vector<double> &background_v
564565
}
565566
}
566567

567-
template<typename PartialType>
568-
void
569-
PartialCompositor<PartialType>::set_comm_handle(int mpi_comm_id)
570-
{
571-
m_mpi_comm_id = mpi_comm_id;
572-
}
573-
574568
//Explicit function instantiations
575569
template class APCOMP_API PartialCompositor<VolumePartial<float>>;
576570
template class APCOMP_API PartialCompositor<VolumePartial<double>>;

src/apcomp/partial_compositor.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class APCOMP_API PartialCompositor
6363
std::vector<PartialType> &output_partials);
6464
void set_background(std::vector<float> &background_values);
6565
void set_background(std::vector<double> &background_values);
66-
void set_comm_handle(int mpi_comm_id);
6766
protected:
6867
void merge(const std::vector<std::vector<PartialType>> &in_partials,
6968
std::vector<PartialType> &partials,
@@ -74,7 +73,6 @@ class APCOMP_API PartialCompositor
7473
std::vector<PartialType> &output_partials);
7574

7675
std::vector<typename PartialType::ValueType> m_background_values;
77-
int m_mpi_comm_id;
7876
};
7977

8078
}; // namespace rover

src/tests/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@
5252
################################
5353
set(BASIC_TESTS t_apcomp_smoke
5454
t_apcomp_zbuffer
55-
t_apcomp_c_order)
55+
t_apcomp_c_order
56+
t_apcomp_volume_partials)
5657

5758
set(MPI_TESTS t_apcomp_mpi_smoke
5859
t_apcomp_zbuffer_mpi
59-
t_apcomp_c_order_mpi)
60+
t_apcomp_c_order_mpi
61+
t_apcomp_volume_partials_mpi)
6062

6163
if(ENABLE_OPENMP)
6264
set(apcomp_deps openmp)
1.86 KB
Loading
1.86 KB
Loading
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2+
// Copyright (c) 2015-2017, Lawrence Livermore National Security, LLC.
3+
//
4+
// Produced at the Lawrence Livermore National Laboratory
5+
//
6+
// LLNL-CODE-716457
7+
//
8+
// All rights reserved.
9+
//
10+
// This file is part of APCompositor.
11+
//
12+
// For details, see: http://software.llnl.gov/ascent/.
13+
//
14+
// Please also read ascent/LICENSE
15+
//
16+
// Redistribution and use in source and binary forms, with or without
17+
// modification, are permitted provided that the following conditions are met:
18+
//
19+
// * Redistributions of source code must retain the above copyright notice,
20+
// this list of conditions and the disclaimer below.
21+
//
22+
// * Redistributions in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the disclaimer (as noted below) in the
24+
// documentation and/or other materials provided with the distribution.
25+
//
26+
// * Neither the name of the LLNS/LLNL nor the names of its contributors may
27+
// be used to endorse or promote products derived from this software without
28+
// specific prior written permission.
29+
//
30+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33+
// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
34+
// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
35+
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37+
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38+
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40+
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41+
// POSSIBILITY OF SUCH DAMAGE.
42+
//
43+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
44+
45+
//-----------------------------------------------------------------------------
46+
///
47+
/// file: t_apcomp_zbuffer.cpp
48+
///
49+
//-----------------------------------------------------------------------------
50+
51+
#include "gtest/gtest.h"
52+
#include "t_test_utils.h"
53+
54+
#include <apcomp/apcomp.hpp>
55+
#include <apcomp/partial_compositor.hpp>
56+
57+
#include <iostream>
58+
59+
using namespace std;
60+
61+
62+
//-----------------------------------------------------------------------------
63+
TEST(apcomp_partials, apcomp_volume_partial)
64+
{
65+
std::string output_dir = prepare_output_dir();
66+
std::string file_name = "volume_partial";
67+
std::string output_file = apcomp::join_file_path(output_dir,file_name);
68+
remove_test_file(output_file);
69+
70+
apcomp::PartialCompositor<apcomp::VolumePartial<float>> compositor;
71+
72+
const int width = 1024;
73+
const int height = 1024;
74+
const int square_size = 300;
75+
const int num_images = 4;
76+
const int y = 500;
77+
float colors[4][4] = { {1.f, 0.f, 0.f, 0.5f},
78+
{0.f, 1.f, 0.f, 0.5f},
79+
{0.f, 0.f, 1.f, 0.5f},
80+
{0.f, 1.f, 1.f, 0.5f} } ;
81+
82+
std::vector<std::vector<apcomp::VolumePartial<float>>> in_partials;
83+
in_partials.resize(num_images);
84+
85+
for(int i = 0; i < num_images; ++i)
86+
{
87+
std::vector<apcomp::VolumePartial<float>> partials;
88+
gen_float32_partials(in_partials[i],
89+
width,
90+
height,
91+
float(i) * 0.05f,
92+
200 + 100*i,
93+
y - i * 50,
94+
square_size,
95+
colors[i]);
96+
97+
}
98+
std::vector<apcomp::VolumePartial<float>> output;
99+
compositor.composite(in_partials, output);
100+
101+
partials_to_png(output, width, height, output_file);
102+
103+
EXPECT_TRUE(check_test_image(output_file));
104+
}
105+
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
2+
// Copyright (c) 2015-2017, Lawrence Livermore National Security, LLC.
3+
//
4+
// Produced at the Lawrence Livermore National Laboratory
5+
//
6+
// LLNL-CODE-716457
7+
//
8+
// All rights reserved.
9+
//
10+
// This file is part of APCompositor.
11+
//
12+
// For details, see: http://software.llnl.gov/ascent/.
13+
//
14+
// Please also read ascent/LICENSE
15+
//
16+
// Redistribution and use in source and binary forms, with or without
17+
// modification, are permitted provided that the following conditions are met:
18+
//
19+
// * Redistributions of source code must retain the above copyright notice,
20+
// this list of conditions and the disclaimer below.
21+
//
22+
// * Redistributions in binary form must reproduce the above copyright notice,
23+
// this list of conditions and the disclaimer (as noted below) in the
24+
// documentation and/or other materials provided with the distribution.
25+
//
26+
// * Neither the name of the LLNS/LLNL nor the names of its contributors may
27+
// be used to endorse or promote products derived from this software without
28+
// specific prior written permission.
29+
//
30+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33+
// ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
34+
// LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
35+
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36+
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37+
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38+
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39+
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40+
// IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41+
// POSSIBILITY OF SUCH DAMAGE.
42+
//
43+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
44+
45+
//-----------------------------------------------------------------------------
46+
///
47+
/// file: t_apcomp_zbuffer.cpp
48+
///
49+
//-----------------------------------------------------------------------------
50+
51+
#include "gtest/gtest.h"
52+
#include "t_test_utils.h"
53+
54+
#include <apcomp/apcomp.hpp>
55+
#include <apcomp/partial_compositor.hpp>
56+
57+
#include <iostream>
58+
#include <mpi.h>
59+
60+
using namespace std;
61+
62+
63+
//-----------------------------------------------------------------------------
64+
TEST(apcomp_vpartial_mpi, apcomp_vpartial_mpi)
65+
{
66+
std::string output_dir = prepare_output_dir();
67+
std::string file_name = "volume_partial_mpi";
68+
std::string output_file = apcomp::join_file_path(output_dir,file_name);
69+
remove_test_file(output_file);
70+
71+
int par_rank;
72+
int par_size;
73+
MPI_Comm comm = MPI_COMM_WORLD;
74+
MPI_Comm_rank(comm, &par_rank);
75+
MPI_Comm_size(comm, &par_size);
76+
apcomp::mpi_comm(MPI_Comm_c2f(comm));
77+
if(par_size > 4)
78+
{
79+
EXPECT_TRUE(false);
80+
}
81+
82+
apcomp::PartialCompositor<apcomp::VolumePartial<float>> compositor;
83+
84+
const int width = 1024;
85+
const int height = 1024;
86+
const int square_size = 300;
87+
const int num_images = 4;
88+
const int y = 500;
89+
float colors[4][4] = { {1.f, 0.f, 0.f, 0.5f},
90+
{0.f, 1.f, 0.f, 0.5f},
91+
{0.f, 0.f, 1.f, 0.5f},
92+
{0.f, 1.f, 1.f, 0.5f} } ;
93+
94+
std::vector<std::vector<apcomp::VolumePartial<float>>> in_partials;
95+
in_partials.resize(1);
96+
97+
std::vector<apcomp::VolumePartial<float>> partials;
98+
gen_float32_partials(in_partials[0],
99+
width,
100+
height,
101+
float(par_rank) * 0.05f,
102+
200 + 100*par_rank,
103+
y - par_rank * 50,
104+
square_size,
105+
colors[par_rank]);
106+
107+
108+
std::vector<apcomp::VolumePartial<float>> output;
109+
compositor.composite(in_partials, output);
110+
111+
if(par_rank == 0)
112+
{
113+
partials_to_png(output, width, height, output_file);
114+
EXPECT_TRUE(check_test_image(output_file));
115+
}
116+
117+
}
118+
119+
int main(int argc, char* argv[])
120+
{
121+
int result = 0;
122+
::testing::InitGoogleTest(&argc, argv);
123+
MPI_Init(&argc, &argv);
124+
result = RUN_ALL_TESTS();
125+
MPI_Finalize();
126+
127+
return result;
128+
}

0 commit comments

Comments
 (0)