KMP-MPI/sequential.c

25 lines
638 B
C
Raw Normal View History

2021-03-26 16:32:20 +00:00
#include "util.h"
#include "kmp.h"
#include <stdio.h>
#include <papi.h>
int main() {
int text_len, pattern_len;
char *text = read_file("data/dante.txt", &text_len);
char *pattern = read_file("data/pattern.txt", &pattern_len);
int lps[pattern_len];
create_lps(pattern, pattern_len, lps);
int match_number = 0;
int residue = 0;
long_long start_time = PAPI_get_real_usec();
int *matches = search_pattern(text, pattern, lps, &match_number, &residue);
long_long end_time = PAPI_get_real_usec();
printf("found %d matches\n", match_number);
printf("elapsed: %d\n", end_time - start_time);
}