/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/develop/api/rpp.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/develop/api/rpp.h Source File#

RPP: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/develop/api/rpp.h Source File
rpp.h
Go to the documentation of this file.
1 /*
2 MIT License
3 
4 Copyright (c) 2019 - 2025 Advanced Micro Devices, Inc.
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
25 #ifndef RPP_H
26 #define RPP_H
27 
34 #include "rpp_backend.h"
35 
36 #if RPP_BACKEND_HIP
37 
38 #include <hip/hip_runtime_api.h>
40 typedef hipStream_t rppAcceleratorQueue_t;
41 
42 #endif
43 
44 #if __cplusplus >= 201703L && __has_include(<filesystem>)
45 #include <filesystem>
46 namespace fs = std::filesystem;
47 #elif __has_include(<experimental/filesystem>)
48 #include <experimental/filesystem>
49 namespace fs = std::experimental::filesystem;
50 #endif
51 
55 #define RPP_DECLARE_OBJECT(name) \
56  struct name \
57  { \
58  }; \
59  typedef struct name* name##_t;
60 
64 RPP_DECLARE_OBJECT(rppHandle); // Create the rppHandle_t type
65 
69 typedef rppHandle_t RppHandle_t; // Create typedef for RppHandle_t
70 
71 #if _WIN32
72 #define SHARED_PUBLIC __declspec(dllexport)
73 #else
74 #define SHARED_PUBLIC __attribute__ ((visibility ("default")))
75 #endif
76 
77 #include "rppdefs.h"
78 #include "rppt.h"
79 #include "rpp_version.h"
80 
87 typedef void* (*rppAllocatorFunction)(void* context, size_t sizeBytes);
88 
95 typedef void (*rppDeallocatorFunction)(void* context, void* memory);
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
120 extern "C" SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t* handle, size_t nBatchSize, Rpp32u numThreads = 0, void* stream = nullptr, RppBackend backend = RppBackend::RPP_HOST_BACKEND);
121 
138 extern "C" SHARED_PUBLIC rppStatus_t rppDestroy(rppHandle_t handle, RppBackend backend = RppBackend::RPP_HOST_BACKEND);
139 
156 extern "C" SHARED_PUBLIC rppStatus_t rppSetBatchSize(rppHandle_t handle, size_t batchSize);
157 
174 extern "C" SHARED_PUBLIC rppStatus_t rppGetBatchSize(rppHandle_t handle, size_t *batchSize);
175 
176 #if RPP_BACKEND_HIP
177 
194 extern "C" SHARED_PUBLIC rppStatus_t rppSetStream(rppHandle_t handle, rppAcceleratorQueue_t streamID);
195 
212 extern "C" SHARED_PUBLIC rppStatus_t rppGetStream(rppHandle_t handle, rppAcceleratorQueue_t* streamID);
213 
232 extern "C" SHARED_PUBLIC rppStatus_t rppSetAllocator(rppHandle_t handle, rppAllocatorFunction allocator, rppDeallocatorFunction deallocator, void* allocatorContext);
233 
250 extern "C" SHARED_PUBLIC rppStatus_t rppGetKernelTime(rppHandle_t handle, float* time);
251 
268 extern "C" SHARED_PUBLIC rppStatus_t rppEnableProfiling(rppHandle_t handle, bool enable);
269 
270 #endif // GPU_SUPPORT
271 
272 #ifdef __cplusplus
273 }
274 #endif // __cplusplus
275 
276 #endif // RPP_H
#define RPP_DECLARE_OBJECT(name)
Construct type name from a struct.
Definition: rpp.h:55
SHARED_PUBLIC rppStatus_t rppSetBatchSize(rppHandle_t handle, size_t batchSize)
Set batch size given a RPP handle.
SHARED_PUBLIC rppStatus_t rppSetAllocator(rppHandle_t handle, rppAllocatorFunction allocator, rppDeallocatorFunction deallocator, void *allocatorContext)
Set allocator given a RPP handle.
hipStream_t rppAcceleratorQueue_t
Set rppAcceleratorQueue_t to hipStream_t if RPP_BACKEND_HIP.
Definition: rpp.h:40
void(* rppDeallocatorFunction)(void *context, void *memory)
Handles RPP context allocations.
Definition: rpp.h:95
SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t *handle, size_t nBatchSize, Rpp32u numThreads=0, void *stream=nullptr, RppBackend backend=RppBackend::RPP_HOST_BACKEND)
Creates RPP handle for HOST/HIP backend batch processing.
SHARED_PUBLIC rppStatus_t rppGetKernelTime(rppHandle_t handle, float *time)
Get time taken by previous kernel.
void *(* rppAllocatorFunction)(void *context, size_t sizeBytes)
Handles RPP context allocations.
Definition: rpp.h:87
SHARED_PUBLIC rppStatus_t rppSetStream(rppHandle_t handle, rppAcceleratorQueue_t streamID)
Set accelerator stream given a RPP handle.
SHARED_PUBLIC rppStatus_t rppGetStream(rppHandle_t handle, rppAcceleratorQueue_t *streamID)
Get accelerator stream given a RPP handle.
rppHandle_t RppHandle_t
RPP handle.
Definition: rpp.h:69
SHARED_PUBLIC rppStatus_t rppDestroy(rppHandle_t handle, RppBackend backend=RppBackend::RPP_HOST_BACKEND)
Destroys RPP handle for HOST/HIP backend batch processing.
SHARED_PUBLIC rppStatus_t rppGetBatchSize(rppHandle_t handle, size_t *batchSize)
Get batch size given a RPP Handle.
SHARED_PUBLIC rppStatus_t rppEnableProfiling(rppHandle_t handle, bool enable)
Enable Profiling.
unsigned int Rpp32u
32 bit unsigned int
Definition: rppdefs.h:115
RppBackend
RPP RppBackend type enums.
Definition: rppdefs.h:202
rppStatus_t
RPP rppStatus_t type enums.
Definition: rppdefs.h:211
RPP common HOST/GPU typedef, enum and structure definitions.
RPP Tensor Operations.