cuml_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <cuda_runtime_api.h>
20 
21 #include <stddef.h>
22 
23 // Block inclusion of this header when compiling libcuml++.so. If this error is
24 // shown during compilation, there is an issue with how the `#include` have
25 // been set up. To debug the issue, run `./build.sh cppdocs` and open the page
26 // 'cpp/build/html/cuml__api_8h.html' in a browser. This will show which files
27 // directly and indirectly include this file. Only files ending in '*_api' or
28 // 'cumlHandle' should include this header.
29 #ifdef CUML_CPP_API
30 #error "This header is only for the C-API and should not be included from the C++ API."
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 typedef int cumlHandle_t;
38 
40 
41 typedef cudaError_t (*cuml_allocate)(void** p, size_t n, cudaStream_t stream);
42 typedef cudaError_t (*cuml_deallocate)(void* p, size_t n, cudaStream_t stream);
43 
50 const char* cumlGetErrorString(cumlError_t error);
51 
59 cumlError_t cumlCreate(cumlHandle_t* handle, cudaStream_t stream);
60 
68 cumlError_t cumlGetStream(cumlHandle_t handle, cudaStream_t* stream);
69 
103  cuml_allocate allocate_fn,
104  cuml_deallocate deallocate_fn);
139  cuml_allocate allocate_fn,
140  cuml_deallocate deallocate_fn);
141 
149 
150 #ifdef __cplusplus
151 }
152 #endif
cudaError_t(* cuml_deallocate)(void *p, size_t n, cudaStream_t stream)
Definition: cuml_api.h:42
cudaError_t(* cuml_allocate)(void **p, size_t n, cudaStream_t stream)
Definition: cuml_api.h:41
int cumlHandle_t
Definition: cuml_api.h:37
const char * cumlGetErrorString(cumlError_t error)
Get a human readable error string for the passed in error code.
Definition: cuml_api.cpp:27
cumlError_t cumlCreate(cumlHandle_t *handle, cudaStream_t stream)
Creates a cumlHandle_t.
Definition: cuml_api.cpp:37
cumlError_t cumlDestroy(cumlHandle_t handle)
Release all resource internally managed by cumlHandle_t.
Definition: cuml_api.cpp:66
cumlError_t cumlSetDeviceAllocator(cumlHandle_t handle, cuml_allocate allocate_fn, cuml_deallocate deallocate_fn)
sets the allocator to use for all device allocations done in cuML.
cumlError_t cumlGetStream(cumlHandle_t handle, cudaStream_t *stream)
sets the stream to which all cuML work issued via the passed handle should be ordered.
Definition: cuml_api.cpp:44
cumlError_t
Definition: cuml_api.h:39
@ CUML_INVALID_HANDLE
Definition: cuml_api.h:39
@ CUML_SUCCESS
Definition: cuml_api.h:39
@ CUML_ERROR_UNKNOWN
Definition: cuml_api.h:39
cumlError_t cumlSetHostAllocator(cumlHandle_t handle, cuml_allocate allocate_fn, cuml_deallocate deallocate_fn)
sets the allocator to use for substantial host allocations done in cuML.