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

use unsigned char for MPI IO

parent 3e2f5ff6
Branches
Tags
No related merge requests found
...@@ -86,6 +86,9 @@ field_descriptor::field_descriptor( ...@@ -86,6 +86,9 @@ field_descriptor::field_descriptor(
tsubsizes[i] = this->subsizes[i]; tsubsizes[i] = this->subsizes[i];
tstarts[i] = this->starts[i]; tstarts[i] = this->starts[i];
} }
tsizes[ndims-1] *= sizeof(float);
tsubsizes[ndims-1] *= sizeof(float);
tstarts[ndims-1] *= sizeof(float);
if (this->mpi_dtype == MPI_COMPLEX8) if (this->mpi_dtype == MPI_COMPLEX8)
{ {
tsizes[ndims-1] *= 2; tsizes[ndims-1] *= 2;
...@@ -160,7 +163,7 @@ field_descriptor::field_descriptor( ...@@ -160,7 +163,7 @@ field_descriptor::field_descriptor(
tsubsizes, tsubsizes,
tstarts, tstarts,
MPI_ORDER_C, MPI_ORDER_C,
MPI_FLOAT, MPI_UNSIGNED_CHAR,
&this->mpi_array_dtype); &this->mpi_array_dtype);
MPI_Type_commit(&this->mpi_array_dtype); MPI_Type_commit(&this->mpi_array_dtype);
} }
...@@ -210,15 +213,14 @@ field_descriptor::~field_descriptor() ...@@ -210,15 +213,14 @@ field_descriptor::~field_descriptor()
int field_descriptor::read( int field_descriptor::read(
const char *fname, const char *fname,
void *buffer, void *buffer)
const char *datarep)
{ {
if (this->subsizes[0] > 0) if (this->subsizes[0] > 0)
{ {
MPI_Info info; MPI_Info info;
MPI_Info_create(&info); MPI_Info_create(&info);
MPI_File f; MPI_File f;
int read_size = this->local_size; int read_size = this->local_size*sizeof(float);
char ffname[200]; char ffname[200];
if (this->mpi_dtype == MPI_COMPLEX8) if (this->mpi_dtype == MPI_COMPLEX8)
read_size *= 2; read_size *= 2;
...@@ -233,15 +235,15 @@ int field_descriptor::read( ...@@ -233,15 +235,15 @@ int field_descriptor::read(
MPI_File_set_view( MPI_File_set_view(
f, f,
0, 0,
MPI_FLOAT, MPI_UNSIGNED_CHAR,
this->mpi_array_dtype, this->mpi_array_dtype,
datarep, "native",
info); info);
MPI_File_read_all( MPI_File_read_all(
f, f,
buffer, buffer,
read_size, read_size,
MPI_FLOAT, MPI_UNSIGNED_CHAR,
MPI_STATUS_IGNORE); MPI_STATUS_IGNORE);
MPI_File_close(&f); MPI_File_close(&f);
} }
...@@ -250,15 +252,14 @@ int field_descriptor::read( ...@@ -250,15 +252,14 @@ int field_descriptor::read(
int field_descriptor::write( int field_descriptor::write(
const char *fname, const char *fname,
void *buffer, void *buffer)
const char *datarep)
{ {
if (this->subsizes[0] > 0) if (this->subsizes[0] > 0)
{ {
MPI_Info info; MPI_Info info;
MPI_Info_create(&info); MPI_Info_create(&info);
MPI_File f; MPI_File f;
int read_size = this->local_size; int read_size = this->local_size*sizeof(float);
char ffname[200]; char ffname[200];
if (this->mpi_dtype == MPI_COMPLEX8) if (this->mpi_dtype == MPI_COMPLEX8)
read_size *= 2; read_size *= 2;
...@@ -273,15 +274,15 @@ int field_descriptor::write( ...@@ -273,15 +274,15 @@ int field_descriptor::write(
MPI_File_set_view( MPI_File_set_view(
f, f,
0, 0,
MPI_FLOAT, MPI_UNSIGNED_CHAR,
this->mpi_array_dtype, this->mpi_array_dtype,
datarep, "native",
info); info);
MPI_File_write_all( MPI_File_write_all(
f, f,
buffer, buffer,
read_size, read_size,
MPI_FLOAT, MPI_UNSIGNED_CHAR,
MPI_STATUS_IGNORE); MPI_STATUS_IGNORE);
MPI_File_close(&f); MPI_File_close(&f);
} }
......
...@@ -57,12 +57,10 @@ class field_descriptor ...@@ -57,12 +57,10 @@ class field_descriptor
* */ * */
int read( int read(
const char *fname, const char *fname,
void *buffer, void *buffer);
const char *datarep = "native");
int write( int write(
const char *fname, const char *fname,
void *buffer, void *buffer);
const char *datarep = "native");
/* a function that generates the transposed descriptor. /* a function that generates the transposed descriptor.
* don't forget to delete the result once you're done with it. * don't forget to delete the result once you're done with it.
...@@ -103,5 +101,17 @@ int fftwf_clip_zero_padding( ...@@ -103,5 +101,17 @@ int fftwf_clip_zero_padding(
field_descriptor *f, field_descriptor *f,
float *a); float *a);
inline float btle(const float be)
{
float le;
char *befloat = (char *) & be;
char *lefloat = (char *) & le;
lefloat[0] = befloat[3];
lefloat[1] = befloat[2];
lefloat[2] = befloat[1];
lefloat[3] = befloat[0];
return le;
}
#endif//FIELD_DESCRIPTOR #endif//FIELD_DESCRIPTOR
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:41b656323632ba5dd67fcd6f67d6e62ab479be1edf0adc21548c493eb5da9b1d" "signature": "sha256:966c6344a3d90cdf5a7423c96eebbfd82f41bd0e6556fcce769383cb4e93116c"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
...@@ -63,8 +63,16 @@ ...@@ -63,8 +63,16 @@
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"prompt_number": 20 {
"output_type": "stream",
"stream": "stderr",
"text": [
"-c:15: RuntimeWarning: divide by zero encountered in true_divide\n"
]
}
],
"prompt_number": 2
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -147,7 +155,7 @@ ...@@ -147,7 +155,7 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 56 "prompt_number": 3
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -200,7 +208,7 @@ ...@@ -200,7 +208,7 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 52 "prompt_number": 5
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -241,11 +249,11 @@ ...@@ -241,11 +249,11 @@
"text": [ "text": [
"0.0\n", "0.0\n",
"distance is small\n", "distance is small\n",
"14.9705\n" "14.4104\n"
] ]
} }
], ],
"prompt_number": 57 "prompt_number": 6
}, },
{ {
"cell_type": "code", "cell_type": "code",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment