소스 검색

Add a get_mf_ops function to the interfaces, so that they can return the multiformat-releated helpers.

This should make it easier for users to define multiformat interfaces other than the standard multiformat interface that is part of StarPU.
Cyril Roelandt 13 년 전
부모
커밋
26837d338b
4개의 변경된 파일21개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 0
      include/starpu_data_interfaces.h
  2. 6 4
      src/core/sched_policy.c
  3. 4 2
      src/datawizard/interfaces/data_interface.c
  4. 10 0
      src/datawizard/interfaces/multiformat_interface.c

+ 1 - 0
include/starpu_data_interfaces.h

@@ -131,6 +131,7 @@ struct starpu_data_interface_ops
 	size_t interface_size;
 
 	int is_multiformat;
+	struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
 };
 
 void starpu_data_register(starpu_data_handle_t *handleptr, uint32_t home_node,

+ 6 - 4
src/core/sched_policy.c

@@ -356,6 +356,8 @@ struct starpu_task *_starpu_create_conversion_task(starpu_data_handle_t handle,
 	handle->refcnt++;
 	handle->busy_count++;
 
+	struct starpu_multiformat_data_interface_ops *mf_ops;
+	mf_ops = (struct starpu_multiformat_data_interface_ops *) handle->ops->get_mf_ops(format_interface);
 	switch(node_kind)
 	{
 	case STARPU_CPU_RAM:
@@ -365,12 +367,12 @@ struct starpu_task *_starpu_create_conversion_task(starpu_data_handle_t handle,
 			STARPU_ASSERT(0);
 #ifdef STARPU_USE_CUDA
 		case STARPU_CUDA_RAM:
-			conversion_task->cl = format_interface->ops->cuda_to_cpu_cl;
+			conversion_task->cl = mf_ops->cuda_to_cpu_cl;
 			break;
 #endif
 #ifdef STARPU_USE_OPENCL
 		case STARPU_OPENCL_RAM:
-			conversion_task->cl = format_interface->ops->opencl_to_cpu_cl;
+			conversion_task->cl = mf_ops->opencl_to_cpu_cl;
 			break;
 #endif
 		default:
@@ -380,12 +382,12 @@ struct starpu_task *_starpu_create_conversion_task(starpu_data_handle_t handle,
 		break;
 #ifdef STARPU_USE_CUDA
 	case STARPU_CUDA_RAM:
-		conversion_task->cl = format_interface->ops->cpu_to_cuda_cl;
+		conversion_task->cl = mf_ops->cpu_to_cuda_cl;
 		break;
 #endif
 #ifdef STARPU_USE_OPENCL
 	case STARPU_OPENCL_RAM:
-		conversion_task->cl = format_interface->ops->cpu_to_opencl_cl;
+		conversion_task->cl = mf_ops->cpu_to_opencl_cl;
 		break;
 #endif
 	case STARPU_SPU_LS: /* Not supported */

+ 4 - 2
src/datawizard/interfaces/data_interface.c

@@ -469,16 +469,18 @@ static void _starpu_data_unregister(starpu_data_handle_t handle, unsigned cohere
 			struct starpu_codelet *cl;
 			enum starpu_node_kind node_kind = starpu_node_get_kind(handle->mf_node);
 
+			struct starpu_multiformat_data_interface_ops *mf_ops;
+			mf_ops = (struct starpu_multiformat_data_interface_ops *) handle->ops->get_mf_ops(format_interface);
 			switch (node_kind)
 			{
 #ifdef STARPU_USE_CUDA
 				case STARPU_CUDA_RAM:
-					cl = format_interface->ops->cuda_to_cpu_cl;
+					cl = mf_ops->cuda_to_cpu_cl;
 					break;
 #endif
 #ifdef STARPU_USE_OPENCL
 				case STARPU_OPENCL_RAM:
-					cl = format_interface->ops->opencl_to_cpu_cl;
+					cl = mf_ops->opencl_to_cpu_cl;
 					break;
 #endif
 				case STARPU_CPU_RAM:      /* Impossible ! */

+ 10 - 0
src/datawizard/interfaces/multiformat_interface.c

@@ -79,6 +79,15 @@ static uint32_t starpu_multiformat_get_nx(starpu_data_handle_t handle);
 static int convert_multiformat_to_gordon(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
 
+static struct starpu_multiformat_data_interface_ops*
+get_mf_ops(void *data_interface)
+{
+	struct starpu_multiformat_interface *mf;
+	mf = (struct starpu_multiformat_interface *) data_interface;
+
+	return mf->ops;
+}
+
 static struct starpu_data_interface_ops interface_multiformat_ops =
 {
 	.register_data_handle  = register_multiformat_handle,
@@ -96,6 +105,7 @@ static struct starpu_data_interface_ops interface_multiformat_ops =
 	.interface_size        = sizeof(struct starpu_multiformat_interface),
 	.display               = display_multiformat_interface,
 	.is_multiformat        = 1,
+	.get_mf_ops            = get_mf_ops
 };
 
 static void *multiformat_handle_to_pointer(starpu_data_handle_t handle, uint32_t node)