Austin Schuh | 8c267c7 | 2023-11-18 14:05:14 -0800 | [diff] [blame] | 1 | #include "frc971/orin/cuda.h" |
| 2 | |
| 3 | #include "gflags/gflags.h" |
| 4 | #include "glog/logging.h" |
| 5 | |
| 6 | DEFINE_bool( |
| 7 | sync, false, |
| 8 | "If true, force synchronization after each step to isolate errors better."); |
| 9 | |
| 10 | namespace frc971 { |
| 11 | namespace apriltag { |
| 12 | |
Austin Schuh | 1fc51fa | 2024-01-01 12:34:00 -0800 | [diff] [blame] | 13 | size_t overall_memory = 0; |
| 14 | |
| 15 | void CheckAndSynchronize(std::string_view message) { |
| 16 | CHECK_CUDA(cudaDeviceSynchronize()) << message; |
| 17 | CHECK_CUDA(cudaGetLastError()) << message; |
Austin Schuh | 8c267c7 | 2023-11-18 14:05:14 -0800 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | void MaybeCheckAndSynchronize() { |
| 21 | if (FLAGS_sync) CheckAndSynchronize(); |
| 22 | } |
| 23 | |
Austin Schuh | 1fc51fa | 2024-01-01 12:34:00 -0800 | [diff] [blame] | 24 | void MaybeCheckAndSynchronize(std::string_view message) { |
| 25 | if (FLAGS_sync) CheckAndSynchronize(message); |
| 26 | } |
| 27 | |
Austin Schuh | 8c267c7 | 2023-11-18 14:05:14 -0800 | [diff] [blame] | 28 | } // namespace apriltag |
| 29 | } // namespace frc971 |