You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -76,7 +77,8 @@ CXLMemSim adds a server-oriented CXL memory backend. The top-level build always
76
77
-`cxlmemsim`, a static library with the core simulator.
77
78
-`cxlmemsim_server`, the Type 3 memory server.
78
79
-`cxlmemsim_latency`, a latency calculator.
79
-
-`test_distributed_shm`, a distributed shared-memory test.
80
+
- built test binaries for unit and integration checks.
81
+
- CTest targets for DCD/GFAM, ROB, and memory-stall unit behavior.
80
82
81
83
The server entry point is `src/main_server.cc`. It creates a CXL controller, adds a CXL memory expander endpoint, loads the topology, initializes a shared memory pool, and then serves requests from QEMU or test clients.
- Dynamic Capacity Device add, release, and query operations.
94
+
- GFAM host map, unmap, access-check, and query operations.
91
95
92
96
The server supports several communication modes:
93
97
@@ -100,6 +104,8 @@ The server supports several communication modes:
100
104
101
105
The memory pool is managed by `SharedMemoryManager`. It can use POSIX shared memory or a regular file as a backing store. The shared-memory header records a magic value, format version, total size, data offset, base address, and cache-line count. The default cache-line data area is mapped with `mmap()` and is reused when the backing object already exists.
102
106
107
+
The server CLI uses local parse-result structs in `src/main_server.cc`, `src/main.cc`, and `src/rob.cc`, so command-line parsing is handled in-tree.
108
+
103
109
## Coherency and Distributed Memory
104
110
105
111
The distributed path is implemented in:
@@ -289,7 +295,7 @@ multiple QEMU guests or server nodes
289
295
290
296
## Build
291
297
292
-
The project uses CMake and C++20. It depends on `cxxopts` and header-only `spdlog`. RDMA support is enabled when `librdmacm` and `libibverbs` are found.
298
+
The project uses CMake and C++20. It depends on header-only `spdlog`; the server and ROB tools use in-tree argument parsing. RDMA support is enabled when `librdmacm` and `libibverbs` are found.
293
299
294
300
```bash
295
301
mkdir -p build
@@ -381,6 +387,9 @@ The launcher reads the following runtime variables:
381
387
|`CXL_PGAS_SHM`|`/cxlmemsim_pgas`| POSIX shared-memory object used by QEMU SHM mode. |
382
388
|`CXL_MEMSIM_SERVER_BINARY`| package `bin/cxlmemsim_server`| Server binary started before QEMU. |
383
389
|`CXL_MEMSIM_SERVER_AUTOSTART`|`auto`| Set to `1` to require server startup or `0` to disable it. |
390
+
|`CXL_DCD_ENABLE`|`0`| Enables DCD reporting in integration wrappers. |
391
+
|`CXL_GFAM_ENABLE`|`0`| Enables GFAM reporting in integration wrappers. |
392
+
|`CXL_GFAM_HOST_ID`|`0`| Host ID passed to fabric-aware integrations. |
384
393
385
394
QEMU's `shm` transport uses the PGAS shared-memory protocol, so the packaged launcher maps `CXL_TRANSPORT_MODE=shm` to the server's `--comm-mode pgas-shm`.
386
395
@@ -401,6 +410,8 @@ CXL_MEMSIM_PORT=9999 \
401
410
qemu_launch_cxl.sh
402
411
```
403
412
413
+
When QEMU connects to `cxlmemsim_server`, the Type 3 device now queries the DCD and GFAM protocol state. If DCD is enabled, QEMU logs the dynamic allocated, total, and free capacity reported by the server. If GFAM is enabled, QEMU logs host, mapping, operation, denied-access, and average-latency counters. Server-side DCD or GFAM denials are returned to QEMU as memory transaction errors instead of being silently treated as successful reads or writes.
414
+
404
415
Inside the guest, quick checks are:
405
416
406
417
```bash
@@ -448,6 +459,24 @@ File-backed memory pool:
448
459
--capacity=1024
449
460
```
450
461
462
+
Dynamic Capacity Device and GFAM:
463
+
464
+
```bash
465
+
./build/cxlmemsim_server \
466
+
--comm-mode=tcp \
467
+
--port=9999 \
468
+
--capacity=10000 \
469
+
--default_latency=400 \
470
+
--topology=topology.txt \
471
+
--enable-dcd \
472
+
--dcd-granularity-mb=1 \
473
+
--dcd-initial-capacity=10000 \
474
+
--enable-gfam \
475
+
--gfam-hosts=16 \
476
+
--gfam-fabric-latency=80 \
477
+
--gfam-bandwidth=64
478
+
```
479
+
451
480
Useful options:
452
481
453
482
| Option | Meaning |
@@ -458,8 +487,17 @@ Useful options:
458
487
|`--topology`| Topology file using Newick-style syntax. |
459
488
|`--comm-mode`|`tcp`, `shm`, `pgas-shm`, or `distributed`. |
460
489
|`--backing-file`| Use a regular file instead of POSIX shared memory. |
490
+
|`--enable-dcd`| Enable the Dynamic Capacity Device model. |
491
+
|`--dcd-granularity-mb`| DCD allocation granularity in MB. |
492
+
|`--dcd-initial-capacity`| Initial DCD capacity in MB. Omit it to allocate the full `--capacity`. |
493
+
|`--enable-gfam`| Enable GFAM access control and fabric latency accounting. |
494
+
|`--gfam-hosts`| Number of GFAM host IDs to register. |
495
+
|`--gfam-fabric-latency`| Per-access GFAM fabric latency in ns. |
496
+
|`--gfam-bandwidth`| Aggregate GFAM bandwidth in GB/s. |
461
497
|`SPDLOG_LEVEL`| Runtime log level, for example `debug` or `trace`. |
462
498
499
+
DCD/GFAM protocol operations are available over TCP and the PGAS shared-memory protocol. Query responses use the 64-byte response data area: DCD query returns total capacity, free capacity, active extents, and failed requests; GFAM query returns mappings, shared mappings, read/write/atomic operations, denied accesses, and average access latency.
500
+
463
501
## Distributed Mode
464
502
465
503
Coordinator node:
@@ -594,6 +632,62 @@ Available tests include:
594
632
-`cxl_pointer_sharing_test`
595
633
-`cxl_bias_benchmark`
596
634
635
+
## Tests
636
+
637
+
Configure with CMake and run the self-contained unit tests through CTest:
638
+
639
+
```bash
640
+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
641
+
cmake --build build -j
642
+
ctest --test-dir build --output-on-failure
643
+
```
644
+
645
+
The top-level CMake file builds every test source in `tests/`:
|`test_rob`| Parses O3CPU/LSQ debug lines and feeds derived instructions into the ROB model. | Yes |
651
+
|`test_mem_stall`| Compares O3CPU memory-stall debug intervals against modeled ROB stalls. | Yes |
652
+
|`test_distributed_shm`| Two in-process distributed memory servers over SHM/TCP helper paths. | Built only |
653
+
|`test_back_invalidation`| TCP/PGAS client for external back-invalidation experiments. | Built only |
654
+
|`test_dax_back_invalidation`| DAX plus TCP client for external guest/device experiments. | Built only |
655
+
656
+
`test_rob` and `test_mem_stall` use gem5-style O3CPU, LSQ, and MemDepUnit debug text. Generate compatible traces with gem5 debug flags such as `O3CPU,LSQ,MemDepUnit`.
657
+
658
+
## gem5-CXL Integration
659
+
660
+
`gem5_integration/run.py` is a small launcher for SlugLab's gem5-CXL fork at <https://github.com/SlugLab/gem5-CXL>. It locates a gem5 binary, selects a config script, sets CXLMemSim environment variables, and enables O3CPU trace debug output by default.
Full-system runs can pass kernel, disk image, workload script, memory size, CXL memory size, and extra gem5 config arguments:
675
+
676
+
```bash
677
+
./gem5_integration/run.py \
678
+
--gem5-root /path/to/gem5-CXL \
679
+
--kernel /path/to/vmlinux \
680
+
--disk-image /path/to/disk.img \
681
+
--script boot.rcS \
682
+
--mem-size 4GB \
683
+
--cxl-mem-size 16GB \
684
+
--cxl-host 127.0.0.1 \
685
+
--cxl-port 9999 \
686
+
--enable-dcd \
687
+
--enable-gfam \
688
+
-- --cpu-type=O3CPU
689
+
```
690
+
597
691
## Legacy Application-Level Simulator Invocation
598
692
599
693
The original CXLMemSim application-level invocation accepts a target executable, sampling interval, CPU set, DRAM latency, bandwidth/latency vectors, capacity vectors, heuristic weights, and topology.
0 commit comments