Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1896e6c
authored
Apr 26, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
algorithms_cpp: converted from tasks_cpp to mtapi_cpp
parent
28ea6ab3
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
190 additions
and
194 deletions
+190
-194
algorithms_cpp/CMakeLists.txt
+4
-4
algorithms_cpp/include/embb/algorithms/count.h
+7
-7
algorithms_cpp/include/embb/algorithms/for_each.h
+4
-4
algorithms_cpp/include/embb/algorithms/internal/count-inl.h
+2
-2
algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h
+20
-21
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
+13
-16
algorithms_cpp/include/embb/algorithms/internal/partition-inl.h
+1
-1
algorithms_cpp/include/embb/algorithms/internal/partition.h
+1
-1
algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h
+18
-14
algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h
+17
-21
algorithms_cpp/include/embb/algorithms/internal/scan-inl.h
+19
-19
algorithms_cpp/include/embb/algorithms/invoke.h
+27
-27
algorithms_cpp/include/embb/algorithms/merge_sort.h
+9
-9
algorithms_cpp/include/embb/algorithms/quick_sort.h
+6
-6
algorithms_cpp/include/embb/algorithms/reduce.h
+5
-5
algorithms_cpp/include/embb/algorithms/scan.h
+5
-5
algorithms_cpp/test/count_test.cc
+3
-3
algorithms_cpp/test/for_each_test.cc
+5
-5
algorithms_cpp/test/invoke_test.cc
+1
-1
algorithms_cpp/test/main.cc
+3
-3
algorithms_cpp/test/merge_sort_test.cc
+6
-6
algorithms_cpp/test/quick_sort_test.cc
+5
-5
algorithms_cpp/test/reduce_test.cc
+4
-4
algorithms_cpp/test/scan_test.cc
+4
-4
algorithms_cpp/test/zip_iterator_test.cc
+1
-1
No files found.
algorithms_cpp/CMakeLists.txt
View file @
b1896e6c
...
@@ -17,18 +17,18 @@ include_directories(${EMBB_ALGORITHMS_CPP_INCLUDE_DIRS}
...
@@ -17,18 +17,18 @@ include_directories(${EMBB_ALGORITHMS_CPP_INCLUDE_DIRS}
${
CMAKE_CURRENT_SOURCE_DIR
}
/../base_cpp/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../base_cpp/include
${
CMAKE_CURRENT_BINARY_DIR
}
/../base_cpp/include
${
CMAKE_CURRENT_BINARY_DIR
}
/../base_cpp/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../mtapi_c/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../mtapi_c/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../
tasks
_cpp/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../
mtapi
_cpp/include
${
CMAKE_CURRENT_BINARY_DIR
}
/../
tasks
_cpp/include
)
${
CMAKE_CURRENT_BINARY_DIR
}
/../
mtapi
_cpp/include
)
add_library
(
embb_algorithms_cpp
${
EMBB_ALGORITHMS_CPP_SOURCES
}
add_library
(
embb_algorithms_cpp
${
EMBB_ALGORITHMS_CPP_SOURCES
}
${
EMBB_ALGORITHMS_CPP_HEADERS
}
)
${
EMBB_ALGORITHMS_CPP_HEADERS
}
)
target_link_libraries
(
embb_algorithms_cpp embb_
tasks
_cpp
)
target_link_libraries
(
embb_algorithms_cpp embb_
mtapi
_cpp
)
if
(
BUILD_TESTS STREQUAL ON
)
if
(
BUILD_TESTS STREQUAL ON
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/../partest/include
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
/../partest/include
)
add_executable
(
embb_algorithms_cpp_test
${
EMBB_ALGORITHMS_CPP_TEST_SOURCES
}
)
add_executable
(
embb_algorithms_cpp_test
${
EMBB_ALGORITHMS_CPP_TEST_SOURCES
}
)
target_link_libraries
(
embb_algorithms_cpp_test embb_algorithms_cpp
target_link_libraries
(
embb_algorithms_cpp_test embb_algorithms_cpp
embb_
tasks
_cpp embb_mtapi_c partest embb_base_cpp
embb_
mtapi
_cpp embb_mtapi_c partest embb_base_cpp
embb_base_c
${
compiler_libs
}
)
embb_base_c
${
compiler_libs
}
)
CopyBin
(
BIN embb_algorithms_cpp_test DEST
${
local_install_dir
}
)
CopyBin
(
BIN embb_algorithms_cpp_test DEST
${
local_install_dir
}
)
endif
()
endif
()
...
...
algorithms_cpp/include/embb/algorithms/count.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_COUNT_H_
#ifndef EMBB_ALGORITHMS_COUNT_H_
#define EMBB_ALGORITHMS_COUNT_H_
#define EMBB_ALGORITHMS_COUNT_H_
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <iterator>
#include <iterator>
namespace
embb
{
namespace
embb
{
...
@@ -132,7 +132,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
...
@@ -132,7 +132,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
const
ValueType
&
value
,
const
ValueType
&
value
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -145,7 +145,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
...
@@ -145,7 +145,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
RAI
last
,
RAI
last
,
const
ValueType
&
value
const
ValueType
&
value
)
{
)
{
return
Count
(
first
,
last
,
value
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
return
Count
(
first
,
last
,
value
,
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -156,7 +156,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
...
@@ -156,7 +156,7 @@ typename std::iterator_traits<RAI>::difference_type Count(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
const
ValueType
&
value
,
const
ValueType
&
value
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
return
Count
(
first
,
last
,
value
,
policy
,
0
);
return
Count
(
first
,
last
,
value
,
policy
,
0
);
}
}
...
@@ -169,7 +169,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
...
@@ -169,7 +169,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -182,7 +182,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
...
@@ -182,7 +182,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
ComparisonFunction
comparison
)
{
)
{
return
CountIf
(
first
,
last
,
comparison
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
return
CountIf
(
first
,
last
,
comparison
,
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -193,7 +193,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
...
@@ -193,7 +193,7 @@ typename std::iterator_traits<RAI>::difference_type CountIf(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
return
CountIf
(
first
,
last
,
comparison
,
policy
,
0
);
return
CountIf
(
first
,
last
,
comparison
,
policy
,
0
);
}
}
...
...
algorithms_cpp/include/embb/algorithms/for_each.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_FOR_EACH_H_
#ifndef EMBB_ALGORITHMS_FOR_EACH_H_
#define EMBB_ALGORITHMS_FOR_EACH_H_
#define EMBB_ALGORITHMS_FOR_EACH_H_
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
namespace
embb
{
namespace
embb
{
namespace
algorithms
{
namespace
algorithms
{
...
@@ -88,7 +88,7 @@ void ForEach(
...
@@ -88,7 +88,7 @@ void ForEach(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
Function
unary
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -101,7 +101,7 @@ void ForEach(
...
@@ -101,7 +101,7 @@ void ForEach(
RAI
last
,
RAI
last
,
Function
unary
Function
unary
)
{
)
{
ForEach
(
first
,
last
,
unary
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
ForEach
(
first
,
last
,
unary
,
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -112,7 +112,7 @@ void ForEach(
...
@@ -112,7 +112,7 @@ void ForEach(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
Function
unary
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
ForEach
(
first
,
last
,
unary
,
policy
,
0
);
ForEach
(
first
,
last
,
unary
,
policy
,
0
);
}
}
...
...
algorithms_cpp/include/embb/algorithms/internal/count-inl.h
View file @
b1896e6c
...
@@ -83,7 +83,7 @@ class FunctionComparisonFunction{
...
@@ -83,7 +83,7 @@ class FunctionComparisonFunction{
template
<
typename
RAI
,
typename
ValueType
>
template
<
typename
RAI
,
typename
ValueType
>
typename
std
::
iterator_traits
<
RAI
>::
difference_type
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Count
(
RAI
first
,
RAI
last
,
const
ValueType
&
value
,
Count
(
RAI
first
,
RAI
last
,
const
ValueType
&
value
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
return
Reduce
(
first
,
last
,
Difference
(
0
),
std
::
plus
<
Difference
>
(),
return
Reduce
(
first
,
last
,
Difference
(
0
),
std
::
plus
<
Difference
>
(),
internal
::
ValueComparisonFunction
<
ValueType
>
(
value
),
policy
,
internal
::
ValueComparisonFunction
<
ValueType
>
(
value
),
policy
,
...
@@ -93,7 +93,7 @@ typename std::iterator_traits<RAI>::difference_type
...
@@ -93,7 +93,7 @@ typename std::iterator_traits<RAI>::difference_type
template
<
typename
RAI
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
ComparisonFunction
>
typename
std
::
iterator_traits
<
RAI
>::
difference_type
typename
std
::
iterator_traits
<
RAI
>::
difference_type
CountIf
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
CountIf
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
return
Reduce
(
first
,
last
,
Difference
(
0
),
std
::
plus
<
Difference
>
(),
return
Reduce
(
first
,
last
,
Difference
(
0
),
std
::
plus
<
Difference
>
(),
internal
::
FunctionComparisonFunction
<
ComparisonFunction
>
internal
::
FunctionComparisonFunction
<
ComparisonFunction
>
...
...
algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h
View file @
b1896e6c
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <cassert>
#include <cassert>
#include <embb/base/exceptions.h>
#include <embb/base/exceptions.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/zip_iterator.h>
#include <embb/algorithms/zip_iterator.h>
...
@@ -46,13 +46,13 @@ class ForEachFunctor {
...
@@ -46,13 +46,13 @@ class ForEachFunctor {
* Constructs a for-each functor with arguments.
* Constructs a for-each functor with arguments.
*/
*/
ForEachFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
Function
unary
,
ForEachFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
const
BlockSizePartitioner
<
RAI
>&
partitioner
)
const
BlockSizePartitioner
<
RAI
>&
partitioner
)
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
unary_
(
unary
),
policy_
(
policy
),
partitioner_
(
partitioner
)
{
unary_
(
unary
),
policy_
(
policy
),
partitioner_
(
partitioner
)
{
}
}
void
Action
(
embb
::
tasks
::
TaskContext
&
)
{
void
Action
(
embb
::
mtapi
::
TaskContext
&
)
{
if
(
chunk_first_
==
chunk_last_
)
{
if
(
chunk_first_
==
chunk_last_
)
{
// Leaf case, recursed to single chunk. Do work on chunk:
// Leaf case, recursed to single chunk. Do work on chunk:
ChunkDescriptor
<
RAI
>
chunk
=
partitioner_
[
chunk_first_
];
ChunkDescriptor
<
RAI
>
chunk
=
partitioner_
[
chunk_first_
];
...
@@ -71,14 +71,13 @@ class ForEachFunctor {
...
@@ -71,14 +71,13 @@ class ForEachFunctor {
self_t
functor_r
(
chunk_split_index
+
1
,
self_t
functor_r
(
chunk_split_index
+
1
,
chunk_last_
,
chunk_last_
,
unary_
,
policy_
,
partitioner_
);
unary_
,
policy_
,
partitioner_
);
embb
::
tasks
::
Task
task_l
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task_l
=
node
.
Start
(
base
::
MakeFunction
(
functor_l
,
&
self_t
::
Action
),
embb
::
base
::
MakeFunction
(
functor_l
,
&
self_t
::
Action
),
policy_
));
policy_
);
embb
::
tasks
::
Task
task_r
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
embb
::
mtapi
::
Task
task_r
=
node
.
Start
(
embb
::
tasks
::
Action
(
embb
::
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
policy_
);
policy_
));
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
}
}
...
@@ -91,7 +90,7 @@ class ForEachFunctor {
...
@@ -91,7 +90,7 @@ class ForEachFunctor {
size_t
chunk_first_
;
size_t
chunk_first_
;
size_t
chunk_last_
;
size_t
chunk_last_
;
Function
unary_
;
Function
unary_
;
const
embb
::
tasks
::
ExecutionPolicy
&
policy_
;
const
embb
::
mtapi
::
ExecutionPolicy
&
policy_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
/**
/**
...
@@ -102,7 +101,7 @@ class ForEachFunctor {
...
@@ -102,7 +101,7 @@ class ForEachFunctor {
template
<
typename
RAI
,
typename
Function
>
template
<
typename
RAI
,
typename
Function
>
void
ForEachRecursive
(
RAI
first
,
RAI
last
,
Function
unary
,
void
ForEachRecursive
(
RAI
first
,
RAI
last
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
if
(
distance
==
0
)
{
if
(
distance
==
0
)
{
...
@@ -114,7 +113,7 @@ void ForEachRecursive(RAI first, RAI last, Function unary,
...
@@ -114,7 +113,7 @@ void ForEachRecursive(RAI first, RAI last, Function unary,
if
(
num_cores
==
0
)
{
if
(
num_cores
==
0
)
{
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"No cores in execution policy"
);
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"No cores in execution policy"
);
}
}
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
// Determine actually used block size
// Determine actually used block size
if
(
block_size
==
0
)
{
if
(
block_size
==
0
)
{
block_size
=
(
static_cast
<
size_t
>
(
distance
)
/
num_cores
);
block_size
=
(
static_cast
<
size_t
>
(
distance
)
/
num_cores
);
...
@@ -129,19 +128,19 @@ void ForEachRecursive(RAI first, RAI last, Function unary,
...
@@ -129,19 +128,19 @@ void ForEachRecursive(RAI first, RAI last, Function unary,
}
}
BlockSizePartitioner
<
RAI
>
partitioner
(
first
,
last
,
block_size
);
BlockSizePartitioner
<
RAI
>
partitioner
(
first
,
last
,
block_size
);
ForEachFunctor
<
RAI
,
Function
>
functor
(
0
,
typedef
ForEachFunctor
<
RAI
,
Function
>
functor_t
;
functor_t
functor
(
0
,
partitioner
.
Size
()
-
1
,
partitioner
.
Size
()
-
1
,
unary
,
policy
,
partitioner
);
unary
,
policy
,
partitioner
);
embb
::
tasks
::
Task
task
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task
=
node
.
Start
(
base
::
MakeFunction
(
functor
,
embb
::
base
::
MakeFunction
(
functor
,
&
functor_t
::
Action
),
&
ForEachFunctor
<
RAI
,
Function
>::
Action
),
policy
);
policy
));
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
}
}
template
<
typename
RAI
,
typename
Function
>
template
<
typename
RAI
,
typename
Function
>
void
ForEachIteratorCheck
(
RAI
first
,
RAI
last
,
Function
unary
,
void
ForEachIteratorCheck
(
RAI
first
,
RAI
last
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
std
::
random_access_iterator_tag
)
{
return
ForEachRecursive
(
first
,
last
,
unary
,
policy
,
block_size
);
return
ForEachRecursive
(
first
,
last
,
unary
,
policy
,
block_size
);
}
}
...
@@ -150,7 +149,7 @@ void ForEachIteratorCheck(RAI first, RAI last, Function unary,
...
@@ -150,7 +149,7 @@ void ForEachIteratorCheck(RAI first, RAI last, Function unary,
template
<
typename
RAI
,
typename
Function
>
template
<
typename
RAI
,
typename
Function
>
void
ForEach
(
RAI
first
,
const
RAI
last
,
Function
unary
,
void
ForEach
(
RAI
first
,
const
RAI
last
,
Function
unary
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
internal
::
ForEachIteratorCheck
(
first
,
last
,
unary
,
policy
,
block_size
,
internal
::
ForEachIteratorCheck
(
first
,
last
,
unary
,
policy
,
block_size
,
category
);
category
);
...
...
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
View file @
b1896e6c
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <functional>
#include <functional>
#include <embb/base/exceptions.h>
#include <embb/base/exceptions.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/internal/partition.h>
namespace
embb
{
namespace
embb
{
...
@@ -50,7 +50,7 @@ class MergeSortFunctor {
...
@@ -50,7 +50,7 @@ class MergeSortFunctor {
MergeSortFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
MergeSortFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
const
BlockSizePartitioner
<
RAI
>&
partitioner
,
const
BlockSizePartitioner
<
RAI
>&
partitioner
,
const
RAI
&
global_first
,
int
depth
)
const
RAI
&
global_first
,
int
depth
)
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
...
@@ -59,7 +59,7 @@ class MergeSortFunctor {
...
@@ -59,7 +59,7 @@ class MergeSortFunctor {
global_first_
(
global_first
),
depth_
(
depth
)
{
global_first_
(
global_first
),
depth_
(
depth
)
{
}
}
void
Action
(
embb
::
tasks
::
TaskContext
&
)
{
void
Action
(
embb
::
mtapi
::
TaskContext
&
)
{
size_t
chunk_split_index
=
(
chunk_first_
+
chunk_last_
)
/
2
;
size_t
chunk_split_index
=
(
chunk_first_
+
chunk_last_
)
/
2
;
if
(
chunk_first_
==
chunk_last_
)
{
if
(
chunk_first_
==
chunk_last_
)
{
// Leaf case: recurse into a single chunk's elements:
// Leaf case: recurse into a single chunk's elements:
...
@@ -77,15 +77,13 @@ class MergeSortFunctor {
...
@@ -77,15 +77,13 @@ class MergeSortFunctor {
temp_first_
,
temp_first_
,
comparison_
,
policy_
,
partitioner_
,
comparison_
,
policy_
,
partitioner_
,
global_first_
,
depth_
+
1
);
global_first_
,
depth_
+
1
);
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
embb
::
tasks
::
Task
task_l
=
node
.
Spawn
(
embb
::
mtapi
::
Task
task_l
=
node
.
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_l
,
&
self_t
::
Action
),
base
::
MakeFunction
(
functor_l
,
&
self_t
::
Action
),
policy_
));
policy_
);
embb
::
tasks
::
Task
task_r
=
node
.
Spawn
(
embb
::
mtapi
::
Task
task_r
=
node
.
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
policy_
)
);
policy_
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
...
@@ -177,7 +175,7 @@ class MergeSortFunctor {
...
@@ -177,7 +175,7 @@ class MergeSortFunctor {
size_t
chunk_last_
;
size_t
chunk_last_
;
RAITemp
temp_first_
;
RAITemp
temp_first_
;
ComparisonFunction
comparison_
;
ComparisonFunction
comparison_
;
const
embb
::
tasks
::
ExecutionPolicy
&
policy_
;
const
embb
::
mtapi
::
ExecutionPolicy
&
policy_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
const
RAI
&
global_first_
;
const
RAI
&
global_first_
;
int
depth_
;
int
depth_
;
...
@@ -219,7 +217,7 @@ void MergeSortIteratorCheck(
...
@@ -219,7 +217,7 @@ void MergeSortIteratorCheck(
RAI
last
,
RAI
last
,
RAITemp
temporary_first
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
size_t
block_size
,
std
::
random_access_iterator_tag
std
::
random_access_iterator_tag
)
{
)
{
...
@@ -257,10 +255,9 @@ void MergeSortIteratorCheck(
...
@@ -257,10 +255,9 @@ void MergeSortIteratorCheck(
partitioner
,
partitioner
,
first
,
first
,
0
);
0
);
embb
::
tasks
::
Task
task
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
embb
::
mtapi
::
Task
task
=
embb
::
mtapi
::
Node
::
GetInstance
().
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor
,
&
functor_t
::
Action
),
base
::
MakeFunction
(
functor
,
&
functor_t
::
Action
),
policy
)
);
policy
);
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
}
}
...
@@ -269,7 +266,7 @@ void MergeSortIteratorCheck(
...
@@ -269,7 +266,7 @@ void MergeSortIteratorCheck(
template
<
typename
RAI
,
typename
RAITemp
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
RAITemp
,
typename
ComparisonFunction
>
void
MergeSort
(
RAI
first
,
RAI
last
,
RAITemp
temporary_first
,
void
MergeSort
(
RAI
first
,
RAI
last
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
ComparisonFunction
comparison
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
internal
::
MergeSortIteratorCheck
(
first
,
last
,
temporary_first
,
comparison
,
internal
::
MergeSortIteratorCheck
(
first
,
last
,
temporary_first
,
comparison
,
...
...
algorithms_cpp/include/embb/algorithms/internal/partition-inl.h
View file @
b1896e6c
...
@@ -93,7 +93,7 @@ ChunkPartitioner<RAI>::ChunkPartitioner(
...
@@ -93,7 +93,7 @@ ChunkPartitioner<RAI>::ChunkPartitioner(
size_
=
amountChunks
;
size_
=
amountChunks
;
}
else
{
}
else
{
// if no concrete chunk size was given, use number of cores
// if no concrete chunk size was given, use number of cores
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
size_
=
node
.
GetWorkerThreadCount
();
size_
=
node
.
GetWorkerThreadCount
();
}
}
elements_count_
=
static_cast
<
size_t
>
(
std
::
distance
(
first_
,
last_
));
elements_count_
=
static_cast
<
size_t
>
(
std
::
distance
(
first_
,
last_
));
...
...
algorithms_cpp/include/embb/algorithms/internal/partition.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_INTERNAL_PARTITION_H_
#ifndef EMBB_ALGORITHMS_INTERNAL_PARTITION_H_
#define EMBB_ALGORITHMS_INTERNAL_PARTITION_H_
#define EMBB_ALGORITHMS_INTERNAL_PARTITION_H_
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
namespace
embb
{
namespace
embb
{
namespace
algorithms
{
namespace
algorithms
{
...
...
algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h
View file @
b1896e6c
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include <functional>
#include <functional>
#include <embb/base/exceptions.h>
#include <embb/base/exceptions.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/internal/partition.h>
namespace
embb
{
namespace
embb
{
...
@@ -48,7 +48,7 @@ class QuickSortFunctor {
...
@@ -48,7 +48,7 @@ class QuickSortFunctor {
* Constructs a functor.
* Constructs a functor.
*/
*/
QuickSortFunctor
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
QuickSortFunctor
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
:
first_
(
first
),
last_
(
last
),
comparison_
(
comparison
),
policy_
(
policy
),
:
first_
(
first
),
last_
(
last
),
comparison_
(
comparison
),
policy_
(
policy
),
block_size_
(
block_size
)
{
block_size_
(
block_size
)
{
}
}
...
@@ -56,7 +56,7 @@ class QuickSortFunctor {
...
@@ -56,7 +56,7 @@ class QuickSortFunctor {
/**
/**
* MTAPI action function and starting point of the parallel quick sort.
* MTAPI action function and starting point of the parallel quick sort.
*/
*/
void
Action
(
embb
::
tasks
::
TaskContext
&
)
{
void
Action
(
embb
::
mtapi
::
TaskContext
&
)
{
Difference
distance
=
last_
-
first_
;
Difference
distance
=
last_
-
first_
;
if
(
distance
<=
1
)
{
if
(
distance
<=
1
)
{
return
;
return
;
...
@@ -68,15 +68,17 @@ class QuickSortFunctor {
...
@@ -68,15 +68,17 @@ class QuickSortFunctor {
SerialQuickSort
(
first_
,
mid
);
SerialQuickSort
(
first_
,
mid
);
SerialQuickSort
(
mid
,
last_
);
SerialQuickSort
(
mid
,
last_
);
}
else
{
}
else
{
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
QuickSortFunctor
functor_l
(
first_
,
mid
,
comparison_
,
policy_
,
QuickSortFunctor
functor_l
(
first_
,
mid
,
comparison_
,
policy_
,
block_size_
);
block_size_
);
embb
::
tasks
::
Task
task_l
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task_l
=
node
.
Start
(
base
::
MakeFunction
(
functor_l
,
&
QuickSortFunctor
::
Action
)));
base
::
MakeFunction
(
functor_l
,
&
QuickSortFunctor
::
Action
),
policy_
);
QuickSortFunctor
functor_r
(
mid
,
last_
,
comparison_
,
policy_
,
QuickSortFunctor
functor_r
(
mid
,
last_
,
comparison_
,
policy_
,
block_size_
);
block_size_
);
embb
::
tasks
::
Task
task_r
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task_r
=
node
.
Start
(
base
::
MakeFunction
(
functor_r
,
&
QuickSortFunctor
::
Action
)));
base
::
MakeFunction
(
functor_r
,
&
QuickSortFunctor
::
Action
),
policy_
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
}
}
...
@@ -87,7 +89,7 @@ class QuickSortFunctor {
...
@@ -87,7 +89,7 @@ class QuickSortFunctor {
RAI
first_
;
RAI
first_
;
RAI
last_
;
RAI
last_
;
ComparisonFunction
comparison_
;
ComparisonFunction
comparison_
;
const
embb
::
tasks
::
ExecutionPolicy
&
policy_
;
const
embb
::
mtapi
::
ExecutionPolicy
&
policy_
;
size_t
block_size_
;
size_t
block_size_
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
Difference
;
...
@@ -189,10 +191,10 @@ class QuickSortFunctor {
...
@@ -189,10 +191,10 @@ class QuickSortFunctor {
template
<
typename
RAI
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
ComparisonFunction
>
void
QuickSortIteratorCheck
(
RAI
first
,
RAI
last
,
void
QuickSortIteratorCheck
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
std
::
random_access_iterator_tag
)
{
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
if
(
distance
==
0
)
{
if
(
distance
==
0
)
{
...
@@ -215,8 +217,10 @@ void QuickSortIteratorCheck(RAI first, RAI last,
...
@@ -215,8 +217,10 @@ void QuickSortIteratorCheck(RAI first, RAI last,
}
}
QuickSortFunctor
<
RAI
,
ComparisonFunction
>
functor
(
QuickSortFunctor
<
RAI
,
ComparisonFunction
>
functor
(
first
,
last
,
comparison
,
policy
,
block_size
);
first
,
last
,
comparison
,
policy
,
block_size
);
embb
::
tasks
::
Task
task
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
embb
::
mtapi
::
Task
task
=
node
.
Start
(
functor
,
&
QuickSortFunctor
<
RAI
,
ComparisonFunction
>::
Action
)));
embb
::
base
::
MakeFunction
(
functor
,
&
QuickSortFunctor
<
RAI
,
ComparisonFunction
>::
Action
),
policy
);
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
}
}
...
@@ -224,7 +228,7 @@ void QuickSortIteratorCheck(RAI first, RAI last,
...
@@ -224,7 +228,7 @@ void QuickSortIteratorCheck(RAI first, RAI last,
template
<
typename
RAI
,
typename
ComparisonFunction
>
template
<
typename
RAI
,
typename
ComparisonFunction
>
void
QuickSort
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
void
QuickSort
(
RAI
first
,
RAI
last
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
internal
::
QuickSortIteratorCheck
(
first
,
last
,
comparison
,
internal
::
QuickSortIteratorCheck
(
first
,
last
,
comparison
,
policy
,
block_size
,
category
());
policy
,
block_size
,
category
());
...
...
algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_INTERNAL_REDUCE_INL_H_
#ifndef EMBB_ALGORITHMS_INTERNAL_REDUCE_INL_H_
#define EMBB_ALGORITHMS_INTERNAL_REDUCE_INL_H_
#define EMBB_ALGORITHMS_INTERNAL_REDUCE_INL_H_
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/internal/partition.h>
#include <functional>
#include <functional>
...
@@ -46,7 +46,7 @@ class ReduceFunctor {
...
@@ -46,7 +46,7 @@ class ReduceFunctor {
ReturnType
neutral
,
ReturnType
neutral
,
ReductionFunction
reduction
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
const
BlockSizePartitioner
<
RAI
>&
partitioner
,
const
BlockSizePartitioner
<
RAI
>&
partitioner
,
ReturnType
&
result
)
ReturnType
&
result
)
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
neutral_
(
neutral
),
:
chunk_first_
(
chunk_first
),
chunk_last_
(
chunk_last
),
neutral_
(
neutral
),
...
@@ -54,7 +54,7 @@ class ReduceFunctor {
...
@@ -54,7 +54,7 @@ class ReduceFunctor {
partitioner_
(
partitioner
),
result_
(
result
)
{
partitioner_
(
partitioner
),
result_
(
result
)
{
}
}
void
Action
(
embb
::
tasks
::
TaskContext
&
)
{
void
Action
(
embb
::
mtapi
::
TaskContext
&
)
{
if
(
chunk_first_
==
chunk_last_
)
{
if
(
chunk_first_
==
chunk_last_
)
{
// Leaf case, recursed to single chunk. Do work on chunk:
// Leaf case, recursed to single chunk. Do work on chunk:
ChunkDescriptor
<
RAI
>
chunk
=
partitioner_
[
chunk_first_
];
ChunkDescriptor
<
RAI
>
chunk
=
partitioner_
[
chunk_first_
];
...
@@ -81,16 +81,12 @@ class ReduceFunctor {
...
@@ -81,16 +81,12 @@ class ReduceFunctor {
neutral_
,
reduction_
,
transformation_
,
policy_
,
neutral_
,
reduction_
,
transformation_
,
policy_
,
partitioner_
,
partitioner_
,
result_r
);
result_r
);
embb
::
tasks
::
Task
task_l
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
embb
::
mtapi
::
Task
task_l
=
embb
::
mtapi
::
Node
::
GetInstance
().
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_l
,
&
self_t
::
Action
),
base
::
MakeFunction
(
policy_
);
functor_l
,
&
self_t
::
Action
),
embb
::
mtapi
::
Task
task_r
=
embb
::
mtapi
::
Node
::
GetInstance
().
Start
(
policy_
));
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
embb
::
tasks
::
Task
task_r
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
policy_
);
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_r
,
&
self_t
::
Action
),
policy_
));
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
result_
=
reduction_
(
result_l
,
result_r
);
result_
=
reduction_
(
result_l
,
result_r
);
...
@@ -108,7 +104,7 @@ class ReduceFunctor {
...
@@ -108,7 +104,7 @@ class ReduceFunctor {
ReturnType
neutral_
;
ReturnType
neutral_
;
ReductionFunction
reduction_
;
ReductionFunction
reduction_
;
TransformationFunction
transformation_
;
TransformationFunction
transformation_
;
const
embb
::
tasks
::
ExecutionPolicy
&
policy_
;
const
embb
::
mtapi
::
ExecutionPolicy
&
policy_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
const
BlockSizePartitioner
<
RAI
>&
partitioner_
;
ReturnType
&
result_
;
ReturnType
&
result_
;
...
@@ -124,7 +120,7 @@ template<typename RAI, typename ReturnType, typename ReductionFunction,
...
@@ -124,7 +120,7 @@ template<typename RAI, typename ReturnType, typename ReductionFunction,
ReturnType
ReduceRecursive
(
RAI
first
,
RAI
last
,
ReturnType
neutral
,
ReturnType
ReduceRecursive
(
RAI
first
,
RAI
last
,
ReturnType
neutral
,
ReductionFunction
reduction
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAI
>::
difference_type
difference_type
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
...
@@ -137,7 +133,7 @@ ReturnType ReduceRecursive(RAI first, RAI last, ReturnType neutral,
...
@@ -137,7 +133,7 @@ ReturnType ReduceRecursive(RAI first, RAI last, ReturnType neutral,
if
(
num_cores
==
0
)
{
if
(
num_cores
==
0
)
{
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"No cores in execution policy"
);
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"No cores in execution policy"
);
}
}
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
// Determine actually used block size
// Determine actually used block size
if
(
block_size
==
0
)
{
if
(
block_size
==
0
)
{
block_size
=
(
static_cast
<
size_t
>
(
distance
)
/
num_cores
);
block_size
=
(
static_cast
<
size_t
>
(
distance
)
/
num_cores
);
...
@@ -162,9 +158,9 @@ ReturnType ReduceRecursive(RAI first, RAI last, ReturnType neutral,
...
@@ -162,9 +158,9 @@ ReturnType ReduceRecursive(RAI first, RAI last, ReturnType neutral,
policy
,
policy
,
partitioner
,
partitioner
,
result
);
result
);
embb
::
tasks
::
Task
task
=
node
.
Spawn
(
embb
::
mtapi
::
Task
task
=
node
.
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
base
::
MakeFunction
(
functor
,
&
Functor
::
Action
),
functor
,
&
Functor
::
Action
),
policy
)
);
policy
);
task
.
Wait
(
MTAPI_INFINITE
);
task
.
Wait
(
MTAPI_INFINITE
);
return
result
;
return
result
;
}
}
...
@@ -174,7 +170,7 @@ template<typename RAI, typename TransformationFunction,
...
@@ -174,7 +170,7 @@ template<typename RAI, typename TransformationFunction,
ReturnType
ReduceIteratorCheck
(
RAI
first
,
RAI
last
,
ReductionFunction
reduction
,
ReturnType
ReduceIteratorCheck
(
RAI
first
,
RAI
last
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
ReturnType
neutral
,
ReturnType
neutral
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
std
::
random_access_iterator_tag
)
{
return
ReduceRecursive
(
first
,
last
,
neutral
,
reduction
,
transformation
,
return
ReduceRecursive
(
first
,
last
,
neutral
,
reduction
,
transformation
,
...
@@ -188,7 +184,7 @@ template<typename RAI, typename ReturnType, typename ReductionFunction,
...
@@ -188,7 +184,7 @@ template<typename RAI, typename ReturnType, typename ReductionFunction,
ReturnType
Reduce
(
RAI
first
,
RAI
last
,
ReturnType
neutral
,
ReturnType
Reduce
(
RAI
first
,
RAI
last
,
ReturnType
neutral
,
ReductionFunction
reduction
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
size_t
block_size
)
{
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
typename
std
::
iterator_traits
<
RAI
>::
iterator_category
category
;
return
internal
::
ReduceIteratorCheck
(
first
,
last
,
reduction
,
transformation
,
return
internal
::
ReduceIteratorCheck
(
first
,
last
,
reduction
,
transformation
,
...
...
algorithms_cpp/include/embb/algorithms/internal/scan-inl.h
View file @
b1896e6c
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
#include <cassert>
#include <cassert>
#include <embb/base/exceptions.h>
#include <embb/base/exceptions.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
base/function
.h>
#include <embb/
tasks/execution_policy
.h>
#include <embb/
mtapi/mtapi
.h>
#include <embb/algorithms/internal/partition.h>
#include <embb/algorithms/internal/partition.h>
namespace
embb
{
namespace
embb
{
...
@@ -44,7 +44,7 @@ class ScanFunctor {
...
@@ -44,7 +44,7 @@ class ScanFunctor {
ScanFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
RAIOut
output_iterator
,
ScanFunctor
(
size_t
chunk_first
,
size_t
chunk_last
,
RAIOut
output_iterator
,
ReturnType
neutral
,
ScanFunction
scan
,
ReturnType
neutral
,
ScanFunction
scan
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
const
BlockSizePartitioner
<
RAIIn
>&
partitioner
,
const
BlockSizePartitioner
<
RAIIn
>&
partitioner
,
ReturnType
*
tree_values
,
size_t
node_id
,
ReturnType
*
tree_values
,
size_t
node_id
,
bool
going_down
)
bool
going_down
)
...
@@ -55,7 +55,7 @@ class ScanFunctor {
...
@@ -55,7 +55,7 @@ class ScanFunctor {
node_id_
(
node_id
),
parent_value_
(
neutral
),
is_first_pass_
(
going_down
)
{
node_id_
(
node_id
),
parent_value_
(
neutral
),
is_first_pass_
(
going_down
)
{
}
}
void
Action
(
embb
::
tasks
::
TaskContext
&
)
{
void
Action
(
embb
::
mtapi
::
TaskContext
&
)
{
if
(
chunk_first_
==
chunk_last_
)
{
if
(
chunk_first_
==
chunk_last_
)
{
ChunkDescriptor
<
RAIIn
>
chunk
=
partitioner_
[
chunk_first_
];
ChunkDescriptor
<
RAIIn
>
chunk
=
partitioner_
[
chunk_first_
];
RAIIn
iter_in
=
chunk
.
GetFirst
();
RAIIn
iter_in
=
chunk
.
GetFirst
();
...
@@ -104,15 +104,13 @@ class ScanFunctor {
...
@@ -104,15 +104,13 @@ class ScanFunctor {
functor_r
.
parent_value_
=
functor_l
.
GetTreeValue
()
+
parent_value_
;
functor_r
.
parent_value_
=
functor_l
.
GetTreeValue
()
+
parent_value_
;
}
}
// Spawn tasks to recurse:
// Spawn tasks to recurse:
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
embb
::
tasks
::
Task
task_l
=
node
.
Spawn
(
embb
::
mtapi
::
Task
task_l
=
node
.
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_l
,
&
ScanFunctor
::
Action
),
base
::
MakeFunction
(
functor_l
,
&
ScanFunctor
::
Action
),
policy_
));
policy_
);
embb
::
tasks
::
Task
task_r
=
node
.
Spawn
(
embb
::
mtapi
::
Task
task_r
=
node
.
Start
(
embb
::
tasks
::
Action
(
base
::
MakeFunction
(
functor_r
,
&
ScanFunctor
::
Action
),
base
::
MakeFunction
(
functor_r
,
&
ScanFunctor
::
Action
),
policy_
)
);
policy_
);
// Wait for tasks to complete:
// Wait for tasks to complete:
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
...
@@ -131,7 +129,7 @@ class ScanFunctor {
...
@@ -131,7 +129,7 @@ class ScanFunctor {
private
:
private
:
static
const
int
LEFT
=
1
;
static
const
int
LEFT
=
1
;
static
const
int
RIGHT
=
2
;
static
const
int
RIGHT
=
2
;
const
embb
::
tasks
::
ExecutionPolicy
&
policy_
;
const
embb
::
mtapi
::
ExecutionPolicy
&
policy_
;
size_t
chunk_first_
;
size_t
chunk_first_
;
size_t
chunk_last_
;
size_t
chunk_last_
;
RAIOut
output_iterator_
;
RAIOut
output_iterator_
;
...
@@ -168,7 +166,7 @@ typename ScanFunction, typename TransformationFunction>
...
@@ -168,7 +166,7 @@ typename ScanFunction, typename TransformationFunction>
void
ScanIteratorCheck
(
RAIIn
first
,
RAIIn
last
,
RAIOut
output_iterator
,
void
ScanIteratorCheck
(
RAIIn
first
,
RAIIn
last
,
RAIOut
output_iterator
,
ReturnType
neutral
,
ScanFunction
scan
,
ReturnType
neutral
,
ScanFunction
scan
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
,
size_t
block_size
,
std
::
random_access_iterator_tag
)
{
std
::
random_access_iterator_tag
)
{
typedef
typename
std
::
iterator_traits
<
RAIIn
>::
difference_type
difference_type
;
typedef
typename
std
::
iterator_traits
<
RAIIn
>::
difference_type
difference_type
;
...
@@ -199,14 +197,15 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
...
@@ -199,14 +197,15 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
// it creates the tree.
// it creates the tree.
typedef
ScanFunctor
<
RAIIn
,
RAIOut
,
ReturnType
,
ScanFunction
,
typedef
ScanFunctor
<
RAIIn
,
RAIOut
,
ReturnType
,
ScanFunction
,
TransformationFunction
>
Functor
;
TransformationFunction
>
Functor
;
embb
::
tasks
::
Node
&
node
=
embb
::
tasks
::
Node
::
GetInstance
();
embb
::
mtapi
::
Node
&
node
=
embb
::
mtapi
::
Node
::
GetInstance
();
BlockSizePartitioner
<
RAIIn
>
partitioner_down
(
first
,
last
,
block_size
);
BlockSizePartitioner
<
RAIIn
>
partitioner_down
(
first
,
last
,
block_size
);
Functor
functor_down
(
0
,
partitioner_down
.
Size
()
-
1
,
output_iterator
,
Functor
functor_down
(
0
,
partitioner_down
.
Size
()
-
1
,
output_iterator
,
neutral
,
scan
,
transformation
,
policy
,
partitioner_down
,
neutral
,
scan
,
transformation
,
policy
,
partitioner_down
,
values
,
0
,
true
);
values
,
0
,
true
);
embb
::
tasks
::
Task
task_down
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task_down
=
node
.
Start
(
base
::
MakeFunction
(
functor_down
,
&
Functor
::
Action
),
policy
));
base
::
MakeFunction
(
functor_down
,
&
Functor
::
Action
),
policy
);
task_down
.
Wait
(
MTAPI_INFINITE
);
task_down
.
Wait
(
MTAPI_INFINITE
);
// Second pass. Gives to each leaf the part of the prefix missing
// Second pass. Gives to each leaf the part of the prefix missing
...
@@ -214,8 +213,9 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
...
@@ -214,8 +213,9 @@ void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator,
Functor
functor_up
(
0
,
partitioner_up
.
Size
()
-
1
,
output_iterator
,
Functor
functor_up
(
0
,
partitioner_up
.
Size
()
-
1
,
output_iterator
,
neutral
,
scan
,
transformation
,
policy
,
partitioner_up
,
neutral
,
scan
,
transformation
,
policy
,
partitioner_up
,
values
,
0
,
false
);
values
,
0
,
false
);
embb
::
tasks
::
Task
task_up
=
node
.
Spawn
(
embb
::
tasks
::
Action
(
embb
::
mtapi
::
Task
task_up
=
node
.
Start
(
base
::
MakeFunction
(
functor_up
,
&
Functor
::
Action
),
policy
));
base
::
MakeFunction
(
functor_up
,
&
Functor
::
Action
),
policy
);
task_up
.
Wait
(
MTAPI_INFINITE
);
task_up
.
Wait
(
MTAPI_INFINITE
);
}
}
...
@@ -225,7 +225,7 @@ template<typename RAIIn, typename RAIOut, typename ReturnType,
...
@@ -225,7 +225,7 @@ template<typename RAIIn, typename RAIOut, typename ReturnType,
typename
ScanFunction
,
typename
TransformationFunction
>
typename
ScanFunction
,
typename
TransformationFunction
>
void
Scan
(
RAIIn
first
,
RAIIn
last
,
RAIOut
output_iterator
,
ReturnType
neutral
,
void
Scan
(
RAIIn
first
,
RAIIn
last
,
RAIOut
output_iterator
,
ReturnType
neutral
,
ScanFunction
scan
,
TransformationFunction
transformation
,
ScanFunction
scan
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
)
{
typedef
typename
std
::
iterator_traits
<
RAIIn
>::
iterator_category
category
;
typedef
typename
std
::
iterator_traits
<
RAIIn
>::
iterator_category
category
;
internal
::
ScanIteratorCheck
(
first
,
last
,
output_iterator
,
neutral
,
internal
::
ScanIteratorCheck
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
transformation
,
policy
,
block_size
,
category
());
scan
,
transformation
,
policy
,
block_size
,
category
());
...
...
algorithms_cpp/include/embb/algorithms/invoke.h
View file @
b1896e6c
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#define EMBB_ALGORITHMS_INVOKE_H_
#define EMBB_ALGORITHMS_INVOKE_H_
#include <embb/base/function.h>
#include <embb/base/function.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
namespace
embb
{
namespace
embb
{
namespace
algorithms
{
namespace
algorithms
{
...
@@ -78,8 +78,8 @@ void Invoke(
...
@@ -78,8 +78,8 @@ void Invoke(
Function2
func2
,
Function2
func2
,
/**< [in] Second function object to invoke */
/**< [in] Second function object to invoke */
...,
...,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
/**< [in] embb::
tasks
::ExecutionPolicy to use */
/**< [in] embb::
mtapi
::ExecutionPolicy to use */
);
);
#else // DOXYGEN
#else // DOXYGEN
...
@@ -98,11 +98,11 @@ class TaskWrapper {
...
@@ -98,11 +98,11 @@ class TaskWrapper {
*/
*/
explicit
TaskWrapper
(
explicit
TaskWrapper
(
Function
function
,
Function
function
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
:
function_
(
function
),
task_
()
{
:
function_
(
function
),
task_
()
{
embb
::
tasks
::
Action
action
(
embb
::
base
::
MakeFunction
(
task_
=
embb
::
mtapi
::
Node
::
GetInstance
().
Start
(
*
this
,
&
TaskWrapper
::
Run
),
policy
);
embb
::
base
::
MakeFunction
(
*
this
,
&
TaskWrapper
::
Run
),
task_
=
embb
::
tasks
::
Node
::
GetInstance
().
Spawn
(
action
);
policy
);
}
}
/**
/**
...
@@ -114,9 +114,9 @@ class TaskWrapper {
...
@@ -114,9 +114,9 @@ class TaskWrapper {
private
:
private
:
Function
function_
;
Function
function_
;
embb
::
tasks
::
Task
task_
;
embb
::
mtapi
::
Task
task_
;
void
Run
(
embb
::
tasks
::
TaskContext
&
)
{
void
Run
(
embb
::
mtapi
::
TaskContext
&
)
{
function_
();
function_
();
}
}
};
};
...
@@ -126,7 +126,7 @@ template<typename Function1, typename Function2>
...
@@ -126,7 +126,7 @@ template<typename Function1, typename Function2>
void
Invoke
(
void
Invoke
(
Function1
func1
,
Function1
func1
,
Function2
func2
,
Function2
func2
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
}
}
...
@@ -136,7 +136,7 @@ void Invoke(
...
@@ -136,7 +136,7 @@ void Invoke(
Function1
func1
,
Function1
func1
,
Function2
func2
,
Function2
func2
,
Function3
func3
,
Function3
func3
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -149,7 +149,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -149,7 +149,7 @@ template<typename Function1, typename Function2, typename Function3,
Function2
func2
,
Function2
func2
,
Function3
func3
,
Function3
func3
,
Function4
func4
,
Function4
func4
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -164,7 +164,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -164,7 +164,7 @@ template<typename Function1, typename Function2, typename Function3,
Function3
func3
,
Function3
func3
,
Function4
func4
,
Function4
func4
,
Function5
func5
,
Function5
func5
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -181,7 +181,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -181,7 +181,7 @@ template<typename Function1, typename Function2, typename Function3,
Function4
func4
,
Function4
func4
,
Function5
func5
,
Function5
func5
,
Function6
func6
,
Function6
func6
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -201,7 +201,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -201,7 +201,7 @@ template<typename Function1, typename Function2, typename Function3,
Function5
func5
,
Function5
func5
,
Function6
func6
,
Function6
func6
,
Function7
func7
,
Function7
func7
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -223,7 +223,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -223,7 +223,7 @@ template<typename Function1, typename Function2, typename Function3,
Function6
func6
,
Function6
func6
,
Function7
func7
,
Function7
func7
,
Function8
func8
,
Function8
func8
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -247,7 +247,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -247,7 +247,7 @@ template<typename Function1, typename Function2, typename Function3,
Function7
func7
,
Function7
func7
,
Function8
func8
,
Function8
func8
,
Function9
func9
,
Function9
func9
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -274,7 +274,7 @@ template<typename Function1, typename Function2, typename Function3,
...
@@ -274,7 +274,7 @@ template<typename Function1, typename Function2, typename Function3,
Function8
func8
,
Function8
func8
,
Function9
func9
,
Function9
func9
,
Function10
func10
,
Function10
func10
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
)
{
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function1
>
wrap1
(
func1
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function2
>
wrap2
(
func2
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
internal
::
TaskWrapper
<
Function3
>
wrap3
(
func3
,
policy
);
...
@@ -291,14 +291,14 @@ template<typename Function1, typename Function2>
...
@@ -291,14 +291,14 @@ template<typename Function1, typename Function2>
void
Invoke
(
void
Invoke
(
Function1
func1
,
Function1
func1
,
Function2
func2
)
{
Function2
func2
)
{
Invoke
(
func1
,
func2
,
embb
::
tasks
::
ExecutionPolicy
());
Invoke
(
func1
,
func2
,
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
>
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
>
void
Invoke
(
void
Invoke
(
Function1
func1
,
Function1
func1
,
Function2
func2
,
Function2
func2
,
Function3
func3
)
{
Function3
func3
)
{
Invoke
(
func1
,
func2
,
func3
,
embb
::
tasks
::
ExecutionPolicy
());
Invoke
(
func1
,
func2
,
func3
,
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -308,7 +308,7 @@ void Invoke(
...
@@ -308,7 +308,7 @@ void Invoke(
Function2
func2
,
Function2
func2
,
Function3
func3
,
Function3
func3
,
Function4
func4
)
{
Function4
func4
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
embb
::
tasks
::
ExecutionPolicy
());
Invoke
(
func1
,
func2
,
func3
,
func4
,
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -319,7 +319,7 @@ void Invoke(
...
@@ -319,7 +319,7 @@ void Invoke(
Function3
func3
,
Function3
func3
,
Function4
func4
,
Function4
func4
,
Function5
func5
)
{
Function5
func5
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
embb
::
tasks
::
ExecutionPolicy
());
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -332,7 +332,7 @@ void Invoke(
...
@@ -332,7 +332,7 @@ void Invoke(
Function5
func5
,
Function5
func5
,
Function6
func6
)
{
Function6
func6
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
embb
::
tasks
::
ExecutionPolicy
());
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -347,7 +347,7 @@ void Invoke(
...
@@ -347,7 +347,7 @@ void Invoke(
Function6
func6
,
Function6
func6
,
Function7
func7
)
{
Function7
func7
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
embb
::
tasks
::
ExecutionPolicy
());
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -363,7 +363,7 @@ void Invoke(
...
@@ -363,7 +363,7 @@ void Invoke(
Function7
func7
,
Function7
func7
,
Function8
func8
)
{
Function8
func8
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
embb
::
tasks
::
ExecutionPolicy
());
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -380,7 +380,7 @@ void Invoke(
...
@@ -380,7 +380,7 @@ void Invoke(
Function8
func8
,
Function8
func8
,
Function9
func9
)
{
Function9
func9
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
func9
,
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
func9
,
embb
::
tasks
::
ExecutionPolicy
());
embb
::
mtapi
::
ExecutionPolicy
());
}
}
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
template
<
typename
Function1
,
typename
Function2
,
typename
Function3
,
...
@@ -399,7 +399,7 @@ void Invoke(
...
@@ -399,7 +399,7 @@ void Invoke(
Function9
func9
,
Function9
func9
,
Function10
func10
)
{
Function10
func10
)
{
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
func9
,
func10
,
Invoke
(
func1
,
func2
,
func3
,
func4
,
func5
,
func6
,
func7
,
func8
,
func9
,
func10
,
embb
::
tasks
::
ExecutionPolicy
());
embb
::
mtapi
::
ExecutionPolicy
());
}
}
#endif // else DOXYGEN
#endif // else DOXYGEN
...
...
algorithms_cpp/include/embb/algorithms/merge_sort.h
View file @
b1896e6c
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#define EMBB_ALGORITHMS_MERGE_SORT_H_
#define EMBB_ALGORITHMS_MERGE_SORT_H_
#include <functional>
#include <functional>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <embb/base/memory_allocation.h>
#include <embb/base/memory_allocation.h>
namespace
embb
{
namespace
embb
{
...
@@ -149,7 +149,7 @@ void MergeSort(
...
@@ -149,7 +149,7 @@ void MergeSort(
RAI
last
,
RAI
last
,
RAITemp
temporary_first
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -161,7 +161,7 @@ void MergeSortAllocate(
...
@@ -161,7 +161,7 @@ void MergeSortAllocate(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
)
{
)
{
typedef
base
::
Allocation
Alloc
;
typedef
base
::
Allocation
Alloc
;
...
@@ -200,7 +200,7 @@ void MergeSortAllocate(
...
@@ -200,7 +200,7 @@ void MergeSortAllocate(
)
{
)
{
MergeSortAllocate
(
first
,
last
,
MergeSortAllocate
(
first
,
last
,
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -212,7 +212,7 @@ void MergeSortAllocate(
...
@@ -212,7 +212,7 @@ void MergeSortAllocate(
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
ComparisonFunction
comparison
)
{
)
{
MergeSortAllocate
(
first
,
last
,
comparison
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
MergeSortAllocate
(
first
,
last
,
comparison
,
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -223,7 +223,7 @@ void MergeSortAllocate(
...
@@ -223,7 +223,7 @@ void MergeSortAllocate(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
MergeSortAllocate
(
first
,
last
,
comparison
,
policy
,
0
);
MergeSortAllocate
(
first
,
last
,
comparison
,
policy
,
0
);
}
}
...
@@ -239,7 +239,7 @@ void MergeSort(
...
@@ -239,7 +239,7 @@ void MergeSort(
)
{
)
{
MergeSort
(
first
,
last
,
temporary_first
,
MergeSort
(
first
,
last
,
temporary_first
,
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -253,7 +253,7 @@ void MergeSort(
...
@@ -253,7 +253,7 @@ void MergeSort(
ComparisonFunction
comparison
ComparisonFunction
comparison
)
{
)
{
MergeSort
(
first
,
last
,
temporary_first
,
comparison
,
MergeSort
(
first
,
last
,
temporary_first
,
comparison
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -265,7 +265,7 @@ void MergeSort(
...
@@ -265,7 +265,7 @@ void MergeSort(
RAI
last
,
RAI
last
,
RAITemp
temporary_first
,
RAITemp
temporary_first
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
MergeSort
(
first
,
last
,
temporary_first
,
comparison
,
policy
,
0
);
MergeSort
(
first
,
last
,
temporary_first
,
comparison
,
policy
,
0
);
}
}
...
...
algorithms_cpp/include/embb/algorithms/quick_sort.h
View file @
b1896e6c
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#define EMBB_ALGORITHMS_QUICK_SORT_H_
#define EMBB_ALGORITHMS_QUICK_SORT_H_
#include <functional>
#include <functional>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
namespace
embb
{
namespace
embb
{
namespace
algorithms
{
namespace
algorithms
{
...
@@ -72,7 +72,7 @@ void QuickSort(
...
@@ -72,7 +72,7 @@ void QuickSort(
\c a appears before an element \c b in the sorted range if
\c a appears before an element \c b in the sorted range if
<tt>comparison(a, b) == true</tt>. The default value uses the
<tt>comparison(a, b) == true</tt>. The default value uses the
less-than relation. */
less-than relation. */
const
embb
::
tasks
::
ExecutionPolicy
&
policy
=
embb
::
tasks
::
ExecutionPolicy
(),
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
=
embb
::
mtapi
::
ExecutionPolicy
(),
/**< [IN] embb::mtapi::ExecutionPolicy for the quick sort algorithm */
/**< [IN] embb::mtapi::ExecutionPolicy for the quick sort algorithm */
size_t
block_size
=
0
size_t
block_size
=
0
/**< [IN] Lower bound for partitioning the range of elements into blocks that
/**< [IN] Lower bound for partitioning the range of elements into blocks that
...
@@ -95,7 +95,7 @@ void QuickSort(
...
@@ -95,7 +95,7 @@ void QuickSort(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -109,7 +109,7 @@ void QuickSort(
...
@@ -109,7 +109,7 @@ void QuickSort(
)
{
)
{
QuickSort
(
first
,
last
,
QuickSort
(
first
,
last
,
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
std
::
less
<
typename
std
::
iterator_traits
<
RAI
>::
value_type
>
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -121,7 +121,7 @@ void QuickSort(
...
@@ -121,7 +121,7 @@ void QuickSort(
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
ComparisonFunction
comparison
)
{
)
{
QuickSort
(
first
,
last
,
comparison
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
QuickSort
(
first
,
last
,
comparison
,
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -132,7 +132,7 @@ void QuickSort(
...
@@ -132,7 +132,7 @@ void QuickSort(
RAI
first
,
RAI
first
,
RAI
last
,
RAI
last
,
ComparisonFunction
comparison
,
ComparisonFunction
comparison
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
QuickSort
(
first
,
last
,
comparison
,
policy
,
0
);
QuickSort
(
first
,
last
,
comparison
,
policy
,
0
);
}
}
...
...
algorithms_cpp/include/embb/algorithms/reduce.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_REDUCE_H_
#ifndef EMBB_ALGORITHMS_REDUCE_H_
#define EMBB_ALGORITHMS_REDUCE_H_
#define EMBB_ALGORITHMS_REDUCE_H_
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <embb/algorithms/identity.h>
#include <embb/algorithms/identity.h>
namespace
embb
{
namespace
embb
{
...
@@ -113,7 +113,7 @@ ReturnType Reduce(
...
@@ -113,7 +113,7 @@ ReturnType Reduce(
ReturnType
neutral
,
ReturnType
neutral
,
ReductionFunction
reduction
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -128,7 +128,7 @@ ReturnType Reduce(
...
@@ -128,7 +128,7 @@ ReturnType Reduce(
ReductionFunction
reduction
ReductionFunction
reduction
)
{
)
{
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
Identity
(),
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
Identity
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -144,7 +144,7 @@ ReturnType Reduce(
...
@@ -144,7 +144,7 @@ ReturnType Reduce(
TransformationFunction
transformation
TransformationFunction
transformation
)
{
)
{
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
transformation
,
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
transformation
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -158,7 +158,7 @@ ReturnType Reduce(
...
@@ -158,7 +158,7 @@ ReturnType Reduce(
ReturnType
neutral
,
ReturnType
neutral
,
ReductionFunction
reduction
,
ReductionFunction
reduction
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
transformation
,
policy
,
0
);
return
Reduce
(
first
,
last
,
neutral
,
reduction
,
transformation
,
policy
,
0
);
}
}
...
...
algorithms_cpp/include/embb/algorithms/scan.h
View file @
b1896e6c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#ifndef EMBB_ALGORITHMS_SCAN_H_
#ifndef EMBB_ALGORITHMS_SCAN_H_
#define EMBB_ALGORITHMS_SCAN_H_
#define EMBB_ALGORITHMS_SCAN_H_
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <embb/algorithms/identity.h>
#include <embb/algorithms/identity.h>
namespace
embb
{
namespace
embb
{
...
@@ -121,7 +121,7 @@ void Scan(
...
@@ -121,7 +121,7 @@ void Scan(
ReturnType
neutral
,
ReturnType
neutral
,
ScanFunction
scan
,
ScanFunction
scan
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
,
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
,
size_t
block_size
size_t
block_size
);
);
...
@@ -138,7 +138,7 @@ void Scan(
...
@@ -138,7 +138,7 @@ void Scan(
ScanFunction
scan
ScanFunction
scan
)
{
)
{
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
Identity
(),
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
Identity
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -155,7 +155,7 @@ void Scan(
...
@@ -155,7 +155,7 @@ void Scan(
TransformationFunction
transformation
TransformationFunction
transformation
)
{
)
{
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
transformation
,
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
transformation
,
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
}
}
/**
/**
...
@@ -170,7 +170,7 @@ void Scan(
...
@@ -170,7 +170,7 @@ void Scan(
ReturnType
neutral
,
ReturnType
neutral
,
ScanFunction
scan
,
ScanFunction
scan
,
TransformationFunction
transformation
,
TransformationFunction
transformation
,
const
embb
::
tasks
::
ExecutionPolicy
&
policy
const
embb
::
mtapi
::
ExecutionPolicy
&
policy
)
{
)
{
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
transformation
,
policy
,
0
);
Scan
(
first
,
last
,
output_iterator
,
neutral
,
scan
,
transformation
,
policy
,
0
);
}
}
...
...
algorithms_cpp/test/count_test.cc
View file @
b1896e6c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <count_test.h>
#include <count_test.h>
#include <embb/algorithms/count.h>
#include <embb/algorithms/count.h>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <deque>
#include <deque>
#include <vector>
#include <vector>
#include <functional>
#include <functional>
...
@@ -122,7 +122,7 @@ void CountTest::TestBlockSizes() {
...
@@ -122,7 +122,7 @@ void CountTest::TestBlockSizes() {
void
CountTest
::
TestPolicy
()
{
void
CountTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
Count
;
using
embb
::
algorithms
::
Count
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
int
a
[]
=
{
10
,
20
,
30
,
30
,
20
,
10
,
10
,
20
,
20
,
20
};
int
a
[]
=
{
10
,
20
,
30
,
30
,
20
,
10
,
10
,
20
,
20
,
20
};
std
::
vector
<
int
>
vector
(
a
,
a
+
(
sizeof
a
/
sizeof
a
[
0
]));
std
::
vector
<
int
>
vector
(
a
,
a
+
(
sizeof
a
/
sizeof
a
[
0
]));
PT_EXPECT_EQ
(
Count
(
vector
.
begin
(),
vector
.
end
(),
10
,
ExecutionPolicy
()),
3
);
PT_EXPECT_EQ
(
Count
(
vector
.
begin
(),
vector
.
end
(),
10
,
ExecutionPolicy
()),
3
);
...
@@ -134,7 +134,7 @@ void CountTest::TestPolicy() {
...
@@ -134,7 +134,7 @@ void CountTest::TestPolicy() {
void
CountTest
::
StressTest
()
{
void
CountTest
::
StressTest
()
{
using
embb
::
algorithms
::
Count
;
using
embb
::
algorithms
::
Count
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
large_vector
[
i
]
=
static_cast
<
int
>
(
0
);
large_vector
[
i
]
=
static_cast
<
int
>
(
0
);
...
...
algorithms_cpp/test/for_each_test.cc
View file @
b1896e6c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <for_each_test.h>
#include <for_each_test.h>
#include <embb/algorithms/for_each.h>
#include <embb/algorithms/for_each.h>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <vector>
#include <vector>
#include <deque>
#include <deque>
#include <sstream>
#include <sstream>
...
@@ -166,7 +166,7 @@ void ForEachTest::TestRanges() {
...
@@ -166,7 +166,7 @@ void ForEachTest::TestRanges() {
void
ForEachTest
::
TestBlockSizes
()
{
void
ForEachTest
::
TestBlockSizes
()
{
using
embb
::
algorithms
::
ForEach
;
using
embb
::
algorithms
::
ForEach
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
vector
(
count
);
std
::
vector
<
int
>
vector
(
count
);
...
@@ -186,7 +186,7 @@ void ForEachTest::TestBlockSizes() {
...
@@ -186,7 +186,7 @@ void ForEachTest::TestBlockSizes() {
void
ForEachTest
::
TestPolicy
()
{
void
ForEachTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
ForEach
;
using
embb
::
algorithms
::
ForEach
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
vector
(
count
);
std
::
vector
<
int
>
vector
(
count
);
...
@@ -240,8 +240,8 @@ void ForEachTest::TestPolicy() {
...
@@ -240,8 +240,8 @@ void ForEachTest::TestPolicy() {
void
ForEachTest
::
StressTest
()
{
void
ForEachTest
::
StressTest
()
{
using
embb
::
algorithms
::
ForEach
;
using
embb
::
algorithms
::
ForEach
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
large_vector
[
i
]
=
static_cast
<
int
>
((
i
+
2
)
%
1000
);
large_vector
[
i
]
=
static_cast
<
int
>
((
i
+
2
)
%
1000
);
...
...
algorithms_cpp/test/invoke_test.cc
View file @
b1896e6c
...
@@ -61,7 +61,7 @@ void InvokeTest::Test() {
...
@@ -61,7 +61,7 @@ void InvokeTest::Test() {
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
&
Invocable4
,
&
Invocable5
,
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
&
Invocable4
,
&
Invocable5
,
&
Invocable6
,
&
Invocable7
,
&
Invocable8
,
&
Invocable9
,
&
Invocable10
);
&
Invocable6
,
&
Invocable7
,
&
Invocable8
,
&
Invocable9
,
&
Invocable10
);
embb
::
tasks
::
ExecutionPolicy
policy
;
embb
::
mtapi
::
ExecutionPolicy
policy
;
Invoke
(
&
Invocable1
,
&
Invocable2
,
policy
);
Invoke
(
&
Invocable1
,
&
Invocable2
,
policy
);
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
policy
);
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
policy
);
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
&
Invocable4
,
policy
);
Invoke
(
&
Invocable1
,
&
Invocable2
,
&
Invocable3
,
&
Invocable4
,
policy
);
...
...
algorithms_cpp/test/main.cc
View file @
b1896e6c
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
*/
*/
#include <partest/partest.h>
#include <partest/partest.h>
#include <embb/
tasks/tasks
.h>
#include <embb/
mtapi/mtapi
.h>
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
...
@@ -66,7 +66,7 @@ int compute1_() {
...
@@ -66,7 +66,7 @@ int compute1_() {
}
}
PT_MAIN
(
"Algorithms"
)
{
PT_MAIN
(
"Algorithms"
)
{
embb
::
tasks
::
Node
::
Initialize
(
THIS_DOMAIN_ID
,
THIS_NODE_ID
);
embb
::
mtapi
::
Node
::
Initialize
(
THIS_DOMAIN_ID
,
THIS_NODE_ID
);
PT_RUN
(
PartitionerTest
);
PT_RUN
(
PartitionerTest
);
PT_RUN
(
ForEachTest
);
PT_RUN
(
ForEachTest
);
...
@@ -78,7 +78,7 @@ PT_MAIN("Algorithms") {
...
@@ -78,7 +78,7 @@ PT_MAIN("Algorithms") {
PT_RUN
(
MergeSortTest
);
PT_RUN
(
MergeSortTest
);
PT_RUN
(
InvokeTest
);
PT_RUN
(
InvokeTest
);
embb
::
tasks
::
Node
::
Finalize
();
embb
::
mtapi
::
Node
::
Finalize
();
PT_EXPECT
(
embb_get_bytes_allocated
()
==
0
);
PT_EXPECT
(
embb_get_bytes_allocated
()
==
0
);
...
...
algorithms_cpp/test/merge_sort_test.cc
View file @
b1896e6c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <merge_sort_test.h>
#include <merge_sort_test.h>
#include <embb/algorithms/merge_sort.h>
#include <embb/algorithms/merge_sort.h>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <vector>
#include <vector>
#include <deque>
#include <deque>
#include <sstream>
#include <sstream>
...
@@ -50,7 +50,7 @@ MergeSortTest::MergeSortTest() {
...
@@ -50,7 +50,7 @@ MergeSortTest::MergeSortTest() {
void
MergeSortTest
::
TestDataStructures
()
{
void
MergeSortTest
::
TestDataStructures
()
{
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
int
array
[
kCountSize
];
int
array
[
kCountSize
];
std
::
vector
<
int
>
vector
(
kCountSize
);
std
::
vector
<
int
>
vector
(
kCountSize
);
std
::
deque
<
int
>
deque
(
kCountSize
);
std
::
deque
<
int
>
deque
(
kCountSize
);
...
@@ -75,7 +75,7 @@ void MergeSortTest::TestDataStructures() {
...
@@ -75,7 +75,7 @@ void MergeSortTest::TestDataStructures() {
void
MergeSortTest
::
TestFunctionPointers
()
{
void
MergeSortTest
::
TestFunctionPointers
()
{
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
std
::
vector
<
int
>
vector
(
kCountSize
);
std
::
vector
<
int
>
vector
(
kCountSize
);
for
(
size_t
i
=
kCountSize
-
1
;
i
>
0
;
i
--
)
{
for
(
size_t
i
=
kCountSize
-
1
;
i
>
0
;
i
--
)
{
...
@@ -158,7 +158,7 @@ void MergeSortTest::TestRanges() {
...
@@ -158,7 +158,7 @@ void MergeSortTest::TestRanges() {
void
MergeSortTest
::
TestBlockSizes
()
{
void
MergeSortTest
::
TestBlockSizes
()
{
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
vector
(
count
);
std
::
vector
<
int
>
vector
(
count
);
...
@@ -181,7 +181,7 @@ void MergeSortTest::TestBlockSizes() {
...
@@ -181,7 +181,7 @@ void MergeSortTest::TestBlockSizes() {
void
MergeSortTest
::
TestPolicy
()
{
void
MergeSortTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
vector
(
count
);
std
::
vector
<
int
>
vector
(
count
);
...
@@ -242,7 +242,7 @@ void MergeSortTest::TestPolicy() {
...
@@ -242,7 +242,7 @@ void MergeSortTest::TestPolicy() {
void
MergeSortTest
::
StressTest
()
{
void
MergeSortTest
::
StressTest
()
{
using
embb
::
algorithms
::
MergeSortAllocate
;
using
embb
::
algorithms
::
MergeSortAllocate
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
vector_copy
(
count
);
std
::
vector
<
int
>
vector_copy
(
count
);
for
(
size_t
i
=
count
-
1
;
i
>
0
;
i
--
)
{
for
(
size_t
i
=
count
-
1
;
i
>
0
;
i
--
)
{
...
...
algorithms_cpp/test/quick_sort_test.cc
View file @
b1896e6c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <quick_sort_test.h>
#include <quick_sort_test.h>
#include <embb/algorithms/quick_sort.h>
#include <embb/algorithms/quick_sort.h>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <vector>
#include <vector>
#include <deque>
#include <deque>
#include <sstream>
#include <sstream>
...
@@ -54,7 +54,7 @@ QuickSortTest::QuickSortTest() {
...
@@ -54,7 +54,7 @@ QuickSortTest::QuickSortTest() {
void
QuickSortTest
::
TestDataStructures
()
{
void
QuickSortTest
::
TestDataStructures
()
{
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
int
array
[
kCountSize
];
int
array
[
kCountSize
];
std
::
vector
<
int
>
vector
(
kCountSize
);
std
::
vector
<
int
>
vector
(
kCountSize
);
...
@@ -163,7 +163,7 @@ void QuickSortTest::TestRanges() {
...
@@ -163,7 +163,7 @@ void QuickSortTest::TestRanges() {
void
QuickSortTest
::
TestBlockSizes
()
{
void
QuickSortTest
::
TestBlockSizes
()
{
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
...
@@ -187,7 +187,7 @@ void QuickSortTest::TestBlockSizes() {
...
@@ -187,7 +187,7 @@ void QuickSortTest::TestBlockSizes() {
void
QuickSortTest
::
TestPolicy
()
{
void
QuickSortTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
vector
(
count
);
std
::
vector
<
int
>
vector
(
count
);
...
@@ -248,7 +248,7 @@ void QuickSortTest::TestPolicy() {
...
@@ -248,7 +248,7 @@ void QuickSortTest::TestPolicy() {
void
QuickSortTest
::
StressTest
()
{
void
QuickSortTest
::
StressTest
()
{
using
embb
::
algorithms
::
QuickSort
;
using
embb
::
algorithms
::
QuickSort
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
vector_copy
(
count
);
std
::
vector
<
int
>
vector_copy
(
count
);
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
...
...
algorithms_cpp/test/reduce_test.cc
View file @
b1896e6c
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <reduce_test.h>
#include <reduce_test.h>
#include <embb/algorithms/reduce.h>
#include <embb/algorithms/reduce.h>
#include <embb/
tasks
/execution_policy.h>
#include <embb/
mtapi
/execution_policy.h>
#include <deque>
#include <deque>
#include <vector>
#include <vector>
#include <functional>
#include <functional>
...
@@ -163,7 +163,7 @@ void ReduceTest::TestBlockSizes() {
...
@@ -163,7 +163,7 @@ void ReduceTest::TestBlockSizes() {
void
ReduceTest
::
TestPolicy
()
{
void
ReduceTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
Reduce
;
using
embb
::
algorithms
::
Reduce
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
algorithms
::
Identity
;
size_t
count
=
4
;
size_t
count
=
4
;
int
sum
=
0
;
int
sum
=
0
;
...
@@ -210,9 +210,9 @@ void ReduceTest::TestPolicy() {
...
@@ -210,9 +210,9 @@ void ReduceTest::TestPolicy() {
void
ReduceTest
::
StressTest
()
{
void
ReduceTest
::
StressTest
()
{
using
embb
::
algorithms
::
Reduce
;
using
embb
::
algorithms
::
Reduce
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
algorithms
::
Identity
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
mtapi_int32_t
expected
=
0
;
mtapi_int32_t
expected
=
0
;
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
...
...
algorithms_cpp/test/scan_test.cc
View file @
b1896e6c
...
@@ -228,7 +228,7 @@ void ScanTest::TestRanges() {
...
@@ -228,7 +228,7 @@ void ScanTest::TestRanges() {
void
ScanTest
::
TestBlockSizes
()
{
void
ScanTest
::
TestBlockSizes
()
{
using
embb
::
algorithms
::
Scan
;
using
embb
::
algorithms
::
Scan
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
algorithms
::
Identity
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
...
@@ -253,7 +253,7 @@ void ScanTest::TestBlockSizes() {
...
@@ -253,7 +253,7 @@ void ScanTest::TestBlockSizes() {
void
ScanTest
::
TestPolicy
()
{
void
ScanTest
::
TestPolicy
()
{
using
embb
::
algorithms
::
Scan
;
using
embb
::
algorithms
::
Scan
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
algorithms
::
Identity
;
size_t
count
=
4
;
size_t
count
=
4
;
std
::
vector
<
int
>
init
(
count
);
std
::
vector
<
int
>
init
(
count
);
...
@@ -324,8 +324,8 @@ void ScanTest::TestPolicy() {
...
@@ -324,8 +324,8 @@ void ScanTest::TestPolicy() {
void
ScanTest
::
StressTest
()
{
void
ScanTest
::
StressTest
()
{
using
embb
::
algorithms
::
Scan
;
using
embb
::
algorithms
::
Scan
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
algorithms
::
Identity
;
using
embb
::
tasks
::
ExecutionPolicy
;
using
embb
::
mtapi
::
ExecutionPolicy
;
size_t
count
=
embb
::
tasks
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
size_t
count
=
embb
::
mtapi
::
Node
::
GetInstance
().
GetCoreCount
()
*
10
;
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector
(
count
);
std
::
vector
<
int
>
large_vector_output
(
count
);
std
::
vector
<
int
>
large_vector_output
(
count
);
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
{
...
...
algorithms_cpp/test/zip_iterator_test.cc
View file @
b1896e6c
...
@@ -136,7 +136,7 @@ void ZipIteratorTest::TestZipScan() {
...
@@ -136,7 +136,7 @@ void ZipIteratorTest::TestZipScan() {
Scan
(
embb
::
algorithms
::
Zip
(
vectorA
.
begin
(),
vectorB
.
begin
()),
Scan
(
embb
::
algorithms
::
Zip
(
vectorA
.
begin
(),
vectorB
.
begin
()),
embb
::
algorithms
::
Zip
(
vectorA
.
end
(),
vectorB
.
end
()),
embb
::
algorithms
::
Zip
(
vectorA
.
end
(),
vectorB
.
end
()),
vectorOut
.
begin
(),
0
,
std
::
plus
<
int
>
(),
DotProductFunctor
(),
vectorOut
.
begin
(),
0
,
std
::
plus
<
int
>
(),
DotProductFunctor
(),
embb
::
tasks
::
ExecutionPolicy
(),
0
);
embb
::
mtapi
::
ExecutionPolicy
(),
0
);
long
sum
=
0
;
long
sum
=
0
;
for
(
size_t
i
=
0
;
i
<
kCountSize
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
kCountSize
;
i
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment