Skip to content
Snippets Groups Projects
Commit 98923844 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Put array on stack when reasonable.

parent be074f09
No related branches found
No related tags found
No related merge requests found
......@@ -70,13 +70,19 @@ XtMPI_Type_create_hindexed_block(int count, int blocklength,
MPI_Datatype oldtype, MPI_Datatype *newtype)
{
size_t count_ = count > 0 ? (size_t)count : 0;
int *restrict blocklengths = xmalloc(count_ * sizeof (*blocklengths));
enum { bl_auto_max = 32 };
int blocklengths_auto[bl_auto_max];
int *restrict blocklengths
= count_ > bl_auto_max
? xmalloc(count_ * sizeof (*blocklengths))
: blocklengths_auto;
for (size_t i = 0; i < count_; ++i)
blocklengths[i] = blocklength;
int rc = MPI_Type_create_hindexed(count, blocklengths,
CAST_MPI_SEND_BUF(array_of_displacements),
oldtype, newtype);
free(blocklengths);
if (count_ > bl_auto_max)
free(blocklengths);
return rc;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment