Skip to content
Snippets Groups Projects
Commit 7ae982f8 authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

use std::copy instead of element-wise copy

parent 3245d1ec
Branches
Tags
No related merge requests found
...@@ -148,16 +148,11 @@ int field_descriptor::transpose( ...@@ -148,16 +148,11 @@ int field_descriptor::transpose(
// for 3D transposition, the input data is messed up // for 3D transposition, the input data is messed up
fftwf_plan tplan; fftwf_plan tplan;
ptrdiff_t dim1; ptrdiff_t dim1;
switch (this->ndims) if (this->ndims == 3)
{ {
case 2:
dim1 = this->sizes[1];
break;
case 3:
// transpose the two local dimensions 1 and 2 // transpose the two local dimensions 1 and 2
dim1 = this->sizes[1]*this->sizes[2];
float *atmp; float *atmp;
atmp = (float*)malloc(dim1*sizeof(float)); atmp = fftwf_alloc_real(this->slice_size);
for (int k = 0; k < this->subsizes[0]; k++) for (int k = 0; k < this->subsizes[0]; k++)
{ {
// put transposed slice in atmp // put transposed slice in atmp
...@@ -166,19 +161,15 @@ int field_descriptor::transpose( ...@@ -166,19 +161,15 @@ int field_descriptor::transpose(
atmp[i*this->sizes[1] + j] = atmp[i*this->sizes[1] + j] =
input[(k*this->sizes[1] + j)*this->sizes[2] + i]; input[(k*this->sizes[1] + j)*this->sizes[2] + i];
// copy back transposed slice // copy back transposed slice
for (int j = 0; j < this->sizes[2]; j++) std::copy(
for (int i = 0; i < this->sizes[1]; i++) atmp,
input[(k*this->sizes[2] + j)*this->sizes[1] + i] = atmp + this->slice_size,
atmp[j*this->sizes[1] + i]; input + k*this->slice_size);
} }
free(atmp); fftwf_free(atmp);
break;
default:
return EXIT_FAILURE;
break;
} }
tplan = fftwf_mpi_plan_transpose( tplan = fftwf_mpi_plan_transpose(
this->sizes[0], dim1, this->sizes[0], this->slice_size,
input, output, input, output,
this->comm, this->comm,
FFTW_ESTIMATE); FFTW_ESTIMATE);
... ...
......
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:e257a2ed63efdfaaad53572bf411ce350bc2da0748cbff2374ba511f3a837cbc" "signature": "sha256:9cf3a6ad81b4021d61957c3d2805faad24a447da957672fc0268ff9b398c6dee"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 51 "prompt_number": 54
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -215,11 +215,11 @@ ...@@ -215,11 +215,11 @@
"output_type": "stream", "output_type": "stream",
"stream": "stdout", "stream": "stdout",
"text": [ "text": [
"3.09944e-06\n" "2.86102e-06\n"
] ]
} }
], ],
"prompt_number": 52 "prompt_number": 55
}, },
{ {
"cell_type": "code", "cell_type": "code",
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment