Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
b72096ac
Commit
b72096ac
authored
7 years ago
by
Artem Polyakov
Committed by
Danny Auble
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix issue with pmi[2|x] when TreeWidth=1. This will very likely never
matter in production, but in testing it can. Bug 4051
parent
7e55acf7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/slurmd/common/reverse_tree_math.c
+32
-1
32 additions, 1 deletion
src/slurmd/common/reverse_tree_math.c
with
32 additions
and
1 deletion
src/slurmd/common/reverse_tree_math.c
+
32
−
1
View file @
b72096ac
...
@@ -9,6 +9,9 @@
...
@@ -9,6 +9,9 @@
* Siberian Branch of Russian Academy of Science
* Siberian Branch of Russian Academy of Science
* Written by Artem Polyakov <artpol84@gmail.com>.
* Written by Artem Polyakov <artpol84@gmail.com>.
* All rights reserved.
* All rights reserved.
* Portions copyright (C) 2017 Mellanox Technologies.
* Written by Artem Polyakov <artpol84@gmail.com>.
* All rights reserved.
*
*
* This file is part of SLURM, a resource management program.
* This file is part of SLURM, a resource management program.
* For details, see <https://slurm.schedmd.com/>.
* For details, see <https://slurm.schedmd.com/>.
...
@@ -63,8 +66,36 @@ static inline int int_pow(int num, int power)
...
@@ -63,8 +66,36 @@ static inline int int_pow(int num, int power)
static
inline
int
geometric_series
(
int
width
,
int
depth
)
static
inline
int
geometric_series
(
int
width
,
int
depth
)
{
{
/*
* the main idea behind this formula is the following math base:
* a^n - b^n = (a-b)*(a^(n-1) + b*a^(n-2) + b^2*a^(n-3) ... +b^(n-1))
* if we set a = 1, b = w (width) we will turn it to:
*
* 1 - w^n = (1-w)*(1 + w + w^2 + ... +w^(n-1)) (1)
* C = (1 + w + w^2 + ... +w^(n-1)) (2)
*
* is perfectly a number of children in the tree with width w.
* So we can calculate C from (1):
*
* 1 - w^n = (1-w)*C => C = (1-w^n)/(1-w) (3)
*
* (2) takes (n-1) sums and (n-2) multiplication (or (n-2) exponentiations).
* (3) takes n+1 multiplications (or one exponentiation), 2 subtractions,
* 1 division.
* However if more optimal exponentiation algorithm is used like this
* (https://en.wikipedia.org/wiki/Exponentiation_by_squaring) number of
* multiplications will be O(log(n)).
* In case of (2) we will still need all the intermediate powers which
* doesn't allow to benefit from efficient exponentiation.
* As it is now - int_pow(x, n) is a primitive O(n) algorithm.
*
* w = 1 is a special case that will lead to divide by 0.
* as C (2) corresponds to a full number of nodes in the tree including
* the root - we need to return analog in the w=1 tree which is
* (depth+1).
*/
return
(
width
==
1
)
?
return
(
width
==
1
)
?
1
:
(
1
-
(
int_pow
(
width
,
(
depth
+
1
))))
/
(
1
-
width
);
(
depth
+
1
)
:
(
1
-
(
int_pow
(
width
,
(
depth
+
1
))))
/
(
1
-
width
);
}
}
static
inline
int
dep
(
int
total
,
int
width
)
static
inline
int
dep
(
int
total
,
int
width
)
...
...
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