/* StarPU --- Runtime system for heterogeneous multicore architectures.
 *
 * Copyright (C) 2012  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.
 */


#ifndef __SOURCE_COMMON_H__
#define __SOURCE_COMMON_H__


#ifdef STARPU_USE_MP

#include <drivers/mp_common/mp_common.h>

int _starpu_src_common_sink_nbcores (const struct _starpu_mp_node *node, int *buf);

int _starpu_src_common_lookup(const struct _starpu_mp_node *node,
			      void (**func_ptr)(void), const char *func_name);

int _starpu_src_common_execute_kernel(const struct _starpu_mp_node *node,
				      void (*kernel)(void), unsigned coreid,
				      starpu_data_handle_t *handles, void **interfaces, unsigned nb_interfaces,
				      void *cl_arg, size_t cl_arg_size);

int _starpu_src_common_execute_kernel_from_task(const struct _starpu_mp_node *node,
						void (*kernel)(void), unsigned coreid,
						struct starpu_task *task);

int _starpu_src_common_allocate(const struct _starpu_mp_node *mp_node,
				void **addr, size_t size);

void _starpu_src_common_free(const struct _starpu_mp_node *mp_node,
			     void *addr);

int _starpu_src_common_copy_host_to_sink(const struct _starpu_mp_node *mp_node,
					 void *src, void *dst, size_t size);

int _starpu_src_common_copy_sink_to_host(const struct _starpu_mp_node *mp_node,
					 void *src, void *dst, size_t size);

int _starpu_src_common_copy_sink_to_sink(const struct _starpu_mp_node *src_node,
					 const struct _starpu_mp_node *dst_node, void *src, void *dst, size_t size);

int _starpu_src_common_locate_file(char *located_file_name,
				   const char *env_file_name, const char *env_mic_path,
				   const char *config_file_name, const char *actual_file_name,
				   const char **suffixes);

#endif /* STARPU_USE_MP */


#endif /* __SOURCE_COMMON_H__ */
