Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -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@'])
5 changes: 5 additions & 0 deletions external/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
externalSources = files(
'clfortran/clfortran.f90',
'fortran-utils/futils_sorting.f90',
'M_strings/M_strings.f90'
)
17 changes: 17 additions & 0 deletions getCLBinary.py
Original file line number Diff line number Diff line change
@@ -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}')
49 changes: 49 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
project(
'Focal',
'fortran',
version: '1.0.1',
license: 'MIT License',
)

subdir('external')
subdir('src')

opencl_dep = dependency('OpenCL', required: false)
pkg = import('pkgconfig')

# ---NonDebug Library--- #
focalNonDebugFileList = sources + nonDebugFile + externalSources
libFocal = static_library('Focal', focalNonDebugFileList,
fortran_args: ['-std=f2008', '-fimplicit-none'],
install: true
)

pkg.generate(libFocal)

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')

13 changes: 13 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -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')
26 changes: 26 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -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