enable lto

This commit is contained in:
Erik Frojdh 2019-04-08 14:57:10 +02:00
parent fad308754b
commit 39221f1230
5 changed files with 67 additions and 62 deletions

View File

@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.9)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0) set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
endif()
include(cmake/project_version.cmake) include(cmake/project_version.cmake)
@ -53,10 +61,14 @@ add_library(slsProjectWarnings INTERFACE)
target_compile_features(slsProjectOptions INTERFACE cxx_std_11) target_compile_features(slsProjectOptions INTERFACE cxx_std_11)
target_compile_options(slsProjectWarnings INTERFACE target_compile_options(slsProjectWarnings INTERFACE
-Wall -Wall
-Wextra
-Wno-unused-parameter #Needs to be slowly mitigated
# -Wold-style-cast
-Wnon-virtual-dtor -Wnon-virtual-dtor
-Woverloaded-virtual -Woverloaded-virtual
-Wdouble-promotion -Wdouble-promotion
-Wformat=2 -Wformat=2
-Wredundant-decls
) )

View File

@ -35,43 +35,49 @@ std::ostream &operator<<(std::ostream &out, const ROI &r) {
} }
int main() { int main() {
// uint32_t imageSize = 101;
// uint32_t packetSize = 100;
// std::cout << "a: " << std::ceil((double)imageSize / (double)packetSize) <<'\n';
// std::cout << "b: " << imageSize / packetSize <<'\n';
// std::cout << "c: " << static_cast<double>(imageSize / packetSize) << '\n';
// std::cout << "c: " << (imageSize + packetSize-1) / packetSize << '\n';
slsDetectorDefs::ROI roilimits[5]; // slsDetectorDefs::ROI roilimits[5];
roilimits[0].xmin = 5; // roilimits[0].xmin = 5;
roilimits[0].xmax = 12; // roilimits[0].xmax = 12;
roilimits[0].ymin = 5; // roilimits[0].ymin = 5;
roilimits[0].ymax = 15; // roilimits[0].ymax = 15;
roilimits[1].xmin = 0; // roilimits[1].xmin = 0;
roilimits[1].xmax = 3; // roilimits[1].xmax = 3;
roilimits[1].ymin = 20; // roilimits[1].ymin = 20;
roilimits[1].ymax = 25; // roilimits[1].ymax = 25;
roilimits[2].xmin = 500; // roilimits[2].xmin = 500;
roilimits[2].xmax = 600; // roilimits[2].xmax = 600;
roilimits[2].ymin = 100; // roilimits[2].ymin = 100;
roilimits[2].ymax = 200; // roilimits[2].ymax = 200;
roilimits[3].xmin = 300; // roilimits[3].xmin = 300;
roilimits[3].xmax = 500; // roilimits[3].xmax = 500;
roilimits[3].ymin = 800; // roilimits[3].ymin = 800;
roilimits[3].ymax = 900; // roilimits[3].ymax = 900;
roilimits[4].xmin = 1000; // roilimits[4].xmin = 1000;
roilimits[4].xmax = 2000; // roilimits[4].xmax = 2000;
roilimits[4].ymin = 300; // roilimits[4].ymin = 300;
roilimits[4].ymax = 500; // roilimits[4].ymax = 500;
std::cout << "Before sorting:\n"; // std::cout << "Before sorting:\n";
for (auto r : roilimits) { // for (auto r : roilimits) {
std::cout << r << '\n'; // std::cout << r << '\n';
} // }
std::sort(std::begin(roilimits), std::end(roilimits), // std::sort(std::begin(roilimits), std::end(roilimits),
[](ROI a, ROI b) { return a.xmin < b.xmin; }); // [](ROI a, ROI b) { return a.xmin < b.xmin; });
std::cout << "After sorting: \n"; // std::cout << "After sorting: \n";
for (auto r : roilimits) { // for (auto r : roilimits) {
std::cout << r << '\n'; // std::cout << r << '\n';
} // }
} }

View File

@ -279,7 +279,7 @@ class SharedMemory {
} }
//size does not match //size does not match
long unsigned int sz = (long unsigned int)sb.st_size; auto sz = static_cast<size_t>(sb.st_size);
if (sz != expectedSize) { if (sz != expectedSize) {
std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz); std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz);
FILE_LOG(logERROR) << msg; FILE_LOG(logERROR) << msg;

View File

@ -10,7 +10,7 @@
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include "logger.h" #include "logger.h"
#include <math.h> //ceil #include <cmath> //ceil
#include <vector> #include <vector>
@ -706,7 +706,7 @@ public:
dataSize = 8192; dataSize = 8192;
packetSize = headerSizeinPacket + dataSize; packetSize = headerSizeinPacket + dataSize;
imageSize = nPixelsX * nPixelsY * 2; imageSize = nPixelsX * nPixelsY * 2;
packetsPerFrame = ceil((double)imageSize / (double)packetSize); packetsPerFrame = (imageSize + packetSize - 1) / packetSize;
standardheader = false; standardheader = false;
} }
// 1g udp (via fifo readout) // 1g udp (via fifo readout)
@ -715,8 +715,8 @@ public:
dataSize = UDP_PACKET_DATA_BYTES; dataSize = UDP_PACKET_DATA_BYTES;
packetSize = headerSizeinPacket + dataSize; packetSize = headerSizeinPacket + dataSize;
imageSize = nPixelsX * nPixelsY * 2; imageSize = nPixelsX * nPixelsY * 2;
packetsPerFrame = ceil((double)imageSize / (double)UDP_PACKET_DATA_BYTES); packetsPerFrame = (imageSize + UDP_PACKET_DATA_BYTES - 1) / UDP_PACKET_DATA_BYTES;
standardheader = true; standardheader = true;
} }
} }
}; };

View File

@ -11,14 +11,6 @@
TEST_CASE("Parse jungfrauctb header", "[receiver]") { TEST_CASE("Parse jungfrauctb header", "[receiver]") {
// typedef struct {
// unsigned char emptyHeader[6];
// unsigned char reserved[4];
// unsigned char packetNumber[1];
// unsigned char frameNumber[3];
// unsigned char bunchid[8];
// } jfrauctb_packet_header_t;
struct packet { struct packet {
unsigned char emptyHeader[6]; unsigned char emptyHeader[6];
unsigned char reserved[4]; unsigned char reserved[4];
@ -29,26 +21,21 @@ TEST_CASE("Parse jungfrauctb header", "[receiver]") {
} __attribute__((packed)); } __attribute__((packed));
MoenchData data; MoenchData data;
// GetHeaderInfo(int index, char *packetData, uint32_t dynamicRange,
// bool oddStartingPacket, uint64_t &frameNumber,
// uint32_t &packetNumber, uint32_t &subFrameNumber,
// uint64_t &bunchId)
packet test_packet; packet test_packet;
test_packet.packetNumber[0] = (unsigned char)53; test_packet.packetNumber[0] = 53u;
test_packet.frameNumber[0] = (unsigned char)32; test_packet.frameNumber[0] = 32u;
test_packet.frameNumber[1] = (unsigned char)15; test_packet.frameNumber[1] = 15u;
test_packet.frameNumber[2] = (unsigned char)91; test_packet.frameNumber[2] = 91u;
test_packet.bunchid[0] = (unsigned char)91; test_packet.bunchid[0] = 91u;
test_packet.bunchid[1] = (unsigned char)25; test_packet.bunchid[1] = 25u;
test_packet.bunchid[2] = (unsigned char)15; test_packet.bunchid[2] = 15u;
test_packet.bunchid[3] = (unsigned char)1; test_packet.bunchid[3] = 1u;
test_packet.bunchid[4] = (unsigned char)32; test_packet.bunchid[4] = 32u;
test_packet.bunchid[5] = (unsigned char)251; test_packet.bunchid[5] = 251u;
test_packet.bunchid[6] = (unsigned char)18; test_packet.bunchid[6] = 18u;
test_packet.bunchid[7] = (unsigned char)240; test_packet.bunchid[7] = 240u;
int index = 0; int index = 0;
char *packetData = reinterpret_cast<char *>(&test_packet); char *packetData = reinterpret_cast<char *>(&test_packet);