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 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame^] | 10 | namespace frc971::apriltag { |
Austin Schuh | 8c267c7 | 2023-11-18 14:05:14 -0800 | [diff] [blame] | 11 | |
Austin Schuh | 1fc51fa | 2024-01-01 12:34:00 -0800 | [diff] [blame] | 12 | size_t overall_memory = 0; |
| 13 | |
| 14 | void CheckAndSynchronize(std::string_view message) { |
| 15 | CHECK_CUDA(cudaDeviceSynchronize()) << message; |
| 16 | CHECK_CUDA(cudaGetLastError()) << message; |
Austin Schuh | 8c267c7 | 2023-11-18 14:05:14 -0800 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | void MaybeCheckAndSynchronize() { |
| 20 | if (FLAGS_sync) CheckAndSynchronize(); |
| 21 | } |
| 22 | |
Austin Schuh | 1fc51fa | 2024-01-01 12:34:00 -0800 | [diff] [blame] | 23 | void MaybeCheckAndSynchronize(std::string_view message) { |
| 24 | if (FLAGS_sync) CheckAndSynchronize(message); |
| 25 | } |
| 26 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame^] | 27 | } // namespace frc971::apriltag |