Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TurTLE
TurTLE
Commits
e38f1267
Commit
e38f1267
authored
Sep 22, 2017
by
Berenger Bramas
Browse files
Add PBC rounding to the positions and add lock free array to protect the cells from race conditions
parent
cba0515b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
bfps/cpp/particles/lock_free_bool_array.hpp
0 → 100644
View file @
e38f1267
#ifndef LOCK_FREE_BOOL_ARRAY_HPP
#define LOCK_FREE_BOOL_ARRAY_HPP
#include
<vector>
#include
<memory>
class
lock_free_bool_array
{
std
::
vector
<
std
::
unique_ptr
<
long
int
>>
keys
;
public:
explicit
lock_free_bool_array
(
const
long
int
inNbKeys
=
512
){
keys
.
resize
(
inNbKeys
);
for
(
std
::
unique_ptr
<
long
int
>&
k
:
keys
){
k
.
reset
(
new
long
int
(
0
));
}
}
void
lock
(
const
int
inKey
){
volatile
long
int
*
k
=
keys
[
inKey
%
keys
.
size
()].
get
();
long
int
res
=
1
;
int
cpt
=
0
;
while
(
res
==
1
){
res
=
__sync_val_compare_and_swap
(
k
,
0
,
res
);
cpt
++
;
}
}
void
unlock
(
const
int
inKey
){
volatile
long
int
*
k
=
keys
[
inKey
%
keys
.
size
()].
get
();
assert
(
k
&&
*
k
);
(
*
k
)
=
0
;
}
};
#endif
bfps/cpp/particles/p2p_distr_mpi.hpp
View file @
e38f1267
This diff is collapsed.
Click to expand it.
bfps/cpp/particles/p2p_tree.hpp
View file @
e38f1267
...
...
@@ -15,7 +15,7 @@ class p2p_tree{
}
long
int
get_cell_coord_y_from_index
(
const
long
int
index
)
const
{
return
(
index
-
get_cell_coord_z_from_index
(
index
)
*
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]))
return
(
index
%
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]))
/
nb_cell_levels
[
IDX_X
];
}
...
...
Write
Preview
Supports
Markdown
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