From 5cc32a0593823215080a22c40094de7b2d3b8863 Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 00:49:59 +0000 Subject: [PATCH 1/6] Added blas_error_if function for parameter checking in cpu wrapper functions --- src/util.mojo | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/util.mojo diff --git a/src/util.mojo b/src/util.mojo new file mode 100644 index 0000000..9bd7a3f --- /dev/null +++ b/src/util.mojo @@ -0,0 +1,5 @@ +# error checking blas_error_if(condition, __function_name__, "parameter_name", parameter) +fn blas_error_if[T: Stringable ](cond: Bool, caller: String, param: String, val: T) raises: + if(cond) : + raise Error(caller, " Error: ", param, " = ", String(val)) + From caa796a9f2f3882957417073f740e8b1b1b0f1cd Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 00:57:37 +0000 Subject: [PATCH 2/6] Added import util to init file --- src/__init__.mojo | 1 + 1 file changed, 1 insertion(+) diff --git a/src/__init__.mojo b/src/__init__.mojo index 4762ea5..b5c2f85 100644 --- a/src/__init__.mojo +++ b/src/__init__.mojo @@ -1,3 +1,4 @@ +from .util import * from .testing_utils import * from .level1 import * from .level2 import * From 9922b86b27b85e931184bb426617fd889a3bc41d Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 03:05:54 +0000 Subject: [PATCH 3/6] Added all error checks and quick returns for level 1 routines --- src/level1/asum_device.mojo | 6 +++--- src/level1/axpy_device.mojo | 14 ++++++++------ src/level1/copy_device.mojo | 10 ++++++---- src/level1/dot_device.mojo | 5 +++-- src/level1/dotc_device.mojo | 4 ++-- src/level1/dotu_device.mojo | 4 ++-- src/level1/iamax_device.mojo | 4 ++++ src/level1/nrm2_device.mojo | 3 +++ src/level1/rot_device.mojo | 11 +++++++++-- src/level1/rotm_device.mojo | 8 ++++++-- src/level1/scal_device.mojo | 11 +++++------ src/level1/swap_device.mojo | 9 +++++---- 12 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/level1/asum_device.mojo b/src/level1/asum_device.mojo index 5bbc8b4..ce69717 100644 --- a/src/level1/asum_device.mojo +++ b/src/level1/asum_device.mojo @@ -18,9 +18,6 @@ fn asum_device[ incx: Int, result: UnsafePointer[Scalar[dtype], MutAnyOrigin] ): - if n < 1 or incx <= 0: - result[0] = 0 - return var local_tid = thread_idx.x @@ -65,6 +62,9 @@ fn blas_asum[dtype: DType]( d_res: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + blas_error_if(n < 1, "asum", "n", n) + blas_error_if(incx <=0, "asum", "incx", incx) + comptime kernel = asum_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, diff --git a/src/level1/axpy_device.mojo b/src/level1/axpy_device.mojo index 953d65a..077776c 100644 --- a/src/level1/axpy_device.mojo +++ b/src/level1/axpy_device.mojo @@ -12,12 +12,6 @@ fn axpy_device[dtype: DType]( y: UnsafePointer[Scalar[dtype], MutAnyOrigin], incy: Int ): - if (n <= 0): - return - if (a == 0): - return - if (incx == 0 or incy == 0): - return var global_i = global_idx.x var n_threads = Int(grid_dim.x * block_dim.x) @@ -36,6 +30,14 @@ fn blas_axpy[dtype: DType]( incy: Int, ctx: DeviceContext ) raises: + blas_error_if(n < 0, "axpy", "n", n) + blas_error_if(incx == 0, "axpy", "incx", incx) + blas_error_if(incy == 0, "axpy", "incy", incy) + + # quick return + if(a == 0) : + return + comptime kernel = axpy_device[dtype] ctx.enqueue_function[kernel, kernel]( n, a, diff --git a/src/level1/copy_device.mojo b/src/level1/copy_device.mojo index ac44ada..76a4d73 100644 --- a/src/level1/copy_device.mojo +++ b/src/level1/copy_device.mojo @@ -13,10 +13,6 @@ fn copy_device[dtype: DType]( y: UnsafePointer[Scalar[dtype], MutAnyOrigin], incy: Int ): - if (n <= 0): - return - if (incx == 0 or incy == 0): - return var global_i = global_idx.x var n_threads = Int(grid_dim.x * block_dim.x) @@ -34,6 +30,12 @@ fn blas_copy[dtype: DType]( incy: Int, ctx: DeviceContext ) raises: + + blas_error_if(n<=0, "blas_copy", "n", n) + blas_error_if(incx == 0, "blas_copy", "incx", incx) + blas_error_if(incy == 0, "blas_copy", "incy", incy) + + comptime kernel = copy_device[dtype] ctx.enqueue_function[kernel, kernel]( n, diff --git a/src/level1/dot_device.mojo b/src/level1/dot_device.mojo index 68025d6..3ca2721 100644 --- a/src/level1/dot_device.mojo +++ b/src/level1/dot_device.mojo @@ -19,8 +19,6 @@ fn dot_device[ incy: Int, output: UnsafePointer[Scalar[dtype], MutAnyOrigin], ): - if n < 1: - return var global_i = block_dim.x * block_idx.x + thread_idx.x var n_threads = grid_dim.x * block_dim.x @@ -59,6 +57,9 @@ fn blas_dot[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + + blas_error_if(n < 1, "blas_dot", "n", n) + comptime kernel = dot_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_x, incx, diff --git a/src/level1/dotc_device.mojo b/src/level1/dotc_device.mojo index f4ae13b..d02d7f9 100644 --- a/src/level1/dotc_device.mojo +++ b/src/level1/dotc_device.mojo @@ -20,8 +20,6 @@ fn dotc_device[ incy: Int, output: UnsafePointer[Scalar[dtype], MutAnyOrigin], ): - if n < 1: - return var global_i = block_dim.x * block_idx.x + thread_idx.x var n_threads = grid_dim.x * block_dim.x @@ -70,6 +68,8 @@ fn blas_dotc[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + blas_error_if(n < 1, "blas_dotc", "n", n) + comptime kernel = dotc_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_x, incx, diff --git a/src/level1/dotu_device.mojo b/src/level1/dotu_device.mojo index 957037a..7da01d6 100644 --- a/src/level1/dotu_device.mojo +++ b/src/level1/dotu_device.mojo @@ -20,8 +20,7 @@ fn dotu_device[ incy: Int, output: UnsafePointer[Scalar[dtype], MutAnyOrigin], ): - if n < 1: - return + var global_i = block_dim.x * block_idx.x + thread_idx.x var n_threads = grid_dim.x * block_dim.x @@ -70,6 +69,7 @@ fn blas_dotu[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + blas_error_if(n < 1, "blas_dotu", "n", n) comptime kernel = dotu_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_x, incx, diff --git a/src/level1/iamax_device.mojo b/src/level1/iamax_device.mojo index 4a70e45..abca1b2 100644 --- a/src/level1/iamax_device.mojo +++ b/src/level1/iamax_device.mojo @@ -89,6 +89,10 @@ fn blas_iamax[dtype: DType]( d_res: UnsafePointer[Scalar[DType.int64], MutAnyOrigin], ctx: DeviceContext ) raises: + + blas_error_if(n < 0, "blas_iamax", "n", n) + blas_error_if(incx <= 0, "blas_iamx", "incx", incx) + comptime kernel = iamax_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_v, incx, diff --git a/src/level1/nrm2_device.mojo b/src/level1/nrm2_device.mojo index 6627f3a..7ad3814 100644 --- a/src/level1/nrm2_device.mojo +++ b/src/level1/nrm2_device.mojo @@ -58,6 +58,9 @@ fn blas_nrm2[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + blas_error_if(n < 0, "blas_nrm2", "n", n) + blas_error_if(incx <= 0, "blas_nrm2", "incx", incx) + comptime kernel = nrm2_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_x, incx, d_out, diff --git a/src/level1/rot_device.mojo b/src/level1/rot_device.mojo index d4bf07b..07b6c91 100644 --- a/src/level1/rot_device.mojo +++ b/src/level1/rot_device.mojo @@ -17,8 +17,7 @@ fn rot_device[ c: Scalar[dtype], s: Scalar[dtype] ): - if (n < 1): - return + var global_tid = block_idx.x * block_dim.x + thread_idx.x var n_threads = grid_dim.x * block_dim.x @@ -43,6 +42,14 @@ fn blas_rot[dtype: DType]( s: Scalar[dtype], ctx: DeviceContext ) raises: + blas_error_if(n < 0, "blas_rot", "n", n) + blas_error_if(incx == 0, "blas_rot", "incx", incx) + blas_error_if(incy == 0, "blas_rot", "incy", incy) + + # quick return + if(n == 0 or (c == 1 and s == 0)) : + return + comptime kernel = rot_device[dtype] ctx.enqueue_function[kernel, kernel]( n, diff --git a/src/level1/rotm_device.mojo b/src/level1/rotm_device.mojo index 940b5c0..6eafbfc 100644 --- a/src/level1/rotm_device.mojo +++ b/src/level1/rotm_device.mojo @@ -17,8 +17,6 @@ fn rotm_device[ param: UnsafePointer[Scalar[dtype], MutAnyOrigin] ): var flag = param[0] - if (n < 1): - return var idx = block_idx.x * block_dim.x + thread_idx.x var n_threads = grid_dim.x * block_dim.x @@ -63,6 +61,12 @@ fn blas_rotm[dtype: DType]( d_param: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: + blas_error_if(n < 0, "blas_rotm", "n", n) + blas_error_if(incx == 0, "blas_rotm", "incx", incx) + blas_error_if(incy == 0, "blas_rotm", "incy", incy) + + if(n == 0 ): + return comptime kernel = rotm_device[dtype] ctx.enqueue_function[kernel, kernel]( n, diff --git a/src/level1/scal_device.mojo b/src/level1/scal_device.mojo index e35f801..38f5d2c 100644 --- a/src/level1/scal_device.mojo +++ b/src/level1/scal_device.mojo @@ -10,12 +10,6 @@ fn scal_device[dtype: DType]( x: UnsafePointer[Scalar[dtype], MutAnyOrigin], incx: Int, ): - if (n <= 0): - return - if (a == 0): - return - if (incx == 0): - return var global_i = global_idx.x var n_threads = Int(grid_dim.x * block_dim.x) @@ -32,6 +26,11 @@ fn blas_scal[dtype: DType] ( incx: Int, ctx: DeviceContext ) raises: + + blas_error_if(n < 0, "blas_scal", "n", n) + blas_error_if(incx <= 0, "blas_scal", "incx", incx) + + comptime kernel = scal_device[dtype] ctx.enqueue_function[kernel, kernel]( n, a, d_x, incx, diff --git a/src/level1/swap_device.mojo b/src/level1/swap_device.mojo index b880ccc..ec2f898 100644 --- a/src/level1/swap_device.mojo +++ b/src/level1/swap_device.mojo @@ -11,10 +11,7 @@ fn swap_device[dtype: DType]( y: UnsafePointer[Scalar[dtype], MutAnyOrigin], incy: Int ): - if (n <= 0): - return - if (incx == 0 or incy == 0): - return + var global_i = global_idx.x var n_threads = Int(grid_dim.x * block_dim.x) @@ -34,6 +31,10 @@ fn blas_swap[dtype: DType]( incy: Int, ctx: DeviceContext ) raises: + blas_error_if(n < 0, "blas_swap", "n", n) + blas_error_if(incx == 0, "blas_swap", "incx", incx) + blas_error_if(incy == 0, "blas_swap", "incy", incy) + comptime kernel = swap_device[dtype] ctx.enqueue_function[kernel, kernel]( n, From 7079d9876422af8be31679fd4b64819332641398 Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 14:45:54 +0000 Subject: [PATCH 4/6] import util file --- src/__init__.mojo | 1 + 1 file changed, 1 insertion(+) diff --git a/src/__init__.mojo b/src/__init__.mojo index 4762ea5..b5c2f85 100644 --- a/src/__init__.mojo +++ b/src/__init__.mojo @@ -1,3 +1,4 @@ +from .util import * from .testing_utils import * from .level1 import * from .level2 import * From b47c5fc58f8d376a831d48e8aac793ff4d6d3e41 Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 14:46:42 +0000 Subject: [PATCH 5/6] recommit util file --- src/util.mojo | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/util.mojo diff --git a/src/util.mojo b/src/util.mojo new file mode 100644 index 0000000..9bd7a3f --- /dev/null +++ b/src/util.mojo @@ -0,0 +1,5 @@ +# error checking blas_error_if(condition, __function_name__, "parameter_name", parameter) +fn blas_error_if[T: Stringable ](cond: Bool, caller: String, param: String, val: T) raises: + if(cond) : + raise Error(caller, " Error: ", param, " = ", String(val)) + From 1412c023afd8f214c6537b9b054d251830de898d Mon Sep 17 00:00:00 2001 From: Holden Roaten Date: Tue, 24 Mar 2026 22:09:28 +0000 Subject: [PATCH 6/6] Final(ish) blas_error_if structure, rewrote error checks accordingly --- src/level1/asum_device.mojo | 4 ++-- src/level1/axpy_device.mojo | 6 +++--- src/level1/copy_device.mojo | 6 +++--- src/level1/dot_device.mojo | 4 +++- src/level1/dotc_device.mojo | 4 +++- src/level1/dotu_device.mojo | 6 +++++- src/level1/iamax_device.mojo | 5 +++-- src/level1/nrm2_device.mojo | 4 ++-- src/level1/rot_device.mojo | 7 ++++--- src/level1/rotm_device.mojo | 6 +++--- src/level1/scal_device.mojo | 4 ++-- src/level1/swap_device.mojo | 6 +++--- src/util.mojo | 9 ++++++--- 13 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/level1/asum_device.mojo b/src/level1/asum_device.mojo index ce69717..9fde31b 100644 --- a/src/level1/asum_device.mojo +++ b/src/level1/asum_device.mojo @@ -62,8 +62,8 @@ fn blas_asum[dtype: DType]( d_res: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: - blas_error_if(n < 1, "asum", "n", n) - blas_error_if(incx <=0, "asum", "incx", incx) + blas_error_if["blas_asum", "n < 0"](n < 0) + blas_error_if["blas_asum", "incx <= 0"](incx <= 0) comptime kernel = asum_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/level1/axpy_device.mojo b/src/level1/axpy_device.mojo index 077776c..0626d08 100644 --- a/src/level1/axpy_device.mojo +++ b/src/level1/axpy_device.mojo @@ -30,9 +30,9 @@ fn blas_axpy[dtype: DType]( incy: Int, ctx: DeviceContext ) raises: - blas_error_if(n < 0, "axpy", "n", n) - blas_error_if(incx == 0, "axpy", "incx", incx) - blas_error_if(incy == 0, "axpy", "incy", incy) + blas_error_if["blas_axpy", "n < 0"](n < 0) + blas_error_if["blas_axpy", "incx == 0"](incx == 0) + blas_error_if["blas_axpy", "incy == 0"](incy == 0) # quick return if(a == 0) : diff --git a/src/level1/copy_device.mojo b/src/level1/copy_device.mojo index 76a4d73..0784174 100644 --- a/src/level1/copy_device.mojo +++ b/src/level1/copy_device.mojo @@ -31,9 +31,9 @@ fn blas_copy[dtype: DType]( ctx: DeviceContext ) raises: - blas_error_if(n<=0, "blas_copy", "n", n) - blas_error_if(incx == 0, "blas_copy", "incx", incx) - blas_error_if(incy == 0, "blas_copy", "incy", incy) + blas_error_if["blas_copy", "n < 0"](n < 0) + blas_error_if["blas_copy", "incx == 0"](incx == 0) + blas_error_if["blas_copy", "incy == 0"](incy == 0) comptime kernel = copy_device[dtype] diff --git a/src/level1/dot_device.mojo b/src/level1/dot_device.mojo index 3ca2721..87e8d5f 100644 --- a/src/level1/dot_device.mojo +++ b/src/level1/dot_device.mojo @@ -58,7 +58,9 @@ fn blas_dot[dtype: DType]( ctx: DeviceContext ) raises: - blas_error_if(n < 1, "blas_dot", "n", n) + blas_error_if["blas_dot", "n < 0"](n < 0) + blas_error_if["blas_copy", "incx == 0"](incx == 0) + blas_error_if["blas_copy", "incy == 0"](incy == 0) comptime kernel = dot_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/level1/dotc_device.mojo b/src/level1/dotc_device.mojo index d02d7f9..c14fac7 100644 --- a/src/level1/dotc_device.mojo +++ b/src/level1/dotc_device.mojo @@ -68,7 +68,9 @@ fn blas_dotc[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: - blas_error_if(n < 1, "blas_dotc", "n", n) + blas_error_if["blas_dotc", "n < 0"](n < 0) + blas_error_if["blas_dotc", "incx == 0"](incx == 0) + blas_error_if["blas_dotc", "incy == 0"](incy == 0) comptime kernel = dotc_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/level1/dotu_device.mojo b/src/level1/dotu_device.mojo index 7da01d6..6d95df1 100644 --- a/src/level1/dotu_device.mojo +++ b/src/level1/dotu_device.mojo @@ -69,7 +69,11 @@ fn blas_dotu[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: - blas_error_if(n < 1, "blas_dotu", "n", n) + + blas_error_if["blas_dotu", "n < 0"](n < 0) + blas_error_if["blas_dotu", "incx == 0"](incx == 0) + blas_error_if["blas_dotu", "incy == 0"](incy == 0) + comptime kernel = dotu_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( n, d_x, incx, diff --git a/src/level1/iamax_device.mojo b/src/level1/iamax_device.mojo index abca1b2..aba2f53 100644 --- a/src/level1/iamax_device.mojo +++ b/src/level1/iamax_device.mojo @@ -90,8 +90,9 @@ fn blas_iamax[dtype: DType]( ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_iamax", "n", n) - blas_error_if(incx <= 0, "blas_iamx", "incx", incx) + blas_error_if["blas_iamax", "n < 0"](n<=0) + blas_error_if["blas_iamax", "incx <= 0"](incx <= 0) + comptime kernel = iamax_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/level1/nrm2_device.mojo b/src/level1/nrm2_device.mojo index 7ad3814..df9ae23 100644 --- a/src/level1/nrm2_device.mojo +++ b/src/level1/nrm2_device.mojo @@ -58,8 +58,8 @@ fn blas_nrm2[dtype: DType]( d_out: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_nrm2", "n", n) - blas_error_if(incx <= 0, "blas_nrm2", "incx", incx) + blas_error_if["blas_nrm2", "n < 0"](n < 0) + blas_error_if["blas_nrm2", "incx <= 0"](incx <= 0) comptime kernel = nrm2_device[TBsize, dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/level1/rot_device.mojo b/src/level1/rot_device.mojo index 07b6c91..63162be 100644 --- a/src/level1/rot_device.mojo +++ b/src/level1/rot_device.mojo @@ -42,9 +42,10 @@ fn blas_rot[dtype: DType]( s: Scalar[dtype], ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_rot", "n", n) - blas_error_if(incx == 0, "blas_rot", "incx", incx) - blas_error_if(incy == 0, "blas_rot", "incy", incy) + blas_error_if["blas_rot", "n < 0"](n < 0) + blas_error_if["blas_rot", "incx == 0"](incx == 0) + blas_error_if["blas_rot", "incy == 0"](incy == 0) + # quick return if(n == 0 or (c == 1 and s == 0)) : diff --git a/src/level1/rotm_device.mojo b/src/level1/rotm_device.mojo index 6eafbfc..e290130 100644 --- a/src/level1/rotm_device.mojo +++ b/src/level1/rotm_device.mojo @@ -61,9 +61,9 @@ fn blas_rotm[dtype: DType]( d_param: UnsafePointer[Scalar[dtype], MutAnyOrigin], ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_rotm", "n", n) - blas_error_if(incx == 0, "blas_rotm", "incx", incx) - blas_error_if(incy == 0, "blas_rotm", "incy", incy) + blas_error_if["blas_rotm", "n < 0"](n < 0) + blas_error_if["blas_rotm", "incx == 0"](incx == 0) + blas_error_if["blas_rotm", "incy == 0"](incy == 0) if(n == 0 ): return diff --git a/src/level1/scal_device.mojo b/src/level1/scal_device.mojo index 38f5d2c..d16f069 100644 --- a/src/level1/scal_device.mojo +++ b/src/level1/scal_device.mojo @@ -27,8 +27,8 @@ fn blas_scal[dtype: DType] ( ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_scal", "n", n) - blas_error_if(incx <= 0, "blas_scal", "incx", incx) + blas_error_if["blas_scal", "n < 0"](n < 0) + blas_error_if["blas_scal", "incx <= 0"](incx <= 0) comptime kernel = scal_device[dtype] diff --git a/src/level1/swap_device.mojo b/src/level1/swap_device.mojo index ec2f898..43b1041 100644 --- a/src/level1/swap_device.mojo +++ b/src/level1/swap_device.mojo @@ -31,9 +31,9 @@ fn blas_swap[dtype: DType]( incy: Int, ctx: DeviceContext ) raises: - blas_error_if(n < 0, "blas_swap", "n", n) - blas_error_if(incx == 0, "blas_swap", "incx", incx) - blas_error_if(incy == 0, "blas_swap", "incy", incy) + blas_error_if["blas_swap", "n < 0"](n < 0) + blas_error_if["blas_swap", "incx == 0"](incx == 0) + blas_error_if["blas_swap", "incy == 0"](incy == 0) comptime kernel = swap_device[dtype] ctx.enqueue_function[kernel, kernel]( diff --git a/src/util.mojo b/src/util.mojo index 9bd7a3f..26e22e7 100644 --- a/src/util.mojo +++ b/src/util.mojo @@ -1,5 +1,8 @@ -# error checking blas_error_if(condition, __function_name__, "parameter_name", parameter) -fn blas_error_if[T: Stringable ](cond: Bool, caller: String, param: String, val: T) raises: + +fn blas_error_if[caller: String, cond_str: String](cond: Bool) raises: + """ + Function raises an error describing the bad paramters passed to caller. + """ if(cond) : - raise Error(caller, " Error: ", param, " = ", String(val)) + raise Error("Error: {} in {}".format(cond_str, caller))