def AddStencilRuntime(self, device_name, device_count, north, south, east, west, data_width, data_height, type_in, type_out, source, max_wg_size, wg_c, wg_r, runtime): """ Add a new stencil runtime. Args: device_name (str): The name of the execution device. device_count (int): The number of execution devices. north (int): The stencil shape north direction. south (int): The stencil shape south direction. east (int): The stencil shape east direction. west (int): The stencil shape west direction. data_width (int): The number of columns of data. data_height (int): The number of rows of data. type_in (str): The input data type. type_out (str): The output data type. source (str): The stencil kernel source code. max_wg_size (int): The maximum kernel workgroup size. wg_c (int): The workgroup size used (columns). wg_r (int): The workgroup size used (rows). runtime (double): The measured runtime in milliseconds. """ # Parse arguments. device_name = util.parse_str(device_name) device_count = int(device_count) north = int(north) south = int(south) east = int(east) west = int(west) data_width = int(data_width) data_height = int(data_height) type_in = util.parse_str(type_in) type_out = util.parse_str(type_out) source = util.parse_str(source) max_wg_size = int(max_wg_size) wg_c = int(wg_c) wg_r = int(wg_r) runtime = float(runtime) # Lookup IDs device = self.db.device_id(device_name, device_count) kernel = self.db.kernel_id(north, south, east, west, max_wg_size, source) dataset = self.db.datasets_id(data_width, data_height, type_in, type_out) scenario = self.db.scenario_id(device, kernel, dataset) params = self.db.params_id(wg_c, wg_r) # Add entry into runtimes table. self.db.add_runtime(scenario, params, runtime) self.db.commit() io.debug(("AddStencilRuntime({scenario}, {params}, {runtime})" .format(scenario=scenario[:8], params=params, runtime=runtime)))
def RequestTrainingStencilParams( self, device_name, device_count, north, south, east, west, data_width, data_height, type_in, type_out, source, max_wg_size, ): """ Request training parameter values for a SkelCL stencil operation. Determines the parameter values to use for a SkelCL stencil operation by iterating over the space of parameter values. Args: device_name (str): The name of the execution device. device_count (int): The number of execution devices. north (int): The stencil shape north direction. south (int): The stencil shape south direction. east (int): The stencil shape east direction. west (int): The stencil shape west direction. data_width (int): The number of columns of data. data_height (int): The number of rows of data. type_in (str): The input data type. type_out (str): The output data type. max_wg_size (int): The maximum kernel workgroup size. source (str): The stencil kernel source code. Returns: A tuple of work group size values, e.g. (16,32) """ # Parse arguments. device_name = util.parse_str(device_name) device_count = int(device_count) north = int(north) south = int(south) east = int(east) west = int(west) data_width = int(data_width) data_height = int(data_height) type_in = util.parse_str(type_in) type_out = util.parse_str(type_out) source = util.parse_str(source) max_wg_size = int(max_wg_size) # Get the next scenario ID to train on. wg = training.random_wg_value(max_wg_size) return wg
def RequestStencilParams(self, device_name, device_count, north, south, east, west, data_width, data_height, type_in, type_out, source, max_wg_size): """ Request parameter values for a SkelCL stencil operation. Determines the parameter values to use for a SkelCL stencil operation, using a machine learning classifier to predict the optimal parameter values given a set of features determined from the arguments. Args: device_name (str): The name of the execution device. device_count (int): The number of execution devices. north (int): The stencil shape north direction. south (int): The stencil shape south direction. east (int): The stencil shape east direction. west (int): The stencil shape west direction. data_width (int): The number of columns of data. data_height (int): The number of rows of data. type_in (str): The input data type. type_out (str): The output data type. max_wg_size (int): The maximum kernel workgroup size. source (str): The stencil kernel source code. Returns: A tuple of work group size values, e.g. (16,32) """ start_time = time.time() # Parse arguments. device_name = util.parse_str(device_name) device_count = int(device_count) north = int(north) south = int(south) east = int(east) west = int(west) data_width = int(data_width) data_height = int(data_height) source = util.parse_str(source) max_wg_size = int(max_wg_size) # TODO: Perform feature extraction & classification wg = (64, 32) end_time = time.time() io.debug(("RequestStencilParams() -> " "({c}, {r}) [{t:.3f}s]".format(c=wg[0], r=wg[1], t=end_time - start_time))) return wg
def RequestStencilParams(self, device_name, device_count, north, south, east, west, data_width, data_height, type_in, type_out, source, max_wg_size): """ Request parameter values for a SkelCL stencil operation. Determines the parameter values to use for a SkelCL stencil operation, using a machine learning classifier to predict the optimal parameter values given a set of features determined from the arguments. Args: device_name (str): The name of the execution device. device_count (int): The number of execution devices. north (int): The stencil shape north direction. south (int): The stencil shape south direction. east (int): The stencil shape east direction. west (int): The stencil shape west direction. data_width (int): The number of columns of data. data_height (int): The number of rows of data. type_in (str): The input data type. type_out (str): The output data type. max_wg_size (int): The maximum kernel workgroup size. source (str): The stencil kernel source code. Returns: A tuple of work group size values, e.g. (16,32) """ start_time = time.time() # Parse arguments. device_name = util.parse_str(device_name) device_count = int(device_count) north = int(north) south = int(south) east = int(east) west = int(west) data_width = int(data_width) data_height = int(data_height) source = util.parse_str(source) max_wg_size = int(max_wg_size) # TODO: Perform feature extraction & classification wg = (64, 32) end_time = time.time() io.debug(("RequestStencilParams() -> " "({c}, {r}) [{t:.3f}s]" .format(c=wg[0], r=wg[1], t=end_time - start_time))) return wg
def RequestTrainingStencilParams(self, device_name, device_count, north, south, east, west, data_width, data_height, type_in, type_out, source, max_wg_size): """ Request training parameter values for a SkelCL stencil operation. Determines the parameter values to use for a SkelCL stencil operation by iterating over the space of parameter values. Args: device_name (str): The name of the execution device. device_count (int): The number of execution devices. north (int): The stencil shape north direction. south (int): The stencil shape south direction. east (int): The stencil shape east direction. west (int): The stencil shape west direction. data_width (int): The number of columns of data. data_height (int): The number of rows of data. type_in (str): The input data type. type_out (str): The output data type. max_wg_size (int): The maximum kernel workgroup size. source (str): The stencil kernel source code. Returns: A tuple of work group size values, e.g. (16,32) """ # Parse arguments. device_name = util.parse_str(device_name) device_count = int(device_count) north = int(north) south = int(south) east = int(east) west = int(west) data_width = int(data_width) data_height = int(data_height) type_in = util.parse_str(type_in) type_out = util.parse_str(type_out) source = util.parse_str(source) max_wg_size = int(max_wg_size) # Get the next scenario ID to train on. wg = training.random_wg_value(max_wg_size) return wg
def test_parse_str(self): self._test("abc", util.parse_str("abc")) self._test("a\nc", util.parse_str("a\nc")) self._test("123", util.parse_str("123"))