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
0f7a2dde
Commit
0f7a2dde
authored
7 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Tidied up includes and now only the space is passed to fof_naive() and fof_serial().
parent
d3b4cb1f
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!543
Fof
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/engine.c
+6
-2
6 additions, 2 deletions
src/engine.c
src/fof.c
+36
-38
36 additions, 38 deletions
src/fof.c
src/fof.h
+4
-10
4 additions, 10 deletions
src/fof.h
with
46 additions
and
50 deletions
src/engine.c
+
6
−
2
View file @
0f7a2dde
...
...
@@ -4200,12 +4200,16 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs,
message
(
"Performing Friends Of Friends search."
);
const
double
l_x
=
0
.
2
*
(
s
->
dim
[
0
]
/
pow
(
s
->
nr_gparts
,
1
.
/
3
.));
const
double
l_x2
=
l_x
*
l_x
;
s
->
l_x2
=
l_x2
;
ticks
tic
=
getticks
();
fof_search_naive
(
e
);
fof_search_naive
(
s
);
message
(
"Naive FOF search took: %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
tic
=
getticks
();
fof_search_serial
(
e
);
fof_search_serial
(
s
);
message
(
"Serial FOF search took: %.3f %s."
,
clocks_from_ticks
(
getticks
()
-
tic
),
clocks_getunit
());
tic
=
getticks
();
...
...
This diff is collapsed.
Click to expand it.
src/fof.c
+
36
−
38
View file @
0f7a2dde
...
...
@@ -26,13 +26,38 @@
/* Local headers. */
//#include "active.h"
void
fof_search_naive
(
struct
engine
*
e
)
{
__attribute__
((
always_inline
))
INLINE
int
fof_find
(
const
int
i
,
const
int
*
pid
)
{
int
root
=
i
;
while
(
root
!=
pid
[
root
])
root
=
pid
[
root
];
const
size_t
nr_gparts
=
e
->
s
->
nr_gparts
;
struct
gpart
*
gparts
=
e
->
s
->
gparts
;
const
double
dim
[
3
]
=
{
e
->
s
->
dim
[
0
],
e
->
s
->
dim
[
1
],
e
->
s
->
dim
[
2
]};
const
double
l_x
=
0
.
2
*
(
dim
[
0
]
/
pow
(
nr_gparts
,
1
.
/
3
.));
const
double
l_x2
=
l_x
*
l_x
;
return
root
;
}
__attribute__
((
always_inline
))
INLINE
int
fof_find_path_comp
(
const
int
i
,
int
*
pid
)
{
int
root
=
i
;
while
(
root
!=
pid
[
root
])
root
=
pid
[
root
];
/* Perform path compression. */
int
index
=
i
;
while
(
index
!=
root
)
{
int
next
=
pid
[
index
];
pid
[
index
]
=
root
;
index
=
next
;
}
return
root
;
}
void
fof_search_naive
(
struct
space
*
s
)
{
const
size_t
nr_gparts
=
s
->
nr_gparts
;
struct
gpart
*
gparts
=
s
->
gparts
;
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
l_x2
=
s
->
l_x2
;
int
*
pid
;
int
*
num_in_groups
;
int
num_groups
=
nr_gparts
;
...
...
@@ -117,39 +142,12 @@ void fof_search_naive(struct engine *e) {
free
(
num_in_groups
);
}
__attribute__
((
always_inline
))
INLINE
int
fof_find
(
const
int
i
,
const
int
*
pid
)
{
int
root
=
i
;
while
(
root
!=
pid
[
root
])
root
=
pid
[
root
];
return
root
;
}
__attribute__
((
always_inline
))
INLINE
int
fof_find_path_comp
(
const
int
i
,
int
*
pid
)
{
int
root
=
i
;
while
(
root
!=
pid
[
root
])
root
=
pid
[
root
];
/* Perform path compression. */
int
index
=
i
;
while
(
index
!=
root
)
{
int
next
=
pid
[
index
];
pid
[
index
]
=
root
;
index
=
next
;
}
return
root
;
}
void
fof_search_serial
(
struct
engine
*
e
)
{
void
fof_search_serial
(
struct
space
*
s
)
{
const
size_t
nr_gparts
=
e
->
s
->
nr_gparts
;
struct
gpart
*
gparts
=
e
->
s
->
gparts
;
const
double
dim
[
3
]
=
{
e
->
s
->
dim
[
0
],
e
->
s
->
dim
[
1
],
e
->
s
->
dim
[
2
]};
const
double
l_x
=
0
.
2
*
(
dim
[
0
]
/
pow
(
nr_gparts
,
1
.
/
3
.));
const
double
l_x2
=
l_x
*
l_x
;
const
size_t
nr_gparts
=
s
->
nr_gparts
;
struct
gpart
*
gparts
=
s
->
gparts
;
const
double
dim
[
3
]
=
{
s
->
dim
[
0
],
s
->
dim
[
1
],
s
->
dim
[
2
]};
const
double
l_x2
=
s
->
l_x2
;
int
*
pid
;
int
*
num_in_groups
;
int
num_groups
=
nr_gparts
;
...
...
This diff is collapsed.
Click to expand it.
src/fof.h
+
4
−
10
View file @
0f7a2dde
...
...
@@ -24,18 +24,12 @@
#include
"../config.h"
/* Local headers */
//#include "active.h"
//#include "cell.h"
#include
"engine.h"
//#include "hydro.h"
//#include "part.h"
//#include "runner.h"
//#include "timers.h"
//#include "vector.h"
#include
"space.h"
#include
"cell.h"
/* Function prototypes. */
void
fof_search_naive
(
struct
engin
e
*
e
);
void
fof_search_serial
(
struct
engin
e
*
e
);
void
fof_search_naive
(
struct
spac
e
*
s
);
void
fof_search_serial
(
struct
spac
e
*
s
);
void
fof_search_cell
(
struct
space
*
s
,
struct
cell
*
c
,
int
*
pid
,
int
*
num_in_groups
,
int
*
num_groups
);
void
fof_search_pair_cells
(
struct
space
*
s
,
struct
cell
*
ci
,
struct
cell
*
cj
,
int
*
pid
,
int
*
num_in_groups
,
int
*
num_groups
);
void
fof_search_tree_serial
(
struct
space
*
s
);
...
...
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