- 
  Notifications
 You must be signed in to change notification settings 
- Fork 58
-
While doing some basic performance testing I noticed that initialising an Array on the GPU is much faster if you either used arrayfire::info or arrayfire::set_device before.
For me using either one decreased the time from about 1.5s to about 350ms.
Is this intended, especially for arrayfire::info ?
use arrayfire::{Array, Dim4, pow, set_device, info};
use std::time::{Instant};
use arrayfire::{Array, Dim4, pow, set_device, info};
use std::time::{Instant};
fn main() {
 //set_device(0);
 //info();
 let values: [f64; 100000] = [3.5; 100000];
 
 let start_loop = Instant::now();
 let mut res_loop: [f64; 100000] = [0.0; 100000];
 for i in 0..values.len() {
 res_loop[i] = values[i].powi(2) + 3.14159 / 6.7;
 }
 println!("Loop:{:?}", start_loop.elapsed());
 let start_gpu_setup = Instant::now();
 let indices = Array::<f64>::new(&values, Dim4::new(&[100000, 1, 1, 1]));
 println!("GPU Setup:{:?}", start_gpu_setup.elapsed());
 let start_gpu = Instant::now();
 let res_gpu = pow(&indices, &2, false) + 3.14159 / 6.7;
 println!("GPU:{:?}", start_gpu.elapsed());
 
}
Beta Was this translation helpful? Give feedback.
All reactions
The device warmup does take time depending the backend. How much time should be considered okay really depends on what other processes are running on the system and how long the the corresponding device initialisation takes place.
By calling, info or set_device ahead of timing section of code you are taking care of the warmup separately so it doesn't show up later. Basically, init is run by whichever function you call later if it isn't done already.
This is not bug.
Replies: 2 comments
-
The device warmup does take time depending the backend. How much time should be considered okay really depends on what other processes are running on the system and how long the the corresponding device initialisation takes place.
By calling, info or set_device ahead of timing section of code you are taking care of the warmup separately so it doesn't show up later. Basically, init is run by whichever function you call later if it isn't done already.
This is not bug.
Beta Was this translation helpful? Give feedback.
All reactions
-
Alright thanks for the clarification.
Beta Was this translation helpful? Give feedback.