Skip to content

Commit ac4320b

Browse files
committed
refactor: cleanup and changes to satisfy Clippy
* This does involve some API changes (function renames) Signed-off-by: Richard Zak <[email protected]>
1 parent 0141608 commit ac4320b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+756
-963
lines changed

.github/workflows/rust.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,12 @@ jobs:
5454
run: |
5555
cd impl
5656
cargo clippy --all-features --tests -- -D warnings
57+
58+
clippy:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v3
62+
- name: UpdateRust
63+
run: rustup update stable
64+
- name: Clippy
65+
run: cargo clippy --workspace --all-features -- -D warnings

impl/src/gen_am.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ pub(crate) fn impl_lamellar_serde_trait(
7171
quote! {
7272
impl #impl_generics #lamellar::active_messaging::LamellarSerde for #am_name #ty_generics #where_clause {
7373
fn serialized_size(&self)->usize{
74-
#lamellar::serialized_size(self,true)
74+
#lamellar::serialized_size(self)
7575
}
7676
fn serialize_into(&self,buf: &mut [u8]){
77-
#lamellar::serialize_into(buf,self,true).expect("can serialize and enough space in buf");
77+
#lamellar::serialize_into(buf,self).expect("can serialize and enough space in buf");
7878
}
7979
fn serialize(&self)->Vec<u8>{
80-
#lamellar::serialize(self,true).expect("can serialize")
80+
#lamellar::serialize(self).expect("can serialize")
8181
}
8282
}
8383
}
@@ -92,13 +92,13 @@ fn impl_return_lamellar_serde_trait(
9292
quote! {
9393
impl #impl_generics #lamellar::active_messaging::LamellarSerde for #am_name #ty_generics #where_clause {
9494
fn serialized_size(&self)->usize{
95-
#lamellar::serialized_size(&self.val,true)
95+
#lamellar::serialized_size(&self.val)
9696
}
9797
fn serialize_into(&self,buf: &mut [u8]){
98-
#lamellar::serialize_into(buf,&self.val,true).expect("can serialize and enough space in buf");
98+
#lamellar::serialize_into(buf,&self.val).expect("can serialize and enough space in buf");
9999
}
100100
fn serialize(&self)->Vec<u8>{
101-
#lamellar::serialize(self,true).expect("can serialize")
101+
#lamellar::serialize(self).expect("can serialize")
102102
}
103103
}
104104
}
@@ -115,11 +115,11 @@ pub(crate) fn impl_lamellar_result_serde_trait(
115115
impl #impl_generics #lamellar::active_messaging::LamellarResultSerde for #am_name #ty_generics #where_clause {
116116
fn serialized_result_size(&self,result: & Box<dyn std::any::Any + Sync + Send>)->usize{
117117
let result = result.downcast_ref::<#ret_type>().expect("can downcast result box");
118-
#lamellar::serialized_size(result,true)
118+
#lamellar::serialized_size(result)
119119
}
120120
fn serialize_result_into(&self,buf: &mut [u8],result: & Box<dyn std::any::Any + Sync + Send>){
121121
let result = result.downcast_ref::<#ret_type>().expect("can downcast result box");
122-
#lamellar::serialize_into(buf,result,true).expect("can serialize and enough size in buf");
122+
#lamellar::serialize_into(buf,result).expect("can serialize and enough size in buf");
123123
}
124124
}
125125
}
@@ -159,7 +159,7 @@ fn impl_unpack_and_register_function(
159159
let am_name_unpack = quote::format_ident!("{}_unpack", am_name.clone());
160160
quote! {
161161
fn #am_name_unpack #impl_generics (bytes: &[u8], cur_pe: Result<usize,#lamellar::IdError>) -> std::sync::Arc<dyn #lamellar::active_messaging::RemoteActiveMessage + Sync + Send> {
162-
let __lamellar_data: std::sync::Arc<#am_name #ty_generics> = std::sync::Arc::new(#lamellar::deserialize(&bytes,true).expect("can deserialize into remote active message"));
162+
let __lamellar_data: std::sync::Arc<#am_name #ty_generics> = std::sync::Arc::new(#lamellar::deserialize(&bytes).expect("can deserialize into remote active message"));
163163
<#am_name #ty_generics as #lamellar::active_messaging::DarcSerde>::des(&__lamellar_data,cur_pe);
164164
__lamellar_data
165165
}
@@ -469,6 +469,7 @@ pub(crate) fn generate_am(
469469
}
470470
}
471471

472+
#[allow(clippy::too_many_arguments)]
472473
pub(crate) fn create_am_struct(
473474
generics: &syn::Generics,
474475
attributes: &proc_macro2::TokenStream,

impl/src/gen_am_group.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ fn gen_am_group_return_stmt(
186186
}
187187
}
188188

189+
#[allow(clippy::too_many_arguments)]
189190
fn impl_am_group_remote(
190191
generics: &syn::Generics,
191192
am_group_am_name: &syn::Ident,
@@ -539,6 +540,7 @@ pub(crate) fn generate_am_group(
539540
}
540541
}
541542

543+
#[allow(clippy::too_many_arguments)]
542544
fn create_am_group_remote(
543545
generics: &syn::Generics,
544546
attributes: &proc_macro2::TokenStream,
@@ -640,6 +642,7 @@ fn create_am_group_remote(
640642
)
641643
}
642644

645+
#[allow(clippy::too_many_arguments)]
643646
pub(crate) fn create_am_group_structs(
644647
generics: &syn::Generics,
645648
attributes: &proc_macro2::TokenStream,

impl/src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use syn::spanned::Spanned;
2525
// use syn::visit_mut::VisitMut;
2626
use syn::parse::{Parse, ParseStream, Result};
2727
use syn::Token;
28+
2829
fn type_name(ty: &syn::Type) -> Option<String> {
2930
match ty {
3031
syn::Type::Path(syn::TypePath { qself: None, path }) => {
@@ -177,7 +178,7 @@ fn check_for_am_group(args: &Punctuated<syn::Meta, Token![,]>) -> bool {
177178
/// impl LamellarAM for HelloWorld {
178179
/// async fn exec(self) {
179180
/// println!(
180-
/// "{:?} on PE {:?} of {:?} using thread {:?}, received from PE {:?}",
181+
/// "{:?} on PE {:?} of {:?} using thread {:?}, received from PE {}",
181182
/// self.msg,
182183
/// lamellar::current_pe,
183184
/// lamellar::num_pes,
@@ -231,18 +232,18 @@ pub fn AmData(args: TokenStream, input: TokenStream) -> TokenStream {
231232
/// );
232233
/// }
233234
/// }
234-
/// fn main() {
235-
/// let world = lamellar::LamellarWorldBuilder::new().build();
236-
/// let my_pe = Arc::new(Mutex::new(world.my_pe()));
237-
/// world.barrier();
238235
///
239-
/// let request = world.exec_am_local(HelloWorld {
240-
/// original_pe: my_pe,
241-
/// });
236+
/// let world = lamellar::LamellarWorldBuilder::new().build();
237+
/// let my_pe = Arc::new(Mutex::new(world.my_pe()));
238+
/// world.barrier();
242239
///
243-
/// //wait for the request to complete
244-
/// request.block();
245-
/// } //when world drops there is an implicit world.barrier() that occurs
240+
/// let request = world.exec_am_local(HelloWorld {
241+
/// original_pe: my_pe,
242+
/// });
243+
///
244+
/// //wait for the request to complete
245+
/// request.block();
246+
/// //when `world` drops there is an implicit world.barrier() that occurs
246247
///```
247248
#[allow(non_snake_case)]
248249
#[proc_macro_error]
@@ -430,7 +431,7 @@ fn parse_am(
430431
/// impl LamellarAM for HelloWorld {
431432
/// async fn exec(self) {
432433
/// println!(
433-
/// "{:?} on PE {:?} of {:?} using thread {:?}, received from PE {:?}",
434+
/// "{:?} on PE {:?} of {:?} using thread {:?}, received from PE {}",
434435
/// self.msg,
435436
/// lamellar::current_pe,
436437
/// lamellar::num_pes,
@@ -447,7 +448,7 @@ fn parse_am(
447448
/// //Send a Hello World Active Message to all pes
448449
/// let request = world.exec_am_all(HelloWorld {
449450
/// original_pe: my_pe,
450-
/// msg: msg,
451+
/// msg: msg.into(),
451452
/// });
452453
///
453454
/// //wait for the request to complete
@@ -471,6 +472,7 @@ pub fn am_group(args: TokenStream, input: TokenStream) -> TokenStream {
471472
///
472473
///```
473474
/// use lamellar::active_messaging::prelude::*;
475+
/// use std::sync::{Arc, Mutex};
474476
///
475477
/// use std::sync::{Arc, Mutex};
476478
///
@@ -894,7 +896,6 @@ impl Parse for AmGroups {
894896
#[proc_macro_error]
895897
#[proc_macro]
896898
pub fn typed_am_group(input: TokenStream) -> TokenStream {
897-
// println!("typed_am_group {:?}",input);
898899
let am_group: AmGroups = syn::parse(input).unwrap();
899900
let am_type = am_group.am;
900901
let team = am_group.team;

src/active_messaging.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,20 @@
438438
//! }
439439
//! }
440440
//!
441-
//! fn main(){
442-
//! let world = lamellar::LamellarWorldBuilder::new().build();
443-
//! let my_pe = world.my_pe();
444-
//! let num_pes = world.num_pes();
445-
//! //Send initial message to right neighbor
446-
//! let next_pe = (my_pe + 1) % num_pes; //account for wrap arround
447-
//! let request = world.exec_am_pe(
448-
//! next_pe,
449-
//! RingAm {
450-
//! original_pe: my_pe
451-
//! }
452-
//! );
453-
//! //wait for the request to complete
454-
//! let results = request.block();
455-
//! println!("PE {my_pe} {results:?}");
456-
//! }
441+
//! let world = lamellar::LamellarWorldBuilder::new().build();
442+
//! let my_pe = world.my_pe();
443+
//! let num_pes = world.num_pes();
444+
//! //Send initial message to right neighbor
445+
//! let next_pe = (my_pe + 1) % num_pes; //account for wrap arround
446+
//! let request = world.exec_am_pe(
447+
//! next_pe,
448+
//! RingAm {
449+
//! original_pe: my_pe
450+
//! }
451+
//! );
452+
//! //wait for the request to complete
453+
//! let results = request.block();
454+
//! println!("PE {my_pe} {results:?}");
457455
//!```
458456
//! The key thing to notice in this example is how we wait for a request to finish will change depending on the context we are executing in.
459457
//! When we are in the active message we are already in an asynchronous context so we can simply `await` the future returned to us by the `exec_am_pe()` call.

src/active_messaging/batching/simple_batcher.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Batcher for SimpleBatcher {
190190
}
191191
let mut darcs = vec![];
192192
data.ser(1, &mut darcs); //1 because we are only sending back to the original PE
193-
let darc_list_size = crate::serialized_size(&darcs, false);
193+
let darc_list_size = crate::serialized_size(&darcs);
194194
let size = batch.add(
195195
req_data,
196196
LamellarData::Data(data, darcs, darc_list_size),
@@ -284,7 +284,7 @@ impl Batcher for SimpleBatcher {
284284
let mut i = 0;
285285
// println!("executing batched msg {:?}", data.len());
286286
while i < data.len() {
287-
let cmd: Cmd = crate::deserialize(&data[i..i + *CMD_LEN], false).unwrap();
287+
let cmd: Cmd = crate::deserialize(&data[i..i + *CMD_LEN]).unwrap();
288288
i += *CMD_LEN;
289289
// let temp_i = i;
290290
// println!("cmd {:?}", cmd);
@@ -407,15 +407,15 @@ impl SimpleBatcher {
407407
cmd: Cmd,
408408
) {
409409
// println!("serialize_am");
410-
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &cmd, false).unwrap();
410+
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &cmd).unwrap();
411411
*i += *CMD_LEN;
412412

413413
let am_header = AmHeader {
414414
am_id,
415415
req_id: req_data.id,
416416
team_addr: req_data.team_addr,
417417
};
418-
crate::serialize_into(&mut data_buf[*i..*i + *AM_HEADER_LEN], &am_header, false).unwrap();
418+
crate::serialize_into(&mut data_buf[*i..*i + *AM_HEADER_LEN], &am_header).unwrap();
419419
*i += *AM_HEADER_LEN;
420420

421421
let am_size = am_size - (*CMD_LEN + *AM_HEADER_LEN);
@@ -446,7 +446,7 @@ impl SimpleBatcher {
446446
darc_list_size: usize,
447447
) {
448448
// println!("serialize_data");
449-
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &Cmd::Data, false).unwrap();
449+
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &Cmd::Data).unwrap();
450450
*i += *CMD_LEN;
451451
let data_size = data_size - (*CMD_LEN + *DATA_HEADER_LEN + darc_list_size);
452452
let data_header = DataHeader {
@@ -457,12 +457,11 @@ impl SimpleBatcher {
457457
crate::serialize_into(
458458
&mut data_buf[*i..*i + *DATA_HEADER_LEN],
459459
&data_header,
460-
false,
461460
)
462461
.unwrap();
463462
*i += *DATA_HEADER_LEN;
464463

465-
crate::serialize_into(&mut data_buf[*i..(*i + darc_list_size)], &darcs, false).unwrap();
464+
crate::serialize_into(&mut data_buf[*i..(*i + darc_list_size)], &darcs).unwrap();
466465
*i += darc_list_size;
467466

468467
data.serialize_into(&mut data_buf[*i..*i + data_size]);
@@ -472,7 +471,7 @@ impl SimpleBatcher {
472471
//#[tracing::instrument(skip_all)]
473472
fn serialize_unit(req_data: ReqMetaData, data_buf: &mut [u8], i: &mut usize) {
474473
// println!("serialize_unit");
475-
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &Cmd::Unit, false).unwrap();
474+
crate::serialize_into(&mut data_buf[*i..*i + *CMD_LEN], &Cmd::Unit).unwrap();
476475
*i += *CMD_LEN;
477476

478477
let unit_header = UnitHeader {
@@ -481,7 +480,6 @@ impl SimpleBatcher {
481480
crate::serialize_into(
482481
&mut data_buf[*i..*i + *UNIT_HEADER_LEN],
483482
&unit_header,
484-
false,
485483
)
486484
.unwrap();
487485
*i += *UNIT_HEADER_LEN;
@@ -512,7 +510,7 @@ impl SimpleBatcher {
512510
Some(AllocError::OutOfMemoryError(_)) => {
513511
lamellae.alloc_pool(size * 2);
514512
}
515-
_ => panic!("unhanlded error!! {:?}", err),
513+
_ => panic!("unhandled error!! {:?}", err),
516514
}
517515
data = lamellae.serialize_header(header.clone(), size);
518516
}
@@ -531,9 +529,9 @@ impl SimpleBatcher {
531529
) {
532530
// println!("exec_am");
533531
let am_header: AmHeader =
534-
crate::deserialize(&data[*i..*i + *AM_HEADER_LEN], false).unwrap();
532+
crate::deserialize(&data[*i..*i + *AM_HEADER_LEN]).unwrap();
535533
let (team, world) =
536-
ame.get_team_and_world(msg.src as usize, am_header.team_addr, &lamellae);
534+
ame.get_team_and_world(msg.src as usize, am_header.team_addr, lamellae);
537535
*i += *AM_HEADER_LEN;
538536

539537
let am = AMS_EXECS.get(&am_header.am_id).unwrap()(&data[*i..], team.team.team_pe);
@@ -590,9 +588,9 @@ impl SimpleBatcher {
590588
) {
591589
// println!("exec_return_am");
592590
let am_header: AmHeader =
593-
crate::deserialize(&data[*i..*i + *AM_HEADER_LEN], false).unwrap();
591+
crate::deserialize(&data[*i..*i + *AM_HEADER_LEN]).unwrap();
594592
let (team, world) =
595-
ame.get_team_and_world(msg.src as usize, am_header.team_addr, &lamellae);
593+
ame.get_team_and_world(msg.src as usize, am_header.team_addr, lamellae);
596594
*i += *AM_HEADER_LEN;
597595
let am = AMS_EXECS.get(&am_header.am_id).unwrap()(&data[*i..], team.team.team_pe);
598596
*i += am.serialized_size();

0 commit comments

Comments
 (0)