|
|
@ -37,7 +37,7 @@ class Heap: |
|
|
|
if self.chunks[loc] == size: |
|
|
|
if self.chunks[loc] == size: |
|
|
|
del self.released[idx] |
|
|
|
del self.released[idx] |
|
|
|
return loc |
|
|
|
return loc |
|
|
|
elif self.chunks[loc] > size: # split chunk |
|
|
|
if self.chunks[loc] > size: # split chunk |
|
|
|
chunksize = self.chunks[loc] |
|
|
|
chunksize = self.chunks[loc] |
|
|
|
self.chunks[loc] = size |
|
|
|
self.chunks[loc] = size |
|
|
|
self.chunks[loc + size] = chunksize - size |
|
|
|
self.chunks[loc + size] = chunksize - size |
|
|
@ -103,7 +103,7 @@ class WaveSim: |
|
|
|
|
|
|
|
|
|
|
|
self.cdata = np.zeros((len(self.interface), sims, 7), dtype='float32') |
|
|
|
self.cdata = np.zeros((len(self.interface), sims, 7), dtype='float32') |
|
|
|
|
|
|
|
|
|
|
|
if type(wavecaps) is int: |
|
|
|
if isinstance(wavecaps, int): |
|
|
|
wavecaps = [wavecaps] * len(circuit.lines) |
|
|
|
wavecaps = [wavecaps] * len(circuit.lines) |
|
|
|
|
|
|
|
|
|
|
|
intf_wavecap = 4 # sufficient for storing only 1 transition. |
|
|
|
intf_wavecap = 4 # sufficient for storing only 1 transition. |
|
|
@ -117,7 +117,7 @@ class WaveSim: |
|
|
|
|
|
|
|
|
|
|
|
# translate circuit structure into self.ops |
|
|
|
# translate circuit structure into self.ops |
|
|
|
ops = [] |
|
|
|
ops = [] |
|
|
|
interface_dict = dict([(n, i) for i, n in enumerate(self.interface)]) |
|
|
|
interface_dict = dict((n, i) for i, n in enumerate(self.interface)) |
|
|
|
for n in circuit.topological_order(): |
|
|
|
for n in circuit.topological_order(): |
|
|
|
if n in interface_dict: |
|
|
|
if n in interface_dict: |
|
|
|
inp_idx = self.ppi_offset + interface_dict[n] |
|
|
|
inp_idx = self.ppi_offset + interface_dict[n] |
|
|
@ -255,8 +255,7 @@ class WaveSim: |
|
|
|
def __repr__(self): |
|
|
|
def __repr__(self): |
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.cdata.nbytes |
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.cdata.nbytes |
|
|
|
return f'<WaveSim {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
return f'<WaveSim {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
f'levels={len(self.level_starts)} state_mem={hr_bytes(self.state.nbytes)} ' + \ |
|
|
|
f'levels={len(self.level_starts)} mem={hr_bytes(total_mem)}>' |
|
|
|
f'total_mem={hr_bytes(total_mem)}>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
return self.timing[line, 0, polarity] |
|
|
|
return self.timing[line, 0, polarity] |
|
|
@ -266,7 +265,7 @@ class WaveSim: |
|
|
|
|
|
|
|
|
|
|
|
def assign(self, vectors, time=0.0, offset=0): |
|
|
|
def assign(self, vectors, time=0.0, offset=0): |
|
|
|
nvectors = min(len(vectors) - offset, self.sims) |
|
|
|
nvectors = min(len(vectors) - offset, self.sims) |
|
|
|
for i, node in enumerate(self.interface): |
|
|
|
for i in range(len(self.interface)): |
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
if ppi_loc < 0: continue |
|
|
|
if ppi_loc < 0: continue |
|
|
|
for p in range(nvectors): |
|
|
|
for p in range(nvectors): |
|
|
@ -321,7 +320,7 @@ class WaveSim: |
|
|
|
return self.cdata |
|
|
|
return self.cdata |
|
|
|
|
|
|
|
|
|
|
|
def reassign(self, time=0.0): |
|
|
|
def reassign(self, time=0.0): |
|
|
|
for i, node in enumerate(self.interface): |
|
|
|
for i in range(len(self.interface)): |
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
ppi_loc = self.sat[self.ppi_offset + i, 0] |
|
|
|
ppo_loc = self.sat[self.ppo_offset + i, 0] |
|
|
|
ppo_loc = self.sat[self.ppo_offset + i, 0] |
|
|
|
if ppi_loc < 0 or ppo_loc < 0: continue |
|
|
|
if ppi_loc < 0 or ppo_loc < 0: continue |
|
|
@ -386,8 +385,7 @@ class WaveSim: |
|
|
|
accs[idx] += 1 |
|
|
|
accs[idx] += 1 |
|
|
|
if s_sqrt2 == 0: |
|
|
|
if s_sqrt2 == 0: |
|
|
|
return values |
|
|
|
return values |
|
|
|
else: |
|
|
|
return accs |
|
|
|
return accs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def vals(self, line, vector, times, sd=0): |
|
|
|
def vals(self, line, vector, times, sd=0): |
|
|
|
return self._vals(line, vector, times, sd) |
|
|
|
return self._vals(line, vector, times, sd) |
|
|
@ -464,7 +462,7 @@ def rand_gauss(seed, sd): |
|
|
|
return 1.0 |
|
|
|
return 1.0 |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
x = -6.0 |
|
|
|
x = -6.0 |
|
|
|
for i in range(12): |
|
|
|
for _ in range(12): |
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
x *= sd |
|
|
|
x *= sd |
|
|
@ -565,8 +563,7 @@ class WaveSimCuda(WaveSim): |
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.timing.nbytes + \ |
|
|
|
total_mem = self.state.nbytes + self.sat.nbytes + self.ops.nbytes + self.timing.nbytes + \ |
|
|
|
self.tdata.nbytes + self.cdata.nbytes |
|
|
|
self.tdata.nbytes + self.cdata.nbytes |
|
|
|
return f'<WaveSimCuda {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
return f'<WaveSimCuda {self.circuit.name} sims={self.sims} ops={len(self.ops)} ' + \ |
|
|
|
f'levels={len(self.level_starts)} state_mem={hr_bytes(self.state.nbytes)} ' + \ |
|
|
|
f'levels={len(self.level_starts)} mem={hr_bytes(total_mem)}>' |
|
|
|
f'total_mem={hr_bytes(total_mem)}>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
def get_line_delay(self, line, polarity): |
|
|
|
return self.d_timing[line, 0, polarity] |
|
|
|
return self.d_timing[line, 0, polarity] |
|
|
@ -661,7 +658,7 @@ def reassign_kernel(state, sat, ppi_offset, ppo_offset, cdata, ppi_time): |
|
|
|
if vector >= state.shape[-1]: return |
|
|
|
if vector >= state.shape[-1]: return |
|
|
|
if ppo_offset + y >= len(sat): return |
|
|
|
if ppo_offset + y >= len(sat): return |
|
|
|
|
|
|
|
|
|
|
|
ppo, ppo_cap, _ = sat[ppo_offset + y] |
|
|
|
ppo, _, _ = sat[ppo_offset + y] |
|
|
|
ppi, ppi_cap, _ = sat[ppi_offset + y] |
|
|
|
ppi, ppi_cap, _ = sat[ppi_offset + y] |
|
|
|
if ppo < 0: return |
|
|
|
if ppo < 0: return |
|
|
|
if ppi < 0: return |
|
|
|
if ppi < 0: return |
|
|
@ -771,7 +768,7 @@ def rand_gauss_dev(seed, sd): |
|
|
|
return 1.0 |
|
|
|
return 1.0 |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
x = -6.0 |
|
|
|
x = -6.0 |
|
|
|
for i in range(12): |
|
|
|
for _ in range(12): |
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
seed = int(0xDEECE66D) * seed + 0xB |
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
x += float((seed >> 8) & 0xffffff) / float(1 << 24) |
|
|
|
x *= sd |
|
|
|
x *= sd |
|
|
|