a5kin / xentica

GPU-accelerated engine for multi-dimensional cellular automata

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Main state assignment fails

a5kin opened this issue · comments

When assinging to main state, without previously get it:

def absorb(self):
    new_val = core.IntegerVariable()
    self.main.state = new_val + 1

it shows CUDA compiler warning:

kernel.cu(176): warning: variable "_cell" is used before its value is set

Kernel runs, but it results in all zero values at the second step.

The workaround for this case is:

def absorb(self):
    new_val = core.IntegerVariable()
    new_val += 1
    self.main.state = new_val + 1 + 0 * self.main.state

Was a problem not only with the main state, but with all buffered states too. The reason is unnecessary code unpacking value from a memory. We fixed it by marking property "unpacked" the very first time it is set by __setattr__.