Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
skailasa committed Nov 22, 2023
1 parent b0e414c commit 5d27bc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 44 deletions.
23 changes: 6 additions & 17 deletions fmm/src/fmm_linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use bempp_traits::{
};
use bempp_tree::types::{morton::MortonKey, single_node::SingleNodeTree};

use crate::types::{FmmData, FmmDataLinear, KiFmm, KiFmmLinear, SendPtr, SendPtrMut, SendPtrMutIter};
use crate::types::{FmmData, FmmDataLinear, KiFmm, KiFmmLinear, SendPtr, SendPtrMut};
use rlst::{
algorithms::{linalg::DenseMatrixLinAlgBuilder, traits::svd::Svd},
common::traits::*,
Expand Down Expand Up @@ -289,10 +289,9 @@ where
let size_real = p * q * (r / 2 + 1);
let pad_size = (p - m, q - n, r - o);
let pad_index = (p - m, q - n, r - o);
// let mut padded_signals = rlst_col_vec![U, size * ntargets];
let mut padded_signals = vec![U::zero(); size*ntargets];
let mut padded_signals = rlst_col_vec![U, size * ntargets];

let padded_signals_chunks = padded_signals.par_chunks_exact_mut(size);
let padded_signals_chunks = padded_signals.data_mut().par_chunks_exact_mut(size);

let ntargets = targets.len();
let min = &targets[0];
Expand All @@ -309,26 +308,16 @@ where
.for_each(|(padded_signal, multipole)| {
let signal = self.fmm.m2l.compute_signal(self.fmm.order, multipole);

let mut tmp = pad3(&signal, pad_size, pad_index);
let tmp = pad3(&signal, pad_size, pad_index);

padded_signal.copy_from_slice(tmp.get_data());
});


// Allocating and handling this vec of structs is really shit
// let mut padded_signals_hat = rlst_col_vec![Complex<U>, size_real * ntargets];
let mut padded_signals_hat = vec![Complex::<U>::zero(); size_real*ntargets];
let mut padded_signals_hat = unsafe {rlst_pointer_mat!['a, Complex<U>, padded_signals_hat.as_mut_ptr(), (size_real*ntargets, 1), (1,1)]};
let mut padded_signals_hat = rlst_col_vec![Complex<U>, size_real * ntargets];

// U::rfft3_fftw_par_vec(&mut padded_signals, &mut padded_signals_hat, &[p, q, r]);

// // let mut real_parts = Vec::with_capacity(padded_signals_hat.data().len());
// // let mut imag_parts = Vec::with_capacity(padded_signals_hat.data().len());

// // for complex_val in padded_signals_hat.data().iter() {
// // real_parts.push(complex_val.re);
// // imag_parts.push(complex_val.im);
// // }
U::rfft3_fftw_par_vec(&mut padded_signals, &mut padded_signals_hat, &[p, q, r]);

// let kernel_data_halo = &self.fmm.m2l.operator_data.kernel_data_rearranged;
// let ntargets = targets.len();
Expand Down
27 changes: 0 additions & 27 deletions fmm/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,36 +212,9 @@ pub struct SendPtr<T> {
unsafe impl<T> Sync for SendPtr<T> {}



impl <T> Default for SendPtr<T> {

fn default() -> Self {
SendPtr { raw: std::ptr::null() }
}
}

pub struct SendPtrMutIter<'a, T> {
vec: &'a Vec<SendPtrMut<T>>,
current: usize,
}


impl<'a, T> SendPtrMutIter<'a, T> {
pub fn new(vec: &'a Vec<SendPtrMut<T>>) -> Self {
SendPtrMutIter { vec, current: 0 }
}
}

impl<'a, T> Iterator for SendPtrMutIter<'a, T> {
type Item = &'a SendPtrMut<T>; // Change this to the type of item you want to return

fn next(&mut self) -> Option<Self::Item> {
if self.current >= self.vec.len() {
None
} else {
let item = &self.vec[self.current];
self.current += 1;
Some(item)
}
}
}

0 comments on commit 5d27bc1

Please sign in to comment.