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
khalid
Dadi
Commits
6f98a81a
Commit
6f98a81a
authored
Jul 03, 2020
by
Ryan Gutenkunst
Browse files
Merge branch 'master' of
https://bitbucket.org/GutenkunstLab/dadi
parents
e82a42cb
90e9f6e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
dadi/cuda/Integration.py
View file @
6f98a81a
...
...
@@ -788,10 +788,10 @@ def _five_pops_temporal_params(phi, xx, T, initial_t, nu1_f, nu2_f, nu3_f, nu4_f
pBuffer
=
pycuda
.
driver
.
mem_alloc
(
bsize_int
)
while
current_t
<
T
:
dt
=
min
(
dadi
.
Integration
.
_compute_dt
(
dx
,
nu1
,
[
m12
,
m13
,
m14
],
gamma1
,
h1
),
dadi
.
Integration
.
_compute_dt
(
dy
,
nu2
,
[
m21
,
m23
,
m24
],
gamma2
,
h2
),
dadi
.
Integration
.
_compute_dt
(
dz
,
nu3
,
[
m31
,
m32
,
m34
],
gamma3
,
h3
),
dadi
.
Integration
.
_compute_dt
(
da
,
nu4
,
[
m41
,
m42
,
m43
],
gamma4
,
h4
),
dt
=
min
(
dadi
.
Integration
.
_compute_dt
(
dx
,
nu1
,
[
m12
,
m13
,
m14
,
m15
],
gamma1
,
h1
),
dadi
.
Integration
.
_compute_dt
(
dy
,
nu2
,
[
m21
,
m23
,
m24
,
m25
],
gamma2
,
h2
),
dadi
.
Integration
.
_compute_dt
(
dz
,
nu3
,
[
m31
,
m32
,
m34
,
m35
],
gamma3
,
h3
),
dadi
.
Integration
.
_compute_dt
(
da
,
nu4
,
[
m41
,
m42
,
m43
,
m45
],
gamma4
,
h4
),
dadi
.
Integration
.
_compute_dt
(
db
,
nu5
,
[
m51
,
m52
,
m53
,
m54
],
gamma5
,
h5
))
this_dt
=
np
.
float64
(
min
(
dt
,
T
-
current_t
))
...
...
dadi/cuda/kernels.cu
View file @
6f98a81a
...
...
@@ -144,21 +144,3 @@ __global__ void compute_bc_nobc(double *dx, double *dfactor,
c
[
ii
*
M
+
jj
]
=
-
dfactor
[
ii
]
*
ctemp
;
}
}
__global__
void
diff_iny_2D
(
double
*
in
,
double
*
out
,
int
L
,
int
M
){
int
ii
=
(
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
)
/
(
M
-
1
);
int
jj
=
(
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
)
%
(
M
-
1
);
if
(
ii
<
L
){
out
[
ii
*
(
M
-
1
)
+
jj
]
=
in
[
ii
*
M
+
jj
+
1
]
-
in
[
ii
*
M
+
jj
];
}
}
__global__
void
drop_last_col_2D
(
double
*
in
,
double
*
out
,
int
L
,
int
M
){
int
ii
=
(
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
)
/
(
M
-
1
);
int
jj
=
(
blockIdx
.
x
*
blockDim
.
x
+
threadIdx
.
x
)
%
(
M
-
1
);
if
(
ii
<
L
){
out
[
ii
*
(
M
-
1
)
+
jj
]
=
in
[
ii
*
M
+
jj
];
}
}
\ No newline at end of file
dadi/cuda/kernels.py
View file @
6f98a81a
...
...
@@ -17,6 +17,4 @@ _Mfunc5D = mod.get_function("Mfunc5D")
_cx0
=
mod
.
get_function
(
"cx0"
)
_compute_ab_nobc
=
mod
.
get_function
(
"compute_ab_nobc"
)
_compute_bc_nobc
=
mod
.
get_function
(
"compute_bc_nobc"
)
_include_bc
=
mod
.
get_function
(
"include_bc"
)
diff_iny_2D
=
mod
.
get_function
(
"diff_iny_2D"
)
drop_last_col_2D
=
mod
.
get_function
(
"drop_last_col_2D"
)
\ No newline at end of file
_include_bc
=
mod
.
get_function
(
"include_bc"
)
\ No newline at end of file
tests/test_CUDA.py
View file @
6f98a81a
...
...
@@ -213,6 +213,34 @@ class CUDATestCase(unittest.TestCase):
gamma1
=
gamma1
,
gamma2
=
gamma2
,
gamma3
=
gamma3
,
gamma4
=
gamma4
,
h1
=
h1
,
h2
=
h2
,
h3
=
h3
,
h4
=
h4
,
theta0
=
theta0
,
frozen1
=
f1
,
frozen2
=
f2
,
frozen3
=
f3
,
frozen4
=
f4
)
self
.
assertTrue
(
np
.
allclose
(
phi_cpu
,
phi_gpu
))
def
test_5d_integration
(
self
):
kwargs
=
{
'T'
:
0.1
,
'nu1'
:
0.2
,
'nu2'
:
1.3
,
'nu3'
:
7.1
,
'nu4'
:
27.1
,
'nu5'
:
lambda
t
:
0.9
-
8
*
t
,
'm12'
:
3
,
'm13'
:
2.9
,
'm14'
:
0.9
,
'm15'
:
10
,
'm21'
:
3
,
'm23'
:
lambda
t
:
0.9
+
10
*
t
,
'm24'
:
0.9
,
'm25'
:
lambda
t
:
2
-
15
*
t
,
'm31'
:
3.5
,
'm32'
:
2.9
,
'm34'
:
0.9
,
'm35'
:
10
,
'm41'
:
3.3
,
'm42'
:
2.2
,
'm43'
:
0.1
,
'm45'
:
9
,
'm51'
:
3.3
,
'm52'
:
2.2
,
'm53'
:
0.8
,
'm54'
:
9.2
,
'gamma1'
:
-
1
,
'gamma2'
:
2
,
'gamma3'
:
-
1.9
,
'gamma4'
:
lambda
t
:
10
*
t
,
'gamma5'
:
-
1
,
'h1'
:
0.1
,
'h2'
:
0.9
,
'h3'
:
0.2
,
'h4'
:
0.9
,
'h5'
:
0.1
,
'frozen1'
:
False
,
'frozen2'
:
False
,
'frozen3'
:
False
,
'frozen4'
:
False
,
'frozen5'
:
False
,
'theta0'
:
lambda
t
:
10
*
t
}
pts
=
5
xx
=
dadi
.
Numerics
.
default_grid
(
pts
)
phi
=
dadi
.
PhiManip
.
phi_1D
(
xx
)
phi
=
dadi
.
PhiManip
.
phi_1D_to_2D
(
xx
,
phi
)
phi
=
dadi
.
PhiManip
.
phi_2D_to_3D
(
phi
,
0
,
xx
,
xx
,
xx
)
phi
=
dadi
.
PhiManip
.
phi_3D_to_4D
(
phi
,
0
,
0
,
xx
,
xx
,
xx
,
xx
)
phi
=
dadi
.
PhiManip
.
phi_4D_to_5D
(
phi
,
0
,
0
,
0
,
xx
,
xx
,
xx
,
xx
,
xx
)
dadi
.
cuda_enabled
(
True
)
phi_gpu
=
dadi
.
Integration
.
five_pops
(
phi
.
copy
(),
xx
,
**
kwargs
)
dadi
.
cuda_enabled
(
False
)
phi_cpu
=
dadi
.
Integration
.
five_pops
(
phi
.
copy
(),
xx
,
**
kwargs
)
self
.
assertTrue
(
np
.
allclose
(
phi_cpu
,
phi_gpu
))
if
dadi
.
cuda_enabled
(
True
):
suite
=
unittest
.
TestLoader
().
loadTestsFromTestCase
(
CUDATestCase
)
...
...
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