Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mklarqvist committed Sep 9, 2019
1 parent 589c006 commit 3c53e3f
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 87 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -30,3 +30,8 @@
*.exe
*.out
*.app

#
bench
utility
generate
26 changes: 13 additions & 13 deletions Makefile
Expand Up @@ -19,14 +19,14 @@
OPTFLAGS := -O3 -march=native
CFLAGS = -std=c99 $(OPTFLAGS) $(DEBUG_FLAGS)
CPPFLAGS = -std=c++0x $(OPTFLAGS) $(DEBUG_FLAGS)
CPP_SOURCE = flagstats.cpp utility.cpp
CPP_SOURCE = benchmark/flagstats.cpp benchmark/utility.cpp benchmark/generate.cpp
C_SOURCE =
OBJECTS = $(CPP_SOURCE:.cpp=.o) $(C_SOURCE:.c=.o)

POSPOPCNT_PATH := libalgebra
POSPOPCNT_PATH := ../libalgebra
LZ4_PATH :=
ZSTD_PATH :=
INCLUDE_PATHS :=
INCLUDE_PATHS := -I$(PWD)
LIBRARY_PATHS :=
ifneq ($(LZ4_PATH),)
INCLUDE_PATHS += -I$(LZ4_PATH)/include
Expand All @@ -42,23 +42,23 @@ INCLUDE_PATHS := $(sort $(INCLUDE_PATHS))
LIBRARY_PATHS := $(sort $(LIBRARY_PATHS))

# Default target
all: flagstats utility
all: benchmark utility generate

# Generic rules
utility.o: utility.cpp
$(CXX) $(CPPFLAGS) -c -o $@ $<
utility: benchmark/utility.cpp
$(CXX) $(CPPFLAGS) -o $@ $<

flagstats.o: flagstats.cpp
$(CXX) $(CPPFLAGS) -I$(POSPOPCNT_PATH) $(INCLUDE_PATHS) -c -o $@ $<
generate: benchmark/generate.cpp
$(CXX) $(CPPFLAGS) -o $@ $<

flagstats: flagstats.o
$(CXX) $(CPPFLAGS) flagstats.o -I$(POSPOPCNT_PATH) $(INCLUDE_PATHS) $(LIBRARY_PATHS) -o flagstats -llz4 -lzstd
bench.o: benchmark/flagstats.cpp
$(CXX) $(CPPFLAGS) -I$(POSPOPCNT_PATH) $(INCLUDE_PATHS) -c -o $@ $<

utility: utility.o
$(CXX) $(CPPFLAGS) utility.o -o utility
benchmark: bench.o
$(CXX) $(CPPFLAGS) bench.o -I$(POSPOPCNT_PATH) $(INCLUDE_PATHS) $(LIBRARY_PATHS) -o bench -llz4 -lzstd

clean:
rm -f $(OBJECTS)
rm -f flagstats utility
rm -f bench bench.o utility generate

.PHONY: all clean
File renamed without changes.
2 changes: 0 additions & 2 deletions generate.cpp → benchmark/generate.cpp
Expand Up @@ -8,8 +8,6 @@ int main(int argc, char** argv) {
std::random_device rd; // obtain a random number from hardware
std::mt19937 eng(rd()); // seed the generator

std::cerr << strtoull( argv[1], NULL, 10 ) << std::endl;

std::uniform_int_distribution<uint16_t> distr(0, 4096-1); // right inclusive
for (int i = 0; i < strtoull( argv[1], NULL, 10 ); ++i) {
uint16_t x = distr(eng);
Expand Down
5 changes: 5 additions & 0 deletions utility.cpp → benchmark/utility.cpp
@@ -1,7 +1,12 @@
#include <string>
#include <iostream>
#include <fstream>
#include <cstring>

// Utility function accepting data from cin stream and converting
// text-based FLAG values into uint16_t words.
// Intended use:
// samtools view FILE | cut -f 2 | utility > DEST_FILE.bin
int main(int argc, char** argv) {
std::string str;
while (std::getline(std::cin, str)) {
Expand Down
225 changes: 154 additions & 71 deletions libflagstats.h

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion positional-popcount
Submodule positional-popcount deleted from 1921b0
Binary file modified utility
Binary file not shown.

0 comments on commit 3c53e3f

Please sign in to comment.