Skip to content

Commit

Permalink
recorder: use plain char pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Aug 17, 2022
1 parent 94b3d94 commit 5597494
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pyxcp/recorder/build_clang.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
clang++ -std=c++20 -O3 -fvectorize -fexceptions -Rpass=loop-vectorize -ggdb -Wall -Wextra -Weffc++ -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder
clang++ -std=c++20 -O0 -fvectorize -fexceptions -Rpass=loop-vectorize -ggdb -Wall -Wextra -Weffc++ -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder.exe
2 changes: 1 addition & 1 deletion pyxcp/recorder/build_clang.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
clang++ -std=c++20 -O3 -fvectorize -Rpass=loop-vectorize -ggdb -Wall -Wextra -Weffc++-lpthread -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder
clang++ -std=c++20 -O0 -fvectorize -Rpass=loop-vectorize -ggdb -Wall -Wextra -Weffc++-lpthread -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder
2 changes: 1 addition & 1 deletion pyxcp/recorder/build_gcc.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
g++ -std=c++20 -O3 -ggdb -march=native -fexceptions -ffast-math -ftree-vectorize -msse4 -mfpmath=sse -pg -fopt-info-vec-all -Wall -Wextra -Weffc++ -fcoroutines -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder.exe
g++ -std=c++20 -O0 -ggdb -march=native -fexceptions -ffast-math -ftree-vectorize -msse4 -mfpmath=sse -pg -fopt-info-vec-all -Wall -Wextra -Weffc++ -fcoroutines -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder.exe
2 changes: 1 addition & 1 deletion pyxcp/recorder/build_gcc.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
g++ -std=c++20 -O3 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=9 -fcoroutines -ggdb -Wall -Wextra -Weffc++ -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder -lpthread
g++ -std=c++20 -O0 -ffast-math -ftree-vectorize -ftree-vectorizer-verbose=9 -fcoroutines -ggdb -Wall -Wextra -Weffc++ -DLZ4_DEBUG=1 -DSTANDALONE_REKORDER=1 lz4.cpp rekorder.cpp -o rekorder -lpthread
3 changes: 1 addition & 2 deletions pyxcp/recorder/rekorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ void some_records(XcpLogFileWriter& writer)
fr.timestamp = std::clock();
fr.length = 10 + (rand() % 240);
filler = (filler + 1) % 16;
printf("buffer: %p\n", buffer);
memset(buffer, filler, fr.length);
writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, reinterpret_cast<char*>(&buffer));
writer.add_frame(fr.category, fr.counter, fr.timestamp, fr.length, reinterpret_cast<char const*>(&buffer));
}
}

Expand Down
27 changes: 7 additions & 20 deletions pyxcp/recorder/rekorder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct frame_header_t
using FrameTuple = std::tuple<std::uint8_t, std::uint16_t, double, std::uint16_t, payload_t>;
using FrameVector = std::vector<FrameTuple>;

using FrameTupleWriter = std::tuple<std::uint8_t, std::uint16_t, double, std::uint16_t, std::shared_ptr<char[]>>;
using FrameTupleWriter = std::tuple<std::uint8_t, std::uint16_t, double, std::uint16_t, char *>;


enum class FrameCategory : std::uint8_t {
Expand Down Expand Up @@ -325,25 +325,12 @@ class XcpLogFileWriter
}

void add_frame(uint8_t category, uint16_t counter, double timestamp, uint16_t length, char const * data) {
auto pl = std::make_shared<char []>(length);
printf("data: %p length: %u\n", data, length);
_fcopy(pl.get(), data, length);
auto payload= new char[length];

my_queue.put(
std::make_tuple(category, counter, timestamp, length, std::move(pl))
_fcopy(payload, data, length);
my_queue.put(
std::make_tuple(category, counter, timestamp, length, payload)
);

#if 0
const frame_header_t frame {category, counter, timestamp, length};

store_im(&frame, sizeof(frame));
store_im(get_payload_ptr(payload), length);
m_container_record_count += 1;
m_container_size_uncompressed += (sizeof(frame) + length);
if (m_container_size_uncompressed > m_chunk_size) {
compress_frames();
}
#endif
}

protected:
Expand Down Expand Up @@ -439,8 +426,8 @@ class XcpLogFileWriter
const frame_header_t frame{ category, counter, timestamp, length };

store_im(&frame, sizeof(frame));
//store_im(get_payload_ptr(payload), length);
store_im(payload.get(), length);
store_im(payload, length);
delete[] payload;
m_container_record_count += 1;
m_container_size_uncompressed += (sizeof(frame) + length);
if (m_container_size_uncompressed > m_chunk_size) {
Expand Down

0 comments on commit 5597494

Please sign in to comment.