def generate_data(): a_blocks = list() b_blocks = list() n = NUMBER_OF_GENERATIONS if NUMBER_OF_GENERATIONS > 0 else NUMBER_OF_ITERATIONS for _ in range(n): a = np.random.random([BLOCKSIZE, BLOCKSIZE]) b = np.random.random([BLOCKSIZE, BLOCKSIZE]) # Only for evaluating in-place excution on Optane DC if INPUT_IN_NVRAM: a = np_persist(a) b = np_persist(b) a_blocks.append(a) b_blocks.append(b) return a_blocks, b_blocks
def generate_data(input_size, output_size): a_blocks = list() b_blocks = list() c_blocks = list() for _ in range(input_size): a = np.random.random([BLOCKSIZE, BLOCKSIZE]) b = np.random.random([BLOCKSIZE, BLOCKSIZE]) # Only for evaluating in-place excution on Optane DC if INPUT_IN_NVRAM: a = np_persist(a) b = np_persist(b) a_blocks.append(a) b_blocks.append(b) for _ in range(output_size): c = np.zeros([BLOCKSIZE, BLOCKSIZE]) if EXEC_IN_NVRAM: c = np_persist(c) c_blocks.append(c) return a_blocks, b_blocks, c_blocks
def generate_data(): blocks = list() n = NUMBER_OF_GENERATIONS if NUMBER_OF_GENERATIONS > 0 else NUMBER_OF_ITERATIONS for _ in range(n): values = np.random.f(10, 2, POINTS_PER_FRAGMENT) # Only for evaluating in-place excution on Optane DC if EXEC_IN_NVRAM: values = np_persist(values) blocks.append(values) bins = np.concatenate((np.arange(0, 10, 0.1), np.arange(10, 50), [np.infty])) return bins, blocks
def generate_data(): blocks = list() n = NUMBER_OF_GENERATIONS if NUMBER_OF_GENERATIONS > 0 else NUMBER_OF_ITERATIONS for _ in range(n): mat = np.array([ np.random.random(DIMENSIONS) for __ in range(POINTS_PER_FRAGMENT) ]) # Normalize all points between 0 and 1 mat -= np.min(mat) mx = np.max(mat) if mx > 0.0: mat /= mx # Only for evaluating in-place excution on Optane DC if EXEC_IN_NVRAM: mat = np_persist(mat) blocks.append(mat) return blocks
def block_sum(a: np.ndarray, b: np.ndarray): ret = a + b if RESULT_IN_NVRAM: ret = np_persist(ret) return ret
def persist_to_nvram(self): self.block = np_persist(self.block)
def persist_to_nvram(self): self.values = np_persist(self.values)
a_blocks.append(a) b_blocks.append(b) c_blocks.append(c[0]) print("Generation time: %f" % (time.time() - start_time)) evaluation_time = list() for _, row, column, result in zip(range(NUMBER_OF_ITERATIONS), cycle(a_blocks), cycle(b_blocks), cycle(c_blocks)): start_time = time.time() for a, b in zip(row, column): fma(a, b, c) if RESULT_IN_NVRAM and not EXEC_IN_NVRAM: c = np_persist(c) evaluation_time.append(time.time() - start_time) print("Execution times for the row x column multiplication: %r" % evaluation_time) # Are we in Memory Mode? # Easy to know: check if there is more than 1TiB of memory mem_bytes = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') mem_tib = mem_bytes / (1024**4) mode = "MM" if mem_tib > 1 else "AD" with open("results_kernel.csv", "a") as f: for result in evaluation_time[-10:]: # Mangling everything with a ",".join
def persist_to_nvram(self): self.points = np_persist(self.points)