Skip to content

Commit

Permalink
Merge pull request #1712 from pace-neutrons/1700_bin_writer
Browse files Browse the repository at this point in the history
1700 bin writer
  • Loading branch information
abuts committed Aug 30, 2024
2 parents 3af77a9 + 36d9bb3 commit 792422e
Show file tree
Hide file tree
Showing 73 changed files with 49,485 additions and 48,598 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ project("Horace" VERSION "${_version}")
#
cmake_host_system_information(RESULT CMAKE_HOST_SYSTEM_NAME QUERY OS_NAME)

# C++11 is required for GTest
set(CMAKE_CXX_STANDARD 11)
# C++11 is required for GTest but 17 for some plugins
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

# Sort our targets into folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down
2 changes: 2 additions & 0 deletions _LowLevelCode/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ set(MEX_FUNCTIONS
"compute_pix_sums"
"mtimesx_horace"
"sort_pixels_by_bins"
"mex_bin_plugin"
"file_parameters"
${HDF_READER}
)
foreach(_mex_func ${MEX_FUNCTIONS})
Expand Down
4 changes: 2 additions & 2 deletions _LowLevelCode/cpp/combine_sqw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ set(
SRC_FILES
"combine_sqw.cpp"
"exchange_buffer.cpp"
"fileParameters.cpp"
"nsqw_pix_reader.cpp"
"pix_mem_map.cpp"
"sqw_pix_writer.cpp"
"sqw_reader.cpp"
"../file_parameters/fileParameters.cpp"
)

set(
HDR_FILES
"../CommonCode.h"
"../file_parameters/fileParameters.h"
"combine_sqw.h"
"exchange_buffer.h"
"fileParameters.h"
"nsqw_pix_reader.h"
"pix_mem_map.h"
"sqw_pix_writer.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class TestCombineSQW : public CxxTest::TestSuite {
sqw_reader reader;
fileParameters file_par;
file_par.fileName = test_file_name;
file_par.file_id = 0;
file_par.run_id = 0;
file_par.nbin_start_pos = bin_pos_in_file;
file_par.pix_start_pos = pix_pos_in_file;
file_par.total_NfileBins = num_bin_in_file;
Expand Down
12 changes: 6 additions & 6 deletions _LowLevelCode/cpp/combine_sqw/combine_sqw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "nsqw_pix_reader.h"
#include "sqw_pix_writer.h"
#include "../utility/version.h"
#include "../file_parameters/fileParameters.h"

#include <memory>
#include <stdio.h>
Expand Down Expand Up @@ -37,16 +38,16 @@ enum OutputArguments { // unique output arguments,
"npix_start_pos" -- the location of the beginning of the npix data in the binary file
(output of ftellg(fid) or of fseek(fid, npix_start_pos)
"pix_start_pos" -- the location of the beginning of the pix data in the binary file. Similar to npix
"file_id" -- number of pixel (pixel ID) distinguishing the pixels, obtained from this run from
all other pixels in combined sqw file.
"run_id" -- the number (pixel ID) distinguishing the pixels, obtained from a particular run from
pixels generated retrieved from other runs in combined sqw file.
"nbins_total" -- number of bins stored in single data file
%
% 2) outFileParams -- structure, which defines the parameters for the pixels to write.
The structure is similar to the one used for inFileParams but some fields are undefined.
The fields need to be defined are file_name, npix_start_pos and pix_start_pos.
The undefined fields are file_id and nbins_total
The undefined fields are run_id and nbins_total
nbins_total is calculated from nbins_total of the input files and file id
is the combination of file_ids of input files to can not be unique or defined.
is the combination of run_ids of input files to can not be unique or defined.
%
% 3) programSettings -- array of parameters defining the file combine process, namely:
% n_bin -- number of bins in the image array
Expand Down Expand Up @@ -269,7 +270,7 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
std::vector<sqw_reader> fileReader(n_files);
for (size_t i = 0; i < n_files; i++) {
if (change_fileno && !fileno_provided) { // renumbering pixel id-s with file number
fileParam[i].file_id = int(i + 1); // file numbers in Matlab start from 1 so adhere to this convention
fileParam[i].run_id = int(i + 1); // file numbers in Matlab start from 1 so adhere to this convention
}
fileReader[i].init(fileParam[i], change_fileno,read_buf_size, read_files_multitreaded);
}
Expand Down Expand Up @@ -314,4 +315,3 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
}
fileReader.clear();
}

7 changes: 1 addition & 6 deletions _LowLevelCode/cpp/combine_sqw/combine_sqw.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef H_COMBINE_SQW
#define H_COMBINE_SQW
#pragma once
#include "nsqw_pix_reader.h"
#include "sqw_pix_writer.h"

Expand All @@ -11,7 +10,3 @@ enum readBinInfoOption {
sumPixInfo,
keepPixInfo
};


#endif

75 changes: 0 additions & 75 deletions _LowLevelCode/cpp/combine_sqw/fileParameters.cpp

This file was deleted.

32 changes: 0 additions & 32 deletions _LowLevelCode/cpp/combine_sqw/fileParameters.h

This file was deleted.

9 changes: 2 additions & 7 deletions _LowLevelCode/cpp/combine_sqw/sqw_pix_writer.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef H_SQW_PIX_WRITER
#define H_SQW_PIX_WRITER

#pragma once
//#include "pix_mem_map.h"
#include "fileParameters.h"
#include "../file_parameters/fileParameters.h"
#include "exchange_buffer.h"

//-----------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -37,7 +35,4 @@ class sqw_pix_writer {
//
static const size_t PIX_BLOCK_SIZE_BYTES = 36; //9 * 4; // size of the pixel block in bytes


};

#endif
8 changes: 4 additions & 4 deletions _LowLevelCode/cpp/combine_sqw/sqw_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sqw_reader::sqw_reader() :
{}

sqw_reader::~sqw_reader() {
//mexPrintf("|MEX::COMBINE_SQW: in destructor for file N %d |",this->fileDescr.file_id);
//mexPrintf("|MEX::COMBINE_SQW: in destructor for file N %d |",this->fileDescr.run_id);
//mexEvalString("pause(.002);");

this->finish_read_job();
Expand Down Expand Up @@ -310,7 +310,7 @@ void sqw_reader::read_pixels_job() {
}
//
void sqw_reader::finish_read_job() {
//mexPrintf("|MEX::COMBINE_SQW: in finish read job for file N %d |",this->fileDescr.file_id);
//mexPrintf("|MEX::COMBINE_SQW: in finish read job for file N %d |",this->fileDescr.run_id);
//mexEvalString("pause(.002);");

this->pix_map.finish_read_bin_job();
Expand All @@ -334,7 +334,7 @@ void sqw_reader::finish_read_job() {
}
this->read_pix_needed.notify_one();
read_pix_job_holder.join();
//mexPrintf(" completed pix read job|\n",this->fileDescr.file_id);
//mexPrintf(" completed pix read job|\n",this->fileDescr.run_id);
//mexEvalString("pause(.002);");

}
Expand Down Expand Up @@ -364,7 +364,7 @@ void sqw_reader::_read_pix(size_t pix_start_num, float *const pix_buffer, size_t

if (this->change_fileno) {
for (size_t i = 0; i < num_pix_to_read; i++) {
*(pix_buffer + 4 + i * 9) = float(this->fileDescr.file_id);
*(pix_buffer + 4 + i * 9) = float(this->fileDescr.run_id);
}

}
Expand Down
6 changes: 3 additions & 3 deletions _LowLevelCode/cpp/combine_sqw/sqw_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define H_SQW_READER

#include "pix_mem_map.h"
#include "fileParameters.h"
#include "../file_parameters/fileParameters.h"
//-----------------------------------------------------------------------------------------------------------------
class sqw_reader
{
Expand Down Expand Up @@ -54,8 +54,8 @@ class sqw_reader
size_t PIX_BUF_SIZE;
//Boolean indicating that the id, which specify pixel run number should be modified
bool change_fileno;
// Boolean, indicating if one needs to offset pixel's run number id by fileDescr.file_id
// or set up its value into fileDescr.file_id;
// Boolean, indicating if one needs to offset pixel's run number id by fileDescr.run_id
// or set up its value into fileDescr.run_id;
bool fileno;

static const size_t PIX_SIZE = 9; // size of the pixel in pixel data units (float)
Expand Down
3 changes: 2 additions & 1 deletion _LowLevelCode/cpp/cpp_communicator/cpp_communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
#include "MPI_wrapper.h"
#include "input_parser.h"

void set_numlab_and_nlabs(class_handle<MPI_wrapper> * const pCommunicatorHolder, int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]);
void set_numlab_and_nlabs(class_handle<MPI_wrapper> * const pCommunicatorHolder,
int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]);
24 changes: 24 additions & 0 deletions _LowLevelCode/cpp/file_parameters/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The project builds tester application for fileParameters
# The class itself is used elsewhere
set(
SRC_FILES
"fileParameters.cpp"
"file_parameters_tester.cpp"
)

set(
HDR_FILES
"../CommonCode.h"
"fileParameters.h"
)

set(MEX_NAME "file_parameters_tester")
pace_add_mex(
NAME "${MEX_NAME}"
SRC "${SRC_FILES}" "${HDR_FILES}"
)
# openmp is currently disabled here but it may be used in a future
#if(${OPENMP_FOUND})
# target_compile_options("${MEX_NAME}" PRIVATE ${OpenMP_CXX_FLAGS})
# target_link_options("${MEX_NAME}" PRIVATE ${OpenMP_EXE_LINKER_FLAGS})
#endif()
Loading

0 comments on commit 792422e

Please sign in to comment.