def test_explicit_init(): import nums import nums.core.application_manager as am nums.init() assert am.is_initialized() am.destroy()
def _get_and_register_block_shape(self, shape): # pylint: disable=import-outside-toplevel # Only allow this to be used if app manager is maintaining an app instance. import nums.core.application_manager as am assert am.is_initialized(), "Unexpected application state: " \ "application instance doesn't exist." app = am.instance() return app.get_block_shape(shape, self.dtype)
def test_app_manager(): for compute_name in ["numpy"]: for system_name in ["serial", "ray-cyclic", "ray-task"]: settings.compute_name = compute_name settings.system_name = system_name app: ArrayApplication = application_manager.instance() assert np.allclose( np.arange(10), app.arange(0, shape=(10, ), block_shape=(10, )).get()) application_manager.destroy() assert not application_manager.is_initialized() time.sleep(1)
def test_app_manager(compute_name, system_name, device_grid_name): settings.use_head = True settings.compute_name = compute_name settings.system_name = system_name settings.device_grid_name = device_grid_name app: ArrayApplication = application_manager.instance() app_arange = app.arange(0, shape=(10, ), block_shape=(10, )) assert np.allclose(np.arange(10), app_arange.get()) application_manager.destroy() assert not application_manager.is_initialized() time.sleep(1) # Revert for other tests. settings.compute_name = "numpy" settings.system_name = "ray" settings.device_grid_name = "cyclic"
def test_app_manager(compute_name, system_name, device_grid_name, num_cpus): settings.use_head = True settings.compute_name = compute_name settings.system_name = system_name settings.device_grid_name = device_grid_name settings.num_cpus = num_cpus app: ArrayApplication = application_manager.instance() print(settings.num_cpus, num_cpus, app.cm.num_cores_total()) app_arange = app.arange(0, shape=(10, ), block_shape=(10, )) assert np.allclose(np.arange(10), app_arange.get()) if num_cpus is None: assert app.cm.num_cores_total() == get_num_cores() else: assert app.cm.num_cores_total() == num_cpus application_manager.destroy() assert not application_manager.is_initialized() time.sleep(1) # Revert for other tests. settings.compute_name = "numpy" settings.system_name = "ray" settings.device_grid_name = "cyclic" settings.num_cpus = None