Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
d8bf23e2
Commit
d8bf23e2
authored
9 years ago
by
Peter W. Draper
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into task_sub_split
parents
2f06ff6f
48ac97ea
No related branches found
No related tags found
1 merge request
!180
Task sub split
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/cell.c
+5
-5
5 additions, 5 deletions
src/cell.c
src/lock.h
+5
-4
5 additions, 4 deletions
src/lock.h
src/map.c
+17
-17
17 additions, 17 deletions
src/map.c
src/timers.h
+2
-1
2 additions, 1 deletion
src/timers.h
with
29 additions
and
27 deletions
src/cell.c
+
5
−
5
View file @
d8bf23e2
...
@@ -269,7 +269,7 @@ int cell_locktree(struct cell *c) {
...
@@ -269,7 +269,7 @@ int cell_locktree(struct cell *c) {
/* Undo the holds up to finger. */
/* Undo the holds up to finger. */
for
(
struct
cell
*
finger2
=
c
->
parent
;
finger2
!=
finger
;
for
(
struct
cell
*
finger2
=
c
->
parent
;
finger2
!=
finger
;
finger2
=
finger2
->
parent
)
finger2
=
finger2
->
parent
)
__sync_fetch_and_sub
(
&
finger2
->
hold
,
1
);
atomic_dec
(
&
finger2
->
hold
);
/* Unlock this cell. */
/* Unlock this cell. */
if
(
lock_unlock
(
&
c
->
lock
)
!=
0
)
error
(
"Failed to unlock cell."
);
if
(
lock_unlock
(
&
c
->
lock
)
!=
0
)
error
(
"Failed to unlock cell."
);
...
@@ -309,7 +309,7 @@ int cell_glocktree(struct cell *c) {
...
@@ -309,7 +309,7 @@ int cell_glocktree(struct cell *c) {
if
(
lock_trylock
(
&
finger
->
glock
)
!=
0
)
break
;
if
(
lock_trylock
(
&
finger
->
glock
)
!=
0
)
break
;
/* Increment the hold. */
/* Increment the hold. */
__sync_fetch_and_add
(
&
finger
->
ghold
,
1
);
atomic_inc
(
&
finger
->
ghold
);
/* Unlock the cell. */
/* Unlock the cell. */
if
(
lock_unlock
(
&
finger
->
glock
)
!=
0
)
error
(
"Failed to unlock cell."
);
if
(
lock_unlock
(
&
finger
->
glock
)
!=
0
)
error
(
"Failed to unlock cell."
);
...
@@ -327,7 +327,7 @@ int cell_glocktree(struct cell *c) {
...
@@ -327,7 +327,7 @@ int cell_glocktree(struct cell *c) {
/* Undo the holds up to finger. */
/* Undo the holds up to finger. */
for
(
struct
cell
*
finger2
=
c
->
parent
;
finger2
!=
finger
;
for
(
struct
cell
*
finger2
=
c
->
parent
;
finger2
!=
finger
;
finger2
=
finger2
->
parent
)
finger2
=
finger2
->
parent
)
__sync_fetch_and_sub
(
&
finger2
->
ghold
,
1
);
atomic_dec
(
&
finger2
->
ghold
);
/* Unlock this cell. */
/* Unlock this cell. */
if
(
lock_unlock
(
&
c
->
glock
)
!=
0
)
error
(
"Failed to unlock cell."
);
if
(
lock_unlock
(
&
c
->
glock
)
!=
0
)
error
(
"Failed to unlock cell."
);
...
@@ -353,7 +353,7 @@ void cell_unlocktree(struct cell *c) {
...
@@ -353,7 +353,7 @@ void cell_unlocktree(struct cell *c) {
/* Climb up the tree and unhold the parents. */
/* Climb up the tree and unhold the parents. */
for
(
struct
cell
*
finger
=
c
->
parent
;
finger
!=
NULL
;
finger
=
finger
->
parent
)
for
(
struct
cell
*
finger
=
c
->
parent
;
finger
!=
NULL
;
finger
=
finger
->
parent
)
__sync_fetch_and_sub
(
&
finger
->
hold
,
1
);
atomic_dec
(
&
finger
->
hold
);
TIMER_TOC
(
timer_locktree
);
TIMER_TOC
(
timer_locktree
);
}
}
...
@@ -367,7 +367,7 @@ void cell_gunlocktree(struct cell *c) {
...
@@ -367,7 +367,7 @@ void cell_gunlocktree(struct cell *c) {
/* Climb up the tree and unhold the parents. */
/* Climb up the tree and unhold the parents. */
for
(
struct
cell
*
finger
=
c
->
parent
;
finger
!=
NULL
;
finger
=
finger
->
parent
)
for
(
struct
cell
*
finger
=
c
->
parent
;
finger
!=
NULL
;
finger
=
finger
->
parent
)
__sync_fetch_and_sub
(
&
finger
->
ghold
,
1
);
atomic_dec
(
&
finger
->
ghold
);
TIMER_TOC
(
timer_locktree
);
TIMER_TOC
(
timer_locktree
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lock.h
+
5
−
4
View file @
d8bf23e2
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include
<pthread.h>
#include
<pthread.h>
/* Includes. */
/* Includes. */
#include
"atomic.h"
#include
"inline.h"
#include
"inline.h"
#ifdef PTHREAD_SPINLOCK
#ifdef PTHREAD_SPINLOCK
...
@@ -48,14 +49,14 @@
...
@@ -48,14 +49,14 @@
#define lock_init(l) (*(l) = 0)
#define lock_init(l) (*(l) = 0)
#define lock_destroy(l) 0
#define lock_destroy(l) 0
INLINE
static
int
lock_lock
(
volatile
int
*
l
)
{
INLINE
static
int
lock_lock
(
volatile
int
*
l
)
{
while
(
__sync_val_compare_and_swap
(
l
,
0
,
1
)
!=
0
)
while
(
atomic_cas
(
l
,
0
,
1
)
!=
0
)
;
;
// while( *l );
// while( *l );
return
0
;
return
0
;
}
}
#define lock_trylock(l) ((*(l)) ? 1 :
__sync_val_compare_and_swap
(l, 0, 1))
#define lock_trylock(l) ((*(l)) ? 1 :
atomic_cas
(l, 0, 1))
#define lock_unlock(l) (
__sync_val_compare_and_swap
(l, 1, 0) != 1)
#define lock_unlock(l) (
atomic_cas
(l, 1, 0) != 1)
#define lock_unlock_blind(l)
__sync_val_compare_and_swap
(l, 1, 0)
#define lock_unlock_blind(l)
atomic_cas
(l, 1, 0)
#endif
#endif
#endif
/* SWIFT_LOCK_H */
#endif
/* SWIFT_LOCK_H */
This diff is collapsed.
Click to expand it.
src/map.c
+
17
−
17
View file @
d8bf23e2
...
@@ -18,15 +18,23 @@
...
@@ -18,15 +18,23 @@
*
*
******************************************************************************/
******************************************************************************/
#include
"map.h"
/* Config parameters. */
#include
"../config.h"
/* Some standard headers. */
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
/* This object's header. */
#include
"map.h"
/* Local headers. */
#include
"atomic.h"
#include
"error.h"
#include
"error.h"
/**
/**
* @brief Mapping function to draw a specific cell (gnuplot).
* @brief Mapping function to draw a specific cell (gnuplot).
*/
*/
void
map_cells_plot
(
struct
cell
*
c
,
void
*
data
)
{
void
map_cells_plot
(
struct
cell
*
c
,
void
*
data
)
{
int
depth
=
*
(
int
*
)
data
;
int
depth
=
*
(
int
*
)
data
;
...
@@ -80,24 +88,21 @@ void map_cells_plot(struct cell *c, void *data) {
...
@@ -80,24 +88,21 @@ void map_cells_plot(struct cell *c, void *data) {
/**
/**
* @brief Mapping function for checking if each part is in its box.
* @brief Mapping function for checking if each part is in its box.
*/
*/
void
map_check
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
/* void map_check ( struct part *p , struct cell *c , void *data ) {
if
(
p
->
x
[
0
]
<
c
->
loc
[
0
]
||
p
->
x
[
0
]
>
c
->
loc
[
0
]
+
c
->
h
[
0
]
||
p
->
x
[
0
]
<
c
->
loc
[
0
]
||
p
->
x
[
0
]
>
c
->
loc
[
0
]
+
c
->
h
[
0
]
||
if ( p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
p
->
x
[
0
]
<
c
->
loc
[
0
]
||
p
->
x
[
0
]
>
c
->
loc
[
0
]
+
c
->
h
[
0
])
p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] ||
printf
(
"map_check: particle %lld is outside of its box.
\n
"
,
p
->
id
);
p->x[0] < c->loc[0] || p->x[0] > c->loc[0]+c->h[0] )
}
printf( "map_check: particle %i is outside of its box.\n" , p->id );
} */
/**
/**
* @brief Mapping function for neighbour count.
* @brief Mapping function for neighbour count.
*/
*/
void
map_cellcheck
(
struct
cell
*
c
,
void
*
data
)
{
void
map_cellcheck
(
struct
cell
*
c
,
void
*
data
)
{
int
*
count
=
(
int
*
)
data
;
int
*
count
=
(
int
*
)
data
;
__sync_fetch_and
_add
(
count
,
c
->
count
);
atomic
_add
(
count
,
c
->
count
);
/* Loop over all parts and check if they are in the cell. */
/* Loop over all parts and check if they are in the cell. */
for
(
int
k
=
0
;
k
<
c
->
count
;
k
++
)
{
for
(
int
k
=
0
;
k
<
c
->
count
;
k
++
)
{
...
@@ -133,7 +138,6 @@ void map_cellcheck(struct cell *c, void *data) {
...
@@ -133,7 +138,6 @@ void map_cellcheck(struct cell *c, void *data) {
/**
/**
* @brief Mapping function for maxdepth cell count.
* @brief Mapping function for maxdepth cell count.
*/
*/
void
map_maxdepth
(
struct
cell
*
c
,
void
*
data
)
{
void
map_maxdepth
(
struct
cell
*
c
,
void
*
data
)
{
int
maxdepth
=
((
int
*
)
data
)[
0
];
int
maxdepth
=
((
int
*
)
data
)[
0
];
...
@@ -147,7 +151,6 @@ void map_maxdepth(struct cell *c, void *data) {
...
@@ -147,7 +151,6 @@ void map_maxdepth(struct cell *c, void *data) {
/**
/**
* @brief Mapping function for neighbour count.
* @brief Mapping function for neighbour count.
*/
*/
void
map_count
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
void
map_count
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
double
*
wcount
=
(
double
*
)
data
;
double
*
wcount
=
(
double
*
)
data
;
...
@@ -156,7 +159,6 @@ void map_count(struct part *p, struct cell *c, void *data) {
...
@@ -156,7 +159,6 @@ void map_count(struct part *p, struct cell *c, void *data) {
*
wcount
+=
p
->
density
.
wcount
;
*
wcount
+=
p
->
density
.
wcount
;
}
}
void
map_wcount_min
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
void
map_wcount_min
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
struct
part
**
p2
=
(
struct
part
**
)
data
;
struct
part
**
p2
=
(
struct
part
**
)
data
;
...
@@ -188,7 +190,6 @@ void map_h_max(struct part *p, struct cell *c, void *data) {
...
@@ -188,7 +190,6 @@ void map_h_max(struct part *p, struct cell *c, void *data) {
/**
/**
* @brief Mapping function for neighbour count.
* @brief Mapping function for neighbour count.
*/
*/
void
map_icount
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
void
map_icount
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
// int *count = (int *)data;
// int *count = (int *)data;
...
@@ -201,7 +202,6 @@ void map_icount(struct part *p, struct cell *c, void *data) {
...
@@ -201,7 +202,6 @@ void map_icount(struct part *p, struct cell *c, void *data) {
/**
/**
* @brief Mapping function to print the particle position.
* @brief Mapping function to print the particle position.
*/
*/
void
map_dump
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
void
map_dump
(
struct
part
*
p
,
struct
cell
*
c
,
void
*
data
)
{
double
*
shift
=
(
double
*
)
data
;
double
*
shift
=
(
double
*
)
data
;
...
...
This diff is collapsed.
Click to expand it.
src/timers.h
+
2
−
1
View file @
d8bf23e2
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#define SWIFT_TIMERS_H
#define SWIFT_TIMERS_H
/* Includes. */
/* Includes. */
#include
"atomic.h"
#include
"cycle.h"
#include
"cycle.h"
#include
"inline.h"
#include
"inline.h"
...
@@ -74,7 +75,7 @@ extern ticks timers[timer_count];
...
@@ -74,7 +75,7 @@ extern ticks timers[timer_count];
#define TIMER_TOC2(t) timers_toc(t, tic2)
#define TIMER_TOC2(t) timers_toc(t, tic2)
INLINE
static
ticks
timers_toc
(
int
t
,
ticks
tic
)
{
INLINE
static
ticks
timers_toc
(
int
t
,
ticks
tic
)
{
ticks
d
=
(
getticks
()
-
tic
);
ticks
d
=
(
getticks
()
-
tic
);
__sync_add_and_fetch
(
&
timers
[
t
],
d
);
atomic_add
(
&
timers
[
t
],
d
);
return
d
;
return
d
;
}
}
#else
#else
...
...
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