Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dg
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
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
gmsh
dg
Commits
2ba63476
Commit
2ba63476
authored
4 years ago
by
Matteo Cicuttin
Browse files
Options
Downloads
Patches
Plain Diff
Reactivated CPU solver.
parent
6333fd61
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/maxwell_gpu.cpp
+5
-5
5 additions, 5 deletions
src/maxwell_gpu.cpp
src/maxwell_solver.cpp
+40
-12
40 additions, 12 deletions
src/maxwell_solver.cpp
with
45 additions
and
17 deletions
src/maxwell_gpu.cpp
+
5
−
5
View file @
2ba63476
...
@@ -204,8 +204,8 @@ compute_rk4_weighted_sum(solver_state_gpu& state, const field_gpu& in,
...
@@ -204,8 +204,8 @@ compute_rk4_weighted_sum(solver_state_gpu& state, const field_gpu& in,
void
void
timestep
(
solver_state_gpu
&
state
)
timestep
(
solver_state_gpu
&
state
)
{
{
timecounter
tc
;
//
timecounter tc;
tc
.
tic
();
//
tc.tic();
/*
/*
apply_operator(state, state.emf_curr, state.tmp);
apply_operator(state, state.emf_curr, state.tmp);
...
@@ -228,9 +228,9 @@ timestep(solver_state_gpu& state)
...
@@ -228,9 +228,9 @@ timestep(solver_state_gpu& state)
state
.
curr_time
+=
state
.
delta_t
;
state
.
curr_time
+=
state
.
delta_t
;
state
.
curr_timestep
+=
1
;
state
.
curr_timestep
+=
1
;
double
time
=
tc
.
toc
();
//
double time = tc.toc();
double
dofs_per_sec
=
6
*
state
.
emf_curr
.
num_dofs
/
time
;
//
double dofs_per_sec = 6*state.emf_curr.num_dofs/time;
std
::
cout
<<
"Timestep "
<<
state
.
curr_timestep
<<
", "
<<
dofs_per_sec
<<
" DOFs/s"
<<
std
::
endl
;
//
std::cout << "Timestep " << state.curr_timestep << ", " << dofs_per_sec << " DOFs/s" << std::endl;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/maxwell_solver.cpp
+
40
−
12
View file @
2ba63476
...
@@ -61,7 +61,7 @@ void initialize_solver(const model& mod, State& state, const maxwell::parameter_
...
@@ -61,7 +61,7 @@ void initialize_solver(const model& mod, State& state, const maxwell::parameter_
}
}
void
void
do_
boundary_
sources
(
const
model
&
mod
,
maxwell
::
solver_state
&
state
,
do_sources
(
const
model
&
mod
,
maxwell
::
solver_state
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
const
maxwell
::
parameter_loader
&
mpl
)
{
{
maxwell
::
eval_boundary_sources
(
mod
,
mpl
,
state
,
state
.
bndsrcs
);
maxwell
::
eval_boundary_sources
(
mod
,
mpl
,
state
,
state
.
bndsrcs
);
...
@@ -69,15 +69,46 @@ do_boundary_sources(const model& mod, maxwell::solver_state& state,
...
@@ -69,15 +69,46 @@ do_boundary_sources(const model& mod, maxwell::solver_state& state,
}
}
void
void
do_boundary_sources
(
const
model
&
mod
,
maxwell
::
solver_state_gpu
&
state
,
prepare_sources
(
const
model
&
mod
,
maxwell
::
solver_state
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
{
do_sources
(
mod
,
state
,
mpl
);
}
void
swap
(
maxwell
::
solver_state
&
state
)
{
std
::
swap
(
state
.
emf_curr
,
state
.
emf_next
);
}
#ifdef ENABLE_GPU_SOLVER
void
prepare_sources
(
const
model
&
mod
,
maxwell
::
solver_state_gpu
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
const
maxwell
::
parameter_loader
&
mpl
)
{
{
maxwell
::
eval_boundary_sources
(
mod
,
mpl
,
state
,
state
.
bndsrcs_cpu
);
maxwell
::
eval_boundary_sources
(
mod
,
mpl
,
state
,
state
.
bndsrcs_cpu
);
state
.
bndsrcs_buf
.
copyin
(
state
.
bndsrcs_cpu
,
state
.
memcpy_stream
);
state
.
bndsrcs_buf
.
copyin
(
state
.
bndsrcs_cpu
,
state
.
memcpy_stream
);
//maxwell::eval_interface_sources(mod, mpl, state, state.bndsrcs_cpu
);
state
.
memcpy_stream
.
wait
(
);
//state.memcpy_stream.wait(
);
std
::
swap
(
state
.
bndsrcs
,
state
.
bndsrcs_buf
);
}
}
void
do_sources
(
const
model
&
mod
,
maxwell
::
solver_state_gpu
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
{
maxwell
::
eval_boundary_sources
(
mod
,
mpl
,
state
,
state
.
bndsrcs_cpu
);
state
.
bndsrcs_buf
.
copyin
(
state
.
bndsrcs_cpu
,
state
.
memcpy_stream
);
}
void
swap
(
maxwell
::
solver_state_gpu
&
state
)
{
cudaDeviceSynchronize
();
std
::
swap
(
state
.
bndsrcs
,
state
.
bndsrcs_buf
);
std
::
swap
(
state
.
emf_curr
,
state
.
emf_next
);
}
#endif
template
<
typename
State
>
template
<
typename
State
>
void
test_it
(
const
model
&
mod
,
State
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
void
test_it
(
const
model
&
mod
,
State
&
state
,
const
maxwell
::
parameter_loader
&
mpl
)
{
{
...
@@ -92,12 +123,11 @@ void test_it(const model& mod, State& state, const maxwell::parameter_loader& mp
...
@@ -92,12 +123,11 @@ void test_it(const model& mod, State& state, const maxwell::parameter_loader& mp
omp_set_num_threads
(
4
);
omp_set_num_threads
(
4
);
#endif
#endif
do_boundary_sources
(
mod
,
state
,
mpl
);
prepare_sources
(
mod
,
state
,
mpl
);
std
::
swap
(
state
.
bndsrcs
,
state
.
bndsrcs_buf
);
for
(
size_t
i
=
0
;
i
<
num_timesteps
;
i
++
)
for
(
size_t
i
=
0
;
i
<
num_timesteps
;
i
++
)
{
{
timestep
(
state
);
timestep
(
state
);
do_
boundary_
sources
(
mod
,
state
,
mpl
);
do_sources
(
mod
,
state
,
mpl
);
std
::
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
mpl
.
sim_name
()
<<
"/timestep_"
<<
i
<<
".silo"
;
ss
<<
mpl
.
sim_name
()
<<
"/timestep_"
<<
i
<<
".silo"
;
...
@@ -109,9 +139,7 @@ void test_it(const model& mod, State& state, const maxwell::parameter_loader& mp
...
@@ -109,9 +139,7 @@ void test_it(const model& mod, State& state, const maxwell::parameter_loader& mp
std
::
cout
<<
"Cycle "
<<
i
<<
": t = "
<<
state
.
curr_time
<<
" s"
;
std
::
cout
<<
"Cycle "
<<
i
<<
": t = "
<<
state
.
curr_time
<<
" s"
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
}
cudaDeviceSynchronize
();
swap
(
state
);
std
::
swap
(
state
.
bndsrcs
,
state
.
bndsrcs_buf
);
std
::
swap
(
state
.
emf_curr
,
state
.
emf_next
);
}
}
}
}
...
@@ -155,8 +183,8 @@ int main(int argc, const char *argv[])
...
@@ -155,8 +183,8 @@ int main(int argc, const char *argv[])
else
else
{
{
#endif
/* ENABLE_GPU_SOLVER */
#endif
/* ENABLE_GPU_SOLVER */
//
maxwell::solver_state state_c;
maxwell
::
solver_state
state_c
;
//
test_it(mod, state_c, mpl);
test_it
(
mod
,
state_c
,
mpl
);
#ifdef ENABLE_GPU_SOLVER
#ifdef ENABLE_GPU_SOLVER
}
}
#endif
#endif
...
...
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