fifo;
- size_t feed = 0, checked = 0, errors = 0;
- size_t e_uf = 0, e_subin = 0, e_special = 0, e_normal = 0; // mismatch buckets
-
- for (size_t c = 0; c < N + LATENCY; ++c) {
- if (feed < N) {
- const TV& t = tests[feed];
- sim->dataa = t.a; sim->frm = t.frm; sim->fmt = 0; sim->mask = 1;
- uint32_t ff = 0;
- uint32_t ga = t.a;
-#ifdef LEAN
- ga = flush_sub(t.a);
-#endif
- uint32_t r = rv_fsqrt_s(ga, t.frm, &ff);
-#ifdef LEAN
- r = flush_sub(r); ff = 0;
-#endif
- fifo.push_back({r, ff, t.a, t.frm});
- ++feed;
- } else {
- sim->mask = 0;
- }
- sim->enable = 1;
- ticks = sim.step(ticks, 2);
-
- if (c >= (size_t)(LATENCY - 1) && !fifo.empty()) {
- Golden g = fifo.front(); fifo.pop_front();
- uint32_t got_r = sim->result, got_f = sim->fflags;
- if (got_r != g.res || got_f != g.fflags) {
- if (g.fflags & 0x2) ++e_uf;
- else if (fclass(g.a) == 1) ++e_subin;
- else if (fclass(g.a) != 2) ++e_special;
- else ++e_normal;
- if (errors < 20)
- printf("MISMATCH fsqrt a=%08x frm=%u : got res=%08x ff=%02x exp res=%08x ff=%02x\n",
- g.a, g.frm, got_r, got_f, g.res, g.fflags);
- ++errors;
- }
- ++checked;
- }
- }
-
- printf("fsqrt_unit: checked=%zu errors=%zu [underflow=%zu subnormal-input=%zu special-operand=%zu normal=%zu]\n",
- checked, errors, e_uf, e_subin, e_special, e_normal);
-
-#if (FLEN == 64) && !defined(LEAN)
- // F64 operands (fmt D) in an F64-wide unit: directed specials, exact squares
- // (k^2 and k^2/4: an exact root must not raise NX nor round up) and random
- // patterns, all rounding modes, against the softfloat RISC-V FSQRT.D.
- size_t checked_d = 0, errors_d = 0;
- {
- const uint64_t kSpecialsD[] = {
- 0x0000000000000000ull, 0x8000000000000000ull, 0x3ff0000000000000ull, 0xbff0000000000000ull,
- 0x4000000000000000ull, 0x4010000000000000ull, 0x4059000000000000ull, 0x400921fb54442d18ull,
- 0x7ff0000000000000ull, 0xfff0000000000000ull, 0x7ff8000000000000ull, 0x7ff4000000000000ull,
- 0x0000000000000001ull, 0x000fffffffffffffull, 0x0010000000000000ull, 0x7fefffffffffffffull,
- 0x3fb999999999999aull, 0x3fd0000000000000ull };
- struct TD { uint64_t a; uint32_t frm; };
- std::vector| td;
- for (uint64_t a : kSpecialsD)
- for (uint32_t f = 0; f < 5; ++f)
- td.push_back({a, f});
- for (uint64_t k = 1; k < 4000; ++k) {
- double d = double(k) * double(k) * ((k & 1) ? 1.0 : 0.25);
- uint64_t b; std::memcpy(&b, &d, sizeof(b));
- td.push_back({b, static_cast(k % 5)});
- }
- std::mt19937_64 rng64(0x5EED64ull);
- for (size_t i = 0; i < num_random / 2; ++i)
- td.push_back({rng64(), static_cast(i % 5)});
- struct GD { uint64_t res; uint32_t ff; uint64_t a; uint32_t frm; };
- std::deque fd;
- const size_t ND = td.size();
- for (size_t c = 0; c < ND + LATENCY; ++c) {
- if (c < ND) {
- sim->dataa = td[c].a; sim->frm = td[c].frm; sim->fmt = 1; sim->mask = 1; // INST_FMT_D
- uint32_t ff = 0;
- uint64_t r = rv_fsqrt_d(td[c].a, td[c].frm, &ff);
- fd.push_back({r, ff, td[c].a, td[c].frm});
- } else {
- sim->mask = 0;
- }
- sim->enable = 1;
- ticks = sim.step(ticks, 2);
- if (c >= (size_t)(LATENCY - 1) && !fd.empty()) {
- GD g = fd.front(); fd.pop_front();
- uint64_t got_r = sim->result;
- uint32_t got_f = sim->fflags;
- if (got_r != g.res || got_f != g.ff) {
- if (errors_d < 20)
- printf("MISMATCH fsqrt.d a=%016llx frm=%u : got res=%016llx ff=%02x exp res=%016llx ff=%02x\n",
- (unsigned long long)g.a, g.frm, (unsigned long long)got_r, got_f,
- (unsigned long long)g.res, g.ff);
- ++errors_d;
- }
- ++checked_d;
- }
- }
- }
- printf("fsqrt_unit F64: checked=%zu errors=%zu\n", checked_d, errors_d);
- errors += errors_d;
-#endif
- printf("%s\n", errors ? "FAILED" : "PASSED");
- return errors ? 1 : 0;
-}
diff --git a/profiles/a100.json b/profiles/a100.json
index 4589cf3ca7..71ac2cdaac 100644
--- a/profiles/a100.json
+++ b/profiles/a100.json
@@ -9,8 +9,6 @@
"VX_CFG_NUM_ALU_LANES": 16,
"VX_CFG_NUM_FPU_LANES": 16,
"VX_CFG_NUM_LSU_LANES": 8,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FCVT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 2,
"VX_CFG_DCACHE_SIZE": 196608,
@@ -64,7 +62,7 @@
},
"sources": {
"NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH": "108 SMs, 64 resident warps/SM, 4 schedulers x 32 lanes (NVIDIA A100 Tensor Core GPU Architecture whitepaper, Table 3)",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and all type conversions not to or from 8/16-bit integers (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 4",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: all type conversions not to or from 8/16-bit integers (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 4",
"DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM (A100 whitepaper): 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part",
"DCACHE_SIZE": "192 KB combined L1/shared per SM (whitepaper): 6 ways over power-of-two sets",
"L2_SIZE, L2_NUM_WAYS, L2_NUM_BANKS": "40 MB L2 in 80 slices (whitepaper): 20 ways over power-of-two sets; 64 banks of 64 B (4 KB/clk), the power of two nearest the 80 slices' 5 KB/clk",
@@ -81,7 +79,7 @@
"EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Off: the datacenter part is built for compute (no display outputs; the raster and ROP hardware is reduced or absent), so the profile models its compute machine",
"NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GA100 SM (A100 whitepaper, Figure 7): 4 processing blocks, each with 16 FP32, 16 INT32, 8 FP64 cores, 8 LD/ST units, 1 SFU and 1 tensor core. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)",
- "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates",
+ "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 conversions take the FCVT rate",
"LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "164 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 8.0) in a 256 KB window. DCACHE_SIZE is the whole 192 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves",
"EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment",
"reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: Abdelkhalik et al., Demystifying the Nvidia Ampere Architecture through Microbenchmarking and Instruction-level Analysis (HPEC 2022), Table IV: L1 33, L2 200, global memory 290 cycles",
diff --git a/profiles/gtx1080.json b/profiles/gtx1080.json
index 73a4ae2c28..3cfd3d26a7 100644
--- a/profiles/gtx1080.json
+++ b/profiles/gtx1080.json
@@ -24,8 +24,6 @@
"VX_CFG_EXT_TEX_ENABLE": true,
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 32,
"VX_CFG_DCACHE_NUM_WAYS": 6,
"VX_CFG_L1_LINK_LATENCY": 26,
@@ -71,8 +69,7 @@
"EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Raster engines in every GPC and ROPs in every memory partition (architecture whitepaper)",
"NUM_TFU_LANES": "32 special-function results per clock per SM (8 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GP104 SM (GTX 1080 whitepaper): 4 processing blocks, each with 32 CUDA cores (FP32 and INT32 on the same cores), 8 LD/ST units and 8 SFUs; 4 FP64 cores per SM. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)",
- "FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 4 FP64 cores per SM, 1 per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 32 = 1 F64 FMA PE. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO": "32 results per clock per SM, 8 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 4",
+ "FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 4 FP64 cores per SM, 1 per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 32 = 1 F64 FMA PE. FP64 conversions take the FCVT rate",
"LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "96 KB dedicated shared memory per SM, separate from the 48 KB L1/texture (GTX 1080 whitepaper), in a 128 KB window",
"EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment",
"reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: Jia et al., Dissecting the NVIDIA Turing T4 GPU via Microbenchmarking (arXiv 1903.07486), Table 3.1: L1 hit 82 and L2 hit ~216 cycles on the Tesla P4, a GP104 like this card. No DRAM latency is published for GP104, so dram_cycles is unchecked. Accel-Sim correlates the Pascal TITAN X and GTX 1080 Ti (posted hardware runs: pascal-titanx, pascal-1080ti)",
diff --git a/profiles/gtx480.json b/profiles/gtx480.json
index 9fffb1e665..cd3cf36980 100644
--- a/profiles/gtx480.json
+++ b/profiles/gtx480.json
@@ -25,8 +25,6 @@
"VX_CFG_EXT_TEX_ENABLE": true,
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 8,
- "VX_CFG_FSQRT_PE_RATIO": 8,
"VX_CFG_FCVT_PE_RATIO": 2,
"VX_CFG_FMA64_PE_RATIO": 8,
"VX_CFG_L1_LINK_LATENCY": 34,
@@ -61,7 +59,7 @@
"NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "15 SMs (480 CUDA cores), 48 resident warps per SM, 2 warp schedulers per SM (NVIDIA Fermi compute architecture whitepaper; GTX 480 specifications)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES, PLATFORM_CLOCK_RATE": "Fermi SM: 2 groups of 16 CUDA cores (FP32 and INT32), 16 LD/ST units and 4 SFUs, the cores at the 1401 MHz shader (hot) clock, twice the 700 MHz core clock (Fermi whitepaper). Each scheduler sends a warp to a 16-core group for two hot clocks, one core clock, so the profile runs at the core clock with 32 lanes per scheduler's block: the same FLOPS (15 x 2 x 32 x 2 x 700 MHz = 1344 GFLOPS) at 960 core-clock lanes against the 480 hot-clock cores, so fp32_lanes is not checked. 16 LD/ST units at the hot clock give 16 lanes per block. 700 MHz is the clock of Accel-Sim's SM2_GTX480 configuration",
"FMA64_PE_RATIO": "FP64 FMA at 1/8 of the FP32 rate on the GeForce part (the Tesla Fermi parts run it at 1/2): 32 FPU lanes / 8 = 4 F64 FMA PEs per block",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "4 SFU results per hot clock per SM, 4 per block per core clock, for the FP32 reciprocal and reciprocal square root on which division and square root are built: 32 / 8; 16 type conversions per hot clock per SM, 16 per block per core clock: 32 / 2 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 2.0)",
+ "FCVT_PE_RATIO": "16 type conversions per hot clock per SM, 16 per block per core clock: 32 / 2 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 2.0)",
"NUM_TFU_LANES": "4 SFUs per SM at the hot clock: 4 results per block per core clock",
"DCACHE_SIZE, DCACHE_NUM_WAYS": "16 KB L1 with 48 KB shared memory, the default split of the 64 KB L1/shared per SM (Fermi whitepaper): 4 ways",
"LMEM_SIZE, LMEM_LOG_SIZE, LMEM_NUM_BANKS": "48 KB shared memory per SM; 32 banks of 4 B (16 Vortex banks of 8 B carry the same bytes per clock)",
diff --git a/profiles/h100.json b/profiles/h100.json
index 9c3a98b68d..36b0432128 100644
--- a/profiles/h100.json
+++ b/profiles/h100.json
@@ -29,8 +29,6 @@
"VX_CFG_EXT_DXA_ENABLE": true,
"VX_CFG_NUM_BARRIERS": 16,
"VX_CFG_EXT_TEX_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 8,
- "VX_CFG_FSQRT_PE_RATIO": 8,
"VX_CFG_FCVT_PE_RATIO": 8,
"VX_CFG_FMA64_PE_RATIO": 2,
"VX_CFG_DCACHE_NUM_BANKS": 4,
@@ -79,8 +77,8 @@
"EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Off: the datacenter part is built for compute (no display outputs; the raster and ROP hardware is reduced or absent), so the profile models its compute machine",
"NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GH100 SM (H100 whitepaper, Figure 7): 4 processing blocks, each with 32 FP32, 16 INT32, 16 FP64 cores, 8 LD/ST units, 1 SFU and 1 tensor core. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)",
- "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0); 32 FPU lanes / 2 = 16 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 9.0",
+ "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0); 32 FPU lanes / 2 = 16 F64 FMA PEs. FP64 conversions take the FCVT rate",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 9.0",
"DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM: 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part",
"LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "228 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 9.0) in a 256 KB window. DCACHE_SIZE keeps the whole 256 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves",
"EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment",
diff --git a/profiles/keplertitan.json b/profiles/keplertitan.json
index e738ddef1c..15a91e3097 100644
--- a/profiles/keplertitan.json
+++ b/profiles/keplertitan.json
@@ -25,8 +25,6 @@
"VX_CFG_EXT_TEX_ENABLE": true,
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FCVT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 2,
"VX_CFG_L1_LINK_LATENCY": 4,
@@ -61,7 +59,7 @@
"NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "14 SMX (2688 CUDA cores), 64 resident warps per SMX, 4 warp schedulers each with 2 dispatch units (NVIDIA Kepler GK110 whitepaper)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GK110 SMX: 192 FP32/INT32 cores, 64 FP64 units, 32 LD/ST units and 32 SFUs over 4 schedulers (GK110 whitepaper). Vortex lanes divide the warp, so each scheduler's block gets 32 lanes (128 per SMX): the other 64 cores are reached on the part only by dual-issuing independent instructions, which Vortex does not model. fp32_lanes (2688) is therefore not checked",
"FMA64_PE_RATIO": "64 FP64 units per SMX, 16 per scheduler (GK110 whitepaper; the TITAN runs FP64 at the full 1/3 rate with its double-precision mode on): 32 FPU lanes / 2 = 16 F64 FMA PEs per block, the part's FP64 lanes",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "32 results per clock per SMX, 8 per scheduler: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 3.5); 32 FPU lanes / 4",
+ "FCVT_PE_RATIO": "32 results per clock per SMX, 8 per scheduler: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 3.5); 32 FPU lanes / 4",
"NUM_TFU_LANES": "32 SFUs per SMX, 8 per scheduler (GK110 whitepaper)",
"DCACHE_SIZE, DCACHE_NUM_WAYS": "16 KB L1 with 48 KB shared memory, the default split of the 64 KB L1/shared per SMX (GK110 whitepaper): 4 ways",
"LMEM_SIZE, LMEM_LOG_SIZE, LMEM_NUM_BANKS": "48 KB shared memory per SMX; 32 banks of 8 B (GK110 shared memory runs in an 8-byte bank mode, 256 B per clock)",
diff --git a/profiles/mi300x.json b/profiles/mi300x.json
index b1ad26d2a7..f5a83a6600 100644
--- a/profiles/mi300x.json
+++ b/profiles/mi300x.json
@@ -28,8 +28,6 @@
"VX_CFG_TCU_INT8_ENABLE": true,
"VX_CFG_TCU_SPARSE_ENABLE": true,
"VX_CFG_NUM_BARRIERS": 16,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_L1_LINK_LATENCY": 19,
"VX_CFG_EXT_LDST_WIDE_ENABLE": true
},
@@ -82,7 +80,6 @@
"PLATFORM_CLOCK_RATE": "2100 MHz peak engine clock",
"EXT_TCU_ENABLE, TCU_*": "4 matrix cores per CU, one per SIMD as NUM_TCU_BLOCKS=ISSUE_WIDTH: FP16/BF16, TF32, FP8, INT8, with structured sparsity. Matrix FP64/FP32 are not modelled",
"TCU_PE_RATIO": "1024 dense FP16 FMA per clock per CU: 1307 TFLOPS at 2100 MHz over 304 CUs (AMD CDNA 3 white paper). A TCU block at NUM_THREADS=64 computes an 8x8x8-word tile, 1024 FP16 FMA per clock, so the 4 blocks give 4096: ratio 4",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO": "Transcendentals (reciprocal, reciprocal square root, on which division and square root are built) run at a quarter of the FP32 rate on GCN, RDNA and CDNA: FPU lanes / 4",
"EXT_LDST_WIDE_ENABLE": "128-bit LDS and global loads and stores: DS_READ_B128 / DS_WRITE_B128 and GLOBAL_LOAD_DWORDX4 / GLOBAL_STORE_DWORDX4 (AMD Instinct MI300 CDNA3 Instruction Set Architecture reference guide, LDS and FLAT/global memory instructions). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as DS_READ_B128, needs 16-byte alignment",
"reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: MGPUSim's measured MI300X ground truth (sarchlab/mgpusim gpu_perf_scripts/calibration/mi300x_ground_truth.csv, cache_latency: a one-thread pointer chase over 64 B lines, 4 laps with at least 131072 and at most 16M timed loads, amd/benchmarks/microbench/cachelatency): 32.4 ns per load up to 16 KB (L1, 68 cycles at 2100 MHz), 85.2 ns from 32 KB to 4 MB (L2, 179 cycles), about 198 ns from 8 to 64 MB (Infinity Cache, the L3: not checked, no chase metric) and 343 ns from 512 MB up (HBM3, 720 cycles)",
"L1_LINK_LATENCY": "19 core cycles each way between a core and its dcache, the L1/texture load pipeline, which the dcache bank pipeline (DCACHE_LATENCY) does not model: calibrated with ci/profile_check.py so the SimX pointer chase gives the 68-cycle L1 hit latency in 'reference'",
diff --git a/profiles/p100.json b/profiles/p100.json
index 6e9b33f604..3395a40ac9 100644
--- a/profiles/p100.json
+++ b/profiles/p100.json
@@ -23,8 +23,6 @@
"VX_CFG_NUM_TFU_LANES": 16,
"VX_CFG_NUM_BARRIERS": 16,
"VX_CFG_EXT_TEX_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FCVT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 2,
"VX_CFG_L1_LINK_LATENCY": 27,
@@ -57,7 +55,7 @@
"NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "56 SMs (3584 CUDA cores), 64 resident warps per SM, 2 processing blocks each with its own warp scheduler and instruction buffer (NVIDIA Tesla P100 whitepaper)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GP100 SM processing block: 32 FP32 cores (FP32 and INT32), 16 FP64 cores, 8 LD/ST units and 8 SFUs (P100 whitepaper, Figure 8). One Vortex ALU/FPU/LSU block per processing block with the part's lanes. FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)",
"FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (P100 whitepaper; CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 2",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 8 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 4",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 8 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 4",
"NUM_TFU_LANES": "16 special-function results per clock per SM, 8 SFUs per processing block (P100 whitepaper)",
"DCACHE_SIZE, DCACHE_NUM_WAYS": "24 KB unified L1/texture per SM (Jia et al., Table 3.1), separate from shared memory: 6 ways over power-of-two sets",
"LMEM_SIZE, LMEM_LOG_SIZE": "64 KB shared memory per SM (P100 whitepaper; CUDA Programming Guide, compute capability 6.0)",
diff --git a/profiles/rtx2060.json b/profiles/rtx2060.json
index 466c9d572b..5b39651f0b 100644
--- a/profiles/rtx2060.json
+++ b/profiles/rtx2060.json
@@ -30,8 +30,6 @@
"VX_CFG_EXT_TEX_ENABLE": true,
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FCVT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 16,
"VX_CFG_EXT_LDST_WIDE_ENABLE": true
@@ -66,7 +64,7 @@
"NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "30 SMs (1920 CUDA cores), 32 resident warps per SM (1024 threads, compute capability 7.5), 4 processing blocks each with its own scheduler and L0 instruction cache (NVIDIA Turing architecture whitepaper)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "TU10x SM processing block: 16 FP32 cores, 16 INT32 cores, 4 LD/ST units, 4 SFUs and 2 tensor cores (Turing whitepaper, Figure 4). One Vortex ALU/FPU/LSU block per processing block with the part's INT32, FP32 and LD/ST lanes. FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)",
"FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 2 FP64 cores per SM (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.5). A block keeps at least one PE, so 16 FPU lanes / 16 = 1 F64 FMA PE per block: 1/16 of FP32, twice the part's FP64 rate",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 7.5); 16 FPU lanes / 4",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 7.5); 16 FPU lanes / 4",
"DCACHE_SIZE, DCACHE_NUM_WAYS, DCACHE_NUM_BANKS": "96 KB L1/shared per SM (Turing whitepaper): 6 ways over power-of-two sets, the whole pool as in the other profiles (the driver gives a kernel the L1 its shared memory leaves). 64 B per clock of L1 data per SM, 16 LD/ST units x 4 B (Jia et al., T4, Table 3.2: 58.8 B/cycle/SM measured): 2 banks of the 32 B dcache word",
"LMEM_SIZE, LMEM_LOG_SIZE": "64 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 7.5)",
"LMEM_NUM_BANKS": "128 B per clock per SM: 32 banks of 4 B on the part (CUDA C++ Programming Guide, shared memory). Vortex banks are XLEN wide (8 B), so 16 banks carry the same bytes per clock",
diff --git a/profiles/rtx5080.json b/profiles/rtx5080.json
index 91cbe27df5..93cfd3dba9 100644
--- a/profiles/rtx5080.json
+++ b/profiles/rtx5080.json
@@ -38,8 +38,6 @@
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
"VX_CFG_RTU_TLAS_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 8,
- "VX_CFG_FSQRT_PE_RATIO": 8,
"VX_CFG_FCVT_PE_RATIO": 8,
"VX_CFG_FMA64_PE_RATIO": 64,
"VX_CFG_L1_LINK_LATENCY": 2,
@@ -115,8 +113,8 @@
"RTU_TLAS_ENABLE": "RT cores traverse two-level acceleration structures (instance TLAS over BLAS), as DXR/Vulkan ray tracing requires",
"NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GB203 SM (RTX Blackwell whitepaper, Figure 5 and App. B): 4 processing blocks, each with 32 unified FP32/INT32 CUDA cores (INT32 TOPS = FP32 TFLOPS, Table 4), 4 LD/ST units and 1 SFU, 1 tensor core; 2 FP64 cores per SM. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)",
- "FMA64_PE_RATIO": "FP64 FMA at 1/64 of the FP32 rate: 2 FP64 results per clock per SM against 128 FP32 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0; arXiv 2507.10789 Table I: 2 FP64 units per SM on GB203). How those units map onto the 4 processing blocks is not documented. A Vortex block keeps at least one full-rate PE, so 32 FPU lanes / 64 rounds up to 1 F64 FMA PE: 1/32 of FP32, twice the part's FP64 rate. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 12.0",
+ "FMA64_PE_RATIO": "FP64 FMA at 1/64 of the FP32 rate: 2 FP64 results per clock per SM against 128 FP32 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0; arXiv 2507.10789 Table I: 2 FP64 units per SM on GB203). How those units map onto the 4 processing blocks is not documented. A Vortex block keeps at least one full-rate PE, so 32 FPU lanes / 64 rounds up to 1 F64 FMA PE: 1/32 of FP32, twice the part's FP64 rate. FP64 conversions take the FCVT rate",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 12.0",
"LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "100 KB maximum shared memory per SM (compute capability 12.0 device query: 102400 B per SM) in a 128 KB window. DCACHE_SIZE keeps the whole 128 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves",
"L1_LINK_LATENCY": "2 core cycles each way between a core and its dcache, the L1 load pipeline, which the dcache bank pipeline (DCACHE_LATENCY) does not model: calibrated with ci/profile_check.py so the SimX pointer chase gives the 35-cycle L1 hit latency in 'reference'"
}
diff --git a/profiles/v100.json b/profiles/v100.json
index fab5eea818..ca7e19ad98 100644
--- a/profiles/v100.json
+++ b/profiles/v100.json
@@ -26,8 +26,6 @@
"VX_CFG_EXT_TEX_ENABLE": true,
"VX_CFG_EXT_RASTER_ENABLE": true,
"VX_CFG_EXT_OM_ENABLE": true,
- "VX_CFG_FDIV_PE_RATIO": 4,
- "VX_CFG_FSQRT_PE_RATIO": 4,
"VX_CFG_FCVT_PE_RATIO": 4,
"VX_CFG_FMA64_PE_RATIO": 2,
"VX_CFG_DCACHE_NUM_BANKS": 4,
@@ -77,8 +75,8 @@
"EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Raster engines in every GPC and ROPs in every memory partition (architecture whitepaper)",
"NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0)",
"NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GV100 SM (Volta whitepaper, Figure 5): 4 processing blocks, each with 16 FP32, 16 INT32, 8 FP64 cores, 8 LD/ST units, 1 SFU and 2 tensor cores. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)",
- "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates",
- "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 16 FPU lanes / 4, compute capability 7.0",
+ "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 conversions take the FCVT rate",
+ "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 16 FPU lanes / 4, compute capability 7.0",
"DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM: 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part (Volta whitepaper: 128 B/clk L1)",
"LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "96 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 7.0) in a 128 KB window. DCACHE_SIZE keeps the whole 128 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves, so a kernel without shared memory sees the full pool",
"EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment",
diff --git a/sim/foldsim/xilinx_fp_models.sv b/sim/foldsim/xilinx_fp_models.sv
index 096678222a..8f67cffb7f 100644
--- a/sim/foldsim/xilinx_fp_models.sv
+++ b/sim/foldsim/xilinx_fp_models.sv
@@ -122,27 +122,6 @@ module xil_fdiv (
.q({m_axis_result_tvalid, m_axis_result_tdata, m_axis_result_tuser}));
endmodule
-module xil_fsqrt (
- input wire aclk,
- input wire aclken,
- input wire s_axis_a_tvalid,
- input wire [31:0] s_axis_a_tdata,
- output wire m_axis_result_tvalid,
- output wire [31:0] m_axis_result_tdata,
- output wire [0:0] m_axis_result_tuser // invalid
-);
- import xilinx_fp_model_pkg::*;
- logic [63:0] r;
- logic [4:0] f;
- always @(*) begin
- dpi_fsqrt(1'b1, 0, box(ftz_in(s_axis_a_tdata)), 3'b000, r, f);
- end
- xilinx_fp_model_pipe #(.LATENCY(28), .D(1 + 32 + 1)) pipe (
- .aclk(aclk), .aclken(aclken),
- .d({s_axis_a_tvalid, ftz_out(r[31:0]), f[4]}),
- .q({m_axis_result_tvalid, m_axis_result_tdata, m_axis_result_tuser}));
-endmodule
-
module xil_fmul (
input wire aclk,
input wire aclken,
diff --git a/sim/simx/decode.cpp b/sim/simx/decode.cpp
index e11670c56b..3b98fd86a2 100644
--- a/sim/simx/decode.cpp
+++ b/sim/simx/decode.cpp
@@ -992,6 +992,7 @@ Instr::Ptr Decoder::decode(uint32_t code, uint64_t uuid, bool fs_off) {
instr->set_src_reg(0, rs1, RegType::Float);
instr->set_src_reg(1, rs2, RegType::Float);
instr->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ instr->set_macro_op(); // TFU micro-ops (FdivUopGen)
break;
case 0x20: // FCVT.S.D, FCVT.S.H
case 0x21: // FCVT.D.S, FCVT.D.H
@@ -1032,6 +1033,7 @@ Instr::Ptr Decoder::decode(uint32_t code, uint64_t uuid, bool fs_off) {
instr->set_dest_reg(rd, RegType::Float);
instr->set_src_reg(0, rs1, RegType::Float);
instr->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ instr->set_macro_op(); // TFU micro-ops (FdivUopGen)
break;
case 0x50: // FLE.S, FLT.S, FEQ.S
case 0x51: // FLE.D, FLT.D, FEQ.D
diff --git a/sim/simx/fpu_unit.cpp b/sim/simx/fpu_unit.cpp
index 6535236204..b6eae5dab7 100644
--- a/sim/simx/fpu_unit.cpp
+++ b/sim/simx/fpu_unit.cpp
@@ -70,10 +70,6 @@ uint32_t FpuUnit::latency_of(const instr_trace_t* trace) const {
case FpuType::FNMADD:
case FpuType::FNMSUB:
return VX_CFG_FMA_LATENCY;
- case FpuType::FDIV:
- return VX_CFG_FDIV_LATENCY;
- case FpuType::FSQRT:
- return VX_CFG_FSQRT_LATENCY;
case FpuType::F2I:
case FpuType::I2F:
case FpuType::F2F:
@@ -93,7 +89,7 @@ constexpr uint32_t pe_batches(uint32_t pe_ratio) {
// pipeline and response arbiter input.
constexpr bool kFma64Split = (VX_CFG_FLEN >= 64)
&& (pe_batches(VX_CFG_FMA64_PE_RATIO) != pe_batches(VX_CFG_FMA_PE_RATIO));
-constexpr uint32_t kRspInputs = kFma64Split ? 5 : 4;
+constexpr uint32_t kRspInputs = kFma64Split ? 4 : 3;
}
uint32_t FpuUnit::pipe_of(const instr_trace_t* trace) const {
@@ -108,10 +104,6 @@ uint32_t FpuUnit::pipe_of(const instr_trace_t* trace) const {
const auto& fpu_args = std::get(trace->instr_ptr->get_args());
return (kFma64Split && fpu_args.is_f64) ? kPipeFma64 : kPipeFma;
}
- case FpuType::FDIV:
- return kPipeDiv;
- case FpuType::FSQRT:
- return kPipeSqrt;
case FpuType::F2I:
case FpuType::I2F:
case FpuType::F2F:
@@ -148,10 +140,6 @@ uint32_t FpuUnit::batches_of(const instr_trace_t* trace) const {
auto fpuArgs = std::get(trace->instr_ptr->get_args());
return fpuArgs.is_f64 ? pe_batches(VX_CFG_FMA64_PE_RATIO) : pe_batches(VX_CFG_FMA_PE_RATIO);
}
- case FpuType::FDIV:
- return pe_batches(VX_CFG_FDIV_PE_RATIO);
- case FpuType::FSQRT:
- return pe_batches(VX_CFG_FSQRT_PE_RATIO);
case FpuType::F2I:
case FpuType::I2F:
case FpuType::F2F:
@@ -222,32 +210,6 @@ uint32_t FpuUnit::execute(instr_trace_t *trace) {
rd_data[t].u64 = nan_box(rv_fmul_s(check_boxing(rs1_data[t].u64), check_boxing(rs2_data[t].u64), frm, &fflags));
}
result_fflags |= fflags;
- }
- } break;
- case FpuType::FDIV: {
- for (uint32_t t = thread_start; t < num_threads; ++t) {
- if (!tmask.test(t)) continue;
- uint32_t frm = csr_unit_->fpu_rm(fpuArgs.frm, wid);
- uint32_t fflags = 0;
- if (fpuArgs.is_f64) {
- rd_data[t].u64 = rv_fdiv_d(rs1_data[t].u64, rs2_data[t].u64, frm, &fflags);
- } else {
- rd_data[t].u64 = nan_box(rv_fdiv_s(check_boxing(rs1_data[t].u64), check_boxing(rs2_data[t].u64), frm, &fflags));
- }
- result_fflags |= fflags;
- }
- } break;
- case FpuType::FSQRT: {
- for (uint32_t t = thread_start; t < num_threads; ++t) {
- if (!tmask.test(t)) continue;
- uint32_t frm = csr_unit_->fpu_rm(fpuArgs.frm, wid);
- uint32_t fflags = 0;
- if (fpuArgs.is_f64) {
- rd_data[t].u64 = rv_fsqrt_d(rs1_data[t].u64, frm, &fflags);
- } else {
- rd_data[t].u64 = nan_box(rv_fsqrt_s(check_boxing(rs1_data[t].u64), frm, &fflags));
- }
- result_fflags |= fflags;
}
} break;
case FpuType::FSGNJ: {
@@ -497,9 +459,6 @@ void FpuUnit::respond(uint32_t b) {
for (uint32_t i = 1; i <= kRspInputs; ++i) {
uint32_t input = (rsp_grant_.at(b) + i) % kRspInputs;
uint32_t p = input;
- if (input == kPipeDiv && !ready(kPipeDiv)) {
- p = kPipeSqrt;
- }
if (!ready(p)) {
continue;
}
@@ -559,3 +518,125 @@ bool FpuUnit::busy() const {
}
return false;
}
+
+namespace {
+enum class FdivStep { TFU, FMUL, FSUB, FABS, CVT_S, CVT_D };
+enum Sel : uint8_t { SEL_NONE, SEL_RS1, SEL_RS2, SEL_RD };
+
+struct FdivUop {
+ FdivStep step;
+ TfuType fn;
+ Sel a, b;
+};
+
+// The macro sequence before a double's TFU steps are wrapped in conversions.
+uint32_t fdiv_macro_steps(const Instr& instr, FdivUop steps[4]) {
+ bool is_sqrt = (std::get(instr.get_op_type()) == FpuType::FSQRT);
+ auto rd = instr.get_dest_reg().idx;
+ bool rd_is_rs1 = (rd == instr.get_src_reg(0).idx);
+ bool rd_is_rs2 = !is_sqrt && (rd == instr.get_src_reg(1).idx);
+ if (is_sqrt) {
+ steps[0] = {FdivStep::TFU, TfuType::RSQRT, SEL_RS1, SEL_NONE};
+ steps[1] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE};
+ return 2;
+ }
+ if (!rd_is_rs1) {
+ steps[0] = {FdivStep::TFU, TfuType::RCP, SEL_RS2, SEL_NONE};
+ steps[1] = {FdivStep::FMUL, TfuType::RCP, SEL_RS1, SEL_RD};
+ return 2;
+ }
+ if (!rd_is_rs2) {
+ steps[0] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE};
+ steps[1] = {FdivStep::FMUL, TfuType::RCP, SEL_RD, SEL_RS2};
+ steps[2] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE};
+ return 3;
+ }
+ steps[0] = {FdivStep::FABS, TfuType::RCP, SEL_RD, SEL_RD};
+ steps[1] = {FdivStep::TFU, TfuType::LG2, SEL_RD, SEL_NONE};
+ steps[2] = {FdivStep::FSUB, TfuType::RCP, SEL_RD, SEL_RD};
+ steps[3] = {FdivStep::TFU, TfuType::EX2, SEL_RD, SEL_NONE};
+ return 4;
+}
+
+// The sequence's uop count; with out set, also uop uop_index's fields.
+uint32_t fdiv_uop(const Instr& instr, uint32_t uop_index, FdivUop* out) {
+ FdivUop steps[4];
+ uint32_t n = fdiv_macro_steps(instr, steps);
+ bool is_d = std::get(instr.get_args()).is_f64;
+ uint32_t pos = 0;
+ for (uint32_t k = 0; k < n; ++k) {
+ if (is_d && steps[k].step == FdivStep::TFU) {
+ if (out && uop_index == pos) *out = {FdivStep::CVT_S, steps[k].fn, steps[k].a, SEL_NONE};
+ if (out && uop_index == pos + 1) *out = {FdivStep::TFU, steps[k].fn, SEL_RD, SEL_NONE};
+ if (out && uop_index == pos + 2) *out = {FdivStep::CVT_D, steps[k].fn, SEL_RD, SEL_NONE};
+ pos += 3;
+ } else {
+ if (out && uop_index == pos) *out = steps[k];
+ pos += 1;
+ }
+ }
+ return pos;
+}
+
+uint32_t fdiv_sel_reg(const Instr& instr, Sel sel) {
+ switch (sel) {
+ case SEL_RS1: return instr.get_src_reg(0).idx;
+ case SEL_RS2: return instr.get_src_reg(1).idx;
+ default: return instr.get_dest_reg().idx;
+ }
+}
+}
+
+uint32_t FdivUopGen::uop_count(const Instr& instr) {
+ return fdiv_uop(instr, 0, nullptr);
+}
+
+Instr::Ptr FdivUopGen::get(const Instr& macro_instr, uint32_t uop_index) {
+ uint64_t parent_uuid = macro_instr.get_uuid();
+ uint64_t uop_uuid = make_uop_uuid(parent_uuid, uop_index);
+ FdivUop u{FdivStep::TFU, TfuType::RCP, SEL_NONE, SEL_NONE};
+ fdiv_uop(macro_instr, uop_index, &u);
+ auto margs = std::get(macro_instr.get_args());
+ auto rd = macro_instr.get_dest_reg().idx;
+ Instr::Ptr uop;
+ if (u.step == FdivStep::TFU) {
+ uop = std::allocate_shared(pool_, uop_uuid, FUType::SFU);
+ uop->set_op_type(u.fn);
+ } else {
+ uop = std::allocate_shared(pool_, uop_uuid, FUType::FPU);
+ uint8_t frm_rd = (margs.frm == 0x7) ? Instr::FCSR_FRM : 0;
+ switch (u.step) {
+ case FdivStep::FMUL:
+ uop->set_op_type(FpuType::FMUL);
+ uop->set_args(IntrFpuArgs{margs.frm, 0, margs.is_f64, 0});
+ uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ break;
+ case FdivStep::FSUB:
+ uop->set_op_type(FpuType::FSUB);
+ uop->set_args(IntrFpuArgs{margs.frm, 0, margs.is_f64, 0});
+ uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ break;
+ case FdivStep::FABS:
+ uop->set_op_type(FpuType::FSGNJ);
+ uop->set_args(IntrFpuArgs{2, 0, margs.is_f64, 0}); // FSGNJX
+ break;
+ case FdivStep::CVT_S:
+ uop->set_op_type(FpuType::F2F);
+ uop->set_args(IntrFpuArgs{margs.frm, 1, 0, 0});
+ uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ break;
+ default: // CVT_D
+ uop->set_op_type(FpuType::F2F);
+ uop->set_args(IntrFpuArgs{margs.frm, 0, 1, 0});
+ uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS);
+ break;
+ }
+ }
+ uop->set_parent_uuid(parent_uuid);
+ uop->set_dest_reg(rd, RegType::Float);
+ uop->set_src_reg(0, fdiv_sel_reg(macro_instr, u.a), RegType::Float);
+ if (u.b != SEL_NONE) {
+ uop->set_src_reg(1, fdiv_sel_reg(macro_instr, u.b), RegType::Float);
+ }
+ return uop;
+}
diff --git a/sim/simx/fpu_unit.h b/sim/simx/fpu_unit.h
index e9ebbcce6c..344a36d0f3 100644
--- a/sim/simx/fpu_unit.h
+++ b/sim/simx/fpu_unit.h
@@ -14,12 +14,28 @@
#pragma once
#include
+#include
#include "func_unit.h"
+#include "instr.h"
namespace vortex {
class CsrUnit;
+// Micro-op generator for FDIV/FSQRT: TFU reciprocal/rsqrt plus FPU ops,
+// mirroring VX_uop_fdiv.
+class FdivUopGen {
+public:
+ FdivUopGen(PoolAllocator& pool) : pool_(pool) {}
+
+ static uint32_t uop_count(const Instr& instr);
+
+ Instr::Ptr get(const Instr& macro_instr, uint32_t uop_index);
+
+private:
+ PoolAllocator& pool_;
+};
+
class FpuUnit : public FuncUnit {
public:
FpuUnit(const SimContext& ctx, const char* name, Core*);
@@ -57,11 +73,8 @@ class FpuUnit : public FuncUnit {
std::array batch_idx_{};
- // Result pipelines, in the order of the block's response arbiter inputs;
- // the divider and the square root share one input, the divider first.
- enum : uint32_t { kPipeFma, kPipeDiv, kPipeCvt, kPipeNcp, kPipeFma64, kPipeSqrt, kNumPipes };
- // respond() indexes arbiter inputs 0..4 directly as pipes; sqrt shares div's input.
- static_assert(kPipeFma64 == 4 && kPipeSqrt == kNumPipes - 1, "arbiter input order");
+ // Result pipelines, in the order of the block's response arbiter inputs.
+ enum : uint32_t { kPipeFma, kPipeCvt, kPipeNcp, kPipeFma64, kNumPipes };
uint32_t pipe_of(const instr_trace_t* trace) const;
// Hands the block one result per cycle, round-robin over the classes whose
diff --git a/sim/simx/sequencer.cpp b/sim/simx/sequencer.cpp
index 2763303546..8e2fee23c9 100644
--- a/sim/simx/sequencer.cpp
+++ b/sim/simx/sequencer.cpp
@@ -25,6 +25,7 @@ Sequencer::Sequencer(const SimContext& ctx, const char* name, Core* core, PoolAl
: SimObject(ctx, name)
, core_(core)
, lsu_uop_gen_(instr_pool)
+ , fdiv_uop_gen_(instr_pool)
#ifdef VX_CFG_EXT_TCU_ENABLE
, tcu_uop_gen_(instr_pool)
#endif
@@ -58,6 +59,12 @@ instr_trace_t* Sequencer::get(instr_trace_t* trace) {
return lsu_uop_gen_.get(m, i);
};
break;
+ case FUType::FPU:
+ state_.uop_count = FdivUopGen::uop_count(*trace->instr_ptr);
+ state_.gen_fn = [this](const Instr& m, uint32_t i) {
+ return fdiv_uop_gen_.get(m, i);
+ };
+ break;
#ifdef VX_CFG_EXT_TCU_ENABLE
case FUType::TCU:
state_.uop_count = TcuUopGen::uop_count(*trace->instr_ptr);
diff --git a/sim/simx/sequencer.h b/sim/simx/sequencer.h
index 56f346470b..267a2b74b2 100644
--- a/sim/simx/sequencer.h
+++ b/sim/simx/sequencer.h
@@ -18,6 +18,7 @@
#include "types.h"
#include "instr.h"
#include "lsu_unit.h"
+#include "fpu_unit.h"
#ifdef VX_CFG_EXT_TCU_ENABLE
#include "tcu_unit.h"
#endif
@@ -83,6 +84,7 @@ class Sequencer : public SimObject {
Core* core_;
State state_;
LsuUopGen lsu_uop_gen_;
+ FdivUopGen fdiv_uop_gen_;
#ifdef VX_CFG_EXT_TCU_ENABLE
TcuUopGen tcu_uop_gen_;
#endif
diff --git a/tests/regression/Makefile b/tests/regression/Makefile
index c1f7abbf95..77551ebaea 100644
--- a/tests/regression/Makefile
+++ b/tests/regression/Makefile
@@ -10,7 +10,7 @@ TESTS := \
fence_mp ldst_order \
vecadd vecadd_v1 sgemm sgemmx sgemm_v1 conv3 relu sgemv \
sgemm2 sgemm2_v1 madmax mixfu stencil3d raycast bfs jacobi pathfinder \
- softmax uniform_ld lmem_access ldst_wide ldst_matrix tfu zfhmin fp_flags \
+ softmax uniform_ld lmem_access ldst_wide ldst_matrix tfu fdiv_tfu zfhmin fp_flags \
flash_attn flash_attn_tcu_wg \
sgemm_tcu sgemm_tcu_mx sgemm_tcu_sp_mx sgemm_tcu_wg sgemm_tcu_wg_mx sgemm_tcu_sp sgemm_tcu_wg_sp \
sgemm2_dxa sgemm2_tcu sgemm_tcu_wg_dxa sgemm_tcu_wg_sp_dxa \
diff --git a/tests/regression/dogfood/testcases.h b/tests/regression/dogfood/testcases.h
index bf274d1d16..37425e4645 100644
--- a/tests/regression/dogfood/testcases.h
+++ b/tests/regression/dogfood/testcases.h
@@ -674,15 +674,17 @@ class Test_FFLAGS_LANES : public ITestCase {
public:
Test_FFLAGS_LANES(TestSuite* suite) : ITestCase(suite, "fflags-lanes") {}
- enum { FL_NX = 0x01, FL_OF = 0x04, FL_DZ = 0x08, FL_NV = 0x10 };
+ enum { FL_NX = 0x01, FL_OF = 0x04, FL_NV = 0x10 };
enum { K_NONE, K_NX, K_X1, K_X2 };
// A warp divides or adds by the parity of its iteration plus its index, so
- // warps running side by side mix the two; X1 is DZ or OF, X2 is NV.
+ // warps running side by side mix the two; X1 is OF, X2 is NV. FDIV is a TFU
+ // reciprocal and an FMUL, and the reciprocal raises no flags: 1/3 and 1/0
+ // raise nothing, and 0/0 raises NV in the multiply (0 * inf).
static uint32_t recipe(bool is_add, int kind, float* a, float* b) {
static const float div_a[] = {1.0f, 1.0f, 1.0f, 0.0f};
static const float div_b[] = {2.0f, 3.0f, 0.0f, 0.0f};
- static const uint32_t div_f[] = {0, FL_NX, FL_DZ, FL_NV};
+ static const uint32_t div_f[] = {0, 0, 0, FL_NV};
static const float add_a[] = {1.0f, 1.0f, std::numeric_limits::max(), INFINITY};
static const float add_b[] = {2.0f, 0x1p-30f, std::numeric_limits::max(), -INFINITY};
static const uint32_t add_f[] = {0, FL_NX, FL_OF | FL_NX, FL_NV};
diff --git a/tests/regression/fdiv_tfu/Makefile b/tests/regression/fdiv_tfu/Makefile
new file mode 100644
index 0000000000..a6ac27cedf
--- /dev/null
+++ b/tests/regression/fdiv_tfu/Makefile
@@ -0,0 +1,18 @@
+ROOT_DIR := $(realpath ../../..)
+include $(ROOT_DIR)/config.mk
+
+PROJECT := fdiv_tfu
+
+SRC_DIR := $(VORTEX_HOME)/tests/regression/$(PROJECT)
+
+SRCS := $(SRC_DIR)/main.cpp
+
+VX_SRCS := $(SRC_DIR)/kernel.cpp
+
+VX_HDRS := $(SRC_DIR)/common.h
+
+OPTS ?= -n1024
+
+KERNEL_LIB := vortex2
+
+include ../common.mk
diff --git a/tests/regression/fdiv_tfu/common.h b/tests/regression/fdiv_tfu/common.h
new file mode 100644
index 0000000000..ff0ebfce25
--- /dev/null
+++ b/tests/regression/fdiv_tfu/common.h
@@ -0,0 +1,26 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include
+
+// Register aliasings of FDIV.S / FSQRT.S, each a different micro-op sequence.
+enum {
+ OP_DIV, // rd, rs1, rs2 distinct
+ OP_DIV_RD_RS1, // rd == rs1
+ OP_DIV_RD_RS2, // rd == rs2
+ OP_DIV_SELF, // rd == rs1 == rs2
+ OP_DIV_SRC_EQ, // rs1 == rs2, rd distinct
+ OP_SQRT, // rd, rs1 distinct
+ OP_SQRT_SELF, // rd == rs1
+ OP_COUNT
+};
+
+typedef struct {
+ uint32_t op;
+ uint32_t num_points;
+ uint64_t a_addr;
+ uint64_t b_addr;
+ uint64_t dst_addr;
+} kernel_arg_t;
+
+#endif
diff --git a/tests/regression/fdiv_tfu/kernel.cpp b/tests/regression/fdiv_tfu/kernel.cpp
new file mode 100644
index 0000000000..df438277e6
--- /dev/null
+++ b/tests/regression/fdiv_tfu/kernel.cpp
@@ -0,0 +1,40 @@
+#include
+#include "common.h"
+
+__kernel void kernel_main(kernel_arg_t* __UNIFORM__ arg) {
+ uint32_t i = blockIdx.x * blockDim.x + threadIdx.x;
+ if (i >= arg->num_points) {
+ return;
+ }
+ float a = reinterpret_cast(arg->a_addr)[i];
+ float b = reinterpret_cast(arg->b_addr)[i];
+ float r;
+ switch (arg->op) {
+ case OP_DIV:
+ __asm__ volatile ("fdiv.s %0, %1, %2" : "=&f"(r) : "f"(a), "f"(b));
+ break;
+ case OP_DIV_RD_RS1:
+ __asm__ volatile ("fdiv.s %0, %0, %1" : "+f"(a) : "f"(b));
+ r = a;
+ break;
+ case OP_DIV_RD_RS2:
+ __asm__ volatile ("fdiv.s %0, %1, %0" : "+f"(b) : "f"(a));
+ r = b;
+ break;
+ case OP_DIV_SELF:
+ __asm__ volatile ("fdiv.s %0, %0, %0" : "+f"(a));
+ r = a;
+ break;
+ case OP_DIV_SRC_EQ:
+ __asm__ volatile ("fdiv.s %0, %1, %1" : "=&f"(r) : "f"(a));
+ break;
+ case OP_SQRT:
+ __asm__ volatile ("fsqrt.s %0, %1" : "=&f"(r) : "f"(a));
+ break;
+ default:
+ __asm__ volatile ("fsqrt.s %0, %0" : "+f"(a));
+ r = a;
+ break;
+ }
+ reinterpret_cast(arg->dst_addr)[i] = r;
+}
diff --git a/tests/regression/fdiv_tfu/main.cpp b/tests/regression/fdiv_tfu/main.cpp
new file mode 100644
index 0000000000..5b049acd47
--- /dev/null
+++ b/tests/regression/fdiv_tfu/main.cpp
@@ -0,0 +1,224 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "common.h"
+
+#define RT_CHECK(_expr) \
+ do { \
+ int _ret = _expr; \
+ if (0 == _ret) \
+ break; \
+ printf("Error: '%s' returned %d!\n", #_expr, (int)_ret); \
+ cleanup(); \
+ exit(-1); \
+ } while (false)
+
+// FDIV/FSQRT run as TFU micro-ops and are not correctly rounded. These are the
+// bounds the sequences meet for normal inputs whose results stay normal.
+static const double kMaxUlp[OP_COUNT] = {2.0, 3.0, 2.0, 0.0, 2.0, 2.0, 2.0};
+
+static const char* kOpNames[OP_COUNT] = {
+ "div", "div_rd_rs1", "div_rd_rs2", "div_self", "div_src_eq", "sqrt", "sqrt_self"
+};
+
+// (a, b) special pairs; b is ignored by sqrt
+static const uint32_t kSpecials[][2] = {
+ {0x3f800000, 0x00000000}, {0xbf800000, 0x00000000}, {0x00000000, 0x00000000},
+ {0x7f800000, 0x7f800000}, {0x40400000, 0x7f800000}, {0x7f800000, 0x40400000},
+ {0x00000000, 0x40400000}, {0x7fc00000, 0x3f800000}, {0x3f800000, 0x7fc00000},
+ {0xbf800000, 0x3f800000}, {0x80000000, 0x3f800000},
+};
+
+const char* kernel_file = "kernel.vxbin";
+uint32_t num_points = 1024;
+int selected_op = -1;
+
+vx_device_h device = nullptr;
+vx_buffer_h a_buffer = nullptr;
+vx_buffer_h b_buffer = nullptr;
+vx_buffer_h dst_buffer = nullptr;
+vx_queue_h queue = nullptr;
+vx_module_h module_ = nullptr;
+vx_kernel_h kernel = nullptr;
+
+static float as_float(uint32_t u) { float f; memcpy(&f, &u, 4); return f; }
+static uint32_t as_bits(float f) { uint32_t u; memcpy(&u, &f, 4); return u; }
+
+static void show_usage() {
+ std::cout << "Usage: [-k: kernel] [-n points] [-t op] [-h: help]" << std::endl;
+}
+
+static void parse_args(int argc, char **argv) {
+ int c;
+ while ((c = getopt(argc, argv, "n:t:k:h")) != -1) {
+ switch (c) {
+ case 'n':
+ num_points = atoi(optarg);
+ break;
+ case 't':
+ for (int i = 0; i < OP_COUNT; ++i) {
+ if (strcmp(optarg, kOpNames[i]) == 0) {
+ selected_op = i;
+ }
+ }
+ if (selected_op < 0) {
+ show_usage();
+ exit(-1);
+ }
+ break;
+ case 'k':
+ kernel_file = optarg;
+ break;
+ default:
+ show_usage();
+ exit(-1);
+ }
+ }
+}
+
+void cleanup() {
+ if (device) {
+ if (a_buffer) vx_buffer_release(a_buffer);
+ if (b_buffer) vx_buffer_release(b_buffer);
+ if (dst_buffer) vx_buffer_release(dst_buffer);
+ if (kernel) vx_kernel_release(kernel);
+ if (module_) vx_module_release(module_);
+ if (queue) vx_queue_release(queue);
+ vx_device_dump_perf(device, stdout);
+ vx_device_release(device);
+ }
+}
+
+static bool is_sqrt(int op) { return op == OP_SQRT || op == OP_SQRT_SELF; }
+
+static double reference(int op, float a, float b) {
+ if (is_sqrt(op)) return std::sqrt((double)a);
+ if (op == OP_DIV_SELF || op == OP_DIV_SRC_EQ) return (double)a / (double)a;
+ return (double)a / (double)b;
+}
+
+static double ulp_error(float got, double exact) {
+ if (std::isnan(exact)) return std::isnan(got) ? 0 : INFINITY;
+ if (std::isinf(exact) || std::isinf(got) || exact == 0) {
+ return (got == (float)exact && std::signbit(got) == std::signbit(exact)) ? 0 : INFINITY;
+ }
+ float ref = (float)exact;
+ double ulp = std::nextafter(std::fabs(ref), INFINITY) - std::fabs(ref);
+ return std::fabs((double)got - exact) / ulp;
+}
+
+static float gen_normal(std::mt19937& rng, int exp_range) {
+ std::uniform_int_distribution man(0, (1u << 23) - 1), sign(0, 1);
+ std::uniform_int_distribution ex(127 - exp_range, 127 + exp_range);
+ return as_float((sign(rng) << 31) | (uint32_t(ex(rng)) << 23) | man(rng));
+}
+
+static int run_op(int op, std::mt19937& rng, uint64_t a_addr, uint64_t b_addr, uint64_t dst_addr) {
+ std::vector h_a(num_points), h_b(num_points), h_dst(num_points);
+ uint32_t ns = std::min(num_points, sizeof(kSpecials) / sizeof(kSpecials[0]));
+ for (uint32_t i = 0; i < num_points; ++i) {
+ if (i < ns) {
+ h_a[i] = as_float(kSpecials[i][0]);
+ h_b[i] = as_float(kSpecials[i][1]);
+ } else {
+ h_a[i] = gen_normal(rng, 60);
+ h_b[i] = gen_normal(rng, 60);
+ if (is_sqrt(op)) h_a[i] = std::fabs(h_a[i]);
+ }
+ }
+
+ kernel_arg_t arg = {};
+ arg.op = op;
+ arg.num_points = num_points;
+ arg.a_addr = a_addr;
+ arg.b_addr = b_addr;
+ arg.dst_addr = dst_addr;
+
+ uint32_t buf_size = num_points * sizeof(float);
+ RT_CHECK(vx_enqueue_write(queue, a_buffer, 0, h_a.data(), buf_size, 0, nullptr, nullptr));
+ RT_CHECK(vx_enqueue_write(queue, b_buffer, 0, h_b.data(), buf_size, 0, nullptr, nullptr));
+
+ vx_event_h launch_ev = nullptr, read_ev = nullptr;
+ {
+ uint32_t grid_dim[1], block_dim[1];
+ RT_CHECK(vx_device_max_occupancy_grid(device, 1, &num_points, grid_dim, block_dim));
+ vx_launch_info_t li = {};
+ li.struct_size = sizeof(li);
+ li.kernel = kernel;
+ li.args_host = &arg;
+ li.args_size = sizeof(arg);
+ li.ndim = 1;
+ li.grid_dim[0] = grid_dim[0];
+ li.block_dim[0] = block_dim[0];
+ RT_CHECK(vx_enqueue_launch(queue, &li, 0, nullptr, &launch_ev));
+ }
+ RT_CHECK(vx_enqueue_read(queue, h_dst.data(), dst_buffer, 0, buf_size, 1, &launch_ev, &read_ev));
+ RT_CHECK(vx_event_wait_value(read_ev, 1, VX_TIMEOUT_INFINITE));
+ vx_event_release(read_ev);
+ vx_event_release(launch_ev);
+
+ int errors = 0;
+ double max_err = 0;
+ for (uint32_t i = 0; i < num_points; ++i) {
+ double exact = reference(op, h_a[i], h_b[i]);
+ double err = ulp_error(h_dst[i], exact);
+ if (err > kMaxUlp[op]) {
+ if (errors < 20) {
+ printf("*** error: %s[%u] a=%a b=%a: actual=%a (0x%08x) expected=%a (%.2f ulp)\n",
+ kOpNames[op], i, h_a[i], h_b[i], h_dst[i], as_bits(h_dst[i]), exact, err);
+ }
+ ++errors;
+ } else if (err > max_err) {
+ max_err = err;
+ }
+ }
+ printf("%s: max %.2f ulp, %d errors\n", kOpNames[op], max_err, errors);
+ return errors;
+}
+
+int main(int argc, char *argv[]) {
+ parse_args(argc, argv);
+
+ std::cout << "open device connection" << std::endl;
+ RT_CHECK(vx_device_open(0, &device));
+
+ vx_queue_info_t qi = { sizeof(qi), nullptr, VX_QUEUE_PRIORITY_NORMAL, 0 };
+ RT_CHECK(vx_queue_create(device, &qi, &queue));
+
+ uint32_t buf_size = num_points * sizeof(float);
+ uint64_t a_addr, b_addr, dst_addr;
+ RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_READ, &a_buffer));
+ RT_CHECK(vx_buffer_address(a_buffer, &a_addr));
+ RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_READ, &b_buffer));
+ RT_CHECK(vx_buffer_address(b_buffer, &b_addr));
+ RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_WRITE, &dst_buffer));
+ RT_CHECK(vx_buffer_address(dst_buffer, &dst_addr));
+
+ RT_CHECK(vx_module_load_file(device, kernel_file, &module_));
+ RT_CHECK(vx_module_get_kernel(module_, "main", &kernel));
+
+ std::mt19937 rng(0x66646976);
+ int errors = 0;
+ for (int op = 0; op < OP_COUNT; ++op) {
+ if (selected_op >= 0 && op != selected_op) {
+ continue;
+ }
+ errors += run_op(op, rng, a_addr, b_addr, dst_addr);
+ }
+
+ std::cout << "cleanup" << std::endl;
+ cleanup();
+
+ if (errors != 0) {
+ std::cout << "Found " << std::dec << errors << " errors!" << std::endl;
+ std::cout << "FAILED!" << std::endl;
+ return 1;
+ }
+
+ std::cout << "PASSED!" << std::endl;
+ return 0;
+}
diff --git a/tests/riscv/isa/Makefile b/tests/riscv/isa/Makefile
index 95e471b1e1..b779d5f0df 100644
--- a/tests/riscv/isa/Makefile
+++ b/tests/riscv/isa/Makefile
@@ -51,7 +51,9 @@ endif
# Known-unsupported tests, skipped by run_isa: fence_i (no instruction-cache
# coherence), ma_data (no misaligned-access trap), rv64uc-p-rvc (misaligned
# C.FLD the upstream test expects to trap on).
-ISA_SKIP := *-fence_i|*-ma_data|rv64uc-p-rvc
+# fdiv checks correctly rounded FDIV/FSQRT results and their flags; Vortex
+# computes them with TFU micro-ops (VX_uop_fdiv), within 3 ulp.
+ISA_SKIP := *-fence_i|*-ma_data|rv64uc-p-rvc|*-fdiv
# The machine-mode suites run mcsr, scall, sbreak, illegal, shamt and
# ma_fetch. The tests that need a trap source or a CSR Vortex does not model
# are skipped:
|