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

Fix OGLC debug builds #6399

Merged
merged 1 commit into from
Nov 9, 2021
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
3 changes: 3 additions & 0 deletions src/runtime/fuchsia_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ WEAK int halide_start_clock(void *user_context) {
}

WEAK int64_t halide_current_time_ns(void *user_context) {
// It is an error to call halide_current_time_ns() if halide_start_clock() has never been called
halide_debug_assert(user_context, halide_reference_clock_inited);

return zx_clock_get_monotonic() - halide_reference_clock;
}

Expand Down
4 changes: 4 additions & 0 deletions src/runtime/linux_clock.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "HalideRuntime.h"
#include "runtime_internal.h"

#ifndef __clockid_t_defined
#define __clockid_t_defined 1
Expand Down Expand Up @@ -62,6 +63,9 @@ WEAK int halide_start_clock(void *user_context) {
}

WEAK int64_t halide_current_time_ns(void *user_context) {
// It is an error to call halide_current_time_ns() if halide_start_clock() has never been called
halide_debug_assert(user_context, halide_reference_clock_inited);

timespec now;
// To avoid requiring people to link -lrt, we just make the syscall directly.

Expand Down
1 change: 1 addition & 0 deletions src/runtime/openglcompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ WEAK char *get_kernel_name(const char *start, const char *end) {
WEAK int halide_openglcompute_initialize_kernels(void *user_context, void **state_ptr,
const char *src, int size) {
#ifdef DEBUG_RUNTIME
halide_start_clock(user_context);
uint64_t t_before = halide_current_time_ns(user_context);
#endif

Expand Down
3 changes: 3 additions & 0 deletions src/runtime/osx_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ WEAK int halide_start_clock(void *user_context) {
}

WEAK int64_t halide_current_time_ns(void *user_context) {
// It is an error to call halide_current_time_ns() if halide_start_clock() has never been called
halide_debug_assert(user_context, halide_reference_clock_inited);

uint64_t now = mach_absolute_time();
return (now - halide_reference_clock) * halide_timebase_info.numer / halide_timebase_info.denom;
}
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/posix_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ WEAK int halide_start_clock(void *user_context) {
// doesn't provide the former. (Use linux_clock.cpp to use clock_gettime(),
// which will provide actual nanosecond accuracy.)
WEAK int64_t halide_current_time_ns(void *user_context) {
// It is an error to call halide_current_time_ns() if halide_start_clock() has never been called
halide_debug_assert(user_context, halide_reference_clock_inited);

timeval now;
gettimeofday(&now, nullptr);
int64_t d = int64_t(now.tv_sec - halide_reference_clock.tv_sec) * 1000000;
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/windows_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ WEAK int halide_start_clock(void *user_context) {
}

WEAK int64_t halide_current_time_ns(void *user_context) {
// It is an error to call halide_current_time_ns() if halide_start_clock() has never been called
halide_debug_assert(user_context, halide_reference_clock_inited);

int64_t clock;
QueryPerformanceCounter(&clock);
clock -= halide_reference_clock;
Expand Down