Skip to content

Commit b7abc44

Browse files
committed
Fix wrong README description
Signed-off-by: Jan Stephan <jan.stephan@amd.com>
1 parent 11305f4 commit b7abc44

5 files changed

Lines changed: 29 additions & 30 deletions

File tree

‎Systems/hipFile/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ library and require neither a GPU nor an `O_DIRECT` filesystem.
2020
## Directory layout
2121

2222
| Directory | What's in it |
23-
|-----------|--------------|
23+
| --------- | ------------ |
2424
| [`api`](api) | Minimal examples of the non-I/O API — calls that query or configure the library (e.g. `get_version`). No `O_DIRECT` filesystem or file arguments needed. |
2525
| [`basics`](basics) | Small, single-purpose programs that each exercise one facet of the synchronous API: buffer registration, the `O_DIRECT` fast path vs. compat fallback, chunked reads, device-buffer offsets, sub-region writes, GPU memory types, and a full round trip. |
2626
| [`async`](async) | Examples of the asynchronous, stream-based API (`hipFileReadAsync` / `hipFileWriteAsync`), including single-stream, non-blocking-stream, and concurrent multi-stream round trips. |
@@ -79,7 +79,7 @@ library rather than move data through the GPU. These do **not** require an `O_DI
7979
filesystem or file arguments.
8080

8181
| Program | What it shows | Args |
82-
|---------|--------------|------|
82+
| ------- | ------------- | ---- |
8383
| [`get_version`](api/get_version) | Read the hipFile version both ways: the `HIPFILE_VERSION_*` header macros (compile-time) and `hipFileGetVersion()` (runtime). | none |
8484

8585
### Running
@@ -101,10 +101,10 @@ They drive the API directly from `main()` and use the shared helpers in
101101
success.
102102

103103
| Program | What it shows | Args |
104-
|---------|--------------|------|
104+
| ------- | ------------- | ---- |
105105
| [`bufregister_write`](basics/bufregister_write) | Write a GPU buffer registered with `hipFileBufRegister` straight to disk (the fast path). | `OUTPUT [GPUID]` |
106106
| [`no_bufregister_write`](basics/no_bufregister_write) | Same write, but without registering the buffer — hipFile copies through its internal pool. | `OUTPUT [GPUID]` |
107-
| [`no_odirect_write`](basics/no_odirect_write) | Register a file opened *without* `O_DIRECT`. hipFile falls back to the POSIX compat path. Requires `HIPFILE_ALLOW_COMPAT_MODE=1`. | `OUTPUT [GPUID]` |
107+
| [`no_odirect_write`](basics/no_odirect_write) | Register a file opened *without* `O_DIRECT`. hipFile transparently reopens with `O_DIRECT` on capable filesystems; falls back to the POSIX compat path otherwise. | `OUTPUT [GPUID]` |
108108
| [`iterative_read`](basics/iterative_read) | Chunked read into GPU memory where the **host pointer** advances each iteration, then one write. | `INPUT OUTPUT [GPUID]` |
109109
| [`iterative_devmem_offset_read`](basics/iterative_devmem_offset_read) | Same chunked read, but the base device pointer is fixed and the **`buf_offset`** argument advances. | `INPUT OUTPUT [GPUID]` |
110110
| [`subregion_write`](basics/subregion_write) | Read a whole file, then write only the bytes at/after an offset using a non-zero `buffer_offset`. | `INPUT OUTPUT [GPUID]` |
@@ -152,7 +152,7 @@ output by FNV-1a hash. They share the helpers in [`common`](common) and print `O
152152
> or filesystem is `O_DIRECT`-capable. Fast-path async support is planned for the future.
153153
154154
| Program | What it shows |
155-
|---------|--------------|
155+
| ------- | ------------- |
156156
| [`roundtrip_async`](async/roundtrip_async) | Async read + write on the **default stream**, a single `hipStreamSynchronize`, then verify. |
157157
| [`roundtrip_async_nonblocking_stream`](async/roundtrip_async_nonblocking_stream) | Same round trip on an explicit `hipStreamNonBlocking` stream (no implicit sync with the legacy default stream). |
158158
| [`roundtrip_async_multi_stream`](async/roundtrip_async_multi_stream) | `NUM_STREAMS` read/write pairs run concurrently, each on its own non-blocking stream covering a distinct file slice. |

‎Systems/hipFile/basics/no_odirect_write/CMakeLists.txt‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ target_include_directories(${example_name}
5252

5353
target_link_libraries(${example_name} PRIVATE hip::hipfile)
5454

55-
# This example requires HIPFILE_ALLOW_COMPAT_MODE=1 to succeed at runtime.
5655
add_test(
5756
NAME ${example_name}
58-
COMMAND ${CMAKE_COMMAND} -E env HIPFILE_ALLOW_COMPAT_MODE=1
59-
$<TARGET_FILE:${example_name}>
60-
"${CMAKE_CURRENT_BINARY_DIR}/no_odirect_write_out.bin"
57+
COMMAND ${example_name} "${CMAKE_CURRENT_BINARY_DIR}/no_odirect_write_out.bin"
6158
)
6259

6360
install(TARGETS ${example_name})

‎Systems/hipFile/basics/no_odirect_write/Makefile‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ SRCS := no-odirect-write.cpp $(COMMON_DIR)/examples_common.cpp
5454
$(EXAMPLE): $(SRCS)
5555
$(HIPCXX) $(ICXXFLAGS) $(ICPPFLAGS) $(ILDFLAGS) -o $@ $(SRCS) $(ILDLIBS)
5656

57-
# Requires HIPFILE_ALLOW_COMPAT_MODE=1 to succeed
5857
test: $(EXAMPLE)
59-
HIPFILE_ALLOW_COMPAT_MODE=1 ./$(EXAMPLE) $(TEST_ARGS)
58+
./$(EXAMPLE) $(TEST_ARGS)
6059

6160
clean:
6261
$(RM) $(EXAMPLE)

‎Systems/hipFile/basics/no_odirect_write/README.md‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
## Description
44

55
This program demonstrates what happens when hipFile is used with a file opened *without*
6-
`O_DIRECT`. Because the GPU-direct fast path requires `O_DIRECT` to bypass the page cache,
7-
omitting it causes hipFile to fall back to a POSIX-compatible I/O path instead.
6+
`O_DIRECT`. On an `O_DIRECT`-capable filesystem, hipFile transparently reopens the file with
7+
`O_DIRECT` and still takes the GPU-direct fast path. On a filesystem that cannot support
8+
`O_DIRECT`, hipFile falls back to its POSIX-compatible I/O path instead.
89

9-
The compat path must be explicitly enabled at runtime by setting the environment variable
10-
`HIPFILE_ALLOW_COMPAT_MODE=1`. Without it, hipFile will reject the operation.
10+
The compat path is enabled by default. The environment variable `HIPFILE_ALLOW_COMPAT_MODE` only
11+
needs to be set to `true` if you previously disabled compat mode and want to re-enable it.
1112

1213
### Application flow
1314

@@ -17,8 +18,9 @@ The compat path must be explicitly enabled at runtime by setting the environment
1718
3. The GPU buffer is registered with `hipFileBufRegister`.
1819
4. The output file is opened **without** `O_DIRECT` and registered with hipFile via
1920
`hipFileHandleRegister`.
20-
5. `hipFileWrite` is called. Because the file descriptor lacks `O_DIRECT`, hipFile routes the
21-
write through a POSIX-compatible bounce path.
21+
5. `hipFileWrite` is called. On an `O_DIRECT`-capable filesystem, hipFile transparently reopens
22+
the file with `O_DIRECT` and takes the fast path. On a filesystem that cannot support
23+
`O_DIRECT`, hipFile routes the write through a POSIX-compatible bounce path.
2224
6. `ftruncate` trims the file to the exact logical payload size (defensive; the compat path can
2325
write the exact size, so the truncate is a no-op here).
2426
7. The written file is read back via plain POSIX I/O and its hash is compared against the expected
@@ -27,10 +29,12 @@ The compat path must be explicitly enabled at runtime by setting the environment
2729

2830
## Key APIs and Concepts
2931

30-
- `O_DIRECT` is required for the hipFile GPU-direct fast path. Files opened without it trigger
31-
the POSIX compatibility path, which performs an extra data copy through the kernel page cache.
32-
- `HIPFILE_ALLOW_COMPAT_MODE=1` enables the compat path. Without it, hipFile rejects writes to
33-
non-`O_DIRECT` file handles to prevent accidental performance degradation.
32+
- When a file is opened without `O_DIRECT`, hipFile first attempts to reopen it with `O_DIRECT` to
33+
engage the GPU-direct fast path. If the filesystem does not support `O_DIRECT`, hipFile falls
34+
back to the POSIX compatibility path, which performs an extra data copy through the kernel page
35+
cache.
36+
- The compat path is enabled by default. Set `HIPFILE_ALLOW_COMPAT_MODE=true` only if you have
37+
previously disabled it and need to re-enable it.
3438
- Unlike the `O_DIRECT` path, the compat path does not require transfer sizes to be a multiple of
3539
the filesystem's logical block size, so the exact payload size can be written directly.
3640

‎Systems/hipFile/basics/no_odirect_write/no-odirect-write.cpp‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,27 @@
44
*/
55

66
/* no-odirect-write - Write a registered GPU buffer to a file opened without
7-
* O_DIRECT. hipFile falls back to its POSIX-IO path because the fast
8-
* GPU-direct path requires O_DIRECT.
7+
* O_DIRECT. On an O_DIRECT-capable filesystem hipFile transparently reopens
8+
* the file with O_DIRECT and still takes the GPU-direct fast path. On a
9+
* filesystem that cannot do O_DIRECT it falls back to the POSIX compat path,
10+
* which is enabled by default — set HIPFILE_ALLOW_COMPAT_MODE=true only if
11+
* you previously disabled it.
912
*
1013
* Usage: ./no_odirect_write OUTPUT [GPUID]
1114
*
1215
* OUTPUT Path to the output file. Created/truncated. Receives NOW_SIZE
13-
* (default 128 KiB) bytes of generated test pattern via the
14-
* compat/POSIX fallback path because the file is opened without
15-
* O_DIRECT.
16+
* (default 128 KiB) bytes of generated test pattern.
1617
* GPUID GPU device index (optional, default 0).
1718
*
1819
* Steps:
1920
* 1. Select GPU
2021
* 2. Build CPU pattern + copy to GPU
2122
* 3. hipFileBufRegister
2223
* 4. open file without O_DIRECT + hipFileHandleRegister
23-
* 5. hipFileWrite via POSIX fallback
24+
* 5. hipFileWrite (hipFile reopens with O_DIRECT on capable filesystems,
25+
* or uses the POSIX compat fallback otherwise)
2426
* 6. ftruncate to exact size
2527
* 7. Hash verify
26-
*
27-
* Compat mode must be enabled via env var:
28-
* HIPFILE_ALLOW_COMPAT_MODE=1 ./no_odirect_write OUTPUT
2928
*/
3029

3130
#include "examples_common.h"

0 commit comments

Comments
 (0)