devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation
http://www.devitoproject.org
MIT License
536 stars 221 forks source link

aarch64 : CompileError #2293

Open gfkdliucheng opened 5 months ago

gfkdliucheng commented 5 months ago

from devito import * import matplotlib.pyplot as plt

def solver(I, dt, T, eqs):


```Nt = int(round(T/dt))
```t = TimeDimension('t', spacing=Constant('h_t'))
```u = TimeFunction(name='u', dimensions=(t,),
                     shape=(Nt+1,), space_order=2, time_order=1)
```u.data[:] = I
```eqn = eval(eqs)
```stencil = Eq(u.forward, solve(eqn, u.forward))
```print(stencil)
```op = Operator(stencil)
```op.apply(h_t=dt, t_M=Nt-1)
```return u.data, np.linspace(0.0001, Nt*dt, Nt+1),op.ccode

u,t,ccode = solver(1, 0.001,2, r'u.dt-u ') 

print(u[-1])

CompileError :
undefined reference to `main'
---------------------------------------------------------------------------
CompileError                              Traceback (most recent call last)
Cell In[11], line 18
     15     op.apply(h_t=dt, t_M=Nt-1)
     16     return u.data, np.linspace(0.0001, Nt*dt, Nt+1),op.ccode
---> 18 u,t,ccode = solver(1, 0.001,2, r'u.dt-u ') # a=0.01
     20 print(u[-1])

Cell In[11], line 15, in solver(I, dt, T, eqs)
     13 print(stencil)
     14 op = Operator(stencil)
---> 15 op.apply(h_t=dt, t_M=Nt-1)
     16 return u.data, np.linspace(0.0001, Nt*dt, Nt+1),op.ccode

File ~/miniconda3/lib/python3.11/site-packages/devito/operator/operator.py:832, in Operator.apply(self, **kwargs)
    830 arg_values = [args[p.name] for p in self.parameters]
    831 try:
--> 832     cfunction = self.cfunction
    833     with self._profiler.timer_on('apply', comm=args.comm):
    834         cfunction(*arg_values)

File ~/miniconda3/lib/python3.11/site-packages/devito/operator/operator.py:714, in Operator.cfunction(self)
    712 """The JIT-compiled C function as a ctypes.FuncPtr object."""
    713 if self._lib is None:
--> 714     self._jit_compile()
    715     self._lib = self._compiler.load(self._soname)
    716     self._lib.name = self._soname

File ~/miniconda3/lib/python3.11/site-packages/devito/operator/operator.py:699, in Operator._jit_compile(self)
    697 if self._lib is None:
    698     with self._profiler.timer_on('jit-compile'):
--> 699         recompiled, src_file = self._compiler.jit_compile(self._soname,
    700                                                           str(self.ccode))
    702     elapsed = self._profiler.py_timers['jit-compile']
    703     if recompiled:

File ~/miniconda3/lib/python3.11/site-packages/devito/arch/compiler.py:360, in Compiler.jit_compile(self, soname, code)
    358 with warnings.catch_warnings():
    359     warnings.simplefilter('ignore')
--> 360     _, _, _, recompiled = compile_from_string(self, target, code, src_file,
    361                                               cache_dir=cache_dir, debug=debug,
    362                                               sleep_delay=sleep_delay)
    364 return recompiled, src_file

File ~/miniconda3/lib/python3.11/site-packages/codepy/jit.py:439, in compile_from_string(toolchain, name, source_string, source_name, cache_dir, debug, wait_on_error, debug_recompile, object, source_is_binary, sleep_delay)
    437     toolchain.build_object(ext_file, source_paths, debug=debug)
    438 else:
--> 439     toolchain.build_extension(ext_file, source_paths, debug=debug)
    441 if info_path is not None:
    442     import pickle

File ~/miniconda3/lib/python3.11/site-packages/codepy/toolchain.py:211, in GCCLikeToolchain.build_extension(self, ext_file, source_files, debug)
    208 import sys
    209 print("FAILED compiler invocation: {}".format(" ".join(cc_cmdline)),
    210       file=sys.stderr)
--> 211 raise CompileError("module compilation failed")

CompileError: module compilation failed
mloubout commented 5 months ago

What's the actual compilaton error? And what's your configuration (DEVITO_ARCH, DEVITO_PLATFORM, DEVITO_LANGUAGE)

gfkdliucheng commented 5 months ago

What's the actual compilaton error? And what's your configuration (DEVITO_ARCH, DEVITO_PLATFORM, DEVITO_LANGUAGE) below is the error output: /root/miniconda3/bin/../lib/gcc/aarch64-conda-linux-gnu/9.5.0/../../../../aarch64-conda-linux-gnu/bin/ld: /root/miniconda3/bin/../aarch64-conda-linux-gnu/sysroot/usr/lib/../lib/Scrt1.o: in function _start': (.text+0x18): undefined reference tomain' /root/miniconda3/bin/../lib/gcc/aarch64-conda-linux-gnu/9.5.0/../../../../aarch64-conda-linux-gnu/bin/ld: (.text+0x1c): undefined reference to `main' collect2: error: ld returned 1 exit status FAILED compiler invocation: /root/miniconda3/bin/aarch64-conda-linux-gnu-cc -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -isystem /root/miniconda3/include -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--allow-shlib-undefined -Wl,-rpath,/root/miniconda3/lib -Wl,-rpath-link,/root/miniconda3/lib -L/root/miniconda3/lib /tmp/devito-jitcache-uid0/d3ed1cb2f1d051147a527d2966d0424b0a74de1f.c -lm -o /tmp/devito-jitcache-uid0/d3ed1cb2f1d051147a527d2966d0424b0a74de1f.so PLATFORM: ubuntu 22.04 (aarch64) refer to the info "When using OpenMP offloading, it is recommended to stick to the corresponding vendor compiler, so ARCH=amdclang for AMD, ARCH={icc,icx,intel} for Intel, and ARCH=nvc for NVidia." devito maybe doesn't support linux arm arch.

mloubout commented 5 months ago

It looks like you have a lot of flags set in your system (i.e Wl,-O2 -Wl,--sort-common -Wl,--as-needed ...)

The only case devito would use those if you don't set any configuration. I would recommend following:

https://github.com/devitocodes/devito/blob/master/FAQ.md#what-are-the-accepted-combinations-of-platform-arch-and-language

to set the devito configuration to something that matches your system,

georgebisbas commented 1 month ago

@gfkdliucheng any updates on that issue?

gfkdliucheng commented 1 month ago

no