Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
resolve
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
resolve
Commits
8c60876d
Commit
8c60876d
authored
Feb 15, 2022
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
resolvelib.PolarizationMatrixExponential: implement apply
parent
0fbcd36a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!37
Draft: Observation: introduce __hash__
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
resolvelib/Makefile
+2
-2
2 additions, 2 deletions
resolvelib/Makefile
resolvelib/devel.py
+16
-5
16 additions, 5 deletions
resolvelib/devel.py
resolvelib/ducc
+1
-1
1 addition, 1 deletion
resolvelib/ducc
resolvelib/resolvelib.cpp
+38
-6
38 additions, 6 deletions
resolvelib/resolvelib.cpp
with
57 additions
and
14 deletions
resolvelib/Makefile
+
2
−
2
View file @
8c60876d
.PHONY
:
build
CXXFLAGS_MINI
:=
-std
=
c++20
-Wfatal-errors
-Wall
-Wextra
-shared
-fPIC
$(
shell python3
-m
pybind11
--includes
)
-Iducc
/src
-fvisibility
=
hidden
#
CXXFLAGS:= -O3 -march=native -ffast-math $(CXXFLAGS_MINI)
CXXFLAGS
:=
$(
CXXFLAGS_MINI
)
CXXFLAGS
:=
-O3
-march
=
native
-ffast-math
$(
CXXFLAGS_MINI
)
#
CXXFLAGS:= $(CXXFLAGS_MINI)
OUT
:=
resolvelib
$(
shell python3-config
--extension-suffix
)
...
...
...
...
This diff is collapsed.
Click to expand it.
resolvelib/devel.py
+
16
−
5
View file @
8c60876d
...
...
@@ -19,17 +19,28 @@ import nifty8 as ift
import
resolvelib
from
cpp2py
import
Pybind11Operator
from
time
import
time
pdom
=
rve
.
PolarizationSpace
([
"
I
"
,
"
Q
"
,
"
U
"
])
sdom
=
ift
.
RGSpace
([
4
,
4
])
pdom
=
rve
.
PolarizationSpace
([
"
I
"
,
"
Q
"
,
"
U
"
,
"
V
"
])
sdom
=
ift
.
RGSpace
([
4
000
,
4000
])
dom
=
rve
.
default_sky_domain
(
pdom
=
pdom
,
sdom
=
sdom
)
dom
=
{
kk
:
dom
[
1
:]
for
kk
in
pdom
.
labels
}
op
=
Pybind11Operator
(
dom
,
dom
,
resolvelib
.
PolarizationMatrixExponential
()
)
tgt
=
rve
.
default_sky_domain
(
p
dom
=
p
dom
,
sdom
=
sdom
)
loc
=
ift
.
from_random
(
op
.
domain
)
nthreads
=
1
loc
=
ift
.
from_random
(
dom
)
ntries
=
100
for
nthreads
in
[
8
]:
#for nthreads in range(1, 9):
op
=
Pybind11Operator
(
dom
,
tgt
,
resolvelib
.
PolarizationMatrixExponential
(
nthreads
))
t0
=
time
()
for
_
in
range
(
ntries
):
op
(
loc
)
print
(
f
"
Nthreads
{
nthreads
}
:
{
(
time
()
-
t0
)
/
ntries
:
.
2
f
}
s
"
)
exit
()
op
(
loc
)
exit
()
...
...
...
...
This diff is collapsed.
Click to expand it.
ducc
@
5d3e4e57
Compare
1548bad0
to
5d3e4e57
Subproject commit
1548bad07fac2f4331b551d7e239401d572a88e0
Subproject commit
5d3e4e577659ea5eb41a67e82f0cf4380ef599d1
This diff is collapsed.
Click to expand it.
resolvelib/resolvelib.cpp
+
38
−
6
View file @
8c60876d
...
...
@@ -52,12 +52,44 @@ class Linearization {
};
template
<
typename
T
,
size_t
ndim
>
class
PolarizationMatrixExponential
{
private:
const
size_t
nthreads
;
public:
PolarizationMatrixExponential
()
{}
PolarizationMatrixExponential
(
size_t
nthreads_
=
1
)
:
nthreads
(
nthreads_
)
{}
py
::
array
apply
(
const
py
::
dict
&
inp
)
const
{
MR_fail
(
"Not implemented yet"
);
return
inp
;
auto
I
{
ducc0
::
to_cmav
<
T
,
ndim
>
(
inp
[
"I"
])},
Q
{
ducc0
::
to_cmav
<
T
,
ndim
>
(
inp
[
"Q"
])},
U
{
ducc0
::
to_cmav
<
T
,
ndim
>
(
inp
[
"U"
])},
V
{
ducc0
::
to_cmav
<
T
,
ndim
>
(
inp
[
"V"
])};
// Instantiate output array
auto
out_
=
ducc0
::
make_Pyarr
<
T
>
({
4
,
I
.
shape
()[
0
],
I
.
shape
()[
1
],
I
.
shape
()[
2
],
I
.
shape
()[
3
]});
auto
out
=
ducc0
::
to_vmav
<
T
,
ndim
+
1
>
(
out_
);
auto
outI
=
ducc0
::
subarray
<
ndim
>
(
out
,
{{
0
},
{},
{},
{},
{}}),
outQ
=
ducc0
::
subarray
<
ndim
>
(
out
,
{{
1
},
{},
{},
{},
{}}),
outU
=
ducc0
::
subarray
<
ndim
>
(
out
,
{{
2
},
{},
{},
{},
{}}),
outV
=
ducc0
::
subarray
<
ndim
>
(
out
,
{{
3
},
{},
{},
{},
{}});
// /Instantiate output array
ducc0
::
mav_apply
([](
const
auto
&
ii
,
const
auto
&
qq
,
const
auto
&
uu
,
const
auto
&
vv
,
auto
&
oii
,
auto
&
oqq
,
auto
&
ouu
,
auto
&
ovv
){
auto
pol
{
qq
*
qq
+
uu
*
uu
+
vv
*
vv
};
oii
=
0.5
*
(
exp
(
ii
+
pol
)
+
exp
(
ii
-
pol
));
auto
tmp
{
0.5
*
(
exp
(
ii
+
pol
)
-
exp
(
ii
-
pol
))
/
sqrt
(
pol
)};
oqq
=
tmp
*
qq
;
ouu
=
tmp
*
uu
;
ovv
=
tmp
*
vv
;
},
nthreads
,
I
,
Q
,
U
,
V
,
outI
,
outQ
,
outU
,
outV
);
return
out_
;
}
// Linearization<py::array,py::array> apply_with_jac(const py::dict &inp) {
...
...
@@ -89,9 +121,9 @@ void add_linearization(py::module_ &msup, const char *name) {
PYBIND11_MODULE
(
resolvelib
,
m
)
{
py
::
class_
<
PolarizationMatrixExponential
>
(
m
,
"PolarizationMatrixExponential"
)
.
def
(
py
::
init
<>
())
.
def
(
"apply"
,
&
PolarizationMatrixExponential
::
apply
);
py
::
class_
<
PolarizationMatrixExponential
<
double
,
4
>
>
(
m
,
"PolarizationMatrixExponential"
)
.
def
(
py
::
init
<
size_t
>
())
.
def
(
"apply"
,
&
PolarizationMatrixExponential
<
double
,
4
>
::
apply
);
//.def("apply_with_jac", &PolarizationMatrixExponential::apply_with_jac);
// add_linearization<py::array, py::array>(m, "Linearization_field2field");
...
...
...
...
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
sign in
to comment