Commit 6c06b879 authored by Mitch Burnett's avatar Mitch Burnett
Browse files

Prevent corsave from hanging on quit

Also added checking for run_threads() in the wait free loop in corsave thread.
This lets the thread detect if a signal was received and can exit. Might be a
better way to do this but works for now.

Decreasse indent and clean up code in correlator thread for readability
parent 14552914
......@@ -61,7 +61,7 @@ static void * run(hashpipe_thread_args_t * args) {
break;
}
}
uint64_t start_mcnt = db_in->block[curblock_in].header.mcnt;
//uint64_t start_mcnt = db_in->block[curblock_in].header.mcnt;
int good_data = (int)(db_in->block[curblock_in].header.good_data);
char BANK[5];
......@@ -71,8 +71,9 @@ static void * run(hashpipe_thread_args_t * args) {
hashpipe_status_unlock_safe(&st);
char filename[256];
sprintf(filename, "%s/TGBT16A_508_01/TMP/BF/beamformer_%s_mcnt_%lld.out", data_dir, BANK, (long long)start_mcnt);
fprintf(stderr, "Saving to %s\n", filename);
sprintf(filename, "/dev/null");
//sprintf(filename, "%s/TGBT16A_508_01/TMP/BF/beamformer_%s_mcnt_%lld.out", data_dir, BANK, (long long)start_mcnt);
//fprintf(stderr, "Saving to %s mcnt: %lld\n", filename, (long long)start_mcnt);
//printf("RTBF: mcnt: %lld\n", (long long)start_mcnt);
if (SAVE) {
float * p = (float *)db_in->block[curblock_in].data;
......
......@@ -163,9 +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"
#if VERBOSE
#if VERBOSE
fprintf(stderr, "COR: Starting correlator!\n");
#endif
#endif
strcpy(integ_status, "on");
float requested_integration_time = 0.0;
float actual_integration_time = 0.0;
......@@ -205,13 +205,13 @@ static void * run(hashpipe_thread_args_t * args) {
int doDump = 0;
if ((db_in->block[curblock_in].header.mcnt + Nm - 1) >= last_mcnt) {
#if VERBOSE
#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
#endif
doDump = 1;
// Wait for new output block to be free
......@@ -250,9 +250,9 @@ static void * run(hashpipe_thread_args_t * args) {
// Mark output block as full and advance
#if VERBOSE==1
#if VERBOSE==1
printf("COR: Marking output block %d as filled, mcnt=%lld\n", curblock_out, (long long int)start_mcnt);
#endif
#endif
flag_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;
......@@ -261,9 +261,9 @@ static void * run(hashpipe_thread_args_t * args) {
good_data = 1;
}
#if VERBOSE==1
#if VERBOSE==1
printf("COR: Marking input block %d as free\n", curblock_in);
#endif
#endif
flag_gpu_input_databuf_set_free(db_in, curblock_in);
curblock_in = (curblock_in + 1) % db_in->header.n_block;
}
......@@ -326,7 +326,7 @@ static void * run(hashpipe_thread_args_t * args) {
// Thread description
static hashpipe_thread_desc_t x_thread = {
name: "flag_correlator_thread",
name: "flag_correlator_thread",
skey: "CORSTAT",
init: NULL,
run: run,
......
......@@ -36,7 +36,7 @@ static void * run(hashpipe_thread_args_t * args) {
while (run_threads()) {
// Wait for input buffer block to be filled
while ((rv=flag_gpu_correlator_output_databuf_wait_filled(db_in, curblock_in)) != HASHPIPE_OK) {
while ((rv=flag_gpu_correlator_output_databuf_wait_filled(db_in, curblock_in)) != HASHPIPE_OK && run_threads()) {
if (rv==HASHPIPE_TIMEOUT) {
hashpipe_status_lock_safe(&st);
hputs(st.buf, status_key, "waiting for free block");
......@@ -58,11 +58,12 @@ static void * run(hashpipe_thread_args_t * args) {
uint64_t start_mcnt = db_in->block[curblock_in].header.mcnt;
//uint64_t start_mcnt = db_in->block[curblock_in].header.mcnt;
//int64_t good_data = db_in->block[curblock_in].header.good_data;
char filename[256];
sprintf(filename, "%s/TGBT16A_508_01/TMP/BF/cor_mcnt_%lld_%s.out", directory, (long long)start_mcnt, BANK);
fprintf(stderr, "SAV: Saving to %s\n", filename);
sprintf(filename, "/dev/null");
//sprintf(filename, "%s/TGBT16A_508_01/TMP/BF/cor_mcnt_%lld_%s.out", directory, (long long)start_mcnt, BANK);
//fprintf(stderr, "SAV: Saving to %s\n", filename);
#if SAVE == 1
Complex * p = (Complex *)db_in->block[curblock_in].data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment