Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed Jul 27, 2020
2 parents c771b8e + 8943b66 commit 83c06a9
Show file tree
Hide file tree
Showing 75 changed files with 3,121 additions and 644 deletions.
2 changes: 1 addition & 1 deletion .jenkins/lsu/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sbatch \
--job-name="jenkins-hpx-${configuration_name_with_build_type}" \
--nodes="${configuration_slurm_num_nodes}" \
--partition="${configuration_slurm_partition}" \
--time="01:30:00" \
--time="03:00:00" \
--output="jenkins-hpx-${configuration_name_with_build_type}.out" \
--error="jenkins-hpx-${configuration_name_with_build_type}.err" \
--wait .jenkins/lsu/batch.sh
Expand Down
2 changes: 1 addition & 1 deletion .jenkins/lsu/slurm-configuration-clang-7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

configuration_slurm_partition="marvin"
configuration_slurm_partition="medusa"
configuration_slurm_num_nodes="1"
2 changes: 1 addition & 1 deletion .jenkins/lsu/slurm-configuration-clang-8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

configuration_slurm_partition="marvin"
configuration_slurm_partition="medusa"
configuration_slurm_num_nodes="1"
2 changes: 1 addition & 1 deletion .jenkins/lsu/slurm-configuration-clang-9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

configuration_slurm_partition="marvin"
configuration_slurm_partition="medusa"
configuration_slurm_num_nodes="1"
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,20 @@ if(HPX_WITH_APEX)
endif()

# LibCDS option
hpx_option(HPX_WITH_LIBCDS BOOL "Enable LibCDS support." OFF)
hpx_option(
HPX_WITH_LIBCDS BOOL "Enable LibCDS support (experimental)." OFF
CATEGORY "Thread Manager" ADVANCED
)
if(HPX_WITH_LIBCDS)
hpx_option(
HPX_WITH_LIBCDS_GIT_REPOSITORY STRING
"Define the LibCDS git repository to use."
https://github.com/STEllAR-GROUP/libcds CATEGORY "Thread Manager" ADVANCED
)
hpx_option(
HPX_WITH_LIBCDS_GIT_TAG STRING "Define the LibCDS git tag to use."
hpx-thread CATEGORY "Thread Manager" ADVANCED
)
include(HPX_SetupLibCDS)
if(NOT libcds_POPULATED)
hpx_error("HPX_WITH_LIBCDS was set to ON, but HPX failed to fetch LibCDS")
Expand Down
13 changes: 10 additions & 3 deletions cmake/HPX_SetupLibCDS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

if(HPX_WITH_LIBCDS AND NOT TARGET LibCDS::cds)
include(FetchContent)
include(HPX_Message)

set(LIBCDS_WITH_HPX
ON
Expand All @@ -27,11 +28,14 @@ if(HPX_WITH_LIBCDS AND NOT TARGET LibCDS::cds)
CACHE INTERNAL ""
)

hpx_info(
"Fetching libCDS from repository: ${HPX_WITH_LIBCDS_GIT_REPOSITORY}, "
"tag: ${HPX_WITH_LIBCDS_GIT_TAG}"
)
fetchcontent_declare(
libcds
# GIT_REPOSITORY https://github.com/khizmax/libcds
GIT_REPOSITORY https://github.com/weilewei/libcds
GIT_TAG hpx-thread
GIT_REPOSITORY ${HPX_WITH_LIBCDS_GIT_REPOSITORY}
GIT_TAG ${HPX_WITH_LIBCDS_GIT_TAG}
GIT_SHALLOW TRUE
)
fetchcontent_getproperties(libcds)
Expand All @@ -40,6 +44,9 @@ if(HPX_WITH_LIBCDS AND NOT TARGET LibCDS::cds)
fetchcontent_populate(libcds)
set(LIBCDS_CXX_STANDARD ${HPX_CXX_STANDARD})
add_subdirectory(${libcds_SOURCE_DIR} ${libcds_BINARY_DIR})

set_target_properties(cds PROPERTIES FOLDER "Core")
set_target_properties(cds-s PROPERTIES FOLDER "Core")
endif()

endif()
8 changes: 4 additions & 4 deletions docs/sphinx/manual/optimizing_hpx_applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ system and application performance.
where:

``<agas_service_category>`` is one of the following: ``primary``,
``locality``, ``component`` or ``symbol``
``locality``, ``component`` or ``symbol``

* ``<agas_instance>/total``

Expand Down Expand Up @@ -868,7 +868,7 @@ system and application performance.
where:

``<agas_service_category>`` is one of the following: ``primary``,
``locality``, ``component`` or ``symbol``.
``locality``, ``component`` or ``symbol``
* ``<agas_instance>/total``

where:
Expand Down Expand Up @@ -901,7 +901,7 @@ system and application performance.
where:

``<cache_statistics>`` is one of the following: ``cache/evictions``,
``cache/hits``, ``cache/inserts``, ``cache/misses``
``cache/hits``, ``cache/insertions``, ``cache/misses``
* ``locality#*/total``

where:
Expand Down Expand Up @@ -1143,7 +1143,7 @@ system and application performance.
where:

``<cache_statistics>`` is one of the following: ``cache/insertions``,
``cache/evictions``, ``cache/hits``, ``cache/misses`` ``cache/misses``
``cache/evictions``, ``cache/hits``, ``cache/misses``

`<connection_type`` is one of the following: ``tcp``, ``mpi``
* ``locality#*/total``
Expand Down
188 changes: 188 additions & 0 deletions examples/1d_stencil/1d_stencil_channel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// Copyright (c) 2020 Nikunj Gupta
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// This is the a separate examples demonstrating the development
// of a fully distributed solver for a simple 1D heat distribution problem.
//
// This example makes use of LCOS channels to send and receive
// elements.

#include "communicator.hpp"
#include "stencil.hpp"

#include <hpx/hpx_init.hpp>
#include <hpx/include/compute.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/components.hpp>
#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/util.hpp>
#include <hpx/program_options/options_description.hpp>

#include <array>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
#include <cstddef>

using communication_type = double;

HPX_REGISTER_CHANNEL_DECLARATION(communication_type);
HPX_REGISTER_CHANNEL(communication_type, stencil_communication);

int hpx_main(boost::program_options::variables_map& vm)
{
std::size_t Nx_global = vm["Nx"].as<std::size_t>();
std::size_t steps = vm["steps"].as<std::size_t>();
std::size_t nlp = vm["Nlp"].as<std::size_t>();

typedef hpx::compute::host::block_allocator<double> allocator_type;
typedef hpx::compute::host::block_executor<> executor_type;
typedef hpx::compute::vector<double, allocator_type> data_type;

std::array<data_type, 2> U;

auto numa_domains = hpx::compute::host::numa_domains();
allocator_type alloc(numa_domains);

std::size_t num_localities = hpx::get_num_localities(hpx::launch::sync);
std::size_t num_worker_threads = hpx::get_num_worker_threads();
std::size_t rank = hpx::get_locality_id();

hpx::util::high_resolution_timer t_main;

// Keep only partial data
std::size_t Nx = Nx_global / num_localities;
std::size_t local_nx = Nx / nlp;

U[0] = data_type(Nx, 0.0, alloc);
U[1] = data_type(Nx, 0.0, alloc);

init(U, Nx, rank, num_localities);

// setup communicator
using communicator_type = communicator<double>;
communicator_type comm(rank, num_localities);

if (rank == 0)
{
std::cout << "Starting benchmark with " << num_localities <<
" nodes and " << num_worker_threads <<
" threads.\n";
}

if (comm.has_neighbor(communicator_type::left))
{
// Send initial value to the left neighbor
comm.set(communicator_type::left, U[0][0], 0);
}
if (comm.has_neighbor(communicator_type::right))
{
// Send initial value to the right neighbor
comm.set(communicator_type::right, U[0][Nx-1], 0);
}

auto range = boost::irange(static_cast<std::size_t>(0), nlp);

executor_type executor(numa_domains);
auto policy = hpx::parallel::execution::par.on(executor);

hpx::util::high_resolution_timer t;
for (std::size_t t = 0; t < steps; ++t)
{
data_type& curr = U[t % 2];
data_type& next = U[(t + 1) % 2];

hpx::future<void> l = hpx::make_ready_future();
hpx::future<void> r = hpx::make_ready_future();

if (comm.has_neighbor(communicator_type::left))
{
l = comm.get(communicator_type::left, t)
.then(hpx::launch::sync,
[&next, &curr, &comm, t](hpx::future<double>&& gg)
{
double left = gg.get();

next[0] = curr[0] +
((k*dt)/(dx*dx)) * (left - 2*curr[0] + curr[1]);

// Dispatch the updated value to left neighbor for it
// to get consumed in the next timestep
comm.set(communicator_type::left, next[0], t+1);
}
);
}

if (comm.has_neighbor(communicator_type::right))
{
r = comm.get(communicator_type::right, t)
.then(hpx::launch::sync,
[&next, &curr, &comm, t, Nx](hpx::future<double>&& gg)
{
double right = gg.get();

next[Nx-1] = curr[Nx-1] + ((k*dt)/(dx*dx)) *
(curr[Nx-2] - 2*curr[Nx-1] + right);

// Dispatch the updated value to right neighbor for it
// to get consumed in the next timestep
comm.set(communicator_type::right, next[Nx-1], t+1);
}
);
}

hpx::parallel::for_each(
policy,
std::begin(range), std::end(range),
[&U, local_nx, nlp, t] (std::size_t i)
{
if (i == 0)
stencil_update(U, 1, local_nx, t);
else if (i == nlp-1)
stencil_update(U, i * local_nx, (i + 1) * local_nx - 1, t);
else if (i > 0 && i < nlp-1)
stencil_update(U, i * local_nx, (i + 1) * local_nx, t);
}
);

hpx::wait_all(l, r);
}
double elapsed = t.elapsed();
double telapsed = t_main.elapsed();

if (rank == 0)
{
std::cout << "Total time: " << telapsed << std::endl;
std::cout << "Kernel execution time: " << elapsed << std::endl;
}

return hpx::finalize();
}

int main(int argc, char* argv[])
{
using namespace hpx::program_options;

options_description desc_commandline;
desc_commandline.add_options()
("Nx", value<std::size_t>()->default_value(1024),
"Total stencil points")
("Nlp", value<std::size_t>()->default_value(16),
"Number of Local Partitions")
("steps", value<std::size_t>()->default_value(100),
"Number of steps to apply the stencil")
;

// Initialize and run HPX, this example requires to run hpx_main on all
// localities
std::vector<std::string> const cfg = {
"hpx.run_hpx_main!=1",
};

return hpx::init(desc_commandline, argc, argv, cfg);
}
1 change: 1 addition & 0 deletions examples/1d_stencil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(example_programs
1d_stencil_6
1d_stencil_7
1d_stencil_8
1d_stencil_channel
)

if(HPX_WITH_APEX)
Expand Down
Loading

0 comments on commit 83c06a9

Please sign in to comment.