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
5cbe814e
authored
Feb 26, 2015
by
Tobias Fuchs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
algorithms_cpp: fixed cpplint warnings in MergeSort
parent
0f7719f9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
+24
-24
No files found.
algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h
View file @
5cbe814e
...
@@ -89,21 +89,21 @@ class MergeSortFunctor {
...
@@ -89,21 +89,21 @@ class MergeSortFunctor {
task_l
.
Wait
(
MTAPI_INFINITE
);
task_l
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
task_r
.
Wait
(
MTAPI_INFINITE
);
ChunkDescriptor
<
RAI
>
c
hun
k_f
=
partitioner_
[
chunk_first_
];
ChunkDescriptor
<
RAI
>
ck_f
=
partitioner_
[
chunk_first_
];
ChunkDescriptor
<
RAI
>
c
hun
k_m
=
partitioner_
[
chunk_split_index
+
1
];
ChunkDescriptor
<
RAI
>
ck_m
=
partitioner_
[
chunk_split_index
+
1
];
ChunkDescriptor
<
RAI
>
c
hun
k_l
=
partitioner_
[
chunk_last_
];
ChunkDescriptor
<
RAI
>
ck_l
=
partitioner_
[
chunk_last_
];
if
(
CloneBackToInput
(
depth_
))
{
if
(
CloneBackToInput
(
depth_
))
{
// Merge from temp into input:
// Merge from temp into input:
difference_type
first
=
std
::
distance
(
global_first_
,
c
hun
k_f
.
GetFirst
());
difference_type
first
=
std
::
distance
(
global_first_
,
ck_f
.
GetFirst
());
difference_type
mid
=
std
::
distance
(
global_first_
,
c
hun
k_m
.
GetFirst
());
difference_type
mid
=
std
::
distance
(
global_first_
,
ck_m
.
GetFirst
());
difference_type
last
=
std
::
distance
(
global_first_
,
c
hun
k_l
.
GetLast
());
difference_type
last
=
std
::
distance
(
global_first_
,
ck_l
.
GetLast
());
SerialMerge
(
temp_first_
+
first
,
temp_first_
+
mid
,
temp_first_
+
last
,
SerialMerge
(
temp_first_
+
first
,
temp_first_
+
mid
,
temp_first_
+
last
,
c
hun
k_f
.
GetFirst
(),
ck_f
.
GetFirst
(),
comparison_
);
comparison_
);
}
else
{
}
else
{
// Merge from input into temp:
// Merge from input into temp:
SerialMerge
(
c
hunk_f
.
GetFirst
(),
chunk_m
.
GetFirst
(),
chun
k_l
.
GetLast
(),
SerialMerge
(
c
k_f
.
GetFirst
(),
ck_m
.
GetFirst
(),
c
k_l
.
GetLast
(),
temp_first_
+
std
::
distance
(
global_first_
,
c
hun
k_f
.
GetFirst
()),
temp_first_
+
std
::
distance
(
global_first_
,
ck_f
.
GetFirst
()),
comparison_
);
comparison_
);
}
}
}
}
...
@@ -129,31 +129,30 @@ class MergeSortFunctor {
...
@@ -129,31 +129,30 @@ class MergeSortFunctor {
// Recurse further. Use binary split, ignoring chunk size as this
// Recurse further. Use binary split, ignoring chunk size as this
// recursion is serial and has leaf size 1:
// recursion is serial and has leaf size 1:
ChunkPartitioner
<
RAI
>
partitioner
(
first
,
last
,
2
);
ChunkPartitioner
<
RAI
>
partitioner
(
first
,
last
,
2
);
ChunkDescriptor
<
RAI
>
c
hun
k_l
=
partitioner
[
0
];
ChunkDescriptor
<
RAI
>
ck_l
=
partitioner
[
0
];
ChunkDescriptor
<
RAI
>
c
hun
k_r
=
partitioner
[
1
];
ChunkDescriptor
<
RAI
>
ck_r
=
partitioner
[
1
];
MergeSortChunk
(
MergeSortChunk
(
c
hun
k_l
.
GetFirst
(),
ck_l
.
GetFirst
(),
c
hun
k_l
.
GetLast
(),
ck_l
.
GetLast
(),
depth
+
1
);
depth
+
1
);
MergeSortChunk
(
MergeSortChunk
(
c
hun
k_r
.
GetFirst
(),
ck_r
.
GetFirst
(),
c
hun
k_r
.
GetLast
(),
ck_r
.
GetLast
(),
depth
+
1
);
depth
+
1
);
if
(
CloneBackToInput
(
depth
))
{
if
(
CloneBackToInput
(
depth
))
{
// Merge from temp into input:
// Merge from temp into input:
difference_type
d_first
=
std
::
distance
(
global_first_
,
c
hun
k_l
.
GetFirst
());
difference_type
d_first
=
std
::
distance
(
global_first_
,
ck_l
.
GetFirst
());
difference_type
d_mid
=
std
::
distance
(
global_first_
,
c
hun
k_r
.
GetFirst
());
difference_type
d_mid
=
std
::
distance
(
global_first_
,
ck_r
.
GetFirst
());
difference_type
d_last
=
std
::
distance
(
global_first_
,
c
hun
k_r
.
GetLast
());
difference_type
d_last
=
std
::
distance
(
global_first_
,
ck_r
.
GetLast
());
SerialMerge
(
SerialMerge
(
temp_first_
+
d_first
,
temp_first_
+
d_mid
,
temp_first_
+
d_last
,
temp_first_
+
d_first
,
temp_first_
+
d_mid
,
temp_first_
+
d_last
,
c
hun
k_l
.
GetFirst
(),
ck_l
.
GetFirst
(),
comparison_
);
comparison_
);
}
}
else
{
else
{
// Merge from input into temp:
// Merge from input into temp:
SerialMerge
(
SerialMerge
(
c
hunk_l
.
GetFirst
(),
chunk_r
.
GetFirst
(),
chun
k_r
.
GetLast
(),
c
k_l
.
GetFirst
(),
ck_r
.
GetFirst
(),
c
k_r
.
GetLast
(),
temp_first_
+
std
::
distance
(
global_first_
,
c
hun
k_l
.
GetFirst
()),
temp_first_
+
std
::
distance
(
global_first_
,
ck_l
.
GetFirst
()),
comparison_
);
comparison_
);
}
}
}
}
...
@@ -226,7 +225,8 @@ void MergeSort(
...
@@ -226,7 +225,8 @@ void MergeSort(
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
;
typedef
internal
::
MergeSortFunctor
<
RAI
,
RAITemp
,
ComparisonFunction
>
functor_t
;
typedef
internal
::
MergeSortFunctor
<
RAI
,
RAITemp
,
ComparisonFunction
>
functor_t
;
difference_type
distance
=
std
::
distance
(
first
,
last
);
difference_type
distance
=
std
::
distance
(
first
,
last
);
if
(
distance
==
0
)
{
if
(
distance
==
0
)
{
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"Distance for ForEach is 0"
);
EMBB_THROW
(
embb
::
base
::
ErrorException
,
"Distance for ForEach is 0"
);
...
...
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