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

add support for single process --- multiple files

parent a4d96433
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,8 @@ Morton_shuffler::Morton_shuffler( ...@@ -8,7 +8,8 @@ Morton_shuffler::Morton_shuffler(
int nfiles) int nfiles)
{ {
this->d = d; this->d = d;
if (nprocs % nfiles != 0) if ((nprocs % nfiles != 0) &&
(nfiles % nprocs != 0))
{ {
std::cerr << std::cerr <<
"Number of output files incompatible with number of processes.\n" "Number of output files incompatible with number of processes.\n"
...@@ -44,6 +45,13 @@ Morton_shuffler::Morton_shuffler( ...@@ -44,6 +45,13 @@ Morton_shuffler::Morton_shuffler(
//set up output file descriptor //set up output file descriptor
int out_rank, out_nprocs; int out_rank, out_nprocs;
out_nprocs = nprocs/nfiles; out_nprocs = nprocs/nfiles;
if (out_nprocs == 0)
{
out_nprocs = 1;
this->files_per_proc = nfiles / nprocs;
}
else
this->files_per_proc = 1;
this->out_group = myrank / out_nprocs; this->out_group = myrank / out_nprocs;
out_rank = myrank % out_nprocs; out_rank = myrank % out_nprocs;
n[0] = ((N0/8) * (N1/8) * (N2/8)) / nfiles; n[0] = ((N0/8) * (N1/8) * (N2/8)) / nfiles;
...@@ -128,11 +136,16 @@ int Morton_shuffler::shuffle( ...@@ -128,11 +136,16 @@ int Morton_shuffler::shuffle(
fftwf_free(rz); fftwf_free(rz);
char temp_char[200]; char temp_char[200];
sprintf(temp_char, for (int fcounter = 0; fcounter < this->files_per_proc; fcounter++)
"%s_z%.7x", {
base_fname, sprintf(temp_char,
this->out_group*this->doutput->sizes[0]); "%s_z%.7x",
this->doutput->write(temp_char, rtmp); base_fname,
(this->files_per_proc*this->out_group + fcounter)*this->doutput->sizes[0]);
this->doutput->write(
temp_char,
rtmp + fcounter*this->doutput->local_size);
}
fftwf_free(rtmp); fftwf_free(rtmp);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -61,7 +61,7 @@ class Morton_shuffler ...@@ -61,7 +61,7 @@ class Morton_shuffler
// communicator to use for output // communicator to use for output
MPI_Comm out_communicator; MPI_Comm out_communicator;
int out_group; int out_group, files_per_proc;
/* methods */ /* methods */
Morton_shuffler( Morton_shuffler(
......
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:e744ea7dc72564d6f526a0a73b97b6f43c1ccd7d5c6c2767d8b6c5a5ec7f4487" "signature": "sha256:bb9dddd64d9a5ac46de7f7d5ba2abecb7dd4bb75c76a6845ace376759bd57f78"
}, },
"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": 14 {
"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",
...@@ -148,13 +156,15 @@ ...@@ -148,13 +156,15 @@
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 15 "prompt_number": 3
}, },
{ {
"cell_type": "code", "cell_type": "code",
"collapsed": false, "collapsed": false,
"input": [ "input": [
"def compute_cpp_data(branch = None):\n", "def compute_cpp_data(\n",
" branch = None,\n",
" nfiles = 16):\n",
" if not (type(branch) == type(None)):\n", " if not (type(branch) == type(None)):\n",
" subprocess.call(['git', 'checkout', branch])\n", " subprocess.call(['git', 'checkout', branch])\n",
" if subprocess.call(['make', 'full.elf']) == 0:\n", " if subprocess.call(['make', 'full.elf']) == 0:\n",
...@@ -164,39 +174,41 @@ ...@@ -164,39 +174,41 @@
" 'time',\n", " 'time',\n",
" 'mpirun.mpich',\n", " 'mpirun.mpich',\n",
" '-np',\n", " '-np',\n",
" '32',\n", " '8',\n",
" './full.elf',\n", " './full.elf',\n",
" '{0}'.format(n),\n", " '{0}'.format(n),\n",
" '{0}'.format(N),\n", " '{0}'.format(N),\n",
" '2',\n", " '{0}'.format(nfiles),\n",
" '3'])\n", " '3'])\n",
" else:\n", " else:\n",
" print ('compilation error')\n", " print ('compilation error')\n",
" return None\n", " return None\n",
" \n", " \n",
"def get_cpp_data(branch = None, run = True):\n", "def get_cpp_data(\n",
" branch = None,\n",
" run = True,\n",
" nfiles = 16):\n",
" if run:\n", " if run:\n",
" subprocess.call(['rm',\n", " subprocess.call(['rm',\n",
" 'Rdata_z{0:0>7x}'.format(0),\n", " 'Rdata_z{0:0>7x}'.format(0),\n",
" 'Rdata_z{0:0>7x}'.format(Rdata_py.shape[0]//2)])\n", " 'Rdata_z{0:0>7x}'.format(Rdata_py.shape[0]//2)])\n",
" compute_cpp_data(branch)\n", " compute_cpp_data(branch, nfiles = nfiles)\n",
" Rdata0 = np.fromfile(\n", " Rdata = []\n",
" 'Rdata_z{0:0>7x}'.format(0),\n", " for nf in range(nfiles):\n",
" dtype = np.float32).reshape(-1, 8, 8, 8, 3)\n", " Rdata.append(np.fromfile(\n",
" Rdata1 = np.fromfile(\n", " 'Rdata_z{0:0>7x}'.format(nf*Rdata_py.shape[0]//nfiles),\n",
" 'Rdata_z{0:0>7x}'.format(Rdata_py.shape[0]//2),\n", " dtype = np.float32).reshape(-1, 8, 8, 8, 3))\n",
" dtype = np.float32).reshape(-1, 8, 8, 8, 3)\n", " return np.concatenate(Rdata)\n",
" return np.concatenate([Rdata0, Rdata1])\n",
"\n", "\n",
"#Rdata = get_cpp_data(branch = 'develop')\n", "#Rdata = get_cpp_data(branch = 'develop')\n",
"# develop says 30 secs, inplace fft is 28 secs\n", "# develop says 30 secs, inplace fft is 28 secs\n",
"#Rdata = get_cpp_data(branch = 'feature-inplace_fft')\n", "#Rdata = get_cpp_data(branch = 'feature-inplace_fft')\n",
"Rdata = get_cpp_data(run = True)" "Rdata = get_cpp_data(run = True, nfiles = 8)"
], ],
"language": "python", "language": "python",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"prompt_number": 16 "prompt_number": 8
}, },
{ {
"cell_type": "code", "cell_type": "code",
...@@ -237,7 +249,7 @@ ...@@ -237,7 +249,7 @@
] ]
} }
], ],
"prompt_number": 17 "prompt_number": 9
}, },
{ {
"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