libkvikio  23.12.00
cufile_h_wrapper.hpp
1 /*
2  * Copyright (c) 2022-2023, 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 #pragma once
17 
25 #ifdef KVIKIO_CUFILE_FOUND
26 #include <cufile.h>
27 #else
28 using CUfileDriverControlFlags_t = enum CUfileDriverControlFlags {
29  CU_FILE_USE_POLL_MODE = 0,
30  CU_FILE_ALLOW_COMPAT_MODE = 1
31 };
32 using CUfileHandle_t = void*;
33 #endif
34 
35 // If the Batch API isn't defined, we define some of the data types here.
36 // Notice, this doesn't need to be ABI compatible with the cufile definitions.
37 #ifndef KVIKIO_CUFILE_BATCH_API_FOUND
38 typedef enum CUfileOpcode { CUFILE_READ = 0, CUFILE_WRITE } CUfileOpcode_t;
39 
40 typedef enum CUFILEStatus_enum {
41  CUFILE_WAITING = 0x000001, /* required value prior to submission */
42  CUFILE_PENDING = 0x000002, /* once enqueued */
43  CUFILE_INVALID = 0x000004, /* request was ill-formed or could not be enqueued */
44  CUFILE_CANCELED = 0x000008, /* request successfully canceled */
45  CUFILE_COMPLETE = 0x0000010, /* request successfully completed */
46  CUFILE_TIMEOUT = 0x0000020, /* request timed out */
47  CUFILE_FAILED = 0x0000040 /* unable to complete */
48 } CUfileStatus_t;
49 
50 typedef struct CUfileIOEvents {
51  void* cookie;
52  CUfileStatus_t status; /* status of the operation */
53  size_t ret; /* -ve error or amount of I/O done. */
55 #endif