def _update(self): """Update the regions and volume sizes based on changed args or region.""" st = time.perf_counter() x_region, y_region, z_region = get_reconstruction_regions(self.args) if not self._resources: self._resources = [Ufo.Resources()] gpus = np.array(self._resources[0].get_gpu_nodes()) gpu_indices = np.array(self.args.gpus or list(range(len(gpus)))) if min(gpu_indices) < 0 or max(gpu_indices) > len(gpus) - 1: raise ValueError('--gpus contains invalid indices') gpus = gpus[gpu_indices] if self.regions is None: self._regions = make_runs(gpus, gpu_indices, x_region, y_region, z_region, DTYPE_CL_SIZE[self.args.store_type], slices_per_device=self.args.slices_per_device, slice_memory_coeff=self.args.slice_memory_coeff, data_splitting_policy=self.args.data_splitting_policy, num_gpu_threads=self.args.num_gpu_threads) else: self._regions = self.regions offset = 0 for batch in self._regions: for i, region in batch: if len(self._resources) < len(batch): self._resources.append(Ufo.Resources()) offset += len(np.arange(*region)) if self.args.slice_metric: shape = (offset,) else: shape = (offset, len(np.arange(*y_region)), len(np.arange(*x_region))) if self.volume is None or shape != self.volume.shape: self.volume = np.empty(shape, dtype=np.float32) LOG.log(PERFDEBUG, 'Backprojector manager update duration: %g s', time.perf_counter() - st)
def test_resource_info(): resources = Ufo.Resources() nodes = resources.get_gpu_nodes() assert (nodes) node = nodes[0] assert (node.get_info(Ufo.GpuNodeInfo.LOCAL_MEM_SIZE) > 0) assert (node.get_info(Ufo.GpuNodeInfo.MAX_MEM_ALLOC_SIZE) > 0) assert (node.get_info(Ufo.GpuNodeInfo.GLOBAL_MEM_SIZE) > node.get_info( Ufo.GpuNodeInfo.LOCAL_MEM_SIZE))
def genreco(args): st = time.time() _fill_missing_args(args) _convert_angles_to_rad(args) set_projection_filter_scale(args) x_region, y_region, z_region = get_reconstruction_regions(args, store=True) resources = [Ufo.Resources()] gpus = np.array(resources[0].get_gpu_nodes()) gpu_indices = np.array(args.gpus or range(len(gpus))) if min(gpu_indices) < 0 or max(gpu_indices) > len(gpus) - 1: raise ValueError('--gpus contains invalid indices') gpus = gpus[gpu_indices] duration = 0 for i, gpu in enumerate(gpus): print 'Max mem for {}: {:.2f} GB'.format(i, gpu.get_info(0) / 2**30) runs = make_runs(gpus, gpu_indices, x_region, y_region, z_region, DTYPE_CL_SIZE[args.store_type], slices_per_device=args.slices_per_device, slice_memory_coeff=args.slice_memory_coeff, data_splitting_policy=args.data_splitting_policy) for i in range(len(runs[0]) - 1): resources.append(Ufo.Resources()) LOG.info('Number of passes: %d', len(runs)) for i, regions in enumerate(runs): duration += _run(resources, args, x_region, y_region, regions, i) vol_shape = get_reconstructed_cube_shape(x_region, y_region, z_region) num_gupdates = vol_shape[0] * vol_shape[1] * vol_shape[ 2] * args.number * 1e-9 total_duration = time.time() - st LOG.debug('UFO duration: %.2f s', duration) LOG.debug('Total duration: %.2f s', total_duration) LOG.debug('UFO performance: %.2f GUPS', num_gupdates / duration) LOG.debug('Total performance: %.2f GUPS', num_gupdates / total_duration)