//loads a batch of reads (signal+information needed for pA conversion) from file, process the batch (convert to pA and sum), and write output //only the time for loading a batch is measured //make zstd=1 //gcc -Wall -O2 -g -I include/ -o convert_to_pa test/bench/convert_to_pa.c lib/libslow5.a -lm -lz -lzstd -fopenmp //only the time for loading a batch to memory (Disk I/O + decompression + parsing and filling the memory arrays) is measured #include #include #include #include #include #include "../src/slow5_extra.h" static inline double realtime(void) { struct timeval tp; struct timezone tzp; gettimeofday(&tp, &tzp); return tp.tv_sec + tp.tv_usec * 1e-6; } /* load a data batch from disk */ int load_raw_batch(char ***mem_records_a, size_t **mem_bytes_a, slow5_file_t *sf, int batch_size) { char **mem_records = (char **)malloc(batch_size * sizeof(char *)); size_t *mem_bytes = (size_t *)malloc(batch_size * sizeof(size_t)); int32_t i = 0; while (i < batch_size) { mem_records[i] = (char *)slow5_get_next_mem(&(mem_bytes[i]), sf); if (mem_records[i] == NULL) { if (slow5_errno != SLOW5_ERR_EOF) { fprintf(stderr,"Error reading from SLOW5 file %d\n", slow5_errno); exit(EXIT_FAILURE); } else { break; } } else { i++; } } *mem_records_a = mem_records; *mem_bytes_a = mem_bytes; return i; } void free_raw_batch(char **mem_records, size_t *mem_bytes, int batch_size) { for(int i=0;iread_id); exit(EXIT_FAILURE); } } tot_time += realtime() - t0; /**** Batch fetched ***/ fprintf(stderr,"batch loaded with %d reads\n",ret); //process and print (time not measured as we want to compare to the time it takes to read the file) #pragma omp parallel for for(int i=0;irange / rec[i]->digitisation; for(int j=0; jlen_raw_signal; j++){ sum += ((rec[i]->raw_signal[j] + rec[i]->offset) * scale); } sums[i] = sum; } fprintf(stderr,"batch processed with %d reads\n",ret); for(int i=0;iread_id,sums[i]); } fprintf(stderr,"batch printed with %d reads\n",ret); /**** Deinit ***/ t0 = realtime(); free_raw_batch(mem_records, mem_bytes, ret); for(int i=0;i