Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_numerics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_numerics
Commits
b95ece0b
Commit
b95ece0b
authored
2 years ago
by
Abhinav Singh
Browse files
Options
Downloads
Patches
Plain Diff
Adding default and more constructor
parent
3ecc7f89
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OdeIntegrators/tests/Odeintegrators_test_gpu.cu
+13
-34
13 additions, 34 deletions
src/OdeIntegrators/tests/Odeintegrators_test_gpu.cu
src/Operators/Vector/vector_dist_operators.hpp
+39
-0
39 additions, 0 deletions
src/Operators/Vector/vector_dist_operators.hpp
with
52 additions
and
34 deletions
src/OdeIntegrators/tests/Odeintegrators_test_gpu.cu
+
13
−
34
View file @
b95ece0b
...
...
@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_SUITE(odeInt_BASE_tests)
BOOST_AUTO_TEST_CASE
(
odeint_base_test_gpu
)
{
size_t
edgeSemiSize
=
40
;
size_t
edgeSemiSize
=
512
;
const
size_t
sz
[
2
]
=
{
edgeSemiSize
,
edgeSemiSize
};
Box
<
2
,
double
>
box
({
0
,
0
},
{
1.0
,
1.0
});
size_t
bc
[
2
]
=
{
NON_PERIODIC
,
NON_PERIODIC
};
...
...
@@ -56,8 +56,8 @@ BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
mem_id
k1
=
key
.
get
(
1
);
double
yp0
=
k1
*
spacing
[
1
];
Particles
.
getLastPos
()[
1
]
=
yp0
;
Particles
.
getLastProp
<
0
>
()
=
xp0
*
yp0
*
exp
(
0
);
Particles
.
getLastProp
<
1
>
()
=
xp0
*
yp0
*
exp
(
0.4
);
Particles
.
getLastProp
<
0
>
()
=
xp0
*
yp0
*
exp
(
-
5
);
Particles
.
getLastProp
<
1
>
()
=
xp0
*
yp0
*
exp
(
5
);
++
it
;
}
...
...
@@ -73,51 +73,30 @@ BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
x0
.
data
.
get
<
0
>
().
getVector
().
deviceToHost
<
0
>
();
// The rhs of x' = f(x)
double
t
=
0
,
tf
=
0.4
;
const
double
dt
=
0.1
;
double
t0
=-
5
,
tf
=
5
;
const
double
dt
=
0.01
;
//This doesnt work Why?
//size_t steps=boost::numeric::odeint::integrate(Exponential,x0,0.0,tf,dt);
size_t
steps
=
boost
::
numeric
::
odeint
::
integrate_const
(
boost
::
numeric
::
odeint
::
runge_kutta4
<
state_type
,
double
,
state_type
,
double
,
boost
::
numeric
::
odeint
::
vector_space_algebra_ofp_gpu
,
boost
::
numeric
::
odeint
::
ofp_operations
>
(),
ExponentialGPU
,
x0
,
0.0
,
tf
,
dt
);
timer
tt
;
tt
.
start
();
size_t
steps
=
boost
::
numeric
::
odeint
::
integrate_const
(
boost
::
numeric
::
odeint
::
runge_kutta4
<
state_type
,
double
,
state_type
,
double
,
boost
::
numeric
::
odeint
::
vector_space_algebra_ofp_gpu
,
boost
::
numeric
::
odeint
::
ofp_operations
>
(),
ExponentialGPU
,
x0
,
t0
,
tf
,
dt
);
tt
.
stop
();
OdeSol
=
x0
.
data
.
get
<
0
>
();
Particles
.
deviceToHostProp
<
0
,
1
,
2
>
();
auto
it2
=
Particles
.
getDomainIterator
();
double
worst
=
0.0
;
while
(
it2
.
isNext
())
{
auto
p
=
it2
.
get
();
std
::
cout
<<
"A:"
<<
Particles
.
getProp
<
1
>
(
p
)
<<
std
::
endl
;
std
::
cout
<<
"B:"
<<
Particles
.
getProp
<
2
>
(
p
)
<<
std
::
endl
;
if
(
fabs
(
Particles
.
getProp
<
1
>
(
p
)
-
Particles
.
getProp
<
2
>
(
p
))
>
worst
)
{
worst
=
fabs
(
Particles
.
getProp
<
1
>
(
p
)
-
Particles
.
getProp
<
2
>
(
p
));
}
++
it2
;
}
//std::cout<<worst<<std::endl;
BOOST_REQUIRE
(
worst
<
1e-6
);
x0
.
data
.
get
<
0
>
()
=
Init
;
boost
::
numeric
::
odeint
::
runge_kutta4
<
state_type
,
double
,
state_type
,
double
,
boost
::
numeric
::
odeint
::
vector_space_algebra_ofp
,
boost
::
numeric
::
odeint
::
ofp_operations
>
rk4
;
while
(
t
<
tf
)
{
rk4
.
do_step
(
ExponentialGPU
,
x0
,
t
,
dt
);
OdeSol
=
x0
.
data
.
get
<
0
>
();
t
+=
dt
;
}
OdeSol
=
x0
.
data
.
get
<
0
>
();
auto
it3
=
Particles
.
getDomainIterator
();
double
worst2
=
0.0
;
while
(
it3
.
isNext
())
{
auto
p
=
it3
.
get
();
if
(
fabs
(
Particles
.
getProp
<
1
>
(
p
)
-
Particles
.
getProp
<
2
>
(
p
))
>
worst2
)
{
worst2
=
fabs
(
Particles
.
getProp
<
1
>
(
p
)
-
Particles
.
getProp
<
2
>
(
p
));
}
++
it3
;
}
//std::cout<<worst2<<std::endl;
std
::
cout
<<
"WCT:"
<<
tt
.
getwct
()
<<
std
::
endl
;
std
::
cout
<<
"CPU:"
<<
tt
.
getcputime
()
<<
std
::
endl
;
std
::
cout
<<
worst
<<
std
::
endl
;
BOOST_REQUIRE
(
worst
<
1e-6
);
BOOST_REQUIRE_EQUAL
(
worst
,
worst2
);
}
BOOST_AUTO_TEST_SUITE_END
()
This diff is collapsed.
Click to expand it.
src/Operators/Vector/vector_dist_operators.hpp
+
39
−
0
View file @
b95ece0b
...
...
@@ -1266,6 +1266,12 @@ public:
vector_dist_expression_impl
()
{}
template
<
unsigned
int
prp2
,
typename
vector2
>
vector_dist_expression_impl
(
const
vector_dist_expression
<
prp2
,
vector2
>
&
v_exp
)
{
this
->
operator
=
(
v_exp
);
};
template
<
typename
exp1
,
typename
exp2
,
unsigned
int
op
>
vector_dist_expression_impl
(
const
vector_dist_expression_op
<
exp1
,
exp2
,
op
>
&
v_exp
)
{
...
...
@@ -1445,7 +1451,24 @@ class vector_dist_expression<0,openfpm::vector<aggregate<T>,memory, layout_base>
{
typedef
openfpm
::
vector
<
aggregate
<
T
>
,
memory
,
layout_base
>
vector
;
typedef
vector_dist_expression_impl
<
vector
>
base
;
public:
vector_dist_expression
()
{
}
template
<
unsigned
int
prp2
,
typename
vector2
>
vector_dist_expression
(
const
vector_dist_expression
<
prp2
,
vector2
>
&
v_exp
)
:
base
(
v_exp
)
{
}
template
<
typename
exp1
,
typename
exp2
,
unsigned
int
op
>
vector_dist_expression
(
const
vector_dist_expression_op
<
exp1
,
exp2
,
op
>
&
v_exp
)
:
base
(
v_exp
)
{
}
template
<
unsigned
int
prp2
,
typename
vector2
>
vector
&
operator
=
(
const
vector_dist_expression
<
prp2
,
vector2
>
&
v_exp
)
{
return
base
::
operator
=
(
v_exp
);
...
...
@@ -1469,6 +1492,22 @@ class vector_dist_expression<0,openfpm::vector_gpu<aggregate<T>>> : public vecto
typedef
openfpm
::
vector_gpu
<
aggregate
<
T
>>
vector
;
typedef
vector_dist_expression_impl
<
vector
>
base
;
public:
vector_dist_expression
()
{
}
template
<
unsigned
int
prp2
,
typename
vector2
>
vector_dist_expression
(
const
vector_dist_expression
<
prp2
,
vector2
>
&
v_exp
)
:
base
(
v_exp
)
{
}
template
<
typename
exp1
,
typename
exp2
,
unsigned
int
op
>
vector_dist_expression
(
const
vector_dist_expression_op
<
exp1
,
exp2
,
op
>
&
v_exp
)
:
base
(
v_exp
)
{
}
template
<
unsigned
int
prp2
,
typename
vector2
>
vector
&
operator
=
(
const
vector_dist_expression
<
prp2
,
vector2
>
&
v_exp
)
{
return
base
::
operator
=
(
v_exp
);
...
...
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