skyreflectedinmirrors / spyJac

Working repo for pyJac sparse upgrade
MIT License
1 stars 0 forks source link

Error related to loopy while creating source file #33

Open DavidAkinpelu opened 3 years ago

DavidAkinpelu commented 3 years ago

Got the error while trying to create jacobian source files for a hydrogen-air system in C .

There is a package change of name from loo.py to loopy and with recent versions, these must have broken the code base. Also, the setup requires loo.py>=2018.1 but unfortunately both loo.py and loopy doesn't have version 2018.1 in their history. I guess that must have been 2017.1.

Machine: Ubuntu 20.04.2 LTS Python: 3.9 loo.py: 2020.2 loopy: 2020.2.1

(cantera-dev) david@david-Inspiron-5570:~/spyJac$ python -m pyjac --lang c --input data/h2o2.inp
2021-07-30 11:04:15,169 - pyjac.core.create_jacobian - WARNING - User specified last species not found or not specified.  Attempting to find a default species
2021-07-30 11:04:15,169 - pyjac.core.create_jacobian - INFO - Default last species AR found.
2021-07-30 11:04:15,252 - loopy.target.c.c_execution - WARNING - Default toolchain guessed from python config not found, replacing with default GCCToolchain.
2021-07-30 11:04:15,261 - loopy.target.c.c_execution - WARNING - Default toolchain guessed from python config not found, replacing with default GCCToolchain.
2021-07-30 11:04:15,269 - loopy.target.c.c_execution - WARNING - Default toolchain guessed from python config not found, replacing with default GCCToolchain.
===========================================================================
failing kernel during pre-schedule check:
===========================================================================
---------------------------------------------------------------------------
KERNEL: dRopi_dT_ns
---------------------------------------------------------------------------
ARGUMENTS:
P_arr: type: np:dtype('float64'), shape: (1), dim_tags: (N0:stride:1) aspace: global
conc: type: np:dtype('float64'), shape: (1, 9), dim_tags: (N1:stride:9, N0:stride:1) aspace: global
jac: type: np:dtype('float64'), shape: (1, 100), dim_tags: (N1:stride:100, N0:stride:1) aspace: global
kf: type: np:dtype('float64'), shape: (1, 28), dim_tags: (N1:stride:28, N0:stride:1) aspace: global
kr: type: np:dtype('float64'), shape: (1, 28), dim_tags: (N1:stride:28, N0:stride:1) aspace: global
phi: type: np:dtype('float64'), shape: (1, 10), dim_tags: (N1:stride:10, N0:stride:1) aspace: global
pres_mod: type: np:dtype('float64'), shape: (1, 6), dim_tags: (N1:stride:6, N0:stride:1) aspace: global
---------------------------------------------------------------------------
DOMAINS:
{ [i] : i = 0 }
{ [j] : j = 0 }
  [offset, offset_next] -> { [net_ind] : offset <= net_ind < offset_next }
  [offset, offset_next] -> { [k_ind] : offset <= k_ind < offset_next }
---------------------------------------------------------------------------
INAME IMPLEMENTATION TAGS:
i: None
j: None
k_ind: None
net_ind: None
---------------------------------------------------------------------------
TEMPORARIES:
Sns_fwd: type: np:dtype('float64'), shape: () scope:private
Sns_rev: type: np:dtype('float64'), shape: () scope:private
ci: type: np:dtype('float64'), shape: () scope:private
dRopidT: type: np:dtype('float64'), shape: () scope:private
i_1: type: np:dtype('int32'), shape: () scope:private
i_2: type: np:dtype('int32'), shape: () scope:private
jac_index: type: np:dtype('int32'), shape: () scope:private
jac_row_ptr: type: np:dtype('int32'), shape: (11), dim_tags: (N0:stride:1) scope:global
kr_i: type: np:dtype('float64'), shape: () scope:private
net_reac_to_spec_offsets: type: np:dtype('int32'), shape: (29), dim_tags: (N0:stride:1) scope:global
net_spec: type: np:dtype('int32'), shape: () scope:private
nu_fwd: type: np:dtype('int32'), shape: () scope:private
nu_rev: type: np:dtype('int32'), shape: () scope:private
offset: type: np:dtype('int32'), shape: () scope:private
offset_next: type: np:dtype('int32'), shape: () scope:private
reac_to_spec_nu: type: np:dtype('int32'), shape: (190), dim_tags: (N0:stride:1) scope:global
rev_mask: type: np:dtype('int32'), shape: (28), dim_tags: (N0:stride:1) scope:global
rxn_to_spec: type: np:dtype('int32'), shape: (95), dim_tags: (N0:stride:1) scope:global
thd_mask: type: np:dtype('int32'), shape: (28), dim_tags: (N0:stride:1) scope:global
---------------------------------------------------------------------------
INSTRUCTIONS:
           for j, i
↱              i_1 = thd_mask[i + 8]  {id=index_i_1}
│↱             i_2 = rev_mask[i + 8]  {id=index_i_2}
││             offset = net_reac_to_spec_offsets[i + 8]  {id=insn}
││↱            offset_next = net_reac_to_spec_offsets[i + 8 + 1]  {id=insn_0}
│││↱           kr_i = 0  {id=kr_in}
││││           if rev_mask[i + 8] >= 0
│└│├↱            kr_i = kr[j, i_2]  {id=kr_up}
│ │││          end
│↱│││          ci = 1  {id=ci_init}
│││││          if thd_mask[i + 8] >= 0
└├│││↱           ci = pres_mod[j, i_1]  {id=ci}
 │││││         end
↱│├│││         Sns_fwd = reac_to_spec_nu[offset_next + offset_next + -2 + 1]  {id=Sns_fwd_init}
││└│││↱        Sns_rev = reac_to_spec_nu[offset_next + offset_next + -2]  {id=Sns_rev_init}
││ ││││        for net_ind
││↱││││          nu_fwd = reac_to_spec_nu[net_ind + net_ind + 1]  {id=nuf_inner}
│││││││↱         nu_rev = reac_to_spec_nu[net_ind + net_ind]  {id=nur_inner}
││││││││↱        net_spec = rxn_to_spec[net_ind]  {id=insn_1}
│││││││││        if net_spec == 8
││└│││││├↱         nu_fwd = nu_fwd + -1  {id=nuf_inner_up}
││ │││││││       end
├│↱│││││├└       Sns_fwd = Sns_fwd*fast_powi(fmax(1e-300, conc[j, net_spec]), nu_fwd)  {id=Sns_fwd_up}
│││││││││        if net_spec == 8
│││││││└├↱         nu_rev = nu_rev + -1  {id=nur_inner_up}
│││││││ ││       end
││││││├↱└└       Sns_rev = Sns_rev*fast_powi(fmax(1e-300, conc[j, net_spec]), nu_rev)  {id=Sns_rev_up}
││││││││       end net_ind
└└└└└└└└↱      dRopidT = (Sns_rev*kr_i + (-1)*Sns_fwd*kf[j, i + 8])*phi[j, 1]*ci*(P_arr[j] / (8314.4621*phi[j, 0]*phi[j, 0]))  {id=Ropi_final}
        │      for k_ind
        │        if rxn_to_spec[k_ind] != 8
↱       ├          jac_index = jac_row_ptr[rxn_to_spec[k_ind] + 2] + jac_indirect(jac_row_ptr[rxn_to_spec[k_ind] + 2], jac_row_ptr[rxn_to_spec[k_ind] + 2 + 1], 0)  {id=sparse_jac_index}
│       │        end
│       │        if rxn_to_spec[k_ind] != 8 and jac_index >= jac_row_ptr[rxn_to_spec[k_ind] + 2]
└       └          jac[j, jac_index] = jac[j, jac_index] + (reac_to_spec_nu[k_ind + k_ind] + (-1)*reac_to_spec_nu[k_ind + k_ind + 1])*dRopidT  {id=jac}
                 end
           end j, i, k_ind
---------------------------------------------------------------------------
===========================================================================
Traceback (most recent call last):
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/david/spyJac/pyjac/__main__.py", line 12, in <module>
    sys.exit(main())
  File "/home/david/spyJac/pyjac/__main__.py", line 8, in main
    utils.create()
  File "/home/david/spyJac/pyjac/utils.py", line 1064, in create
    create_jacobian(lang=args.lang,
  File "/home/david/spyJac/pyjac/core/create_jacobian.py", line 5508, in create_jacobian
    gen.generate(build_path, data_filename=data_filename,
  File "/home/david/spyJac/pyjac/kernel_utils/kernel_gen.py", line 1098, in generate
    callgen, record, result = self._generate_wrapping_kernel(path)
  File "/home/david/spyJac/pyjac/kernel_utils/kernel_gen.py", line 2569, in _generate_wrapping_kernel
    result = self._merge_kernels(record, result, kernels=kernels)
  File "/home/david/spyJac/pyjac/kernel_utils/kernel_gen.py", line 2253, in _merge_kernels
    cgr = lp.generate_code_v2(k)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/codegen/__init__.py", line 401, in generate_code_v2
    kernel = get_one_scheduled_kernel(kernel)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/schedule/__init__.py", line 2143, in get_one_scheduled_kernel
    return get_one_linearized_kernel(kernel)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/schedule/__init__.py", line 2164, in get_one_linearized_kernel
    result = _get_one_scheduled_kernel_inner(kernel)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/schedule/__init__.py", line 2134, in _get_one_scheduled_kernel_inner
    return next(iter(generate_loop_schedules(kernel)))
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/schedule/__init__.py", line 1945, in generate_loop_schedules
    yield from generate_loop_schedules_inner(kernel, debug_args=debug_args)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/schedule/__init__.py", line 1955, in generate_loop_schedules_inner
    pre_schedule_checks(kernel)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/check.py", line 819, in pre_schedule_checks
    check_bounds(kernel)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/check.py", line 486, in check_bounds
    insn.with_transformed_expressions(run_acm)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/kernel/instruction.py", line 877, in with_transformed_expressions
    expression=f(self.expression),
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/check.py", line 483, in run_acm
    acm(expr, domain_with_assumptions)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/pymbolic/mapper/__init__.py", line 129, in __call__
    return method(expr, *args, **kwargs)
  File "/home/david/anaconda3/envs/cantera-dev/lib/python3.9/site-packages/loopy-2020.2.1-py3.9.egg/loopy/check.py", line 442, in map_subscript
    raise LoopyError("'%s' in instruction '%s' "
loopy.diagnostic.LoopyError: 'reac_to_spec_nu[offset_next + offset_next + -2 + 1]' in instruction 'Sns_fwd_init' accesses out-of-bounds array element (could not establish '[offset_next, offset] -> { [-1 + 2offset_next] }' is a subset of '[offset_next, offset] -> { [i0] : 0 <= i0 <= 189 }').