Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libsharp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
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
Martin Reinecke
libsharp
Commits
1e406585
Commit
1e406585
authored
2 years ago
by
Martin Reinecke
Browse files
Options
Downloads
Patches
Plain Diff
try MPI_Alltoall() instead of MPI_Alltoallv()
parent
004b3aea
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libsharp2/sharp_mpi.c
+58
-23
58 additions, 23 deletions
libsharp2/sharp_mpi.c
with
58 additions
and
23 deletions
libsharp2/sharp_mpi.c
+
58
−
23
View file @
1e406585
...
...
@@ -50,6 +50,9 @@ typedef struct
int
*
ispair
;
/* is this really a pair? */
int
*
almcount
,
*
almdisp
,
*
mapcount
,
*
mapdisp
;
/* for all2all communication */
int
npairmax
;
/* maxium value in npair */
int
nmmax
;
/* maximum value in nm */
}
sharp_mpi_info
;
static
void
sharp_make_mpi_info
(
MPI_Comm
comm
,
const
sharp_job
*
job
,
...
...
@@ -111,6 +114,13 @@ static void sharp_make_mpi_info (MPI_Comm comm, const sharp_job *job,
minfo
->
mapcount
[
i
]
=
2
*
minfo
->
nph
*
minfo
->
nm
[
i
]
*
minfo
->
npair
[
minfo
->
mytask
];
minfo
->
mapdisp
[
i
+
1
]
=
minfo
->
mapdisp
[
i
]
+
minfo
->
mapcount
[
i
];
}
minfo
->
npairmax
=
minfo
->
nmmax
=
0
;
for
(
int
i
=
0
;
i
<
minfo
->
ntasks
;
++
i
)
{
if
(
minfo
->
npair
[
i
]
>
minfo
->
npairmax
)
minfo
->
npairmax
=
minfo
->
npair
[
i
];
if
(
minfo
->
nm
[
i
]
>
minfo
->
nmmax
)
minfo
->
nmmax
=
minfo
->
nm
[
i
];
}
}
static
void
sharp_destroy_mpi_info
(
sharp_mpi_info
*
minfo
)
...
...
@@ -130,49 +140,74 @@ static void sharp_destroy_mpi_info (sharp_mpi_info *minfo)
static
void
sharp_communicate_alm2map
(
const
sharp_mpi_info
*
minfo
,
dcmplx
**
ph
)
{
dcmplx
*
phas_tmp
=
RALLOC
(
dcmplx
,
minfo
->
mapdisp
[
minfo
->
ntasks
]
/
2
);
MPI_Alltoallv
(
*
ph
,
minfo
->
almcount
,
minfo
->
almdisp
,
MPI_DOUBLE
,
phas_tmp
,
minfo
->
mapcount
,
minfo
->
mapdisp
,
MPI_DOUBLE
,
minfo
->
comm
);
// on input: ph has shape(npairtotal,nm[task],nph)
dcmplx
*
sendbuf
=
RALLOC
(
dcmplx
,
minfo
->
nmmax
*
minfo
->
ntasks
*
minfo
->
npairmax
*
minfo
->
nph
);
for
(
int
task
=
0
;
task
<
minfo
->
ntasks
;
++
task
)
for
(
int
ti
=
0
;
ti
<
minfo
->
npair
[
task
];
++
ti
)
for
(
int
mi
=
0
;
mi
<
minfo
->
nm
[
minfo
->
mytask
];
++
mi
)
{
int
th
=
minfo
->
ofs_pair
[
task
]
+
ti
;
int
obuf
=
minfo
->
nmmax
*
minfo
->
npairmax
*
minfo
->
nph
*
task
+
minfo
->
nph
*
(
mi
+
minfo
->
nmmax
*
ti
);
int
oarr
=
minfo
->
nph
*
(
th
*
(
minfo
->
nm
[
minfo
->
mytask
])
+
mi
);
for
(
int
i
=
0
;
i
<
minfo
->
nph
;
++
i
)
sendbuf
[
obuf
+
i
]
=
(
*
ph
)[
oarr
+
i
];
}
DEALLOC
(
*
ph
);
dcmplx
*
recvbuf
=
RALLOC
(
dcmplx
,
minfo
->
nmmax
*
minfo
->
ntasks
*
minfo
->
npairmax
*
minfo
->
nph
);
MPI_Alltoall
(
sendbuf
,
minfo
->
nph
*
minfo
->
nmmax
*
minfo
->
npairmax
*
2
,
MPI_DOUBLE
,
recvbuf
,
minfo
->
nph
*
minfo
->
nmmax
*
minfo
->
npairmax
*
2
,
MPI_DOUBLE
,
minfo
->
comm
);
DEALLOC
(
sendbuf
);
ALLOC
(
*
ph
,
dcmplx
,
minfo
->
nph
*
minfo
->
npair
[
minfo
->
mytask
]
*
minfo
->
nmtotal
);
// on output: ph has shape(npair[task],mmax+1,nph)
for
(
int
task
=
0
;
task
<
minfo
->
ntasks
;
++
task
)
for
(
int
t
h
=
0
;
t
h
<
minfo
->
npair
[
minfo
->
mytask
];
++
t
h
)
for
(
int
t
i
=
0
;
t
i
<
minfo
->
npair
[
minfo
->
mytask
];
++
t
i
)
for
(
int
mi
=
0
;
mi
<
minfo
->
nm
[
task
];
++
mi
)
{
int
m
=
minfo
->
mval
[
mi
+
minfo
->
ofs_m
[
task
]];
int
o1
=
minfo
->
nph
*
(
th
*
(
minfo
->
mmax
+
1
)
+
m
);
int
o2
=
minfo
->
mapdisp
[
task
]
/
2
+
minfo
->
nph
*
(
mi
+
th
*
minfo
->
nm
[
task
]);
int
obuf
=
minfo
->
nmmax
*
minfo
->
npairmax
*
minfo
->
nph
*
task
+
minfo
->
nph
*
(
mi
+
minfo
->
nmmax
*
ti
);
int
oarr
=
minfo
->
nph
*
(
ti
*
(
minfo
->
mmax
+
1
)
+
m
);
for
(
int
i
=
0
;
i
<
minfo
->
nph
;
++
i
)
(
*
ph
)[
o
1
+
i
]
=
phas_tmp
[
o2
+
i
];
(
*
ph
)[
o
arr
+
i
]
=
recvbuf
[
obuf
+
i
];
}
DEALLOC
(
phas_tmp
);
DEALLOC
(
recvbuf
);
}
static
void
sharp_communicate_map2alm
(
const
sharp_mpi_info
*
minfo
,
dcmplx
**
ph
)
{
dcmplx
*
phas_tmp
=
RALLOC
(
dcmplx
,
minfo
->
mapdisp
[
minfo
->
ntasks
]
/
2
);
dcmplx
*
sendbuf
=
RALLOC
(
dcmplx
,
minfo
->
nmmax
*
minfo
->
ntasks
*
minfo
->
npairmax
*
minfo
->
nph
);
for
(
int
task
=
0
;
task
<
minfo
->
ntasks
;
++
task
)
for
(
int
t
h
=
0
;
t
h
<
minfo
->
npair
[
minfo
->
mytask
];
++
t
h
)
for
(
int
t
i
=
0
;
t
i
<
minfo
->
npair
[
minfo
->
mytask
];
++
t
i
)
for
(
int
mi
=
0
;
mi
<
minfo
->
nm
[
task
];
++
mi
)
{
int
m
=
minfo
->
mval
[
mi
+
minfo
->
ofs_m
[
task
]];
int
o1
=
minfo
->
mapdisp
[
task
]
/
2
+
minfo
->
nph
*
(
mi
+
th
*
minfo
->
nm
[
task
]);
int
o2
=
minfo
->
nph
*
(
th
*
(
minfo
->
mmax
+
1
)
+
m
);
int
obuf
=
minfo
->
nmmax
*
minfo
->
npairmax
*
minfo
->
nph
*
task
+
minfo
->
nph
*
(
mi
+
minfo
->
nmmax
*
ti
);
int
oarr
=
minfo
->
nph
*
(
ti
*
(
minfo
->
mmax
+
1
)
+
m
);
for
(
int
i
=
0
;
i
<
minfo
->
nph
;
++
i
)
phas_tmp
[
o1
+
i
]
=
(
*
ph
)[
o
2
+
i
];
sendbuf
[
obuf
+
i
]
=
(
*
ph
)[
o
arr
+
i
];
}
DEALLOC
(
*
ph
);
dcmplx
*
recvbuf
=
RALLOC
(
dcmplx
,
minfo
->
nmmax
*
minfo
->
ntasks
*
minfo
->
npairmax
*
minfo
->
nph
);
MPI_Alltoall
(
sendbuf
,
minfo
->
nph
*
minfo
->
nmmax
*
minfo
->
npairmax
*
2
,
MPI_DOUBLE
,
recvbuf
,
minfo
->
nph
*
minfo
->
nmmax
*
minfo
->
npairmax
*
2
,
MPI_DOUBLE
,
minfo
->
comm
);
DEALLOC
(
sendbuf
);
ALLOC
(
*
ph
,
dcmplx
,
minfo
->
nph
*
minfo
->
nm
[
minfo
->
mytask
]
*
minfo
->
npairtotal
);
MPI_Alltoallv
(
phas_tmp
,
minfo
->
mapcount
,
minfo
->
mapdisp
,
MPI_DOUBLE
,
*
ph
,
minfo
->
almcount
,
minfo
->
almdisp
,
MPI_DOUBLE
,
minfo
->
comm
);
DEALLOC
(
phas_tmp
);
for
(
int
task
=
0
;
task
<
minfo
->
ntasks
;
++
task
)
for
(
int
ti
=
0
;
ti
<
minfo
->
npair
[
task
];
++
ti
)
for
(
int
mi
=
0
;
mi
<
minfo
->
nm
[
minfo
->
mytask
];
++
mi
)
{
int
th
=
minfo
->
ofs_pair
[
task
]
+
ti
;
int
obuf
=
minfo
->
nmmax
*
minfo
->
npairmax
*
minfo
->
nph
*
task
+
minfo
->
nph
*
(
mi
+
minfo
->
nmmax
*
ti
);
int
oarr
=
minfo
->
nph
*
(
th
*
(
minfo
->
nm
[
minfo
->
mytask
])
+
mi
);
for
(
int
i
=
0
;
i
<
minfo
->
nph
;
++
i
)
(
*
ph
)[
oarr
+
i
]
=
recvbuf
[
obuf
+
i
];
}
DEALLOC
(
recvbuf
);
}
static
void
alloc_phase_mpi
(
sharp_job
*
job
,
int
nm
,
int
ntheta
,
...
...
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