Skip to content

Commit

Permalink
Merge branch 'master' into fix_ubsan
Browse files Browse the repository at this point in the history
Conflicts:
	hpx/runtime/components/server/simple_component_base.hpp
  • Loading branch information
Thomas Heller committed Aug 23, 2017
2 parents 83bcd87 + 6c214b2 commit 76db2d9
Show file tree
Hide file tree
Showing 110 changed files with 10,965 additions and 4,818 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Expand Up @@ -61,7 +61,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: true
FixNamespaceComments: false
# ForEachMacros: ['']
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Expand Up @@ -646,6 +646,21 @@ foreach(_scheduler ${HPX_WITH_THREAD_SCHEDULERS_UC})
unset(_all)
endforeach()

## Experimental settings
hpx_option(HPX_WITH_IO_POOL BOOL
"Disable internal IO thread pool, do not change if not absolutely necessary (default: ON)"
ON CATEGORY "Thread Manager" ADVANCED)
if(HPX_WITH_IO_POOL)
hpx_add_config_define(HPX_HAVE_IO_POOL)
endif()

hpx_option(HPX_WITH_TIMER_POOL BOOL
"Disable internal timer thread pool, do not change if not absolutely necessary (default: ON)"
ON CATEGORY "Thread Manager" ADVANCED)
if(HPX_WITH_TIMER_POOL)
hpx_add_config_define(HPX_HAVE_TIMER_POOL)
endif()

## AGAS related build options
hpx_option(HPX_WITH_AGAS_DUMP_REFCNT_ENTRIES BOOL
"Enable dumps of the AGAS refcnt tables to logs (default: OFF)"
Expand Down
188 changes: 148 additions & 40 deletions docs/manual/existing_performance_counters.qbk

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions docs/manual/parallel_algorithms.qbk
Expand Up @@ -120,6 +120,11 @@ __hpx__ provides implementations of the following parallel algorithms:

[table Non-modifying Parallel Algorithms (In Header: `<hpx/include/parallel_algorithm.hpp>`)
[[Name] [Description] [In Header] [Algorithm page at cppreference.com]]
[[ [algoref adjacent_find] ]
[Computes the differences between adjacent elements in a range.]
[`<hpx/include/parallel_adjacent_find.hpp>`]
[[cpprefalgodocs adjacent_find]]
]
[[ [algoref all_of] ]
[Checks if a predicate is `true` for all of the elements in a range.]
[`<hpx/include/parallel_all_any_none.hpp>`]
Expand All @@ -130,21 +135,6 @@ __hpx__ provides implementations of the following parallel algorithms:
[`<hpx/include/parallel_all_any_none.hpp>`]
[[cpprefalgodocs all_any_none_of]]
]
[[ [algoref none_of] ]
[Checks if a predicate is `true` for none of the elements in a range.]
[`<hpx/include/parallel_all_any_none.hpp>`]
[[cpprefalgodocs all_any_none_of]]
]
[[ [algoref for_each] ]
[Applies a function to a range of elements.]
[`<hpx/include/parallel_for_each.hpp>`]
[[cpprefalgodocs for_each]]
]
[[ [algoref for_each_n] ]
[Applies a function to a number of elements.]
[`<hpx/include/parallel_for_each.hpp>`]
[[cpprefalgodocs for_each_n]]
]
[[ [algoref count] ]
[Returns the number of elements equal to a given value.]
[`<hpx/include/parallel_count.hpp>`]
Expand All @@ -160,10 +150,10 @@ __hpx__ provides implementations of the following parallel algorithms:
[`<hpx/include/parallel_equal.hpp>`]
[[cpprefalgodocs equal]]
]
[[ [algoref mismatch] ]
[Finds the first position where two ranges differ.]
[`<hpx/include/parallel_mismatch.hpp>`]
[[cpprefalgodocs mismatch]]
[[ [algoref exclusive_scan] ]
[Does an exclusive parallel scan over a range of elements.]
[`<hpx/include/parallel_scan.hpp>`]
[[cpprefalgodocs exclusive_scan]]
]
[[ [algoref find] ]
[Finds the first element equal to a given value.]
Expand All @@ -175,32 +165,52 @@ __hpx__ provides implementations of the following parallel algorithms:
[`<hpx/include/parallel_find.hpp>`]
[[cpprefalgodocs find_end]]
]
[[ [algoref find_if] ]
[Finds the first element satisfying a specific criteria.]
[`<hpx/include/parallel_find.hpp>`]
[[cpprefalgodocs find]]
]
[[ [algoref find_first_of] ]
[Searches for any one of a set of elements.]
[`<hpx/include/parallel_find.hpp>`]
[[cpprefalgodocs find_first_of]]
]
[[ [algoref find] ]
[[ [algoref find_if] ]
[Finds the first element satisfying a specific criteria.]
[`<hpx/include/parallel_find.hpp>`]
[[cpprefalgodocs find]]
]
[[ [algoref find_if_not] ]
[Finds the first element not satisfying a specific criteria.]
[`<hpx/include/parallel_find.hpp>`]
[[cpprefalgodocs find_if_not]]
]
[[ [algoref adjacent_find] ]
[Computes the differences between adjacent elements in a range.]
[`<hpx/include/parallel_adjacent_find.hpp>`]
[[cpprefalgodocs adjacent_find]]
[[ [algoref for_each] ]
[Applies a function to a range of elements.]
[`<hpx/include/parallel_for_each.hpp>`]
[[cpprefalgodocs for_each]]
]
[[ [algoref for_each_n] ]
[Applies a function to a number of elements.]
[`<hpx/include/parallel_for_each.hpp>`]
[[cpprefalgodocs for_each_n]]
]
[[ [algoref inclusive_scan] ]
[Does an inclusive parallel scan over a range of elements.]
[`<hpx/include/parallel_scan.hpp>`]
[[cpprefalgodocs inclusive_scan]]
]
[[ [algoref lexicographical_compare] ]
[Checks if a range of values is lexicographically less than another range
of values.]
[`<hpx/include/parallel_lexicographical_compare.hpp>`]
[[cpprefalgodocs lexicographical_compare]]
]
[[ [algoref mismatch] ]
[Finds the first position where two ranges differ.]
[`<hpx/include/parallel_mismatch.hpp>`]
[[cpprefalgodocs mismatch]]
]
[[ [algoref none_of] ]
[Checks if a predicate is `true` for none of the elements in a range.]
[`<hpx/include/parallel_all_any_none.hpp>`]
[[cpprefalgodocs all_any_none_of]]
]
[[ [algoref search] ]
[Searches for a range of elements.]
[`<hpx/include/parallel_search.hpp>`]
Expand All @@ -211,16 +221,6 @@ __hpx__ provides implementations of the following parallel algorithms:
[`<hpx/include/parallel_search.hpp>`]
[[cpprefalgodocs search_n]]
]
[[ [algoref inclusive_scan] ]
[Does an inclusive parallel scan over a range of elements.]
[`<hpx/include/parallel_scan.hpp>`]
[[cpprefalgodocs inclusive_scan]]
]
[[ [algoref exclusive_scan] ]
[Does an exclusive parallel scan over a range of elements.]
[`<hpx/include/parallel_scan.hpp>`]
[[cpprefalgodocs exclusive_scan]]
]
]

[table Modifying Parallel Algorithms (In Header: `<hpx/include/parallel_algorithm.hpp>`)
Expand Down
150 changes: 124 additions & 26 deletions docs/manual/vector.qbk
Expand Up @@ -144,7 +144,7 @@ __hpx__ provides the following segmented containers:
[section:segmented_iterators Segmented Iterators and Segmented Iterator Traits]

The basic iterator used in the STL library is only suitable for
one-dimensional structures. The iterators we use in `hpx` must adapt to
one-dimensional structures. The iterators we use in __hpx__ must adapt to
the segmented format of our containers. Our iterators are then able to know when
incrementing themselves if the next element of type `T` is in the same data
segment or in another segment. In this second case, the iterator will
Expand Down Expand Up @@ -221,7 +221,7 @@ in the numerical field whether to perform dense matrix operations
or to process images. It exist many libraries which implement such object
classes overloading their basic operators (e.g. `+`, `-`, `*`, `()`, etc.).
However, such operation becomes more delicate when the underlying data layout
is segmented or when it is mandatory to use fully-optimimized linear algebra
is segmented or when it is mandatory to use optimized linear algebra
subroutines (i.e. BLAS subroutines).

Our solution is thus to relax the level of abstraction by allowing
Expand All @@ -233,14 +233,14 @@ access mode.

[section:spmd_block Preface : Why SPMD ?]

Although HPX refutes by design this programming model, the locality plays a
Although __hpx__ refutes by design this programming model, the locality plays a
dominant role when it comes to implement vectorized code. To maximize local
computing and avoid the unneeded data transfer, a parallel section (or Single
computations and avoid unneeded data transfers, a parallel section (or Single
Programming Multiple Data section) is required. Because the use of global
variables is prohibited, this parallel section is created via the RAII idiom.

To define a parallel section, simply write an action taking a `spmd_block`
variable as the first parameter.
variable as a first parameter.

#include <hpx/lcos/spmd_block.hpp>

Expand All @@ -252,10 +252,7 @@ variable as the first parameter.
}
HPX_PLAIN_ACTION(bulk_function, bulk_action);

[note In the following paragraphs, we will use the term "image" several times.
An image is defined as a lightweight process whose the entry point is a
      function provided by the user. It's an "image of the function".
]
[note In the following paragraphs, we will use the term "image" several times. An image is defined as a lightweight process whose the entry point is a function provided by the user. It's an "image of the function".]

The `spmd_block` class contains the following methods:

Expand Down Expand Up @@ -291,7 +288,7 @@ Here is a sample code summarizing the features offered by the `spmd_block` class
// Synchronize images 2, 3 and 4
block.sync_images(vec_images);

// Alternate call to synchronize images 2, 3 and 4
// Alternative call to synchronize images 2, 3 and 4
block.sync_images(vec_images.begin(), vec_images.end());

/* Do some code */
Expand Down Expand Up @@ -339,15 +336,13 @@ indicating the number of images per locality to create.

return 0;
}
[note In principle, the user should never call the `spmd_block` constructor.
The `define_spmd_block` function is responsible of instantiating it and
broadcasting it to each created image.
[note In principle, the user should never call the `spmd_block` constructor. The `define_spmd_block` function is responsible of instantiating `spmd_block` objects and broadcasting them to each created image.
]
[endsect]

[section:spmd_views SPMD Multidimensionnal Views]
Object classes are defined as "container views" when the purpose is to
observe and/or to modify the values of a container using another perspective
Some classes are defined as "container views" when the purpose is to
observe and/or modify the values of a container using another perspective
than the one that characterizes the container. For example, the values of an
`std::vector` object can be accessed via the expression `v[i]`. Container views
can be used, for example, when it is desired for those values to be "viewed" as
Expand All @@ -364,6 +359,9 @@ By default, the `partitioned_vector` class integrates 1-D views of its segments
//
``[macroref HPX_REGISTER_PARTITIONED_VECTOR `HPX_REGISTER_PARTITIONED_VECTOR`]``(double);

using iterator = hpx::partitioned_vector<double>::iterator;
using traits = hpx::traits::segmented_iterator_traits<iterator>;

hpx::partitioned_vector<double> v;

// Create a 1-D view of the vector of segments
Expand All @@ -373,16 +371,13 @@ By default, the `partitioned_vector` class integrates 1-D views of its segments
std::vector<double> v = vv[i];

Our views are called "multi-dimensional" in the sense that they generalize
to N dimensions the purpose of `traits::segments()` in the 1-D case. Note that
to N dimensions the purpose of `segmented_iterator_traits::segments()` in the 1-D case. Note that
in a parallel section, the 2-D expression `a(i,j) = b(i,j)` is quite confusing
because without convention, each of the images invoked will race to execute
the statement. For this reason, our views are not only multi-dimensional
but also "spmd-aware".

[note Spmd-awareness: The convention is simple. If an assignment statement
       contains a view subscript as an l-value, it is only and only the image
       holding the r-value who is evaluating the statement. (In MPI sense,
       it is called a Put operation]
[note Spmd-awareness: The convention is simple. If an assignment statement contains a view subscript as an l-value, it is only and only the image holding the r-value who is evaluating the statement. (In MPI sense, it is called a Put operation)]

[section:Subscripts Subscript-based operations]
Here are some examples of using subscripts in the 2-D view case:
Expand Down Expand Up @@ -443,8 +438,8 @@ Here are some examples of using iterators in the 3-D view case :
std::size_t sixe_x, size_y, size_z;

// Instanciate the views
View_3D vv1(block, v.begin(), v.end(), {sixe_x,size_y,size_z});
View_3D vv2(block, v.begin(), v.end(), {sixe_x,size_y,size_z});
View_3D vv1(block, v1.begin(), v1.end(), {sixe_x,size_y,size_z});
View_3D vv2(block, v2.begin(), v2.end(), {sixe_x,size_y,size_z});

// Save previous segments covered by vv1 into segments covered by vv2
auto vv2_it = vv2.begin();
Expand Down Expand Up @@ -556,12 +551,115 @@ sub-view.
}

}
[note The last parameter of the subview constructor is the size of the
original view. If one would like to create a subview of the subview and so
on, this parameter should stay unchanged. (`{N,N}` for the above example)
]
[note The last parameter of the subview constructor is the size of the original view. If one would like to create a subview of the subview and so on, this parameter should stay unchanged. (`{N,N}` for the above example)]
[endsect]
[endsect]
[endsect]
[section C++ Co-Arrays]
Fortran has extended its scalar element indexing approach to reference each
segment of a distributed array. In this extension, a segment is attributed a
”co-index” and lives in a specific locality. A co-index provides the application
with enough information to retrieve the corresponding data reference. In C++,
containers present themselves as a ”smarter” alternative of Fortran arrays but
there are still no corresponding standardized features similar to the Fortran
co-indexing approach. We present here an implementation of such features in __hpx__.

[section Preface : Co-array, a segmented container tied to a SPMD Multidimensionnal View]
As mentioned before, a co-array is a distributed array whose segments
are accessible through an array -inspired access mode. We have previously seen
that it is possible to reproduce such access mode using the concept of views.
Nevertheless, the user must pre-create a segmented container to instanciate this
view. We illustrate below how a single constructor call can perform those two
operations :

#include <hpx/components/containers/coarray/coarray.hpp>
#include <hpx/lcos/spmd_block.hpp>

// The following code generates all necessary boiler plate to enable the
// co-creation of 'coarray'
//
``[macroref HPX_REGISTER_COARRAY `HPX_REGISTER_COARRAY`]``(double);

// Parallel section (suppose 'block' an spmd_block instance)
{
using hpx::container::placeholders::_;

std::size_t height=32, width=4, segment_size=10;

hpx::coarray<double,3> a(block, "a", {height,width,_}, segment_size);

/* Do some code */
}

Unlike segmented containers, a co-array object can only be
instantiated within a parallel section; Here is the description of
the parameters to provide to the coarray constructor :

[table Parameters of coarray constructor
[[Parameter] [Description]]
[[`block`][Reference to a `spmd_block` object]]
[[`"a"`][Symbolic name of type `std::string`]]
[[`{height,width,_}`][Dimensions of the `coarray` object]]
[[`segment_size`][Size of a co-indexed element (i.e. size of the object referenced by the expression `a(i,j,k)`)]]
]

Note that the "last dimension size" cannot be set by the user. It only accepts
the constexpr variable `hpx::container::placeholders::_`. This size, which is
considered private, is equal to the number of current images (value returned by
`block.get_num_images()`)

[note An important constraint to remember about coarray objects is that all
segments sharing the same "last dimension index" are located in the same image]
[endsect]

[section Using Co-Arrays]
The member functions owned by the `coarray` objects are exactly the
same as those of spmd multidimensional views. These are:

* Subscript-based operations
* Iterator-based operations

However, one additional functionality is provided. Knowing that the element
`a(i,j,k)` is in the memory of the `k`th image, the use of local subscripts is
possible.

[note For spmd multidimensional views, subscripts are only global
as it still involves potential remote data transfers.]

Here is an example of using local subscripts :

#include <hpx/components/containers/coarray/coarray.hpp>
#include <hpx/lcos/spmd_block.hpp>

// The following code generates all necessary boiler plate to enable the
// co-creation of 'coarray'
//
``[macroref HPX_REGISTER_COARRAY `HPX_REGISTER_COARRAY`]``(double);

// Parallel section (suppose 'block' an spmd_block instance)
{
using hpx::container::placeholders::_;

std::size_t height=32, width=4, segment_size=10;

hpx::coarray<double,3> a(block, "a", {height,width,_}, segment_size);

double idx = block.this_image()*height*width;

for (std::size_t j = 0; j<width; j++)
for (std::size_t i = 0; i<height; i++)
{
// Local write operation performed via the use of local subscript
a(i,j,_) = std::vector<double>(elt_size,idx);
idx++;
}

block.sync_all();
}

[note When the "last dimension index" of a subscript is equal to
`hpx::container::placeholders::_`, local subscript (and not global subscript)
is used. It is equivalent to a global subscript used with a
"last dimension index" equal to the value returned by `block.this_image()`.]
[endsect]
[endsect]

0 comments on commit 76db2d9

Please sign in to comment.