PandA-2024.02
local_support.c
Go to the documentation of this file.
1 #include "nw.h"
2 #include <string.h>
3 
4 int INPUT_SIZE = sizeof(struct bench_args_t);
5 
6 void run_benchmark( void *vargs ) {
7  struct bench_args_t *args = (struct bench_args_t *)vargs;
8  needwun( args->seqA, args->seqB, args->alignedA, args->alignedB, args->M, args->ptr);
9 }
10 
11 /* Input format:
12 %% Section 1
13 char[]: sequence A
14 %% Section 2
15 char[]: sequence B
16 */
17 
18 void input_to_data(int fd, void *vdata) {
19  struct bench_args_t *data = (struct bench_args_t *)vdata;
20  char *p, *s;
21  // Zero-out everything.
22  memset(vdata,0,sizeof(struct bench_args_t));
23  // Load input string
24  p = readfile(fd);
25 
26  s = find_section_start(p,1);
27  parse_string(s, data->seqA, ALEN);
28 
29  s = find_section_start(p,2);
30  parse_string(s, data->seqB, BLEN);
31  free(p);
32 
33 }
34 
35 void data_to_input(int fd, void *vdata) {
36  struct bench_args_t *data = (struct bench_args_t *)vdata;
37 
39  write_string(fd, data->seqA, ALEN);
40 
42  write_string(fd, data->seqB, BLEN);
43 
45 }
46 
47 /* Output format:
48 %% Section 1
49 char[sum_size]: aligned sequence A
50 %% Section 2
51 char[sum_size]: aligned sequence B
52 */
53 
54 void output_to_data(int fd, void *vdata) {
55  struct bench_args_t *data = (struct bench_args_t *)vdata;
56  char *p, *s;
57  // Zero-out everything.
58  memset(vdata,0,sizeof(struct bench_args_t));
59  // Load input string
60  p = readfile(fd);
61 
62  s = find_section_start(p,1);
63  parse_string(s, data->alignedA, ALEN+BLEN);
64 
65  s = find_section_start(p,2);
66  parse_string(s, data->alignedB, ALEN+BLEN);
67  free(p);
68 }
69 
70 void data_to_output(int fd, void *vdata) {
71  struct bench_args_t *data = (struct bench_args_t *)vdata;
72 
74  write_string(fd, data->alignedA, ALEN+BLEN);
75 
77  write_string(fd, data->alignedB, ALEN+BLEN);
78 
80 }
81 
82 int check_data( void *vdata, void *vref ) {
83  struct bench_args_t *data = (struct bench_args_t *)vdata;
84  struct bench_args_t *ref = (struct bench_args_t *)vref;
85  int has_errors = 0;
86 
87  has_errors |= memcmp(data->alignedA, ref->alignedA, ALEN+BLEN);
88  has_errors |= memcmp(data->alignedB, ref->alignedB, ALEN+BLEN);
89 
90  // Return true if it's correct.
91  return !has_errors;
92 }
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
void needwun(char SEQA[ALEN], char SEQB[BLEN], char alignedA[ALEN+BLEN], char alignedB[ALEN+BLEN], int M[(ALEN+1) *(BLEN+1)], char ptr[(ALEN+1) *(BLEN+1)])
Definition: nw.c:13
#define BLEN
Definition: nw.h:6
int check_data(void *vdata, void *vref)
Definition: local_support.c:70
int M[(ALEN+1) *(BLEN+1)]
Definition: nw.h:19
char alignedB[ALEN+BLEN]
Definition: nw.h:18
char alignedA[ALEN+BLEN]
Definition: nw.h:17
#define ALEN
Definition: nw.h:5
int INPUT_SIZE
Definition: local_support.c:4
int parse_string(char *s, char *arr, int n)
Definition: support.c:77
int write_string(int fd, char *arr, int n)
void data_to_output(int fd, void *vdata)
Definition: local_support.c:63
int write_section_header(int fd)
char seqA[ALEN]
Definition: nw.h:15
void output_to_data(int fd, void *vdata)
Definition: local_support.c:49
char * readfile(int fd)
Definition: support.c:34
void input_to_data(int fd, void *vdata)
Definition: local_support.c:18
char * find_section_start(char *s, int n)
Definition: support.c:56
void run_benchmark(void *vargs)
Definition: local_support.c:6
char seqB[BLEN]
Definition: nw.h:16
char ptr[(ALEN+1) *(BLEN+1)]
Definition: nw.h:20

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13