Skip to content
Open
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
1 change: 1 addition & 0 deletions scripts/generate_public_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
("hygon", "data_type_.h", "native/cuda/hygon/data_type_.h"),
("hygon", "device_.h", "native/cuda/hygon/device_.h"),
("hygon", "runtime_.h", "native/cuda/hygon/runtime_.h"),
("hygon", "driver_.h", "native/cuda/hygon/driver_.h"),
),
"thead": (
("thead", "data_type_.h", "native/cuda/thead/data_type_.h"),
Expand Down
54 changes: 54 additions & 0 deletions src/native/cuda/hygon/driver_.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef INFINI_RT_HYGON_DRIVER__H_
#define INFINI_RT_HYGON_DRIVER__H_

// clang-format off
#include <cuda.h>
// clang-format on

#include "native/cuda/driver_.h"
#include "native/cuda/hygon/device_.h"

namespace infini::rt::driver {

template <>
struct Driver<Device::Type::kHygon> : CudaDriver<Driver<Device::Type::kHygon>> {
using Result = CUresult;

using Module = CUmodule;

using Function = CUfunction;

using Stream = CUstream;

static constexpr Device::Type kDeviceType = Device::Type::kHygon;

static constexpr Result kSuccess = CUDA_SUCCESS;

static constexpr auto ModuleLoadData = cuModuleLoadData;

static constexpr auto ModuleGetFunction = cuModuleGetFunction;

static constexpr auto ModuleUnload = cuModuleUnload;

static constexpr auto FuncGetAttribute = cuFuncGetAttribute;

static constexpr auto kFuncAttributeSharedSizeBytes =
CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES;

static constexpr auto FuncSetCacheConfig = cuFuncSetCacheConfig;

static constexpr auto kFuncCachePreferShared = CU_FUNC_CACHE_PREFER_SHARED;

static constexpr auto FuncSetAttribute = cuFuncSetAttribute;

static constexpr auto kFuncAttributeMaxDynamicSharedSizeBytes =
CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES;

static constexpr auto LaunchKernel = cuLaunchKernel;
};

static_assert(Driver<Device::Type::kHygon>::Validate());

} // namespace infini::rt::driver

#endif
13 changes: 13 additions & 0 deletions src/native/cuda/hygon/runtime_.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ struct Runtime<Device::Type::kHygon>

static constexpr auto GetDeviceCount = cudaGetDeviceCount;

static constexpr auto DeviceGetAttribute = cudaDeviceGetAttribute;

static constexpr auto kDevAttrWarpSize = cudaDevAttrWarpSize;

static constexpr auto kDevAttrComputeCapabilityMajor =
cudaDevAttrComputeCapabilityMajor;

static constexpr auto kDevAttrComputeCapabilityMinor =
cudaDevAttrComputeCapabilityMinor;

static constexpr auto kDevAttrMaxSharedMemoryPerBlockOptin =
cudaDevAttrMaxSharedMemoryPerBlockOptin;

static constexpr auto DeviceSynchronize = cudaDeviceSynchronize;

static constexpr auto Malloc = [](auto&&... args) {
Expand Down