Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
3ff2b5e3
Unverified
Commit
3ff2b5e3
authored
2 years ago
by
boeschf
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
guard for zero random variables (#2031)
parent
aba57992
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arbor/backends/gpu/rand.cpp
+9
-2
9 additions, 2 deletions
arbor/backends/gpu/rand.cpp
arbor/util/pimpl.hpp
+4
-0
4 additions, 0 deletions
arbor/util/pimpl.hpp
arbor/util/pimpl_src.hpp
+4
-1
4 additions, 1 deletion
arbor/util/pimpl_src.hpp
with
17 additions
and
3 deletions
arbor/backends/gpu/rand.cpp
+
9
−
2
View file @
3ff2b5e3
...
...
@@ -15,13 +15,17 @@ namespace gpu {
void
random_numbers
::
instantiate
(
mechanism
&
m
,
std
::
size_t
value_width_padded
,
const
mechanism_layout
&
pos_data
,
arb_seed_type
seed
)
{
using
util
::
make_span
;
// bail out if there are no random variables
if
(
m
.
mech_
.
n_random_variables
==
0
)
return
;
// Allocate view pointers for random nubers
std
::
size_t
num_random_numbers_per_cv
=
m
.
mech_
.
n_random_variables
;
std
::
size_t
random_number_storage
=
num_random_numbers_per_cv
*
cbprng
::
cache_size
();
for
(
auto
&
v
:
random_numbers_
)
v
.
resize
(
num_random_numbers_per_cv
);
for
(
auto
&
v
:
random_numbers_
)
{
v
.
resize
(
num_random_numbers_per_cv
);
}
// Allocate bulk storage
std
::
size_t
count
=
random_number_storage
*
value_width_padded
;
...
...
@@ -44,6 +48,9 @@ void random_numbers::instantiate(mechanism& m, std::size_t value_width_padded,
}
void
random_numbers
::
update
(
mechanism
&
m
)
{
// bail out if there are no random variables
if
(
!
impl_
)
return
;
// Assign new random numbers by selecting the next cache
const
auto
counter
=
random_number_update_counter_
++
;
const
auto
cache_idx
=
cbprng
::
cache_index
(
counter
);
...
...
This diff is collapsed.
Click to expand it.
arbor/util/pimpl.hpp
+
4
−
0
View file @
3ff2b5e3
...
...
@@ -17,6 +17,8 @@ class pimpl
pimpl
()
noexcept
;
pimpl
(
T
*
ptr
)
noexcept
;
template
<
typename
...
Args
>
pimpl
(
Args
&&
...
args
);
...
...
@@ -30,6 +32,8 @@ class pimpl
const
T
*
operator
->
()
const
noexcept
;
T
&
operator
*
()
noexcept
;
const
T
&
operator
*
()
const
noexcept
;
operator
bool
()
const
noexcept
{
return
(
bool
)
m
;
}
};
...
...
This diff is collapsed.
Click to expand it.
arbor/util/pimpl_src.hpp
+
4
−
1
View file @
3ff2b5e3
...
...
@@ -16,6 +16,9 @@ pimpl<T>::~pimpl() = default;
template
<
typename
T
>
pimpl
<
T
>::
pimpl
()
noexcept
=
default
;
template
<
typename
T
>
pimpl
<
T
>::
pimpl
(
T
*
ptr
)
noexcept
:
m
{
ptr
}
{}
template
<
typename
T
>
template
<
typename
...
Args
>
pimpl
<
T
>::
pimpl
(
Args
&&
...
args
)
...
...
@@ -41,7 +44,7 @@ const T& pimpl<T>::operator*() const noexcept { return *m.get(); }
template
<
typename
T
,
typename
...
Args
>
pimpl
<
T
>
make_pimpl
(
Args
&&
...
args
)
{
return
pimpl
<
T
>
{
std
::
forward
<
Args
>
(
args
)...};
return
{
new
T
{
std
::
forward
<
Args
>
(
args
)...}
}
;
}
}
// namespace util
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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