Loading...
Searching...
No Matches
CudaEngine.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3#pragma once
4
5// C ABI of libgpr_scheme2_cuda.so, the device half of the INT8 Scheme II
6// engine (provider=cuda). The host computes the scale exponents; the device
7// scales the operands and forms their residues with the operations of the
8// CPU residue pass (SchemeII.cpp), multiplies them on INT8 tensor cores
9// with INT32 accumulation, which is exact, reduces the products modulo each
10// p_t and reconstructs the integer A'B' with the limb arithmetic of the CPU
11// reconstruction, so every output entry has the bits of the CPU engines.
12
13#include <stddef.h>
14#include <stdint.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
22 int32_t count; // moduli
23 int32_t limbs; // limbs of M and of the CRT weights
24 int32_t beta_bits; // limb width
25 int64_t chunk; // inner length of one exact INT32 product
26 const uint32_t* moduli; // count
27 const double* weight; // count * limbs, weight[t * limbs + l]
28 const double* modulus; // limbs of M
29 double inverse_modulus; // 2^-log2(M)
30 const double* inverse_p; // count, 1.0 / p_t
32
40 const double* values;
41 int64_t ld;
42 int32_t l_contiguous;
43 const int8_t* residues;
44 int64_t extent;
45 int64_t depth;
46 int32_t rows; // nonzero for a row operand
47 const int32_t* exponents; // extent scale exponents
49
54 int32_t rows;
55 int32_t cols;
56 int64_t row0;
57 int64_t m;
58 int64_t col0;
59 int64_t n;
60 double* values;
61 int64_t ld;
63
65void* gpr_scheme2_cuda_create_v1(int device, char* error, size_t capacity);
66void gpr_scheme2_cuda_destroy_v1(void* engine);
68int gpr_scheme2_cuda_describe_v1(void* engine, char* text, size_t capacity);
70int gpr_scheme2_cuda_run_v1(void* engine,
71 const gpr_scheme2_cuda_table_v1* table,
72 const gpr_scheme2_cuda_operand_v1* operands,
73 int32_t operand_count,
74 const gpr_scheme2_cuda_task_v1* tasks,
75 int32_t task_count, char* error, size_t capacity);
78int gpr_scheme2_cuda_gemm_s8_v1(void* engine, int64_t m, int64_t n, int64_t k,
79 const int8_t* r, int64_t ldr, const int8_t* s,
80 int64_t lds, int32_t* c, int64_t ldc,
81 char* error, size_t capacity);
82
83#ifdef __cplusplus
84}
85#endif
int gpr_scheme2_cuda_gemm_s8_v1(void *engine, int64_t m, int64_t n, int64_t k, const int8_t *r, int64_t ldr, const int8_t *s, int64_t lds, int32_t *c, int64_t ldc, char *error, size_t capacity)
int gpr_scheme2_cuda_run_v1(void *engine, const gpr_scheme2_cuda_table_v1 *table, const gpr_scheme2_cuda_operand_v1 *operands, int32_t operand_count, const gpr_scheme2_cuda_task_v1 *tasks, int32_t task_count, char *error, size_t capacity)
Products of every task. Operands are copied to the device once per call.
void gpr_scheme2_cuda_destroy_v1(void *engine)
void * gpr_scheme2_cuda_create_v1(int device, char *error, size_t capacity)
device < 0 selects the local rank modulo the visible device count.
int gpr_scheme2_cuda_describe_v1(void *engine, char *text, size_t capacity)
One line naming the device.
const int32_t * exponents
Definition CudaEngine.h:47
Moduli and CRT tables of one inner dimension (Context::Impl::Table).
Definition CudaEngine.h:21
const double * modulus
Definition CudaEngine.h:28
const uint32_t * moduli
Definition CudaEngine.h:26
const double * weight
Definition CudaEngine.h:27
const double * inverse_p
Definition CudaEngine.h:30