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

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

RPP: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rpp/checkouts/develop/projects/rpp/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  typedef struct name* name##_t;
58 
62 RPP_DECLARE_OBJECT(rppHandle); // Create the rppHandle_t type
63 
67 typedef rppHandle_t RppHandle_t; // Create typedef for RppHandle_t
68 
69 #if _WIN32
70 #define SHARED_PUBLIC __declspec(dllexport)
71 #else
72 #define SHARED_PUBLIC __attribute__((visibility("default")))
73 #endif
74 
75 #include "rpp_version.h"
76 #include "rppdefs.h"
77 #include "rppt.h"
78 
85 typedef void* (*rppAllocatorFunction)(void* context, size_t sizeBytes);
86 
93 typedef void (*rppDeallocatorFunction)(void* context, void* memory);
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
119 extern "C" SHARED_PUBLIC rppStatus_t rppCreate(rppHandle_t* handle, size_t nBatchSize,
120  Rpp32u numThreads = 0, void* stream = nullptr,
121  RppBackend backend = RppBackend::RPP_HOST_BACKEND);
122 
140 extern "C" SHARED_PUBLIC rppStatus_t rppDestroy(rppHandle_t handle,
141  RppBackend backend = RppBackend::RPP_HOST_BACKEND);
142 
159 extern "C" SHARED_PUBLIC rppStatus_t rppSetBatchSize(rppHandle_t handle, size_t batchSize);
160 
177 extern "C" SHARED_PUBLIC rppStatus_t rppGetBatchSize(rppHandle_t handle, size_t* batchSize);
178 
179 #if RPP_BACKEND_HIP
180 
190 extern "C" SHARED_PUBLIC rppStatus_t rppSetStream(rppHandle_t handle,
191  rppAcceleratorQueue_t streamID);
192 
202 extern "C" SHARED_PUBLIC rppStatus_t rppGetStream(rppHandle_t handle,
203  rppAcceleratorQueue_t* streamID);
204 
227 extern "C" SHARED_PUBLIC rppStatus_t rppSetAllocator(rppHandle_t handle,
228  rppAllocatorFunction allocator,
229  rppDeallocatorFunction deallocator,
230  void* allocatorContext);
231 
247 extern "C" SHARED_PUBLIC rppStatus_t rppGetKernelTime(rppHandle_t handle, float* time);
248 
265 extern "C" SHARED_PUBLIC rppStatus_t rppEnableProfiling(rppHandle_t handle, bool enable);
266 
267 #endif // GPU_SUPPORT
268 
269 #ifdef __cplusplus
270 }
271 #endif // __cplusplus
272 
273 #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:93
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:85
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:67
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:147
RppBackend
RPP RppBackend type enums.
Definition: rppdefs.h:331
rppStatus_t
RPP rppStatus_t type enums.
Definition: rppdefs.h:336
RPP common HOST/GPU typedef, enum and structure definitions.
RPP Tensor Operations.