123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- # StarPU --- Runtime system for heterogeneous multicore architectures.
- #
- # Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
- #
- # StarPU is free software; you can redistribute it and/or modify
- # it under the terms of the GNU Lesser General Public License as published by
- # the Free Software Foundation; either version 2.1 of the License, or (at
- # your option) any later version.
- #
- # StarPU is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- #
- # See the GNU Lesser General Public License in COPYING.LGPL for more details.
- #
- using StarPU
- @target STARPU_CPU
- @codelet function variable(val ::Ref{Int32}) :: Nothing
- val[] = val[] + 1
- return
- end
- starpu_init()
- function callback(args)
- cl = args[1]
- handles = args[2]
- task = starpu_task(cl = cl, handles=handles)
- starpu_task_submit(task)
- end
- function variable_with_starpu(val ::Ref{Int32})
- perfmodel = starpu_perfmodel(
- perf_type = starpu_perfmodel_type(STARPU_HISTORY_BASED),
- symbol = "history_perf"
- )
- cl = starpu_codelet(
- cpu_func = CPU_CODELETS["variable"],
- # cuda_func = CUDA_CODELETS["matrix_mult"],
- #opencl_func="ocl_matrix_mult",
- modes = [STARPU_RW],
- perfmodel = perfmodel
- )
- @starpu_block let
- hVal = starpu_data_register(val)
- task = starpu_task(cl = cl, handles = [hVal], callback=callback, callback_arg=(cl, [hVal]))
- starpu_task_submit(task)
- starpu_task_wait_for_all()
- end
- end
- function display()
- v = Ref(Int32(40))
- variable_with_starpu(v)
- println("variable -> ", v[])
- if v[] == 42
- println("result is correct")
- else
- println("result is incorret")
- end
- end
- display()
- starpu_shutdown()
|