Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks around some platform-specific benchmark code #455

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions benchmarks/bench_utils/generation_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,15 @@ namespace detail
template <typename T>
struct random_to_item_t<T, typename std::enable_if<!std::is_floating_point<T>::value>::type>
{
#if THRUST_BENCHMARKS_HAVE_INT128_SUPPORT
using CastT = typename std::conditional<
std::is_same<T, int128_t>::value || std::is_same<T, uint128_t>::value,
typename std::conditional<std::is_signed<T>::value, long, unsigned long>::type,
T>::type;
#else
using CastT = typename std::conditional<std::is_signed<T>::value, long, unsigned long>::type;
#endif


double m_min;
double m_max;
Expand Down
45 changes: 45 additions & 0 deletions internal/benchmark/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@
#include <thrust/detail/config.h>

#include <cassert>

#if(THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC || defined(_WIN32))
#include <windows.h>

class steady_timer
{
LARGE_INTEGER start_;
LARGE_INTEGER stop_;
LARGE_INTEGER frequency_; // Cached to avoid system calls.

public:
steady_timer() : start_(), stop_(), frequency_()
{
BOOL const r = QueryPerformanceFrequency(&frequency_);
assert(0 != r);
(void)r; // Silence unused variable 'r' in Release builds, when
// the assertion evaporates.
}

void start()
{
BOOL const r = QueryPerformanceCounter(&start_);
assert(0 != r);
(void)r; // Silence unused variable 'r' in Release builds, when
// the assertion evaporates.
}


void stop()
{
BOOL const r = QueryPerformanceCounter(&stop_);
assert(0 != r);
(void)r; // Silence unused variable 'r' in Release builds, when
// the assertion evaporates.
}

double seconds_elapsed()
{
return double(stop_.QuadPart - start_.QuadPart)
/ double(frequency_.QuadPart);
}
};

#else
#include <time.h>

class steady_timer
Expand Down Expand Up @@ -35,3 +79,4 @@ class steady_timer
+ double(stop_.tv_nsec - start_.tv_nsec) * 1.0e-9;
}
};
#endif