Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

calc pi example fails #31

@petacube

Description

@petacube

#calc_pi.py
import hpat
import numpy as np
import time

@hpat.jit
def calc_pi(n):

t1 = time.time()
x = 2 * np.random.ranf(n) - 1
y = 2 * np.random.ranf(n) - 1
pi = 4 * np.sum(x**2 + y**2 < 1) / n
print("Execution time:", time.time()-t1, "\nresult:", pi)
return pi

calc_pi(2 * 10**8)

python calc_pi.py
Traceback (most recent call last):
File "calc_pi.py", line 15, in
calc_pi(2 * 10**8)
File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 360, in _compile_for_args
raise e
File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 311, in _compile_for_args
return self.compile(tuple(argtypes))
File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 618, in compile
cres = self._compiler.compile(args, return_type)
File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 83, in compile
pipeline_class=self.pipeline_class)
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 871, in compile_extra
return pipeline.compile_extra(func)
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 365, in compile_extra
return self._compile_bytecode()
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 802, in _compile_bytecode
return self._compile_core()
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 789, in _compile_core
res = pm.run(self.status)
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 251, in run
raise patched_exception
File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 243, in run
stage()
File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/compiler.py", line 209, in stage_distributed_pass
dist_pass.run()
File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 92, in run
self.func_ir.blocks = self._run_dist_pass(self.func_ir.blocks)
File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 225, in _run_dist_pass
new_body += self._gen_barrier()
File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 1954, in _gen_barrier
self.typemap, self.calltypes).blocks
File "/anaconda3/lib/python3.5/site-packages/numba/ir_utils.py", line 1445, in compile_to_numba_ir
f_ir = get_ir_of_code(glbls, code)
File "/anaconda3/lib/python3.5/site-packages/numba/ir_utils.py", line 1490, in get_ir_of_code
if co_varnames[0] == ".0":
IndexError: Failed at hpat (convert to distributed)
list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions