macro.h 921 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 *  Copyright (c) 2023 by Contributors
 * @file macro.h
 * @brief Graphbolt macros.
 */

#ifndef GRAPHBOLT_MACRO_H_
#define GRAPHBOLT_MACRO_H_

#include <torch/script.h>

namespace graphbolt {

// Dispatch operator implementation function to CUDA device only.
#ifdef GRAPHBOLT_USE_CUDA
#define GRAPHBOLT_DISPATCH_CUDA_ONLY_DEVICE(device_type, name, ...) \
  if (device_type == c10::DeviceType::CUDA) {                       \
18
    [[maybe_unused]] auto XPU = c10::DeviceType::CUDA;              \
19
20
21
22
23
24
25
26
27
28
29
30
    __VA_ARGS__                                                     \
  } else {                                                          \
    TORCH_CHECK(false, name, " is only available on CUDA device."); \
  }
#else
#define GRAPHBOLT_DISPATCH_CUDA_ONLY_DEVICE(device_type, name, ...) \
  TORCH_CHECK(false, name, " is only available on CUDA device.");
#endif

}  // namespace graphbolt

#endif  // GRAPHBOLT_MACRO_H_