cctbx / cctbx_project

Computational Crystallography Toolbox
https://cci.lbl.gov/docs/cctbx
Other
218 stars 116 forks source link

undefined symbol error #868

Closed Trzs closed 1 year ago

Trzs commented 1 year ago

A basic simtbx.kokkos script aborts with an undefined symbol error:

fwittwer@perlmutter$ cat test_script.py
from simtbx import get_exascale

def main():
    gpu_instance_type = get_exascale("gpu_instance", context='kokkos_gpu')
    gpu_instance = gpu_instance_type(deviceId = 0)

if __name__=="__main__":
    main()
    print("OK")

fwittwer@perlmutter$ libtbx.ipython test_script.py
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File /pscratch/sd/f/fwittwer/workbench/alcc-recipes/cctbx/modules/cctbx_project/boost_adaptbx/boost/python.py:22, in import_ext(name, optional)
     21   sys.setdlopenflags(0x100|0x2)
---> 22 try: mod = __import__(name)
     23 except ImportError as e:

ImportError: /pscratch/sd/f/fwittwer/workbench/alcc-recipes/cctbx/build/lib/libsimtbx_kokkos.so: undefined symbol: _ZNK6simtbx9nanoBragg9nanoBragg9add_noiseEN6scitbx2af5versaIdNS3_9flex_gridINS3_5smallIlLm10EEEEEEE
[...]

However, unit tests run without a problem.

Trzs commented 1 year ago

By simply adding an import from nanoBragg to the script, all runs correctly:

fwittwer@perlmutter$ cat test_script2.py
from simtbx import get_exascale
from simtbx.nanoBragg.tst_gauss_argchk import water

def main():
    gpu_instance_type = get_exascale("gpu_instance", context='kokkos_gpu')
    gpu_instance = gpu_instance_type(deviceId = 0)

if __name__=="__main__":
    main()
    print("OK")

fwittwer@perlmutter$ libtbx.ipython test_script2.py
OK
Trzs commented 1 year ago

The missing add_noise function is currently defined in nanoBragg_nks.cpp and build into simtbx_nanoBragg_ext.so. Possible solutions:

nksauter commented 1 year ago

How about including "from simtbx import nanoBragg" in the file simtbx/init.py

This might be the most transparent way to accomplish the required library import.