devito icon indicating copy to clipboard operation
devito copied to clipboard

module compilation failed

Open AMzaheri opened this issue 1 year ago • 1 comments

Hello,

I have encountered a compilation error when running a simple example on a Macbook. The error is :

clang: error: the clang compiler does not support '-march=native' FAILED compiler invocation:gcc -O3 -g -fPIC -Wall -std=c99 -march=native -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -ffast-math -shared /var/folders/6r/g59xwcqd73nft3q3n_00hrqr0000gq/T/devito-jitcache-uid503/8b237ac1f1a4370f307afea8531adbdba661d48e.c -lm -o /var/folders/6r/g59xwcqd73nft3q3n_00hrqr0000gq/T/devito-jitcache-uid503/8b237ac1f1a4370f307afea8531adbdba661d48e.dylib

CompileError Traceback (most recent call last) Cell In [11], line 1 ----> 1 model = Model(vp=Vp, origin=(0.,0.), shape=shape, spacing=spacing, 2 space_order=2, nbl=nbl, bcs="damp") 4 # Create initial model and smooth the boundaries 5 model0 = copy.deepcopy(model)

File ~/local/devito/examples/seismic/model.py:272, in SeismicModel.init(self, origin, spacing, shape, space_order, vp, nbl, fs, dtype, subdomains, bcs, grid, **kwargs) 270 def init(self, origin, spacing, shape, space_order, vp, nbl=20, fs=False, 271 dtype=np.float32, subdomains=(), bcs="mask", grid=None, **kwargs): --> 272 super(SeismicModel, self).init(origin, spacing, shape, space_order, nbl, 273 dtype, subdomains, grid=grid, bcs=bcs, fs=fs) 275 # Initialize physics 276 self._initialize_physics(vp, space_order, **kwargs)

File ~/local/devito/examples/seismic/model.py:125, in GenericModel.init(self, origin, spacing, shape, space_order, nbl, dtype, subdomains, bcs, grid, fs) 123 self._physical_parameters = set() 124 self.damp = None --> 125 self._initialize_bcs(bcs=bcs)

File ~/local/devito/examples/seismic/model.py:148, in GenericModel._initialize_bcs(self, bcs) 145 warning("Re-initializing damp profile from %s to %s" % (bcs_o, bcs)) 146 warning("Model has to be created with bcs=\"%s\"" 147 "for this WaveSolver" % bcs) --> 148 initialize_damp(self.damp, self.padsizes, self.spacing, 149 abc_type=bcs, fs=self.fs) 150 self._physical_parameters.update(['damp'])

File ~/local/devito/examples/seismic/model.py:52, in initialize_damp(damp, padsizes, spacing, abc_type, fs) 49 val = -val if abc_type == "mask" else val 50 eqs += [Inc(damp.subs({d: dim_r}), val/d.spacing)] ---> 52 Operator(eqs, name='initdamp')()

File ~/local/devito/devito/operator/operator.py:703, in Operator.call(self, **kwargs) 702 def call(self, **kwargs): --> 703 return self.apply(**kwargs)

File ~/local/devito/devito/operator/operator.py:774, in Operator.apply(self, **kwargs) 772 arg_values = [args[p.name] for p in self.parameters] 773 try: --> 774 cfunction = self.cfunction 775 with self._profiler.timer_on('apply', comm=args.comm): 776 cfunction(*arg_values)

File ~/local/devito/devito/operator/operator.py:656, in Operator.cfunction(self) 654 """The JIT-compiled C function as a ctypes.FuncPtr object.""" 655 if self._lib is None: --> 656 self._jit_compile() 657 self._lib = self._compiler.load(self._soname) 658 self._lib.name = self._soname

File ~/local/devito/devito/operator/operator.py:641, in Operator._jit_compile(self) 639 if self._lib is None: 640 with self._profiler.timer_on('jit-compile'): --> 641 recompiled, src_file = self._compiler.jit_compile(self._soname, 642 str(self.ccode)) 644 elapsed = self._profiler.py_timers['jit-compile'] 645 if recompiled:

File ~/local/devito/devito/arch/compiler.py:320, in Compiler.jit_compile(self, soname, code) 318 with warnings.catch_warnings(): 319 warnings.simplefilter('ignore') --> 320 _, _, _, recompiled = compile_from_string(self, target, code, src_file, 321 cache_dir=cache_dir, debug=debug, 322 sleep_delay=sleep_delay) 324 return recompiled, src_file

File ~/anaconda3/envs/devito/lib/python3.10/site-packages/codepy/jit.py:433, in compile_from_string(toolchain, name, source_string, source_name, cache_dir, debug, wait_on_error, debug_recompile, object, source_is_binary, sleep_delay) 431 toolchain.build_object(ext_file, source_paths, debug=debug) 432 else: --> 433 toolchain.build_extension(ext_file, source_paths, debug=debug) 435 if info_path is not None: 436 from six.moves.cPickle import dump

File ~/anaconda3/envs/devito/lib/python3.10/site-packages/codepy/toolchain.py:210, in GCCLikeToolchain.build_extension(self, ext_file, source_files, debug) 207 import sys 208 print("FAILED compiler invocation:" + " ".join(cc_cmdline), 209 file=sys.stderr) --> 210 raise CompileError("module compilation failed")

CompileError: module compilation failed

Python version: 3.10.4 MacOS Monterey: version 12.6

Regards,

AMzaheri avatar Sep 16 '22 12:09 AMzaheri

It looks like you have devito configured for gcc (gnu) but that your gcc links to clang instead.

You will need to either configure devito with clang (DEVITO_ARCH=osx) or install a proper gcc compiler. You can for example install it with brew brew install gcc.

mloubout avatar Sep 16 '22 13:09 mloubout