Skip to content

Commit

Permalink
changed timing code
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoLassmann committed Mar 16, 2020
1 parent f31f541 commit 4dc6103
Show file tree
Hide file tree
Showing 11 changed files with 580 additions and 30 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-03-16 Timo Lassmann

* version 3.2.3
- replaced timing code with code from the easel lib.

2020-02-23 Timo Lassmann

* version 3.2.2
Expand Down
24 changes: 16 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

AC_INIT(kalign, 3.2.2)
AC_INIT(kalign, 3.2.3)

#AC_CONFIG_AUX_DIR([.])

AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
#AC_PROG_RANLIB
AC_PROG_INSTALL
AM_SILENT_RULES([no])

Expand Down Expand Up @@ -91,30 +91,38 @@ AC_PROG_INSTALL

AC_CHECK_LIB([m], [sqrt])
AC_CHECK_LIB([pthread], [main])
AC_SEARCH_LIBS([clock_gettime],[rt])
AC_SEARCH_LIBS([clock_gettime],[rt posix])

# Checks for header files.
AC_CHECK_HEADERS([math.h float.h stdlib.h unistd.h])
AC_CHECK_HEADERS([sys/time.h])

AC_CHECK_HEADERS([mach/mach.h])

AC_CHECK_HEADERS([limits.h])


AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

AC_TYPE_INT8_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_SIZE_T

AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STRNLEN
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([gettimeofday pow realpath sqrt strstr memset])


AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_FUNCS([gethrtime])
AC_CHECK_FUNCS([gettimeofday])

AC_CANONICAL_HOST
case $host_os in
Expand Down
10 changes: 10 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ bin_PROGRAMS = timescorealn kalign
kalign_SOURCES = run_kalign.c \
tldevel.h \
tldevel.c \
esl_stopwatch.h \
esl_stopwatch.c \
rng.h \
rng.c \
global.h \
Expand Down Expand Up @@ -56,6 +58,8 @@ TESTS = edist alphabet misc_test bpm_test rstdin_test
rwaln_SOURCES = \
tldevel.h \
tldevel.c \
esl_stopwatch.h \
esl_stopwatch.c \
rwalign.c \
alphabet.h \
alphabet.c \
Expand All @@ -65,6 +69,8 @@ rwaln_CPPFLAGS = $(AM_CPPFLAGS) -DRWALIGN_TEST
timescorealn_SOURCES = \
tldevel.h \
tldevel.c \
esl_stopwatch.h \
esl_stopwatch.c \
time_and_score_aln.c \
msa.h \
parameters.h \
Expand All @@ -79,6 +85,8 @@ misc.c
bpm_test_SOURCES = \
tldevel.h \
tldevel.c \
esl_stopwatch.h \
esl_stopwatch.c \
rng.h \
rng.c \
bpm.h \
Expand Down Expand Up @@ -109,6 +117,8 @@ alphabet_CPPFLAGS = $(AM_CPPFLAGS) -DITEST_ALPHABET
edist_SOURCES = \
tldevel.h \
tldevel.c \
esl_stopwatch.h \
esl_stopwatch.c \
rng.h \
rng.c \
euclidean_dist.h \
Expand Down
12 changes: 6 additions & 6 deletions src/bisectingKmeans.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "alignment.h"
#include "pick_anchor.h"

#include "esl_stopwatch.h"
struct node{
struct node* left;
struct node* right;
Expand Down Expand Up @@ -90,8 +90,8 @@ int build_tree_kmeans(struct msa* msa, struct aln_param* ap)
RUNP(dm = d_estimation(msa, anchors, num_anchors,0));//les,int pair)

STOP_TIMER(timer);

LOG_MSG("Done in %f sec.", GET_TIMING(timer));
GET_TIMING(timer);
//LOG_MSG("Done in %f sec.", GET_TIMING(timer));

MFREE(anchors);

Expand All @@ -111,8 +111,8 @@ int build_tree_kmeans(struct msa* msa, struct aln_param* ap)

RUNP(root = bisecting_kmeans(msa,root, dm, samples, numseq, num_anchors, numseq, ap->rng));
STOP_TIMER(timer);

LOG_MSG("Done in %f sec.", GET_TIMING(timer));
GET_TIMING(timer);
//LOG_MSG("Done in %f sec.", GET_TIMING(timer));

label_internal(root, numseq);

Expand All @@ -126,7 +126,7 @@ int build_tree_kmeans(struct msa* msa, struct aln_param* ap)
_mm_free(dm[i]);
}
MFREE(dm);

DESTROY_TIMER(timer);
return OK;
ERROR:
return FAIL;
Expand Down
29 changes: 20 additions & 9 deletions src/bpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#include "rng.h"



#ifdef HAVE_AVX2
#include <immintrin.h>

Expand All @@ -40,7 +42,9 @@ __m256i bitShiftRight256ymm (__m256i *data, int count);
/* Below are test functions */
#ifdef BPM_UTEST


#include "alphabet.h"
#include "esl_stopwatch.h"

/* Functions needed for the unit test*/
uint8_t dyn_256(const uint8_t* t,const uint8_t* p,int n,int m);
Expand Down Expand Up @@ -177,38 +181,45 @@ int bpm_test(void)
double dyn_timing;
double bpm_timing;
int timing_iter = 100;
fprintf(stdout,"Dyn\tAVX\tDYN/AVX\n");
//fprintf(stdout,"Dyn\tAVX\tDYN/AVX\n");
DECLARE_TIMER(t);

START_TIMER(t);
for(i = 0; i < 100;i+=10){
RUN(mutate_seq(b,len,i,alphabet->L,rng));
START_TIMER(t);

for(j = 0; j < timing_iter;j++){
dyn_score = dyn_256(a,b,len,len);
}
STOP_TIMER(t);
dyn_timing = GET_TIMING(t);
//dyn_timing = GET_TIMING(t);
}
STOP_TIMER(t);
GET_TIMING(t);

START_TIMER(t);
for(i = 0; i < 100;i+=10){
RUN(mutate_seq(b,len,i,alphabet->L,rng));

START_TIMER(t);
#ifdef HAVE_AVX2
for(j = 0; j < timing_iter;j++){
bpm_score = bpm_256(a,b,len,len);
}
#else
bpm_score = dyn_score;
#endif
STOP_TIMER(t);

bpm_timing = GET_TIMING(t);

ASSERT(dyn_score == bpm_score, "Scores differ: %d %d.",dyn_score, bpm_score);
fprintf(stdout,"%f\t%f\t%f\n",dyn_timing,bpm_timing, dyn_timing / bpm_timing);
//ASSERT(dyn_score == bpm_score, "Scores differ: %d %d.",dyn_score, bpm_score);
//fprintf(stdout,"%f\t%f\t%f\n",dyn_timing,bpm_timing, dyn_timing / bpm_timing);

/* restore seq */
for(j = 0;j < len;j++){
b[j] = a[j];
}
}
STOP_TIMER(t);
GET_TIMING(t);
DESTROY_TIMER(t);
MFREE(alphabet);
MFREE(a);
MFREE(b);
Expand Down
Loading

0 comments on commit 4dc6103

Please sign in to comment.