Skip to content

Commit

Permalink
difftest: Turn off h2c when it is not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaokamikami committed Nov 19, 2024
1 parent fcc98c7 commit 64f8928
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/test/csrc/common/mpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/test/csrc/fpga/xdma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ 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;
perror("Failed to open XDMA device");
exit(-1);
}
std::cout << "XDMA link " << XDMA_H2C_DEVICE << std::endl;
#endif
}

void FpgaXdma::handle_sigint(int sig) {
Expand Down Expand Up @@ -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();
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/csrc/fpga/xdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 64f8928

Please sign in to comment.