Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
682bd9f6
Commit
682bd9f6
authored
6 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
gaussian density, avoid large async function
parent
735e497a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-math/geometry/gaussian-density/cpu.ts
+64
-58
64 additions, 58 deletions
src/mol-math/geometry/gaussian-density/cpu.ts
with
64 additions
and
58 deletions
src/mol-math/geometry/gaussian-density/cpu.ts
+
64
−
58
View file @
682bd9f6
...
@@ -24,10 +24,6 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
...
@@ -24,10 +24,6 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
const
r
=
radius
(
OrderedSet
.
getAt
(
indices
,
i
))
+
radiusOffset
const
r
=
radius
(
OrderedSet
.
getAt
(
indices
,
i
))
+
radiusOffset
if
(
maxRadius
<
r
)
maxRadius
=
r
if
(
maxRadius
<
r
)
maxRadius
=
r
radii
[
i
]
=
r
radii
[
i
]
=
r
if
(
i
%
100000
===
0
&&
ctx
.
shouldUpdate
)
{
await
ctx
.
update
({
message
:
'
calculating max radius
'
,
current
:
i
,
max
:
n
})
}
}
}
const
pad
=
maxRadius
*
2
+
resolution
const
pad
=
maxRadius
*
2
+
resolution
...
@@ -54,10 +50,10 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
...
@@ -54,10 +50,10 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
const
densData
=
space
.
create
()
const
densData
=
space
.
create
()
const
alpha
=
smoothness
const
alpha
=
smoothness
const
updateChunk
=
Math
.
ceil
(
100000
0
/
(
Math
.
pow
(
maxRadius
*
2
,
3
)
*
resolution
))
const
updateChunk
=
Math
.
ceil
(
100000
/
((
Math
.
pow
(
Math
.
pow
(
maxRadius
,
3
)
,
3
)
*
scaleFactor
)
))
console
.
time
(
'
gaussian density cpu
'
)
function
accumulateRange
(
begI
:
number
,
endI
:
number
)
{
for
(
let
i
=
0
;
i
<
n
;
++
i
)
{
for
(
let
i
=
begI
;
i
<
endI
;
++
i
)
{
const
j
=
OrderedSet
.
getAt
(
indices
,
i
)
const
j
=
OrderedSet
.
getAt
(
indices
,
i
)
const
vx
=
x
[
j
],
vy
=
y
[
j
],
vz
=
z
[
j
]
const
vx
=
x
[
j
],
vy
=
y
[
j
],
vz
=
z
[
j
]
...
@@ -110,12 +106,22 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
...
@@ -110,12 +106,22 @@ export async function GaussianDensityCPU(ctx: RuntimeContext, position: Position
}
}
}
}
}
}
}
}
async
function
accumulate
()
{
for
(
let
i
=
0
;
i
<
n
;
i
+=
updateChunk
)
{
accumulateRange
(
i
,
Math
.
min
(
i
+
updateChunk
,
n
))
if
(
i
%
updateChunk
===
0
&&
ctx
.
shouldUpdate
)
{
if
(
ctx
.
shouldUpdate
)
{
await
ctx
.
update
({
message
:
'
filling density grid
'
,
current
:
i
,
max
:
n
})
await
ctx
.
update
({
message
:
'
filling density grid
'
,
current
:
i
,
max
:
n
})
}
}
}
}
console
.
timeEnd
(
'
gaussian density cpu
'
)
}
// console.time('gaussian density cpu')
await
accumulate
()
// console.timeEnd('gaussian density cpu')
const
transform
=
Mat4
.
identity
()
const
transform
=
Mat4
.
identity
()
Mat4
.
fromScaling
(
transform
,
Vec3
.
create
(
resolution
,
resolution
,
resolution
))
Mat4
.
fromScaling
(
transform
,
Vec3
.
create
(
resolution
,
resolution
,
resolution
))
...
...
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