-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdmaTestServer.main.cpp
51 lines (34 loc) · 1.26 KB
/
rdmaTestServer.main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Created by jonas on 08.04.21.
//
#include "fmt/format.h"
#include <thread>
#include <opencv2/opencv.hpp>
#include "rdmaLib.hpp"
#include "RDMAServer.hpp"
#include <csignal>
volatile bool done = false;
std::unique_ptr<RDMAServer> s = nullptr;
void intHandler(int sig) {
fmt::print("Signal received! {}\n", sig);
s.reset();
done = true;
}
void receiveCB(Buffer<char> &&b) {
auto start = std::chrono::high_resolution_clock::now();
cv::Mat inputMatrix(HEIGHT, WIDTH, CV_8UC1, (void *) b.data());
Buffer<char> sendB = s->getSendBuffer();
cv::Mat outputMatrix(HEIGHT, WIDTH, CV_8UC1, (void *) sendB.data());
cv::GaussianBlur(inputMatrix, outputMatrix, cv::Size(0, 0), 5);
auto time = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - start);
fmt::print("Calculation took {}ms\n", time.count());
s->send(std::move(sendB));
}
int main(int argc, char *argv[]) {
s = std::make_unique<RDMAServer>(42069, BUFFER_SIZE, BUFFER_SIZE, []() { fmt::print("Client connected\n"); },
&receiveCB);
signal(SIGINT, intHandler);
signal(SIGTERM, intHandler);
while (not done) { std::this_thread::sleep_for(std::chrono::milliseconds(500)); }
return 0;
}