kernel: add linalg functions #309

Merged
sb10q merged 1 commits from abdul124/artiq-zynq:add_linalg_functions into master 2024-08-01 18:20:33 +08:00
Contributor

Adds linalg functions from M-Labs/nac3#478

Adds linalg functions from M-Labs/nac3#478
Owner

Do we really need to call the firmware for something as simple as transpose?
Should probably go to IRRT instead.

Do we really need to call the firmware for something as simple as transpose? Should probably go to IRRT instead.
sb10q reviewed 2024-07-31 12:01:45 +08:00
@ -435,6 +435,8 @@ static EXCEPTION_ID_LOOKUP: [(&str, u32); 12] = [
("IndexError", 9),
("UnwrapNoneError", 10),
("SubkernelError", 11),
("ValueError", 12),
Owner

I don't think this ValueError addition belongs in this PR?

I don't think this ValueError addition belongs in this PR?
sb10q reviewed 2024-07-31 12:02:43 +08:00
@ -436,2 +436,4 @@
("UnwrapNoneError", 10),
("SubkernelError", 11),
("ValueError", 12),
("LinAlgError", 13),
Owner

Needs update in ARTIQ and PR there.

Needs update in ARTIQ and PR there.
Author
Contributor

Will update ARTIQ first then and add these in an additional PR.

Will update ARTIQ first then and add these in an additional PR.
sb10q reviewed 2024-07-31 12:03:33 +08:00
@ -345,2 +324,2 @@
api!(linalg_try_invert_to = linalg_try_invert_to),
api!(linalg_wilkinson_shift = linalg_wilkinson_shift),
api!(np_transpose = linalg::np_transpose),
api!(np_dot = linalg::np_dot),
Owner

As far as I can tell, these two are trivial and do not need firmware calls. Suggest moving to IRRT.

As far as I can tell, these two are trivial and do not need firmware calls. Suggest moving to IRRT.
Author
Contributor

Re-implemented np_transpose and np_reshape using LLVM IR in core. Will move np_dot as well and remove these from firmware.

Re-implemented `np_transpose` and `np_reshape` using LLVM IR in core. Will move `np_dot` as well and remove these from firmware.
Owner

Manual calls to LLVM builder or IRRT? Which way is best?

Manual calls to LLVM builder or IRRT? Which way is best?
Author
Contributor

Since other functions like np_array and np_zero are already written using LLVM IR in core/codegen/numpy I think keeping things consistent is more important.

Since other functions like `np_array` and `np_zero` are already written using LLVM IR in `core/codegen/numpy` I think keeping things consistent is more important.
sb10q marked this conversation as resolved
sb10q reviewed 2024-07-31 12:05:15 +08:00
@ -0,0 +25,4 @@
}
}
/// # Safety
Owner

Remove all those "safety" headers, C calls are never "safe" as per Rust's definition.

Keep the descriptions of what the arguments should point to, however.

Remove all those "safety" headers, C calls are never "safe" as per Rust's definition. Keep the descriptions of what the arguments should point to, however.
Author
Contributor

Adding safety headers over unsafe functions is required when using stable rust. Should I still remove those?

Adding safety headers over unsafe functions is required when using stable rust. Should I still remove those?
Owner

Hmm ok, keep them then.

Hmm ok, keep them then.
sb10q marked this conversation as resolved
sb10q reviewed 2024-07-31 12:06:10 +08:00
@ -0,0 +321,4 @@
"last 2 dimensions of the array must be square: {0} != {1}",
dim1[0], dim1[1]
);
artiq_raise!("LinAlgError", err_msg);
Owner

Is it really OK to use a formatted string in artiq_raise?
Where is the memory allocated?

Is it really OK to use a formatted string in artiq_raise? Where is the memory allocated?
Author
Contributor

Is it really OK to use a formatted string in artiq_raise? Where is the memory allocated?

Not sure about the memory allocation, but formatted string is being used in other parts of code base (63f4783687/src/libksupport/src/rtio_acp.rs (L90)).

> Is it really OK to use a formatted string in artiq_raise? Where is the memory allocated? Not sure about the memory allocation, but formatted string is being used in other parts of code base (https://git.m-labs.hk/M-Labs/artiq-zynq/src/commit/63f4783687b85902e6c6181321df7dc067778f47/src/libksupport/src/rtio_acp.rs#L90).
sb10q reviewed 2024-07-31 12:06:50 +08:00
@ -0,0 +310,4 @@
let out_z = out_z.as_mut().unwrap();
if mat1.ndims != 2 {
let err_msg = format!("expected 2D Vector Input, but received {}-D input", mat1.ndims);
Owner

2D vs. 2-D inconsistency.

2D vs. 2-D inconsistency.
Author
Contributor

Updated.

Updated.
abdul124 force-pushed add_linalg_functions from 0664f3336b to 9c82781217 2024-07-31 18:00:18 +08:00 Compare
sb10q reviewed 2024-08-01 17:59:56 +08:00
@ -470,1 +470,3 @@
($name:expr, $message:expr) => {{ artiq_raise!($name, $message, 0, 0, 0) }};
($name:expr, $message:expr) => {{
artiq_raise!($name, $message, 0, 0, 0)
}};
Owner

This change does not belong in this PR (and maybe should not be made at all).

This change does not belong in this PR (and maybe should not be made at all).
Owner

Friendly reminder, just run cargo fmt --all after you make your changes. Manual formatting changes are unnecessary.

Friendly reminder, just run ``cargo fmt --all`` after you make your changes. Manual formatting changes are unnecessary.
sb10q reviewed 2024-08-01 18:00:18 +08:00
@ -344,3 +325,2 @@
// linalg
api!(linalg_try_invert_to = linalg_try_invert_to),
api!(linalg_wilkinson_shift = linalg_wilkinson_shift),
api!(np_linalg_matmul = linalg::np_linalg_matmul),
Owner

Still needs removal.

Still needs removal.
sb10q marked this conversation as resolved
abdul124 force-pushed add_linalg_functions from 9c82781217 to ce8b8949bc 2024-08-01 18:17:21 +08:00 Compare
sb10q merged commit fe6f259d48 into master 2024-08-01 18:20:33 +08:00
Owner

I just ran build latest master, and got these warnings:

firmware> warning: unnecessary `unsafe` block
firmware>   --> libksupport/src/kernel/linalg.rs:58:21
firmware>    |
firmware> 32 | pub unsafe extern "C" fn np_linalg_cholesky(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>    | ------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn
firmware> ...
firmware> 58 |     let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) };
firmware>    |                     ^^^^^^ unnecessary `unsafe` block
firmware>    |
firmware>    = note: `#[warn(unused_unsafe)]` on by default
firmware> warning: unnecessary `unsafe` block
firmware>   --> libksupport/src/kernel/linalg.rs:59:23
firmware>    |
firmware> 32 | pub unsafe extern "C" fn np_linalg_cholesky(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>    | ------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn
firmware> ...
firmware> 59 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>    |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>   --> libksupport/src/kernel/linalg.rs:96:23
firmware>    |
firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) {
firmware>    | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 96 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>    |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>   --> libksupport/src/kernel/linalg.rs:97:23
firmware>    |
firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) {
firmware>    | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 97 |     let out_q_slice = unsafe { slice::from_raw_parts_mut(out_q.data, outq_dim[0] * outq_dim[1]) };
firmware>    |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>   --> libksupport/src/kernel/linalg.rs:98:23
firmware>    |
firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) {
firmware>    | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 98 |     let out_r_slice = unsafe { slice::from_raw_parts_mut(out_r.data, outr_dim[0] * outr_dim[1]) };
firmware>    |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:141:23
firmware>     |
firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd(
firmware> 116 | |     mat1: *mut InputMatrix,
firmware> 117 | |     outu: *mut InputMatrix,
firmware> 118 | |     outs: *mut InputMatrix,
firmware> 119 | |     outvh: *mut InputMatrix,
firmware> 120 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 141 |       let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:142:23
firmware>     |
firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd(
firmware> 116 | |     mat1: *mut InputMatrix,
firmware> 117 | |     outu: *mut InputMatrix,
firmware> 118 | |     outs: *mut InputMatrix,
firmware> 119 | |     outvh: *mut InputMatrix,
firmware> 120 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 142 |       let out_u_slice = unsafe { slice::from_raw_parts_mut(outu.data, outu_dim[0] * outu_dim[1]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:143:23
firmware>     |
firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd(
firmware> 116 | |     mat1: *mut InputMatrix,
firmware> 117 | |     outu: *mut InputMatrix,
firmware> 118 | |     outs: *mut InputMatrix,
firmware> 119 | |     outvh: *mut InputMatrix,
firmware> 120 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 143 |       let out_s_slice = unsafe { slice::from_raw_parts_mut(outs.data, outs_dim[0]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:144:24
firmware>     |
firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd(
firmware> 116 | |     mat1: *mut InputMatrix,
firmware> 117 | |     outu: *mut InputMatrix,
firmware> 118 | |     outs: *mut InputMatrix,
firmware> 119 | |     outvh: *mut InputMatrix,
firmware> 120 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 144 |       let out_vh_slice = unsafe { slice::from_raw_parts_mut(outvh.data, outvh_dim[0] * outvh_dim[1]) };
firmware>     |                          ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:183:21
firmware>     |
firmware> 157 | pub unsafe extern "C" fn np_linalg_inv(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 183 |     let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) };
firmware>     |                     ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:184:23
firmware>     |
firmware> 157 | pub unsafe extern "C" fn np_linalg_inv(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 184 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:213:21
firmware>     |
firmware> 198 | pub unsafe extern "C" fn np_linalg_pinv(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | -------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 213 |     let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) };
firmware>     |                     ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:214:23
firmware>     |
firmware> 198 | pub unsafe extern "C" fn np_linalg_pinv(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | -------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 214 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:250:17
firmware>     |
firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 250 |     let power = unsafe { slice::from_raw_parts_mut(mat2.data, 1) };
firmware>     |                 ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:253:21
firmware>     |
firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 253 |     let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) };
firmware>     |                     ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:254:23
firmware>     |
firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 254 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:298:21
firmware>     |
firmware> 284 | pub unsafe extern "C" fn np_linalg_det(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 298 |     let out_slice = unsafe { slice::from_raw_parts_mut(out.data, 1) };
firmware>     |                     ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:299:23
firmware>     |
firmware> 284 | pub unsafe extern "C" fn np_linalg_det(mat1: *mut InputMatrix, out: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 299 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:337:23
firmware>     |
firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) {
firmware>     | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 337 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:338:23
firmware>     |
firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) {
firmware>     | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 338 |     let out_l_slice = unsafe { slice::from_raw_parts_mut(out_l.data, outl_dim[0] * outl_dim[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:339:23
firmware>     |
firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) {
firmware>     | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn
firmware> ...
firmware> 339 |     let out_u_slice = unsafe { slice::from_raw_parts_mut(out_u.data, outu_dim[0] * outu_dim[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:382:23
firmware>     |
firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn
firmware> ...
firmware> 382 |     let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:383:23
firmware>     |
firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn
firmware> ...
firmware> 383 |     let out_t_slice = unsafe { slice::from_raw_parts_mut(out_t.data, out_t_dim[0] * out_t_dim[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:384:23
firmware>     |
firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) {
firmware>     | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn
firmware> ...
firmware> 384 |     let out_z_slice = unsafe { slice::from_raw_parts_mut(out_z.data, out_z_dim[0] * out_z_dim[1]) };
firmware>     |                       ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:431:23
firmware>     |
firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg(
firmware> 398 | |     mat1: *mut InputMatrix,
firmware> 399 | |     out_h: *mut InputMatrix,
firmware> 400 | |     out_q: *mut InputMatrix,
firmware> 401 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 431 |       let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:432:23
firmware>     |
firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg(
firmware> 398 | |     mat1: *mut InputMatrix,
firmware> 399 | |     out_h: *mut InputMatrix,
firmware> 400 | |     out_q: *mut InputMatrix,
firmware> 401 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 432 |       let out_h_slice = unsafe { slice::from_raw_parts_mut(out_h.data, out_h_dim[0] * out_h_dim[1]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
firmware> warning: unnecessary `unsafe` block
firmware>    --> libksupport/src/kernel/linalg.rs:433:23
firmware>     |
firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg(
firmware> 398 | |     mat1: *mut InputMatrix,
firmware> 399 | |     out_h: *mut InputMatrix,
firmware> 400 | |     out_q: *mut InputMatrix,
firmware> 401 | | ) {
firmware>     | |_- because it's nested under this `unsafe` fn
firmware> ...
firmware> 433 |       let out_q_slice = unsafe { slice::from_raw_parts_mut(out_q.data, out_q_dim[0] * out_q_dim[1]) };
firmware>     |                         ^^^^^^ unnecessary `unsafe` block
I just ran build latest master, and got these warnings: ``` firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:58:21 firmware> | firmware> 32 | pub unsafe extern "C" fn np_linalg_cholesky(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn firmware> ... firmware> 58 | let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> | firmware> = note: `#[warn(unused_unsafe)]` on by default firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:59:23 firmware> | firmware> 32 | pub unsafe extern "C" fn np_linalg_cholesky(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn firmware> ... firmware> 59 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:96:23 firmware> | firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 96 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:97:23 firmware> | firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 97 | let out_q_slice = unsafe { slice::from_raw_parts_mut(out_q.data, outq_dim[0] * outq_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:98:23 firmware> | firmware> 77 | pub unsafe extern "C" fn np_linalg_qr(mat1: *mut InputMatrix, out_q: *mut InputMatrix, out_r: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 98 | let out_r_slice = unsafe { slice::from_raw_parts_mut(out_r.data, outr_dim[0] * outr_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:141:23 firmware> | firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd( firmware> 116 | | mat1: *mut InputMatrix, firmware> 117 | | outu: *mut InputMatrix, firmware> 118 | | outs: *mut InputMatrix, firmware> 119 | | outvh: *mut InputMatrix, firmware> 120 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 141 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:142:23 firmware> | firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd( firmware> 116 | | mat1: *mut InputMatrix, firmware> 117 | | outu: *mut InputMatrix, firmware> 118 | | outs: *mut InputMatrix, firmware> 119 | | outvh: *mut InputMatrix, firmware> 120 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 142 | let out_u_slice = unsafe { slice::from_raw_parts_mut(outu.data, outu_dim[0] * outu_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:143:23 firmware> | firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd( firmware> 116 | | mat1: *mut InputMatrix, firmware> 117 | | outu: *mut InputMatrix, firmware> 118 | | outs: *mut InputMatrix, firmware> 119 | | outvh: *mut InputMatrix, firmware> 120 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 143 | let out_s_slice = unsafe { slice::from_raw_parts_mut(outs.data, outs_dim[0]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:144:24 firmware> | firmware> 115 | / pub unsafe extern "C" fn np_linalg_svd( firmware> 116 | | mat1: *mut InputMatrix, firmware> 117 | | outu: *mut InputMatrix, firmware> 118 | | outs: *mut InputMatrix, firmware> 119 | | outvh: *mut InputMatrix, firmware> 120 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 144 | let out_vh_slice = unsafe { slice::from_raw_parts_mut(outvh.data, outvh_dim[0] * outvh_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:183:21 firmware> | firmware> 157 | pub unsafe extern "C" fn np_linalg_inv(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 183 | let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:184:23 firmware> | firmware> 157 | pub unsafe extern "C" fn np_linalg_inv(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 184 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:213:21 firmware> | firmware> 198 | pub unsafe extern "C" fn np_linalg_pinv(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | -------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 213 | let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:214:23 firmware> | firmware> 198 | pub unsafe extern "C" fn np_linalg_pinv(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | -------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 214 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:250:17 firmware> | firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 250 | let power = unsafe { slice::from_raw_parts_mut(mat2.data, 1) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:253:21 firmware> | firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 253 | let out_slice = unsafe { slice::from_raw_parts_mut(out.data, outdim[0] * outdim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:254:23 firmware> | firmware> 234 | pub unsafe extern "C" fn np_linalg_matrix_power(mat1: *mut InputMatrix, mat2: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ---------------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 254 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:298:21 firmware> | firmware> 284 | pub unsafe extern "C" fn np_linalg_det(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 298 | let out_slice = unsafe { slice::from_raw_parts_mut(out.data, 1) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:299:23 firmware> | firmware> 284 | pub unsafe extern "C" fn np_linalg_det(mat1: *mut InputMatrix, out: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 299 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:337:23 firmware> | firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 337 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:338:23 firmware> | firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 338 | let out_l_slice = unsafe { slice::from_raw_parts_mut(out_l.data, outl_dim[0] * outl_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:339:23 firmware> | firmware> 318 | pub unsafe extern "C" fn sp_linalg_lu(mat1: *mut InputMatrix, out_l: *mut InputMatrix, out_u: *mut InputMatrix) { firmware> | --------------------------------------------------------------------------------------------------------------- because it's nested under this `unsafe` fn firmware> ... firmware> 339 | let out_u_slice = unsafe { slice::from_raw_parts_mut(out_u.data, outu_dim[0] * outu_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:382:23 firmware> | firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn firmware> ... firmware> 382 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:383:23 firmware> | firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn firmware> ... firmware> 383 | let out_t_slice = unsafe { slice::from_raw_parts_mut(out_t.data, out_t_dim[0] * out_t_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:384:23 firmware> | firmware> 352 | pub unsafe extern "C" fn sp_linalg_schur(mat1: *mut InputMatrix, out_t: *mut InputMatrix, out_z: *mut InputMatrix) { firmware> | ------------------------------------------------------------------------------------------------------------------ because it's nested under this `unsafe` fn firmware> ... firmware> 384 | let out_z_slice = unsafe { slice::from_raw_parts_mut(out_z.data, out_z_dim[0] * out_z_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:431:23 firmware> | firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg( firmware> 398 | | mat1: *mut InputMatrix, firmware> 399 | | out_h: *mut InputMatrix, firmware> 400 | | out_q: *mut InputMatrix, firmware> 401 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 431 | let data_slice1 = unsafe { slice::from_raw_parts_mut(mat1.data, dim1[0] * dim1[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:432:23 firmware> | firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg( firmware> 398 | | mat1: *mut InputMatrix, firmware> 399 | | out_h: *mut InputMatrix, firmware> 400 | | out_q: *mut InputMatrix, firmware> 401 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 432 | let out_h_slice = unsafe { slice::from_raw_parts_mut(out_h.data, out_h_dim[0] * out_h_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block firmware> warning: unnecessary `unsafe` block firmware> --> libksupport/src/kernel/linalg.rs:433:23 firmware> | firmware> 397 | / pub unsafe extern "C" fn sp_linalg_hessenberg( firmware> 398 | | mat1: *mut InputMatrix, firmware> 399 | | out_h: *mut InputMatrix, firmware> 400 | | out_q: *mut InputMatrix, firmware> 401 | | ) { firmware> | |_- because it's nested under this `unsafe` fn firmware> ... firmware> 433 | let out_q_slice = unsafe { slice::from_raw_parts_mut(out_q.data, out_q_dim[0] * out_q_dim[1]) }; firmware> | ^^^^^^ unnecessary `unsafe` block ```
Author
Contributor

I just ran build latest master, and got these warnings:

rust-stable allows nested unsafe blocks for clarity, but with rust-nightly having nested unsafe is discouraged (hence the warning). Will create another PR to remove the nested unsafe.

> I just ran build latest master, and got these warnings: rust-stable allows nested unsafe blocks for clarity, but with rust-nightly having nested unsafe is discouraged (hence the warning). Will create another PR to remove the nested unsafe.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/artiq-zynq#309
No description provided.