Commit d0bbd449 authored by Mitch Burnett's avatar Mitch Burnett
Browse files

Fixes to pfb corr mode. The GPU needed to flush the buffer that stores the...

Fixes to pfb corr mode. The GPU needed to flush the buffer that stores the last filter length worth of data. Also added new clean up logic lat waits until the net_thread has gone to the idle state. Also added a method for most threads that looks at the amount of locked blocks extending a hashpipe function
parent dafece46
......@@ -124,6 +124,13 @@ int runPFB(signed char* inputData_h, float* outputData_h, params pfbParams) {
}
void flushBuffer(params pfbParams) {
int start = pfbParams.fine_channels*pfbParams.elements*pfbParams.nfft*pfbParams.taps;
CUDASafeCallWithCleanUp(cudaMemset((void *) g_pc2Data_d, 0, start*2*sizeof(char)));
return;
}
// return true or false upon successful setup.
int initPFB(int iCudaDevice, params pfbParams){
......
......@@ -56,5 +56,6 @@ int runPFB(signed char* inputData_h, float* outputData_h, params pfbParams);
int doFFT();
int resetDevice(void);
void cleanUp(void);
void flushBuffer(params pfbParams);
#endif
......@@ -117,7 +117,7 @@ static void * run(hashpipe_thread_args_t * args) {
// Print out the header information for this block
flag_gpu_input_header_t tmp_header;
memcpy(&tmp_header, &db_in->block[curblock_in].header, sizeof(flag_gpu_input_header_t));
//printf("COR: Received block %d, starting mcnt = %lld\n", curblock_in, (long long int)tmp_header.mcnt);
//printf("COR: Received block %d, starting mcnt = %lld\n", curblock_in, (long long int)tmp_header.mcnt);
good_data &= tmp_header.good_data;
hashpipe_status_lock_safe(&st);
hputi4(st.buf, "CORMCNT", tmp_header.mcnt);
......@@ -151,8 +151,8 @@ static void * run(hashpipe_thread_args_t * args) {
// Check to see if block's starting mcnt matches INTSYNC
if (db_in->block[curblock_in].header.mcnt < start_mcnt) {
// If we get here, then there is a bug since the net thread shouldn't
// mark blocks as filled that are before the starting mcnt
// If we get here, then there is a bug since the net thread shouldn't
// mark blocks as filled that are before the starting mcnt
// fprintf(stderr, "COR: Unable to start yet... waiting for mcnt = %lld\n", (long long int)start_mcnt);
// starting mcnt not yet reached
......@@ -163,7 +163,9 @@ static void * run(hashpipe_thread_args_t * args) {
}
else if (db_in->block[curblock_in].header.mcnt == start_mcnt) {
// set correlator integrator to "on"
// fprintf(stderr, "COR: Starting correlator!\n");
#if VERBOSE
fprintf(stderr, "COR: Starting correlator!\n");
#endif
strcpy(integ_status, "on");
float requested_integration_time = 0.0;
float actual_integration_time = 0.0;
......@@ -185,7 +187,7 @@ static void * run(hashpipe_thread_args_t * args) {
}
else {
// fprintf(stdout, "COR: We missed the start of the integration\n");
fprintf(stdout, "COR: Missed start. Expected start_mcnt = %lld, got %lld\n", (long long int)start_mcnt, (long long int)db_in->block[curblock_in].header.mcnt);
fprintf(stdout, "COR: Missed start. Expected start_mcnt = %lld, got %lld\n", (long long int)start_mcnt, (long long int)db_in->block[curblock_in].header.mcnt);
// we apparently missed the start of the integation... ouch...
}
}
......@@ -201,7 +203,15 @@ static void * run(hashpipe_thread_args_t * args) {
context.output_offset = curblock_out * sizeof(flag_gpu_correlator_output_block_t) / sizeof(Complex);
int doDump = 0;
if ((db_in->block[curblock_in].header.mcnt + int_count*Nm - 1) >= last_mcnt) {
if ((db_in->block[curblock_in].header.mcnt + Nm - 1) >= last_mcnt) {
#if VERBOSE
printf("COR: Setting dump\n\t last_mcnt=%lld\n\t int_count=%d\n\t rx_mcnt=%lld\n\t Nm=%d\n",
(long long int)last_mcnt,
int_count,
(long long int)(db_in->block[curblock_in].header.mcnt),
Nm);
#endif
doDump = 1;
// Wait for new output block to be free
......
......@@ -107,7 +107,6 @@ int flag_pfb_gpu_input_databuf_set_filled(flag_pfb_gpu_input_databuf_t * d, int
hashpipe_databuf_t * flag_gpu_correlator_output_databuf_create(int instance_id, int databuf_id) {
size_t header_size = sizeof(hashpipe_databuf_t) + sizeof(hashpipe_databuf_cache_alignment);
size_t block_size = sizeof(flag_gpu_correlator_output_block_t);
......@@ -181,6 +180,25 @@ int flag_pfb_gpu_correlator_output_databuf_set_filled(flag_pfb_gpu_correlator_ou
return hashpipe_databuf_set_filled((hashpipe_databuf_t *)d, block_id);
}
int flag_pfb_gpu_correlator_output_databuf_total_status(flag_pfb_gpu_correlator_output_databuf_t * d) {
return hashpipe_databuf_total_status((hashpipe_databuf_t *)d);
}
int flag_gpu_pfb_output_databuf_total_status(flag_gpu_pfb_output_databuf_t * d) {
return hashpipe_databuf_total_status((hashpipe_databuf_t *)d);
}
int flag_pfb_gpu_input_databuf_total_status(flag_pfb_gpu_input_databuf_t * d) {
return hashpipe_databuf_total_status((hashpipe_databuf_t *) d);
}
int flag_input_databuf_total_status(flag_input_databuf_t * d) {
return hashpipe_databuf_total_status((hashpipe_databuf_t *) d);
}
int flag_gpu_correlator_output_databuf_total_status(flag_gpu_correlator_output_databuf_t * d) {
return hashpipe_databuf_total_status((hashpipe_databuf_t *) d);
}
hashpipe_databuf_t * flag_gpu_beamformer_output_databuf_create(int instance_id, int databuf_id) {
size_t header_size = sizeof(hashpipe_databuf_t) + sizeof(hashpipe_databuf_cache_alignment);
......
......@@ -8,7 +8,7 @@
#include "pfb.h"
#include "config.h"
#define VERBOSE 0
#define VERBOSE 0
#define SAVE 0
// Total number of antennas (nominally 40)
......@@ -162,7 +162,7 @@ typedef uint8_t hashpipe_databuf_cache_alignment[
* It is the input buffer of the flag_transpose_thread.
*/
#define N_INPUT_BLOCKS 100
#define N_INPUT_BLOCKS 4
// A typedef for a block header
typedef struct flag_input_header {
......@@ -423,6 +423,14 @@ int flag_pfb_gpu_correlator_output_databuf_wait_filled (flag_pfb_gpu_correlator_
int flag_pfb_gpu_correlator_output_databuf_set_free (flag_pfb_gpu_correlator_output_databuf_t * d, int block_id);
int flag_pfb_gpu_correlator_output_databuf_set_filled (flag_pfb_gpu_correlator_output_databuf_t * d, int block_id);
int flag_pfb_gpu_correlator_output_databuf_total_status (flag_pfb_gpu_correlator_output_databuf_t * d);
int flag_gpu_pfb_output_databuf_total_status (flag_gpu_pfb_output_databuf_t * d);
int flag_pfb_gpu_input_databuf_total_status(flag_pfb_gpu_input_databuf_t * d);
int flag_gpu_correlator_output_databuf_total_status(flag_gpu_correlator_output_databuf_t * d);
int flag_input_databuf_total_status(flag_input_databuf_t * d);
hashpipe_databuf_t * flag_gpu_beamformer_output_databuf_create(int instance_id, int databuf_id);
int flag_gpu_beamformer_output_databuf_wait_free (flag_gpu_beamformer_output_databuf_t * d, int block_id);
......
......@@ -109,8 +109,8 @@ void print_pkt_header(packet_header_t * pkt_header) {
static long long prior_mcnt;
printf("packet header : mcnt %012lx (diff from prior %lld) cal %hx fid %d xid %d\n",
pkt_header->mcnt, pkt_header->mcnt-prior_mcnt, pkt_header->cal, pkt_header->fid, pkt_header->xid);
pkt_header->mcnt, pkt_header->mcnt-prior_mcnt, pkt_header->cal, pkt_header->fid, pkt_header->xid);
prior_mcnt = pkt_header->mcnt;
}
......@@ -251,7 +251,7 @@ static void set_block_filled(flag_input_databuf_t * db, block_info_t * binfo) {
//printf("NET: Time = %f\n", (float)tval_result.tv_usec/1000);
}
#define WINDOW_SIZE 50
#define WINDOW_SIZE 2
// Method to process a received packet
// Processing involves the following
......@@ -313,19 +313,21 @@ static inline int64_t process_packet(flag_input_databuf_t * db, struct hashpipe_
binfo.packet_count[dest_block_idx] = 0;
}
else if (pkt_mcnt_dist >= (N_INPUT_BLOCKS-1)*Nm) { // > current block + 2
/*
char msg[60];
printf("NET: Writing to NETERR\n");
sprintf(msg, "Late Packet! - %lld", (long long int)pkt_mcnt);
hashpipe_status_lock_safe(st_p);
hputs(st_p->buf, "NETERR", msg);
hashpipe_status_unlock_safe(st_p);
*/
/*
// The x-engine is lagging behind the f-engine, or the x-engine
// has just started. Reinitialize the current block
// to have the next multiple of Nm. Then initialize the next block appropriately
uint64_t new_mcnt = pkt_mcnt - (pkt_mcnt % (Nm*N_INPUT_BLOCKS)) + Nm*N_INPUT_BLOCKS;
// binfo.block_i = get_block_idx(new_mcnt);
// binfo.block_i = get_block_idx(new_mcnt);
fprintf(stderr, "Packet mcnt %lld is very late... resettting current block mcnt to %lld (%012lx)\n", (long long int)pkt_mcnt, (long long int)new_mcnt, new_mcnt);
fprintf(stderr, "pkt_mcnt_dist = %lld\n", (long long int)pkt_mcnt_dist);
......@@ -362,14 +364,16 @@ static inline int64_t process_packet(flag_input_databuf_t * db, struct hashpipe_
int rv;
while ((rv = flag_input_databuf_wait_free(db, dest_block_idx)) != HASHPIPE_OK) {
if (rv == HASHPIPE_TIMEOUT) {
continue;
}
else {
hashpipe_error(__FUNCTION__, "error waiting for databuf free");
pthread_exit(NULL);
break;
}
printf("NET: Timed out!!!!!!!!\n");
continue;
}
else {
hashpipe_error(__FUNCTION__, "error waiting for databuf free");
pthread_exit(NULL);
break;
}
}
uint64_t * dest_p = db->block[dest_block_idx].data + flag_input_databuf_idx(binfo.m, binfo.f, 0, 0);
const uint64_t * payload_p = (uint64_t *)(p->data+8); // Ignore header
......@@ -392,11 +396,7 @@ static inline int64_t process_packet(flag_input_databuf_t * db, struct hashpipe_
}
*/
//print_pkt_header(&pkt_header);
return last_filled_mcnt;
}
......@@ -438,21 +438,21 @@ static void *run(hashpipe_thread_args_t * args) {
/* Read network params */
struct hashpipe_udp_params up = {
.bindhost = "0.0.0.0",
.bindport = 8511,
.packet_size = N_BYTES_PER_PACKET
.bindhost = "0.0.0.0",
.bindport = 8511,
.packet_size = N_BYTES_PER_PACKET
};
hashpipe_status_lock_safe(&st);
// Get info from status buffer if present (no change if not present)
hgets(st.buf, "BINDHOST", 80, up.bindhost);
hgeti4(st.buf, "BINDPORT", &up.bindport);
// Get info from status buffer if present (no change if not present)
hgets(st.buf, "BINDHOST", 80, up.bindhost);
hgeti4(st.buf, "BINDPORT", &up.bindport);
// Store bind host/port info etc in status buffer
hputs(st.buf, "BINDHOST", up.bindhost);
hputi4(st.buf, "BINDPORT", up.bindport);
hputu4(st.buf, "MISSEDFE", 0);
hputu4(st.buf, "MISSEDPK", 0);
// Store bind host/port info etc in status buffer
hputs(st.buf, "BINDHOST", up.bindhost);
hputi4(st.buf, "BINDPORT", up.bindport);
hputu4(st.buf, "MISSEDFE", 0);
hputu4(st.buf, "MISSEDPK", 0);
hashpipe_status_unlock_safe(&st);
struct hashpipe_udp_packet p;
......
......@@ -109,11 +109,12 @@ static void * run(hashpipe_thread_args_t * args) {
state next_state = ACQUIRE;
char netstat[17];
int64_t good_data = 1;
while (run_threads()) {
if (cur_state == ACQUIRE) {
next_state = ACQUIRE;
// Wait for input buffer block to be filled
// Wait for input buffer block to be filled
while ((rv=flag_gpu_pfb_output_databuf_wait_filled(db_in, curblock_in)) != HASHPIPE_OK && run_threads()) {
if (rv==HASHPIPE_TIMEOUT) {
int cleanc;
......@@ -136,186 +137,201 @@ static void * run(hashpipe_thread_args_t * args) {
if (!run_threads()) break;
if (next_state != CLEANUP) {
// Print out the header information for this block
flag_gpu_input_header_t tmp_header;
memcpy(&tmp_header, &db_in->block[curblock_in].header, sizeof(flag_gpu_input_header_t));
#if VERBOSE==1
printf("COR: Received block %d, starting mcnt = %lld\n", curblock_in, (long long int)tmp_header.mcnt);
#endif
good_data &= tmp_header.good_data;
hashpipe_status_lock_safe(&st);
hputi4(st.buf, "CORMCNT", tmp_header.mcnt);
hashpipe_status_unlock_safe(&st);
// Retrieve correlator integrator status
hashpipe_status_lock_safe(&st);
hgets(st.buf, "INTSTAT", 16, integ_status);
hashpipe_status_unlock_safe(&st);
// If the correlator integrator status is "off,"
// Free the input block and continue
if (strcmp(integ_status, "off") == 0) {
// Print out the header information for this block
flag_gpu_input_header_t tmp_header;
memcpy(&tmp_header, &db_in->block[curblock_in].header, sizeof(flag_gpu_input_header_t));
#if VERBOSE==1
fprintf(stderr, "COR: Correlator is off...\n");
printf("COR: Received block %d, starting mcnt = %lld\n", curblock_in, (long long int)tmp_header.mcnt);
#endif
flag_gpu_pfb_output_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
good_data = 1;
continue;
}
// If the correlator integrator status is "start,"
// Get the correlator started
// The INTSTAT string is set to "start" by the net thread once it's up and running
if (strcmp(integ_status, "start") == 0) {
// Get the starting mcnt for integration (should be zero)
good_data &= tmp_header.good_data;
hashpipe_status_lock_safe(&st);
hgeti4(st.buf, "NETMCNT", (int *)(&start_mcnt));
hashpipe_status_unlock_safe(&st);
// Check to see if block's starting mcnt matches INTSYNC
if (db_in->block[curblock_in].header.mcnt < start_mcnt) {
hputi4(st.buf, "CORMCNT", tmp_header.mcnt);
hashpipe_status_unlock_safe(&st);
// If we get here, then there is a bug since the net thread shouldn't
// mark blocks as filled that are before the starting mcnt
// fprintf(stderr, "COR: Unable to start yet... waiting for mcnt = %lld\n", (long long int)start_mcnt);
// starting mcnt not yet reached
// free block and continue
// Retrieve correlator integrator status
hashpipe_status_lock_safe(&st);
hgets(st.buf, "INTSTAT", 16, integ_status);
hashpipe_status_unlock_safe(&st);
// If the correlator integrator status is "off,"
// Free the input block and continue
if (strcmp(integ_status, "off") == 0) {
#if VERBOSE==1
fprintf(stderr, "COR: Correlator is off...\n");
#endif
flag_gpu_pfb_output_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
good_data = 1;
continue;
}
else if (db_in->block[curblock_in].header.mcnt == start_mcnt) {
// set correlator integrator to "on"
#if VERBOSE==1
fprintf(stderr, "COR: Starting correlator!\n");
#endif
strcpy(integ_status, "on");
float requested_integration_time = 0.0;
float actual_integration_time = 0.0;
hashpipe_status_lock_safe(&st);
hputs(st.buf, "INTSTAT", integ_status);
hgetr4(st.buf, "REQSTI", &requested_integration_time);
hashpipe_status_unlock_safe(&st);
int_count = ceil((N_MCNT_PER_SECOND / Nm) * requested_integration_time);
actual_integration_time = int_count/(N_MCNT_PER_SECOND / Nm);
// If the correlator integrator status is "start,"
// Get the correlator started
// The INTSTAT string is set to "start" by the net thread once it's up and running
if (strcmp(integ_status, "start") == 0) {
// Get the starting mcnt for integration (should be zero)
hashpipe_status_lock_safe(&st);
hputr4(st.buf, "ACTSTI", actual_integration_time);
hputi4(st.buf, "INTCOUNT", int_count);
hashpipe_status_unlock_safe(&st);
hgeti4(st.buf, "NETMCNT", (int *)(&start_mcnt));
hashpipe_status_unlock_safe(&st);
// Compute last mcount
last_mcnt = start_mcnt + int_count*Nm - 1;
}
else {
// fprintf(stdout, "COR: We missed the start of the integration\n");
fprintf(stdout, "COR: Missed start. Expected start_mcnt = %lld, got %lld\n", (long long int)start_mcnt, (long long int)db_in->block[curblock_in].header.mcnt);
// we apparently missed the start of the integation... ouch...
}
}
// Check to see if block's starting mcnt matches INTSYNC
if (db_in->block[curblock_in].header.mcnt < start_mcnt) {
// Check to see if a stop is issued
if (strcmp(integ_status, "stop") == 0) {
continue;
}
// If we get here, then there is a bug since the net thread shouldn't
// mark blocks as filled that are before the starting mcnt
// fprintf(stderr, "COR: Unable to start yet... waiting for mcnt = %lld\n", (long long int)start_mcnt);
// starting mcnt not yet reached
// free block and continue
flag_gpu_pfb_output_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
continue;
}
else if (db_in->block[curblock_in].header.mcnt == start_mcnt) {
// set correlator integrator to "on"
#if VERBOSE
fprintf(stderr, "COR: Starting correlator!\n");
#endif
strcpy(integ_status, "on");
float requested_integration_time = 0.0;
float actual_integration_time = 0.0;
hashpipe_status_lock_safe(&st);
hputs(st.buf, "INTSTAT", integ_status);
hgetr4(st.buf, "REQSTI", &requested_integration_time);
hashpipe_status_unlock_safe(&st);
int_count = ceil((N_MCNT_PER_SECOND / Nm) * requested_integration_time);
actual_integration_time = int_count/(N_MCNT_PER_SECOND / Nm);
// If we get here, then integ_status == "on"
// Setup for current chunk
context.input_offset = curblock_in * sizeof(flag_gpu_pfb_output_block_t) / sizeof(ComplexInput);
context.output_offset = curblock_out * sizeof(flag_pfb_gpu_correlator_output_block_t) / sizeof(Complex);
int doDump = 0;
if ((db_in->block[curblock_in].header.mcnt + int_count*Nm - 1) >= last_mcnt) {
doDump = 1;
// Wait for new output block to be free
while ((rv=flag_pfb_gpu_correlator_output_databuf_wait_free(db_out, curblock_out)) != HASHPIPE_OK) {
if (rv==HASHPIPE_TIMEOUT) {
/*
int cleanc;
hashpipe_status_lock_safe(&st);
hgetl(st.buf, "CLEANC", &cleanc);
hgets(st.buf, "NETSTAT", 16, netstat);
hputr4(st.buf, "ACTSTI", actual_integration_time);
hputi4(st.buf, "INTCOUNT", int_count);
hashpipe_status_unlock_safe(&st);
if (cleanc == 0 && strcmp(netstat, "CLEANUP") == 0) {
printf("COR: Cleanup condition met!\n");
next_state = CLEANUP;
break;
// Compute last mcount
last_mcnt = start_mcnt + int_count*Nm - 1;
}
else {
// fprintf(stdout, "COR: We missed the start of the integration\n");
fprintf(stdout, "COR: Missed start. Expected start_mcnt = %lld, got %lld\n", (long long int)start_mcnt, (long long int)db_in->block[curblock_in].header.mcnt);
// we apparently missed the start of the integation... ouch...
}
}
// Check to see if a stop is issued
if (strcmp(integ_status, "stop") == 0) {
continue;
}
// If we get here, then integ_status == "on"
// Setup for current chunk
context.input_offset = curblock_in * sizeof(flag_gpu_pfb_output_block_t) / sizeof(ComplexInput);
context.output_offset = curblock_out * sizeof(flag_pfb_gpu_correlator_output_block_t) / sizeof(Complex);
int doDump = 0;
if ((db_in->block[curblock_in].header.mcnt + Nm - 1) >= last_mcnt) {
doDump = 1;
#if VERBOSE
printf("COR: Setting dump\n\t last_mcnt=%lld\n\t int_count=%d\n\t rx_mcnt=%lld\n\t Nm=%d\n",
(long long int)last_mcnt,
int_count,
(long long int)(db_in->block[curblock_in].header.mcnt),
Nm);
#endif
// Wait for new output block to be free
while ((rv=flag_pfb_gpu_correlator_output_databuf_wait_free(db_out, curblock_out)) != HASHPIPE_OK) {
if (rv==HASHPIPE_TIMEOUT) {
continue;
} else {
hashpipe_error(__FUNCTION__, "error waiting for free databuf");
// fprintf(stderr, "rv = %d\n", rv);
pthread_exit(NULL);
break;
}
*/
continue;
} else {
hashpipe_error(__FUNCTION__, "error waiting for free databuf");
// fprintf(stderr, "rv = %d\n", rv);
pthread_exit(NULL);
break;
}
}
}
#if VERBOSE==1
printf("COR: Running xgpuCudaXengine now...\n");
#endif
xgpuCudaXengine(&context, doDump ? SYNCOP_DUMP : SYNCOP_SYNC_TRANSFER);
#if VERBOSE==1
printf("COR: Done!\n");
#endif
#if VERBOSE==1
printf("COR: doDump = %d\n", doDump);
printf("COR: start_mcnt = %lld, last_mcnt = %lld\n", (long long int)start_mcnt, (long long int)last_mcnt);
#endif
#if VERBOSE==1
printf("COR: Running xgpuCudaXengine now...\n");
#endif
xgpuCudaXengine(&context, doDump ? SYNCOP_DUMP : SYNCOP_SYNC_TRANSFER);
#if VERBOSE==1
printf("COR: Done!\n");
#endif
#if VERBOSE==1
printf("COR: doDump = %d\n", doDump);
printf("COR: start_mcnt = %lld, last_mcnt = %lld\n", (long long int)start_mcnt, (long long int)last_mcnt);
#endif
if (doDump) {
xgpuClearDeviceIntegrationBuffer(&context);
//xgpuReorderMatrix((Complex *)db_out->block[curblock_out].data);
db_out->block[curblock_out].header.mcnt = start_mcnt;
db_out->block[curblock_out].header.good_data = good_data;
//printf("COR: Dumping correlator output with mcnt %lld\n", (long long int) start_mcnt);
if (doDump) {
xgpuClearDeviceIntegrationBuffer(&context);
//xgpuReorderMatrix((Complex *)db_out->block[curblock_out].data);
db_out->block[curblock_out].header.mcnt = start_mcnt;
db_out->block[curblock_out].header.good_data = good_data;
//printf("COR: Dumping correlator output with mcnt %lld\n", (long long int) start_mcnt);
// Mark output block as full and advance
#if VERBOSE==1
printf("COR: Marking output block %d as filled, mcnt=%lld\n", curblock_out, (long long int)start_mcnt);
#endif
flag_pfb_gpu_correlator_output_databuf_set_filled(db_out, curblock_out);
curblock_out = (curblock_out + 1) % db_out->header.n_block;
start_mcnt = last_mcnt + 1;
last_mcnt = start_mcnt + int_count*Nm - 1;
// Reset good_data flag for next block
good_data = 1;
}
// Mark output block as full and advance
#if VERBOSE==1
printf("COR: Marking output block %d as filled, mcnt=%lld\n", curblock_out, (long long int)start_mcnt);
printf("COR: Marking input block %d as free\n", curblock_in);
#endif
flag_pfb_gpu_correlator_output_databuf_set_filled(db_out, curblock_out);
curblock_out = (curblock_out + 1) % db_out->header.n_block;
start_mcnt = last_mcnt + 1;
last_mcnt = start_mcnt + int_count*Nm - 1;
// Reset good_data flag for next block
good_data = 1;
flag_gpu_pfb_output_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
}
#if VERBOSE==1
printf("COR: Marking input block %d as free\n", curblock_in);
#endif
flag_gpu_pfb_output_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
}
}
else if (cur_state == CLEANUP) {
printf("COR: In Cleanup\n");
next_state = ACQUIRE;
// Set interntal integ_status to start
hashpipe_status_lock_safe(&st);
hputs(st.buf, "INTSTAT", "start");
hashpipe_status_unlock_safe(&st);
strcpy(integ_status, "start");
// Clear out integration buffer on GPU
xgpuClearDeviceIntegrationBuffer(&context);
curblock_in = 0;
curblock_out = 0;
//start_mcnt = 0;
//last_mcnt = 0;
good_data = 1;
//printf("COR: In Cleanup\n");
hashpipe_status_lock_safe(&st);
hputl(st.buf, "CLEANC", 1);
hgets(st.buf, "NETSTAT", 16, netstat);
hashpipe_status_unlock_safe(&st);
if (strcmp(netstat, "IDLE") == 0) {
next_state = ACQUIRE;
} else {
next_state = CLEANUP;
// Set interntal integ_status to start
hashpipe_status_lock_safe(&st);
hputs(st.buf, "INTSTAT", "start");
hashpipe_status_unlock_safe(&st);
strcpy(integ_status, "start");
// Clear out integration buffer on GPU
xgpuClearDeviceIntegrationBuffer(&context);
curblock_in = 0;
curblock_out = 0;