pub(crate) fn new_with_strength(
        strength: Strength,
        max_batch_size: usize,
    ) -> Result<Self, Error> {
        let gpu_count = match env::var("GPU_COUNT") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find GPU_COUNT={} from env var", n);
                      n
                  },
                  Err(_e) => 1,
                }
            },
            Err(_e) => 1
        };
        
        let kernel_per_gpu = match env::var("KERNEL_PER_GPU") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find KERNEL_PER_GPU={} from env var", n);
                      n
                  },
                  Err(_e) => 4,
                }
            },
            Err(_e) => 4
        };

        // 4: Kernels per GPU.
        let kernel_count = std::cmp::min(kernel_per_gpu*gpu_count, 32);

        let mut next_index = FUTHARK_CONTEXT_NEXT_INDEX.lock().unwrap();
        let index = *next_index % kernel_count;
        *next_index += 1;
        let ctx: &Mutex<FutharkContext> = match index {
            0 => &*FUTHARK_CONTEXT_0,
            1 => &*FUTHARK_CONTEXT_1,
            2 => &*FUTHARK_CONTEXT_2,
            3 => &*FUTHARK_CONTEXT_3,
            4 => &*FUTHARK_CONTEXT_4,
            5 => &*FUTHARK_CONTEXT_5,
            6 => &*FUTHARK_CONTEXT_6,
            7 => &*FUTHARK_CONTEXT_7,
            8 => &*FUTHARK_CONTEXT_8,
            9 => &*FUTHARK_CONTEXT_9,
            10 => &*FUTHARK_CONTEXT_10,
            11 => &*FUTHARK_CONTEXT_11,
            12 => &*FUTHARK_CONTEXT_12,
            13 => &*FUTHARK_CONTEXT_13,
            14 => &*FUTHARK_CONTEXT_14,
            15 => &*FUTHARK_CONTEXT_15,
            16 => &*FUTHARK_CONTEXT_16,
            17 => &*FUTHARK_CONTEXT_17,
            18 => &*FUTHARK_CONTEXT_18,
            19 => &*FUTHARK_CONTEXT_19,
            20 => &*FUTHARK_CONTEXT_20,
            21 => &*FUTHARK_CONTEXT_21,
            22 => &*FUTHARK_CONTEXT_22,
            23 => &*FUTHARK_CONTEXT_23,
            24 => &*FUTHARK_CONTEXT_24,
            25 => &*FUTHARK_CONTEXT_25,
            26 => &*FUTHARK_CONTEXT_26,
            27 => &*FUTHARK_CONTEXT_27,
            28 => &*FUTHARK_CONTEXT_28,
            29 => &*FUTHARK_CONTEXT_29,
            30 => &*FUTHARK_CONTEXT_30,
            31 => &*FUTHARK_CONTEXT_31,
            _ => &*FUTHARK_CONTEXT_0
        };
        info!("Create GPUBatchHasher using the {}/{} FUTHARK_CONTEXT", index + 1, kernel_count);

        let hash_retry = match env::var("P2_RETRY") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find P2_RETRY={} from env var", n);
                      n
                  },
                  Err(_e) => 3600,
                }
            },
            Err(_e) => 3600
        };

        let new = Self {
            ctx: ctx,
            state: BatcherState::new_with_strength::<A>(ctx, strength)?,
            tree_builder_state: None,
            max_batch_size,
            hash_retry,
            _a: PhantomData::<A>,
        };
        Ok(new)
    }
/// Create a new `GPUBatchHasher` and initialize it with state corresponding with its `A`.
Create a new `GPUBatchHasher` and initialize it with state corresponding with its `A`.
Create a new ` GPUBatchHasher ` and initialize it with state corresponding with its ` A ` .
pub(crate) fn new_with_strength(
        strength: Strength,
        max_batch_size: usize,
    ) -> Result<Self, Error> {
        let gpu_count = match env::var("GPU_COUNT") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find GPU_COUNT={} from env var", n);
                      n
                  },
                  Err(_e) => 1,
                }
            },
            Err(_e) => 1
        };
        let kernel_per_gpu = match env::var("KERNEL_PER_GPU") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find KERNEL_PER_GPU={} from env var", n);
                      n
                  },
                  Err(_e) => 4,
                }
            },
            Err(_e) => 4
        };
        // 4: Kernels per GPU.
        let kernel_count = std::cmp::min(kernel_per_gpu*gpu_count, 32);
        let mut next_index = FUTHARK_CONTEXT_NEXT_INDEX.lock().unwrap();
        let index = *next_index % kernel_count;
        *next_index += 1;
        let ctx: &Mutex<FutharkContext> = match index {
            0 => &*FUTHARK_CONTEXT_0,
            1 => &*FUTHARK_CONTEXT_1,
            2 => &*FUTHARK_CONTEXT_2,
            3 => &*FUTHARK_CONTEXT_3,
            4 => &*FUTHARK_CONTEXT_4,
            5 => &*FUTHARK_CONTEXT_5,
            6 => &*FUTHARK_CONTEXT_6,
            7 => &*FUTHARK_CONTEXT_7,
            8 => &*FUTHARK_CONTEXT_8,
            9 => &*FUTHARK_CONTEXT_9,
            10 => &*FUTHARK_CONTEXT_10,
            11 => &*FUTHARK_CONTEXT_11,
            12 => &*FUTHARK_CONTEXT_12,
            13 => &*FUTHARK_CONTEXT_13,
            14 => &*FUTHARK_CONTEXT_14,
            15 => &*FUTHARK_CONTEXT_15,
            16 => &*FUTHARK_CONTEXT_16,
            17 => &*FUTHARK_CONTEXT_17,
            18 => &*FUTHARK_CONTEXT_18,
            19 => &*FUTHARK_CONTEXT_19,
            20 => &*FUTHARK_CONTEXT_20,
            21 => &*FUTHARK_CONTEXT_21,
            22 => &*FUTHARK_CONTEXT_22,
            23 => &*FUTHARK_CONTEXT_23,
            24 => &*FUTHARK_CONTEXT_24,
            25 => &*FUTHARK_CONTEXT_25,
            26 => &*FUTHARK_CONTEXT_26,
            27 => &*FUTHARK_CONTEXT_27,
            28 => &*FUTHARK_CONTEXT_28,
            29 => &*FUTHARK_CONTEXT_29,
            30 => &*FUTHARK_CONTEXT_30,
            31 => &*FUTHARK_CONTEXT_31,
            _ => &*FUTHARK_CONTEXT_0
        };
        info!("Create GPUBatchHasher using the {}/{} FUTHARK_CONTEXT", index + 1, kernel_count);
        let hash_retry = match env::var("P2_RETRY") {
            Ok(val) => {
                match val.parse::<usize>() {
                  Ok(n) => {
                      info!("GPUBatchHasher find P2_RETRY={} from env var", n);
                      n
                  },
                  Err(_e) => 3600,
                }
            },
            Err(_e) => 3600
        };
        let new = Self {
            ctx: ctx,
            state: BatcherState::new_with_strength::<A>(ctx, strength)?,
            tree_builder_state: None,
            max_batch_size,
            hash_retry,
            _a: PhantomData::<A>,
        };
        Ok(new)
    }
pub ( crate ) fn new_with_strength ( strength : Strength , max_batch_size : usize , ) -> Result < Self , Error > { let gpu_count = match env :: var ( " " ) { Ok ( val ) => { match val . parse :: < usize > ( ) { Ok ( n ) => { info ! ( " " n ) ; n } , Err ( _e ) => 1 , } } , Err ( _e ) => 1 } ; let kernel_per_gpu = match env :: var ( " " ) { Ok ( val ) => { match val . parse :: < usize > ( ) { Ok ( n ) => { info ! ( " " n ) ; n } , Err ( _e ) => 4 , } } , Err ( _e ) => 4 } ; // 4: Kernels per GPU. let kernel_count = std :: cmp :: min ( kernel_per_gpu * gpu_count , 32 ) ; let mut next_index = FUTHARK_CONTEXT_NEXT_INDEX . lock ( ) . unwrap ( ) ; let index = * next_index % kernel_count ; * next_index += 1 ; let ctx : & Mutex < FutharkContext > = match index { 0 => & * FUTHARK_CONTEXT_0 , 1 => & * FUTHARK_CONTEXT_1 , 2 => & * FUTHARK_CONTEXT_2 , 3 => & * FUTHARK_CONTEXT_3 , 4 => & * FUTHARK_CONTEXT_4 , 5 => & * FUTHARK_CONTEXT_5 , 6 => & * FUTHARK_CONTEXT_6 , 7 => & * FUTHARK_CONTEXT_7 , 8 => & * FUTHARK_CONTEXT_8 , 9 => & * FUTHARK_CONTEXT_9 , 10 => & * FUTHARK_CONTEXT_10 , 11 => & * FUTHARK_CONTEXT_11 , 12 => & * FUTHARK_CONTEXT_12 , 13 => & * FUTHARK_CONTEXT_13 , 14 => & * FUTHARK_CONTEXT_14 , 15 => & * FUTHARK_CONTEXT_15 , 16 => & * FUTHARK_CONTEXT_16 , 17 => & * FUTHARK_CONTEXT_17 , 18 => & * FUTHARK_CONTEXT_18 , 19 => & * FUTHARK_CONTEXT_19 , 20 => & * FUTHARK_CONTEXT_20 , 21 => & * FUTHARK_CONTEXT_21 , 22 => & * FUTHARK_CONTEXT_22 , 23 => & * FUTHARK_CONTEXT_23 , 24 => & * FUTHARK_CONTEXT_24 , 25 => & * FUTHARK_CONTEXT_25 , 26 => & * FUTHARK_CONTEXT_26 , 27 => & * FUTHARK_CONTEXT_27 , 28 => & * FUTHARK_CONTEXT_28 , 29 => & * FUTHARK_CONTEXT_29 , 30 => & * FUTHARK_CONTEXT_30 , 31 => & * FUTHARK_CONTEXT_31 , _ => & * FUTHARK_CONTEXT_0 } ; info ! ( " " index 1 kernel_count ) ; let hash_retry = match env :: var ( " " ) { Ok ( val ) => { match val . parse :: < usize > ( ) { Ok ( n ) => { info ! ( " " n ) ; n } , Err ( _e ) => 3600 , } } , Err ( _e ) => 3600 } ; let new = Self { ctx : ctx , state : BatcherState :: new_with_strength :: < A > ( ctx , strength ) ? , tree_builder_state : None , max_batch_size , hash_retry , _a : PhantomData :: < A > , } ; Ok ( new ) }
Create a new `GPUBatchHasher` and initialize it with state corresponding with its `A`.
Create a new ` GPUBatchHasher ` and initialize it with state corresponding with its ` A ` .
strength
Strength
max_batch_size
usize
strength
Strength
max_batch_size
usize