Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
yaxt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dkrz-sw
yaxt
Commits
b76a179e
Commit
b76a179e
authored
2 years ago
by
Thomas Jahns
Browse files
Options
Downloads
Patches
Plain Diff
Eliminate PLT lookup from recursive calls.
parent
c88e522d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xt_quicksort_base.h
+11
-3
11 additions, 3 deletions
src/xt_quicksort_base.h
with
11 additions
and
3 deletions
src/xt_quicksort_base.h
+
11
−
3
View file @
b76a179e
...
...
@@ -162,6 +162,7 @@
#define MED3 NAME_COMPOSE(med3,SORT_TYPE_SUFFIX)
#define VECSWAP NAME_COMPOSE(vecswap,SORT_TYPE_SUFFIX)
#define XT_QUICKSORT NAME_COMPOSE(xt_quicksort,SORT_TYPE_SUFFIX)
#define XT_QUICKSORT_INNER NAME_COMPOSE(xt_qsort_i,SORT_TYPE_SUFFIX)
static
inline
size_t
MED3
(
const
SORT_TYPE
*
a
,
size_t
i
,
size_t
j
,
size_t
k
...
...
@@ -188,8 +189,8 @@ VECSWAP(SORT_TYPE *restrict a, size_t ia, size_t ib, size_t n XT_SORT_VECSWAP_EX
SWAP
(
ia
+
i
,
ib
+
i
);
}
XT_SORTFUNC_DECL
void
XT_QUICKSORT
(
SORT_TYPE
*
restrict
a
,
size_t
n
XT_SORT_EXTRA_ARGS_DECL
)
static
void
XT_QUICKSORT
_INNER
(
SORT_TYPE
*
restrict
a
,
size_t
n
XT_SORT_EXTRA_ARGS_DECL
)
{
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
...
...
@@ -257,7 +258,7 @@ void XT_QUICKSORT(SORT_TYPE *restrict a, size_t n XT_SORT_EXTRA_ARGS_DECL)
pdiff
=
MIN
(
d
-
c
,
n
-
d
-
1
);
VECSWAP
(
a
,
b
,
n
-
pdiff
,
pdiff
XT_SORT_VECSWAP_EXTRA_ARGS_PASS
);
if
((
pdiff
=
b
-
i
)
>
1U
)
XT_QUICKSORT
(
a
,
pdiff
XT_SORT_EXTRA_ARGS_PASS
);
XT_QUICKSORT
_INNER
(
a
,
pdiff
XT_SORT_EXTRA_ARGS_PASS
);
if
((
pdiff
=
d
-
c
)
>
1U
)
{
/* Iterate rather than recurse to save stack space */
size_t
adv
=
n
-
pdiff
;
...
...
@@ -271,6 +272,13 @@ void XT_QUICKSORT(SORT_TYPE *restrict a, size_t n XT_SORT_EXTRA_ARGS_DECL)
#undef MIN
}
XT_SORTFUNC_DECL
void
XT_QUICKSORT
(
SORT_TYPE
*
restrict
a
,
size_t
n
XT_SORT_EXTRA_ARGS_DECL
)
{
XT_QUICKSORT_INNER
(
a
,
n
XT_SORT_EXTRA_ARGS_PASS
);
}
#ifdef XT_SORT_MED3_EXTRA_ARGS_PASS_UNDEF
#undef XT_SORT_MED3_EXTRA_ARGS_PASS
#undef XT_SORT_MED3_EXTRA_ARGS_PASS_UNDEF
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment