From 64f8928b23c77dd83d4f4a85eef2848d1a01b074 Mon Sep 17 00:00:00 2001 From: Kami Date: Mon, 18 Nov 2024 18:17:22 +0800 Subject: [PATCH] difftest: Turn off h2c when it is not needed --- src/test/csrc/common/mpool.h | 1 + src/test/csrc/fpga/xdma.cpp | 6 ++++-- src/test/csrc/fpga/xdma.h | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/csrc/common/mpool.h b/src/test/csrc/common/mpool.h index 59f2fe445..25fe02c8b 100644 --- a/src/test/csrc/common/mpool.h +++ b/src/test/csrc/common/mpool.h @@ -146,6 +146,7 @@ class MemoryIdxPool { // Wait mempool have data void wait_mempool_start(); + private: MemoryBlock memory_pool[NUM_BLOCKS]; // Mempool std::mutex window_mutexes; // window sliding protection diff --git a/src/test/csrc/fpga/xdma.cpp b/src/test/csrc/fpga/xdma.cpp index 1c78cacac..52e1a0070 100644 --- a/src/test/csrc/fpga/xdma.cpp +++ b/src/test/csrc/fpga/xdma.cpp @@ -42,7 +42,7 @@ FpgaXdma::FpgaXdma(const char *workload) { } std::cout << "XDMA link " << c2h_device << std::endl; } - +#ifdef CONFIG_USE_XDMA_H2C xdma_h2c_fd = open(XDMA_H2C_DEVICE, O_WRONLY); if (xdma_h2c_fd == -1) { std::cout << XDMA_H2C_DEVICE << std::endl; @@ -50,6 +50,7 @@ FpgaXdma::FpgaXdma(const char *workload) { exit(-1); } std::cout << "XDMA link " << XDMA_H2C_DEVICE << std::endl; +#endif } void FpgaXdma::handle_sigint(int sig) { @@ -127,8 +128,9 @@ void FpgaXdma::stop_thansmit_thread() { if (process_thread.joinable()) process_thread.join(); - +#ifdef CONFIG_USE_XDMA_H2C close(xdma_h2c_fd); +#endif xdma_mempool.cleanupMemoryPool(); } diff --git a/src/test/csrc/fpga/xdma.h b/src/test/csrc/fpga/xdma.h index 17749d976..0b2ff5da1 100644 --- a/src/test/csrc/fpga/xdma.h +++ b/src/test/csrc/fpga/xdma.h @@ -75,7 +75,9 @@ class FpgaXdma { std::thread process_thread; int xdma_c2h_fd[CONFIG_DMA_CHANNELS]; +#ifdef CONFIG_USE_XDMA_H2C int xdma_h2c_fd; +#endif static void handle_sigint(int sig); };