Good afternoon!
I would like to use OpenCL from Fortran host program using Focal.
I succeeded, using the following lines in Makefile,
. . .
FFLAGS += -I/path_to_focal/focal/mod
OCL_LIB_FLAGS = -L/path_to_focal/focal/lib
FFLAGS += -I/usr/local/cuda/include
OCL_LIB_FLAGS += -L/usr/local/cuda/lib64
. . .
$(FC) $(FFLAGS) -o $@ $(addprefix $(OBJDIR)/,$(OBJECTS)) -lstdc++ $(OCL_LIB_FLAGS) -lFocal -lOpenCL
and writing the needed program code. It worked perfectly for long time.
Now my colleagues decided to use CMake to produce the Makefile, and I don't know how to include Focal using CMake (my procedures are a part of the larger program written by my colleagues).
I tried
link_directories(/path_to_focal/focal/lib)
. . .
add_executable(OurTarget main.f)
. . .
find_package(CUDAToolkit)
set(Focal_INCLUDE_DIR "/path_to_focal/focal/mod")
target_include_directories(OurTarget PUBLIC ${Focal_INCLUDE_DIR})
. . .
target_link_libraries(OurTarget MAIN SOMETHING_OTHER Focal OpenCL)
CMake produced the Makefile, but I obtain the following errors during compilation:
/OurProjectPath/CLSetup.f:3:10:
3 | USE CLFortran
| 1
Fatal Error: Cannot open module file ‘clfortran.mod’ for reading at (1): No such file or directory
compilation terminated
/OurProjectPath/CLSetup.f:4:10:
4 | USE Focal
| 1
Fatal Error: Cannot open module file ‘focal.mod’ for reading at (1): No such file or directory
compilation terminated.
(there are two lines,
USE CLFortran
USE Focal
in CLSetup.f)
I also tried
add_compile_options(-I/path_to_focal/focal/mod/)
with the same result.
This is an additional information on Focal:
> ls /path_to_focal/focal/mod
clfortran.mod focal@focal_memory.smod focal@focal_setup.smod futils_sorting.mod
focal@focal_debug.smod focal@focal_nodebug.smod focal@focal_utils.smod m_strings.mod
focal@focal_error.smod focal@focal_profile.smod focal.mod
focal@focal_hostmemory.smod focal@focal_query.smod focal.smod
> ls /path_to_focal/focal/lib
libFocal.a libFocaldbg.a
I understand, that the obtained errors are because the folder /path_to_focal/focal/mod is not accepted by CMake. But I don't know how to fix this. And I'm not sure about correct inclusion of the libraries.
If someone can help me, please, do this.
Regards, Natalia