Skip to content

Commit

Permalink
Added benchmark timing
Browse files Browse the repository at this point in the history
  • Loading branch information
CeSchmitz committed Jun 13, 2023
1 parent e89293c commit 82b2cfd
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Optimisation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 /O2")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")

# Add library subdirectory
add_subdirectory (${CMAKE_SOURCE_DIR}/lib)
Expand Down
20 changes: 19 additions & 1 deletion ISSLScoreOfftargets/ISSLScoreOfftargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ string signatureToSequence(uint64_t sig, uint64_t seqLen)

int main(int argc, char** argv)
{
auto startLoading = std::chrono::high_resolution_clock::now();

if (argc < 4) {
fprintf(stderr, "Usage: %s [issltable] [query file] [max distance] [score-threshold] [score-method]\n", argv[0]);
exit(1);
Expand Down Expand Up @@ -221,6 +223,9 @@ int main(int argc, char** argv)
sliceLimitOffset += sliceLimit;
}

auto endLoading = std::chrono::high_resolution_clock::now();
auto startProcessing = std::chrono::high_resolution_clock::now();

//TODO: rewrite
/** Load query file (candidate guides)
* and prepare memory for calculated global scores
Expand Down Expand Up @@ -259,7 +264,6 @@ int main(int argc, char** argv)
}

/** Begin scoring */
omp_set_num_threads(32);
#pragma omp parallel
{
vector<uint64_t> offtargetToggles(numOfftargetToggles);
Expand Down Expand Up @@ -459,6 +463,20 @@ int main(int argc, char** argv)
}
}

auto endProcessing = std::chrono::high_resolution_clock::now();
vector<std::chrono::nanoseconds> durations;
durations.push_back(endProcessing - startLoading);
durations.push_back(endProcessing - startProcessing);
durations.push_back(endLoading - startLoading);

for (const auto& duration : durations)
{
std::chrono::minutes minutes = std::chrono::duration_cast<std::chrono::minutes>(duration);
std::chrono::seconds seconds = std::chrono::duration_cast<std::chrono::seconds>(duration - minutes);
printf("%02ld:%02ld\t", minutes.count(), seconds.count());
}
printf("\n");

/** Print global scores to stdout */
for (size_t searchIdx = 0; searchIdx < querySignatures.size(); searchIdx++) {
auto querySequence = signatureToSequence(querySignatures[searchIdx], 20);
Expand Down
1 change: 1 addition & 0 deletions ISSLScoreOfftargets/ISSLScoreOfftargets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>
#include <boost/iostreams/device/mapped_file.hpp>
#include <omp.h>
#include <chrono>
#include "../include/phmap/phmap.h"
#include "../include/libpopcnt/libpopcnt.h"
#include "../include/otScorePenalties.hpp"
Expand Down
24 changes: 21 additions & 3 deletions ISSLScoreOfftargetsMMF/ISSLScoreOfftargetsMMF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ string signatureToSequence(uint64_t sig, uint64_t seqLen)

int main(int argc, char** argv)
{
auto startLoading = std::chrono::high_resolution_clock::now();

if (argc < 4) {
fprintf(stderr, "Usage: %s [issltable] [query file] [max distance] [score-threshold] [score-method]\n", argv[0]);
exit(1);
Expand Down Expand Up @@ -196,6 +198,9 @@ int main(int argc, char** argv)
}
}

auto endLoading = std::chrono::high_resolution_clock::now();
auto startProcessing = std::chrono::high_resolution_clock::now();

//TODO: rewrite
/** Load query file (candidate guides)
* and prepare memory for calculated global scores
Expand Down Expand Up @@ -223,9 +228,9 @@ int main(int argc, char** argv)
fclose(fp);

/** Binary encode query sequences */
#pragma omp parallel
#pragma omp parallel
{
#pragma omp for
#pragma omp for
for (int i = 0; i < queryCount; i++) {
char* ptr = &queryDataSet[i * seqLineLength];
uint64_t signature = sequenceToSignature(ptr, 20);
Expand All @@ -234,7 +239,6 @@ int main(int argc, char** argv)
}

/** Begin scoring */
omp_set_num_threads(32);
#pragma omp parallel
{
vector<uint64_t> offtargetToggles(numOfftargetToggles);
Expand Down Expand Up @@ -434,6 +438,20 @@ int main(int argc, char** argv)
}
}

auto endProcessing = std::chrono::high_resolution_clock::now();
vector<std::chrono::nanoseconds> durations;
durations.push_back(endProcessing - startLoading);
durations.push_back(endProcessing - startProcessing);
durations.push_back(endLoading - startLoading);

for (const auto& duration : durations)
{
std::chrono::minutes minutes = std::chrono::duration_cast<std::chrono::minutes>(duration);
std::chrono::seconds seconds = std::chrono::duration_cast<std::chrono::seconds>(duration - minutes);
printf("%02ld:%02ld\t", minutes.count(), seconds.count());
}
printf("\n");

/** Print global scores to stdout */
for (size_t searchIdx = 0; searchIdx < querySignatures.size(); searchIdx++) {
auto querySequence = signatureToSequence(querySignatures[searchIdx], 20);
Expand Down
1 change: 1 addition & 0 deletions ISSLScoreOfftargetsMMF/ISSLScoreOfftargetsMMF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>
#include <boost/iostreams/device/mapped_file.hpp>
#include <omp.h>
#include <chrono>
#include "../include/phmap/phmap.h"
#include "../include/libpopcnt/libpopcnt.h"
#include "../include/otScorePenalties.hpp"
Expand Down

0 comments on commit 82b2cfd

Please sign in to comment.