FPGA: work requests are consumed while host_writer not working

This commit is contained in:
2023-05-26 22:12:34 +02:00
parent b926e69885
commit c1212a14d9
7 changed files with 18 additions and 23 deletions

View File

@@ -49,9 +49,8 @@
#define DEFAULT_G2_FACTOR (-0.1145)
// For FPGA
/* This number is unique and is declared in ~snap/ActionTypes.md */
#define ACTION_TYPE 0x52324158
#define RELEASE_LEVEL 0x0035
#define RELEASE_LEVEL 0x0036
#define MODE_CONV 0x0001L
#define MODE_INTERNAL_PACKET_GEN 0x0002L

View File

@@ -126,6 +126,15 @@ void host_writer(STREAM_512 &data_in,
jf_bunchid[i] = 0;
}
ap_uint<32> req_handle;
ap_uint<64> req_host_offset;
while (data_in.empty()) {
#pragma HLS PIPELINE II=4
if (!s_axis_work_request.empty())
read_request(s_axis_work_request, req_handle, req_host_offset);
}
ap_uint<ADDR_STREAM_WIDTH> addr;
addr_in >> addr;
@@ -150,9 +159,6 @@ void host_writer(STREAM_512 &data_in,
packet_out.dest = 0;
packet_out.id = 0;
packet_out.user = 0;
ap_uint<32> req_handle;
ap_uint<64> req_host_offset;
Loop_good_packet:
while (!addr_last_flag(addr)) {
@@ -252,11 +258,4 @@ void host_writer(STREAM_512 &data_in,
data_in >> packet_in;
write_completion(m_axis_completion, HANDLE_END, 0, total_counter, 0, 0, 0, 0, 0, 0, data_collection_counter);
read_request(s_axis_work_request, req_handle, req_host_offset);
while (req_handle != UINT32_MAX) {
#pragma HLS PIPELINE II=4
read_request(s_axis_work_request, req_handle, req_host_offset);
}
}

View File

@@ -130,6 +130,8 @@ void AcquisitionDevice::StartAction(const DiffractionExperiment &experiment) {
if (c.type != Completion::Type::Start)
throw JFJochException(JFJochExceptionCategory::AcquisitionDeviceError, "Mismatch in completion queue");
StartSendingWorkRequests();
start_time = std::chrono::system_clock::now();
if (logger)

View File

@@ -40,8 +40,6 @@ class AcquisitionDevice {
AcquisitionOnlineCounters counters;
AcquisitionOfflineCounters completion_vector;
void EndWorkRequestAndSignalQueues();
virtual void HW_WriteActionRegister(const ActionConfig *job) = 0;
virtual void HW_ReadActionRegister(ActionConfig *job) = 0;
virtual void HW_StartAction() = 0;
@@ -56,6 +54,7 @@ class AcquisitionDevice {
virtual uint64_t HW_GetMACAddress() const = 0;
virtual void HW_EndAction() {}; // do clean-up after action is done
virtual void CopyInternalPacketGenFrameToDeviceBuffer();
virtual void StartSendingWorkRequests() {};
protected:
ThreadSafeFIFO<Completion> work_completion_queue;
ThreadSafeFIFO<WorkRequest> work_request_queue;

View File

@@ -5,11 +5,12 @@
void FPGAAcquisitionDevice::HW_StartAction() {
FPGA_StartAction();
read_work_completion_future = std::async(std::launch::async, &FPGAAcquisitionDevice::ReadWorkCompletionThread, this);
}
void FPGAAcquisitionDevice::StartSendingWorkRequests() {
stop_work_requests = false;
send_work_request_future = std::async(std::launch::async, &FPGAAcquisitionDevice::SendWorkRequestThread, this);
read_work_completion_future = std::async(std::launch::async, &FPGAAcquisitionDevice::ReadWorkCompletionThread, this);
}
void FPGAAcquisitionDevice::HW_EndAction() {
@@ -18,9 +19,6 @@ void FPGAAcquisitionDevice::HW_EndAction() {
stop_work_requests = true;
send_work_request_future.get();
while (!HW_SendWorkRequest(UINT32_MAX))
std::this_thread::sleep_for(std::chrono::microseconds(10));
FPGA_EndAction();
}

View File

@@ -22,6 +22,7 @@ class FPGAAcquisitionDevice : public AcquisitionDevice {
virtual bool HW_ReadMailbox(uint32_t values[16]) = 0;
virtual bool HW_SendWorkRequest(uint32_t handle) = 0;
void StartSendingWorkRequests() override;
protected:
explicit FPGAAcquisitionDevice(uint16_t data_stream) : AcquisitionDevice(data_stream) {}
};

View File

@@ -352,10 +352,7 @@ void HLSSimulatedDevice::HLSMainThread() {
if (!datamover_in.GetDataStream().empty())
throw std::runtime_error("Datamover queue is not empty");
if (!work_request_stream.empty())
throw std::runtime_error("Work request stream is not empty");
if (err_reg != 0)
if (err_reg != 0)
throw std::runtime_error("Error reg for frame_statistics not zero, val=" + std::to_string(err_reg));
while (!datamover_out.IsIdle())