diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 0000000..67c9c00 --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,29 @@ +# -----nbody------ # + +nbody_files = files('nbody.f90') +nbody_kernel_files = files('nbody.cl') + +nbody_obj = custom_target('nbody_kernel', + input: nbody_kernel_files, + output: 'nbody.cl.o', + command: [python_exe, script, '@INPUT@', '@OUTPUT@']) + +# -platform query- # + +platform_query_files = files('platform_query.f90') +platform_query_kernel_files = files('platform_query.cl') + +platform_query_obj = custom_target('platform_query_kernel', + input: platform_query_kernel_files, + output: 'platform_query.cl.o', + command: [python_exe, script, '@INPUT@', '@OUTPUT@']) + +# ------sum------- # + +sum_files = files('sum.f90') +sum_kernel_files = files('sum.cl') + +sum_obj = custom_target('sum_kernel', + input: sum_kernel_files, + output: 'sum.cl.o', + command: [python_exe, script, '@INPUT@', '@OUTPUT@']) diff --git a/external/meson.build b/external/meson.build new file mode 100644 index 0000000..9bde7ef --- /dev/null +++ b/external/meson.build @@ -0,0 +1,5 @@ +externalSources = files( + 'clfortran/clfortran.f90', + 'fortran-utils/futils_sorting.f90', + 'M_strings/M_strings.f90' + ) diff --git a/getCLBinary.py b/getCLBinary.py new file mode 100644 index 0000000..f089871 --- /dev/null +++ b/getCLBinary.py @@ -0,0 +1,17 @@ +import sys +import shutil +import os +import random + +inputFile = sys.argv[1] +aux = 'fclKernels.cl' +outputFile = sys.argv[2] + +actualFolder = os.getcwd() +folder = '/tmp/' + str(random.randint(1,1e15)) +os.system(f'mkdir {folder}') +shutil.copyfile(inputFile,folder + '/' + aux) +os.chdir(folder) +os.system(f'ld -r -b binary {aux} -o {actualFolder}/{outputFile}') +os.chdir(actualFolder) +os.system(f'rm -rf {folder}') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..055a4ef --- /dev/null +++ b/meson.build @@ -0,0 +1,39 @@ +project('Focal','fortran') + +subdir('external') +subdir('src') +opencl_dep = dependency('OpenCL') + +# ---NonDebug Library--- # +focalNonDebugFileList = sources + nonDebugFile + externalSources +libFocal = static_library('Focal', focalNonDebugFileList, + fortran_args: ['-std=f2008', '-fimplicit-none'] +) + +libFocal_dep = declare_dependency(link_with: libFocal, + dependencies: opencl_dep) + +# ----Debug Library---- # +focalDebugFileList = sources + debugFile + externalSources +libFocalDbg = static_library('FocalDbg', focalDebugFileList, + fortran_args: ['-std=f2008', '-fimplicit-none'] +) + +libFocalDbg_dep = declare_dependency(link_with: libFocalDbg, + dependencies: opencl_dep) + +# ------Examples------ # +python_exe = find_program('python') +script = join_paths(meson.source_root(),'getCLBinary.py') +subdir('examples') + +executable('nbody',[nbody_files,nbody_obj], + dependencies: libFocal_dep) +executable('sum',[sum_files,sum_obj], + dependencies: libFocal_dep) +executable('platform_query',[platform_query_files,platform_query_obj], + dependencies: libFocal_dep) + +# -------Tests-------# +subdir('test') + diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..dd4aa39 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,13 @@ +sources = files( + 'Focal_Error.f90', + 'Focal.f90', + 'Focal_HostMemory.f90', + 'Focal_Memory.f90', + 'Focal_Profile.f90', + 'Focal_Query.f90', + 'Focal_Setup.f90', + 'Focal_Utils.f90', + ) + +debugFile = files('Focal_NoDebug.f90') +nonDebugFile = files('Focal_Debug.f90') diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..b4e032c --- /dev/null +++ b/test/meson.build @@ -0,0 +1,26 @@ +progs = [ + #['testExample',['testExample.cl', 'testExample.f90']], + ['testEvents',['testEvents.cl', 'testEvents.f90']], + ['testFileSource',['testFileSource.cl', 'testFileSource.f90']], + ['testKernelSetup',['testKernelSetup.cl', 'testKernelSetup.f90']], + ['testLocalMem',['testLocalMem.cl', 'testLocalMem.f90']], + ['testMemoryTransfer',['testMemoryTransfer.cl', 'testMemoryTransfer.f90']], + ['testPinnedMemory',['testPinnedMemory.cl', 'testPinnedMemory.f90']], + ['testProfiling',['testProfiling.cl', 'testProfiling.f90']], + ['testQueuePool',['testQueuePool.cl', 'testQueuePool.f90']], + ['testSubBuffers',['testSubBuffers.cl', 'testSubBuffers.f90']] + ] + +moduleFocal_Test_Utils = files('Focal_Test_Utils.f90') + +foreach p : progs + openCL_obj = custom_target(p[0] + '_kernel', + input: p[1][0], + output: p[1][0] + '.o', + command: [python_exe, script, '@INPUT@', '@OUTPUT@']) + + exe = executable(p[0],[openCL_obj, p[1][1], moduleFocal_Test_Utils], + dependencies: libFocal_dep) + + test(p[0], exe) +endforeach