Stab1el / BAGUA

11 stars 3 forks source link

Crash while solving the equation #3

Closed danmaam closed 1 year ago

danmaam commented 1 year ago

While trying to run BAGUA with the command provided in the README.md file, I got the following error

root@3862fb99fc50:/tmp/BAGUA# python2 hplayout_generator.py [+] Using split mode for occupying holes! [-] can not occupy by this way, quit this method re-solve the equation Traceback (most recent call last): File "hplayout_generator.py", line 197, in plg.select_heap_layout_mode() File "hplayout_generator.py", line 44, in select_heap_layout_mode self.do_split_generate() File "hplayout_generator.py", line 56, in do_split_generate target_prim, TARGET_OP_INDEX, MULTI_TARGETS) File "/tmp/BAGUA/split_occupation_executor.py", line 232, in do_multiple_occupation_by_multiple_steps primitive_time_list, new_layout = sp_oc.do_split_occupy() File "/tmp/BAGUA/split_occupation_executor.py", line 190, in do_split_occupy primitive_timeline = self.generate_primitive_timeline_by_solves(primitive_times, malloc_sizes) File "/tmp/BAGUA/split_occupation_executor.py", line 155, in generate_primitive_timeline_by_solves each_op.malloc_size = sizes_list[each_prim_name] - 2 * SIZE_SZ KeyError: 'P2'

I'm using Ubuntu 20.04 with Python 2.7.18

Stab1el commented 1 year ago

We run the given demo of BAGUA again and we don't encounter the same problem. An expected running result may be

_lrh@test:/tmp/BAGUA$ python2 hplayoutgenerator.py [+] Using split mode for occupying holes! [-] can not occupy by this way, quit this method re-solve the equation P0 f(P4, 0,4112,94523111639568) --> m(32) --> P1 m(8208) --> m(16) --> f(P1, 1,32,94523111651952) --> P2 f(P0, 1,48,94523111643680) --> m(11264) --> f(P1, 0,8224,94523111643728) --> P5 m(8208) --> m(8208) --> m(8208) --> m(8208) --> m(8208) --> 6.79567098618

Due to the randomness in the process of solving the ILP model, you might run the script again, and to see whether it still crashes.

Hanseltu commented 1 year ago

While trying to run BAGUA with the command provided in the README.md file, I got the following error

root@3862fb99fc50:/tmp/BAGUA# python2 hplayout_generator.py [+] Using split mode for occupying holes! [-] can not occupy by this way, quit this method re-solve the equation Traceback (most recent call last): File "hplayout_generator.py", line 197, in plg.select_heap_layout_mode() File "hplayout_generator.py", line 44, in select_heap_layout_mode self.do_split_generate() File "hplayout_generator.py", line 56, in do_split_generate target_prim, TARGET_OP_INDEX, MULTI_TARGETS) File "/tmp/BAGUA/split_occupation_executor.py", line 232, in do_multiple_occupation_by_multiple_steps primitive_time_list, new_layout = sp_oc.do_split_occupy() File "/tmp/BAGUA/split_occupation_executor.py", line 190, in do_split_occupy primitive_timeline = self.generate_primitive_timeline_by_solves(primitive_times, malloc_sizes) File "/tmp/BAGUA/split_occupation_executor.py", line 155, in generate_primitive_timeline_by_solves each_op.malloc_size = sizes_list[each_prim_name] - 2 * SIZE_SZ KeyError: 'P2'

I'm using Ubuntu 20.04 with Python 2.7.18

Hi @danmaam, I encountered the same issue here. Also, I run it multiple times and the results are the same. Did you resolve it? Thanks.

Hanseltu commented 1 year ago

Hi, may I seek your further help here, please?

After I printed the details, it seems the sizes_list became empty after a few round operations.

('## all_prims : ', OrderedDict([('P0', <primitive.Primitive instance at 0x7f42ce0fddc0>), ('P1', <primitive.Primitive instance at 0x7f42ce0fde60>), ('P2', <primitive.Primitive instance at 0x7f42ce006050>), ('P3', <primitive.Primitive instance at 0x7f42ce006190>), ('P4', <primitive.Primitive instance at 0x7f42ce006280>), ('P5', <primitive.Primitive instance at 0x7f42ce006320>), ('P6', <primitive.Primitive instance at 0x7f42ce006500>), ('P7', <primitive.Primitive instance at 0x7f42ce006780>), ('P8', <primitive.Primitive instance at 0x7f42ce006a50>), ('P9', <primitive.Primitive instance at 0x7f42ce006c80>)]))
('## prims_count_dependency : ', OrderedDict([(u'P2', {u'Max': 1, u'Min': 0}), (u'P3', {u'Max': 1, u'Min': 0}), (u'P0', {u'Max': 1, u'Min': 0}), (u'P1', {u'Max': 1, u'Min': 0}), (u'P6', {u'Max': 1, u'Min': 0}), (u'P7', {u'Max': 1, u'Min': 0}), (u'P4', {u'Max': 0, u'Min': 0}), (u'P5', {u'Max': 1, u'Min': 0}), (u'P8', {u'Max': 1, u'Min': 0}), (u'P9', {u'Max': 0, u'Min': 0})]))
('## target_prim_abi : ', <primitive_ability.PrimitiveAbility instance at 0x7f42ce0fdd70>)
('## target_prim_abi_list : ', [[-1, -1, -1, -1, -1], [0, -1, -1, -1, -1]])
('## sum_abi : ', -1)
('## init_layout : ', <layout.Layout instance at 0x7f42cd534fa0>)
[+] Using split mode for occupying holes!
('occupy_mode : ', 'split')
('target_prim : ', <primitive.Primitive instance at 0x7f42ce006320>)
[-] can not occupy by this way, quit this method
('final_op_list : ', -1)
('# times_list : ', {'P2': 1})
('# sizes_list : ', {'P2': 48})
('each_prim_name : ', 'P2')
('each_prim_name : ', 'P2')
('each_prim_name : ', 'P2')
re-solve the equation
('# times_list : ', {'P0': 1})
('# sizes_list : ', {'P0': 48})
('each_prim_name : ', 'P0')
('each_prim_name : ', 'P0')
('# times_list : ', {'P2': 1, 'P1': 1})
('# sizes_list : ', {})
('each_prim_name : ', 'P2')
('each_prim_name : ', 'P2')
Traceback (most recent call last):
  File "hplayout_generator.py", line 205, in <module>
    plg.select_heap_layout_mode()
  File "hplayout_generator.py", line 50, in select_heap_layout_mode
    self.do_split_generate()
  File "hplayout_generator.py", line 64, in do_split_generate
    target_prim, TARGET_OP_INDEX, MULTI_TARGETS)
  File "/home/haoxin/haoxin-data/smu-research/BAGUA/split_occupation_executor.py", line 240, in do_multiple_occupation_by_multiple_steps
    primitive_time_list, new_layout = sp_oc.do_split_occupy()
  File "/home/haoxin/haoxin-data/smu-research/BAGUA/split_occupation_executor.py", line 196, in do_split_occupy
    primitive_timeline = self.generate_primitive_timeline_by_solves(primitive_times, malloc_sizes)
  File "/home/haoxin/haoxin-data/smu-research/BAGUA/split_occupation_executor.py", line 160, in generate_primitive_timeline_by_solves
    each_op.malloc_size = sizes_list[each_prim_name] -  2 * SIZE_SZ
KeyError: 'P2'

The log ('# times_list : ', {'P2': 1, 'P1': 1}) and ('# sizes_list : ', {}) are printed after I inserted two printings here: https://github.com/Stab1el/BAGUA/blob/main/split_occupation_executor.py#L146.

May I know what could be the possible reasons why sizes_list became empty and how I can fix this issue?

Thank you so much if you can help me out!

Best regards, Haoxin

Stab1el commented 1 year ago

Thanks for your reporting. It seems that the issue appears during the process of z3 solving constraints. The issue arises in some situations due to the inherent randomness involved in constraint solving. We've been able to reproduce the problem and have implemented fixes to prevent this from happening in the future.