mirror of
				https://github.com/xythrez/RustMP.git
				synced 2025-11-03 21:41:01 +00:00 
			
		
		
		
	Cleanup and refactoring
This commit is contained in:
		
					parent
					
						
							
								e23b39ee41
							
						
					
				
			
			
				commit
				
					
						24c3772926
					
				
			
		
					 2 changed files with 11 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -47,19 +47,21 @@ impl SystemObject {
 | 
			
		|||
        // PUs per Package
 | 
			
		||||
        let puppa = coppa * pupco;
 | 
			
		||||
        // PUs per Machine
 | 
			
		||||
        let available_hwthreads= papma * puppa;
 | 
			
		||||
        let available_hwthreads = papma * puppa;
 | 
			
		||||
 | 
			
		||||
        // The cpu_bind_map can be instantiated using environment variables if desired.
 | 
			
		||||
        // Possible interesting improvement would be building a cpu_bind_map using a syntax like
 | 
			
		||||
        // OpenMP's OMP_PLACES. But that is outside of this project's scope due to difficulty of
 | 
			
		||||
        // writing a parser.
 | 
			
		||||
        let cpu_bind_map= (0..available_hwthreads).map(|x| {
 | 
			
		||||
            let package_id = x / puppa;
 | 
			
		||||
            let package_offset = x % puppa;
 | 
			
		||||
            let core_id = package_offset % coppa;
 | 
			
		||||
            let core_offset = package_offset / coppa;
 | 
			
		||||
            return puppa * package_id + core_id * pupco + core_offset;
 | 
			
		||||
        }).collect::<Vec<usize>>();
 | 
			
		||||
        let cpu_bind_map = (0..available_hwthreads)
 | 
			
		||||
            .map(|x| {
 | 
			
		||||
                let package_id = x / puppa;
 | 
			
		||||
                let package_offset = x % puppa;
 | 
			
		||||
                let core_id = package_offset % coppa;
 | 
			
		||||
                let core_offset = package_offset / coppa;
 | 
			
		||||
                return puppa * package_id + core_id * pupco + core_offset;
 | 
			
		||||
            })
 | 
			
		||||
            .collect::<Vec<usize>>();
 | 
			
		||||
 | 
			
		||||
        let max_num_threads = max(
 | 
			
		||||
            option_env!("RMP_NUM_THREADS")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -119,7 +119,7 @@ impl ThreadPoolManager {
 | 
			
		|||
    /// long as the default Rust for loop accepts it.
 | 
			
		||||
    pub fn split_iterators<T, S>(&self, iter: T, block_size: usize) -> Vec<Vec<S>>
 | 
			
		||||
    where
 | 
			
		||||
        T: Iterator<Item=S>
 | 
			
		||||
        T: Iterator<Item = S>,
 | 
			
		||||
    {
 | 
			
		||||
        let mut split = Vec::new();
 | 
			
		||||
        split.reserve_exact(self.num_threads);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue