Skip to content

Commit

Permalink
Merge pull request #42 from latesnow/master
Browse files Browse the repository at this point in the history
fix the bug when OpInput is empty for initiate_batch_fetch_op_2
  • Loading branch information
rdfriese authored May 9, 2024
2 parents 983f340 + 3a2d205 commit 56ae0a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/array/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ impl<'a, T: Dist> OpInput<'a, T> for &'a [T] {
fn as_op_input(self) -> (Vec<OpInputEnum<'a, T>>, usize) {
let len = self.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}
let num = if len < 1000 {
1
} else {
Expand Down Expand Up @@ -500,6 +503,9 @@ impl<'a, T: Dist> OpInput<'a, T> for &'a mut [T] {
fn as_op_input(self) -> (Vec<OpInputEnum<'a, T>>, usize) {
let len = self.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}

let num = if len < 1000 {
1
Expand Down Expand Up @@ -573,6 +579,9 @@ impl<'a, T: Dist> OpInput<'a, T> for Vec<T> {
//#[tracing::instrument(skip_all)]
fn as_op_input(self) -> (Vec<OpInputEnum<'a, T>>, usize) {
let len = self.len();
if len == 0 {
return (vec![], len);
}
let num = if len < 1000 {
1
} else {
Expand Down Expand Up @@ -692,6 +701,9 @@ impl<'a, T: Dist> OpInput<'a, T> for &'a LocalLockLocalData<'_, T> {
fn as_op_input(self) -> (Vec<OpInputEnum<'a, T>>, usize) {
let len = self.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}
let my_pe = self.array.my_pe();
if let Some(_start_index) = self.array.array.inner.start_index_for_pe(my_pe) {
let num = if len < 1000 {
Expand Down Expand Up @@ -732,6 +744,10 @@ impl<'a, T: Dist> OpInput<'a, T> for &'a GlobalLockLocalData<'_, T> {
fn as_op_input(self) -> (Vec<OpInputEnum<'a, T>>, usize) {
let len = self.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}

let my_pe = self.array.my_pe();
if let Some(_start_index) = self.array.array.inner.start_index_for_pe(my_pe) {
let num = if len < 1000 {
Expand Down Expand Up @@ -807,6 +823,9 @@ impl<'a, T: Dist + ElementOps> OpInput<'a, T> for &GenericAtomicLocalData<T> {
let local_data = self.clone();
let len = local_data.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}
let my_pe = self.array.my_pe();
if let Some(_start_index) = self.array.array.inner.start_index_for_pe(my_pe) {
let num = if len < 1000 {
Expand Down Expand Up @@ -854,6 +873,9 @@ impl<'a, T: Dist + ElementOps> OpInput<'a, T> for &NativeAtomicLocalData<T> {
let local_data = self.clone();
let len = local_data.len();
let mut iters = vec![];
if len == 0 {
return (iters, len);
}
let my_pe = self.array.my_pe();
if let Some(_start_index) = self.array.array.inner.start_index_for_pe(my_pe) {
let num = if len < 1000 {
Expand Down
4 changes: 2 additions & 2 deletions src/array/unsafe/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ impl<T: AmDist + Dist + 'static> UnsafeArray<T> {
)
} else {
//no vals no indices
panic!("should not be here");
// Box::pin(async { Vec::new() })
//panic!("should not be here");
Box::pin(async { Vec::new() })
};
Box::pin(async move {
let mut results = Vec::with_capacity(std::cmp::max(i_len, v_len));
Expand Down

0 comments on commit 56ae0a3

Please sign in to comment.