ipc_debug.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stddef.h>
  4. #ifdef __cplusplus
  5. // Only expose templated version with C++
  6. template<typename T>
  7. void debug_ipc_assert_equal(T value);
  8. extern "C" {
  9. #endif
  10. #define DEBUG_IPC_CHECKPOINT() debug_ipc_assert_source_location(__FILE__, __LINE__)
  11. void debug_ipc_init();
  12. void debug_ipc_assert_equal_double(double value);
  13. void debug_ipc_assert_equal_uint(uint32_t value);
  14. void debug_ipc_assert_equal_int(int32_t value);
  15. void debug_ipc_assert_equal_int64(int64_t value);
  16. void debug_ipc_assert_equal_array(void *value, size_t size);
  17. /**
  18. * Check that root and client are executing the same source line.
  19. * Should typically be called like this:
  20. * debug_ipc_assert_source_location(__FILE__, __LINE__)
  21. */
  22. void debug_ipc_assert_source_location(const char *source_file, const long int line_number);
  23. void debug_ipc_mpi_set_data_distribution(int start_index, uint64_t local_length);
  24. /**
  25. * Compare two MPI distributed arrays between processes.
  26. * array_length denotes the number of double elements in the array, not the number of bytes.
  27. *
  28. * The data distribution must be given through `debug_ipc_mpi_set_data_distribution` before calling
  29. * this method.
  30. *
  31. * Span is an additional parameter that acts as a multiplier on the assigned indices given by the data distribution.
  32. * For example, if our data distribution looks like this with three doubles assigned per global index:
  33. * Rank 0 Rank 1 Rank 2
  34. * ┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐
  35. * │ │ │ │ │ │
  36. * │ A B C │ │ A B C │ │ A B C │
  37. * │ │ │ │ │ │
  38. * └───────────────────┘ └───────────────────┘ └───────────────────┘
  39. * global index 0 1 2
  40. *
  41. *
  42. * …we would have to specify a span of 3, because each global index spans across 3 doubles.
  43. */
  44. void debug_ipc_assert_equal_mpi_double_array(double *array, size_t array_length, int span);
  45. #ifdef __cplusplus
  46. }
  47. #endif