Commit 58f84368 authored by Jason Wu's avatar Jason Wu
Browse files

add global defined varibles

parent 0972c6d0
Pipeline #92296 failed with stages
in 1 minute and 27 seconds
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_EDDPOLNMERGE10TO8_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_EDDPOLNMERGE10TO8_HPP
#define HEAP_SIZE_10BIT = 5120
#include "psrdada_cpp/dada_write_client.hpp"
#include "psrdada_cpp/raw_bytes.hpp"
#include "psrdada_cpp/common.hpp"
......
#ifndef PSRDADA_CPP_EFFELSBERG_EDD_DADA_DISK_SINK_LEAP_HPP
#define PSRDADA_CPP_EFFELSBERG_EDD_DADA_DISK_SINK_LEAP_HPP
#define HEADER_SIZE 4096
#define START_TIME 1024
#define HEAP_SIZE 32000
#include "psrdada_cpp/raw_bytes.hpp"
#include "psrdada_cpp/common.hpp"
#include "psrdada_cpp/dada_write_client.hpp"
......@@ -21,8 +23,8 @@ public:
std::string _prefix;
std::size_t _counter;
int _nchan;
char _header[4096];
char _start_time[1024];
char _header[HEADER_SIZE];
char _start_time[START_TIME];
bool first_block;
std::vector<char> _transpose;
std::vector<std::ofstream> _output_streams;
......
......@@ -19,15 +19,15 @@ uint64_t interleave(uint32_t x, uint32_t y) {
void merge2pol(char const *buf, char *out)
{
uint8_t *qword0 = (uint8_t*)(buf);
uint8_t *qword1 = (uint8_t*)(buf) + 4096;
uint8_t *qword1 = (uint8_t*)(buf) + _nsamps_per_heap;
uint64_t* D = reinterpret_cast<uint64_t*>(out);
for (int i = 0; i < 4096 / 4; i++)
for (int i = 0; i < _nsamps_per_heap / sizeof(uint32_t); i++)
{
uint32_t* S0 = reinterpret_cast<uint32_t*>(qword0);
uint32_t* S1 = reinterpret_cast<uint32_t*>(qword1);
*D++ = interleave(*S1++, *S0++);
qword0 += 4;
qword1 += 4;
qword0 += sizeof(uint32_t);
qword1 += sizeof(uint32_t);
}
}
......
......@@ -159,7 +159,7 @@ void EDDPolnMerge10to8::init(RawBytes& block)
bool EDDPolnMerge10to8::operator()(RawBytes& block)
{
std::cout << "Beginning of the operator" << std::endl;
std: size_t nheap_groups = 0.8 * block.used_bytes() / _npol / _nsamps_per_heap;
std: size_t nheap_groups = block.used_bytes() / _npol / HEAP_SIZE_10BIT;
RawBytes& oblock = _writer.data_stream().next();
// if (block.used_bytes() > oblock.total_bytes())
......@@ -173,12 +173,12 @@ std: size_t nheap_groups = 0.8 * block.used_bytes() / _npol / _nsamps_per_heap;
BOOST_LOG_TRIVIAL(debug) << "Entering unpack loop";
#pragma omp parallel for schedule(dynamic, _nthreads) num_threads(_nthreads)
for (std::size_t kk = 0; kk < block.used_bytes() / 5120 / 2 ; ++kk)
for (std::size_t kk = 0; kk < block.used_bytes() / HEAP_SIZE_10BIT / _npol ; ++kk)
{
char *buffer = block.ptr() + 5120 * 2 * kk;
handle_packet_numbers_4096x10_s(buffer, oblock.ptr() + kk * 8192);
char *buffer = block.ptr() + HEAP_SIZE_10BIT * _npol * kk;
handle_packet_numbers_4096x10_s(buffer, oblock.ptr() + kk * _nsamps_per_heap * _npol);
}
oblock.used_bytes(block.used_bytes() * 0.8);
oblock.used_bytes(block.used_bytes() * _nsamps_per_heap / HEAP_SIZE_10BIT);
//oblock.used_bytes(block.used_bytes());
_writer.data_stream().release();
return false;
......
......@@ -38,7 +38,7 @@ bool DiskSinkLeap::operator()(RawBytes& block)
of.close();
}
}
std::size_t heap_size = 32000;
std::size_t heap_size = HEAP_SIZE;
int fstart = 1340;
std::size_t nheap_groups = block.used_bytes() / heap_size / _nchan;
_transpose.resize(block.used_bytes());
......@@ -54,8 +54,8 @@ bool DiskSinkLeap::operator()(RawBytes& block)
#pragma omp parallel for num_threads(_nchan)
for (std::size_t ii = 0; ii < _nchan; ++ii) {
std::size_t index = ii * heap_size * nheap_groups;
char _loop_header[4096];
std::memcpy(&_loop_header, &_header, 4096);
char _loop_header[HEADER_SIZE];
std::memcpy(&_loop_header, &_header, HEADER_SIZE);
ascii_header_set(_loop_header, "FREQ", "%d", fstart + 16 * ii);
ascii_header_set(_loop_header, "OBS_OFFSET", "%ld", _counter);
ascii_header_set(_loop_header, "FILE_SIZE", "%ld", 640000000);
......@@ -63,7 +63,7 @@ bool DiskSinkLeap::operator()(RawBytes& block)
fname << _start_time << "_" << fstart + 16 * ii << "_" << std::setw(20) << std::setfill('0') << _counter << ".dada";
BOOST_LOG_TRIVIAL(debug) << "filename" << fname.str();
_output_streams[ii].open(fname.str().c_str(), std::ios::out | std::ios::app | std::ios::binary);
_output_streams[ii].write((char*) _loop_header, 4096);
_output_streams[ii].write((char*) _loop_header, HEADER_SIZE);
_output_streams[ii].write(&_transpose[index], heap_size * nheap_groups);
}
_counter += heap_size * nheap_groups;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment