From 2a4345c36c278109faeb648910d60d869f43d3ce Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 5 Sep 2019 09:00:13 +0100 Subject: [PATCH] add c code on daxpy --- simple_v_extension/daxpy_example.mdwn | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/simple_v_extension/daxpy_example.mdwn b/simple_v_extension/daxpy_example.mdwn index 587d9354a..3e26b25d4 100644 --- a/simple_v_extension/daxpy_example.mdwn +++ b/simple_v_extension/daxpy_example.mdwn @@ -1,6 +1,14 @@ - # a0 is n, a1 is ptr to x[0], a2 is ptr to y[0], fa0 is a - VBLK.REG[0] = {type: F, regkey: a3, regidx: a3, elwidth: dflt} - VBLK.REG[1] = {type: F, regkey: a7, regidx: a7, elwidth: dflt} + # c code + void daxpy(size_t n, double a, const double x[], double y[]) + { + for (size_t i = 0; i < n; i++) { + y[i] = a*x[i] + y[i]; + } + } + + # a0 is n, a1 is ptr to x[0], a2 is ptr to y[0], fa0 is a (scalar) + VBLK.REG[0] = {type: F, isvec: 1, regkey: a3, regidx: a3, elwidth: dflt} + VBLK.REG[1] = {type: F, isvec: 1, regkey: a7, regidx: a7, elwidth: dflt} VBLK.MVL = 4 loop: setvl t0, a0 # vl = t0 = min(a0, MVL)) -- 2.30.2