Forráskód Böngészése

data interface: Operations on a data interface (i.e. struct
starpu_data_interface_ops) define a new function pointer
allocate_new_data which creates a new data interface of the given type
based on an existing handle (e.g for a vector, the number of elements
and the size of an element for the new data is set as in the given
data handle, and the pointer is set to NULL)

Nathalie Furmento 13 éve
szülő
commit
0eae3162bc

+ 3 - 0
include/starpu_data_interfaces.h

@@ -130,6 +130,9 @@ struct starpu_data_interface_ops
 	/* The size of the interface data descriptor */
 	size_t interface_size;
 
+	/* */
+	void (*allocate_new_data)(starpu_data_handle_t handle, void **data_interface);
+
 	int is_multiformat;
 	struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
 };

+ 19 - 2
src/datawizard/interfaces/block_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -77,6 +77,7 @@ static void display_block_interface(starpu_data_handle_t handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_block_to_gordon(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
+static void allocate_new_block(starpu_data_handle_t handle, void **data_interface);
 
 static struct starpu_data_interface_ops interface_block_ops =
 {
@@ -93,7 +94,8 @@ static struct starpu_data_interface_ops interface_block_ops =
 #endif
 	.interfaceid = STARPU_BLOCK_INTERFACE_ID,
 	.interface_size = sizeof(struct starpu_block_interface),
-	.display = display_block_interface
+	.display = display_block_interface,
+	.allocate_new_data = allocate_new_block
 };
 
 #ifdef STARPU_USE_GORDON
@@ -405,6 +407,21 @@ static void free_block_buffer_on_node(void *data_interface, uint32_t node)
 	}
 }
 
+static void allocate_new_block(starpu_data_handle_t handle, void **data_interface)
+{
+	struct starpu_block_interface *block_interface = (struct starpu_block_interface *)malloc(sizeof(struct starpu_block_interface));
+	block_interface->ptr = (uintptr_t) NULL;
+	block_interface->dev_handle = (uintptr_t) NULL;
+	block_interface->offset = 0;
+	block_interface->nx = starpu_block_get_nx(handle);
+	block_interface->ny = starpu_block_get_ny(handle);
+	block_interface->nz = starpu_block_get_nz(handle);
+	block_interface->ldy = starpu_block_get_local_ldy(handle);
+	block_interface->ldz = starpu_block_get_local_ldz(handle);
+	block_interface->elemsize = starpu_block_get_elemsize(handle);
+	*data_interface = block_interface;
+}
+
 #ifdef STARPU_USE_CUDA
 static int copy_cuda_common(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, enum cudaMemcpyKind kind)
 {

+ 16 - 2
src/datawizard/interfaces/csr_interface.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -70,6 +70,7 @@ static void free_csr_buffer_on_node(void *data_interface, uint32_t node);
 static size_t csr_interface_get_size(starpu_data_handle_t handle);
 static int csr_compare(void *data_interface_a, void *data_interface_b);
 static uint32_t footprint_csr_interface_crc32(starpu_data_handle_t handle);
+static void allocate_new_csr(starpu_data_handle_t handle, void **data_interface);
 
 static struct starpu_data_interface_ops interface_csr_ops =
 {
@@ -81,7 +82,8 @@ static struct starpu_data_interface_ops interface_csr_ops =
 	.interfaceid = STARPU_CSR_INTERFACE_ID,
 	.interface_size = sizeof(struct starpu_csr_interface),
 	.footprint = footprint_csr_interface_crc32,
-	.compare = csr_compare
+	.compare = csr_compare,
+	.allocate_new_data = allocate_new_csr
 };
 
 static void register_csr_handle(starpu_data_handle_t handle, uint32_t home_node, void *data_interface)
@@ -413,6 +415,18 @@ static void free_csr_buffer_on_node(void *data_interface, uint32_t node)
 	}
 }
 
+static void allocate_new_csr(starpu_data_handle_t handle, void **data_interface)
+{
+	struct starpu_csr_interface *csr_interface = (struct starpu_csr_interface *)malloc(sizeof(struct starpu_csr_interface));
+	csr_interface->nnz = starpu_csr_get_nnz(handle);
+	csr_interface->nrow = starpu_csr_get_nrow(handle);
+	csr_interface->nzval = starpu_csr_get_local_nzval(handle);
+	csr_interface->colind = starpu_csr_get_local_colind(handle);
+	csr_interface->rowptr = starpu_csr_get_local_rowptr(handle);
+	csr_interface->elemsize = starpu_csr_get_elemsize(handle);
+	*data_interface = csr_interface;
+}
+
 #ifdef STARPU_USE_CUDA
 static int copy_cuda_common(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, enum cudaMemcpyKind kind)
 {

+ 17 - 2
src/datawizard/interfaces/matrix_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -83,6 +83,7 @@ static void display_matrix_interface(starpu_data_handle_t handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_matrix_to_gordon(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
+static void allocate_new_matrix(starpu_data_handle_t handle, void **data_interface);
 
 struct starpu_data_interface_ops _starpu_interface_matrix_ops =
 {
@@ -99,7 +100,8 @@ struct starpu_data_interface_ops _starpu_interface_matrix_ops =
 #endif
 	.interfaceid = STARPU_MATRIX_INTERFACE_ID,
 	.interface_size = sizeof(struct starpu_matrix_interface),
-	.display = display_matrix_interface
+	.display = display_matrix_interface,
+	.allocate_new_data = allocate_new_matrix
 };
 
 #ifdef STARPU_USE_GORDON
@@ -383,6 +385,19 @@ static void free_matrix_buffer_on_node(void *data_interface, uint32_t node)
 	}
 }
 
+static void allocate_new_matrix(starpu_data_handle_t handle, void **data_interface)
+{
+	struct starpu_matrix_interface *matrix_interface = (struct starpu_matrix_interface *)malloc(sizeof(struct starpu_matrix_interface));
+	matrix_interface->ptr = (uintptr_t) NULL;
+	matrix_interface->dev_handle = (uintptr_t) NULL;
+	matrix_interface->offset = 0;
+	matrix_interface->nx = starpu_matrix_get_nx(handle);
+	matrix_interface->ny = starpu_matrix_get_ny(handle);
+	matrix_interface->ld = starpu_matrix_get_local_ld(handle);
+	matrix_interface->elemsize = starpu_matrix_get_elemsize(handle);
+	*data_interface = matrix_interface;
+}
+
 #ifdef STARPU_USE_CUDA
 static int copy_cuda_common(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED, void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, enum cudaMemcpyKind kind, int is_async, cudaStream_t stream)
 {

+ 12 - 2
src/datawizard/interfaces/variable_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -78,6 +78,7 @@ static void display_variable_interface(starpu_data_handle_t handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_variable_to_gordon(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
+static void allocate_new_variable(starpu_data_handle_t handle, void **data_interface);
 
 static struct starpu_data_interface_ops interface_variable_ops =
 {
@@ -94,7 +95,8 @@ static struct starpu_data_interface_ops interface_variable_ops =
 #endif
 	.interfaceid = STARPU_VARIABLE_INTERFACE_ID,
 	.interface_size = sizeof(struct starpu_variable_interface),
-	.display = display_variable_interface
+	.display = display_variable_interface,
+	.allocate_new_data = allocate_new_variable
 };
 
 static void *variable_handle_to_pointer(starpu_data_handle_t handle, uint32_t node)
@@ -285,6 +287,14 @@ static void free_variable_buffer_on_node(void *data_interface, uint32_t node)
 	}
 }
 
+static void allocate_new_variable(starpu_data_handle_t handle, void **data_interface)
+{
+	struct starpu_variable_interface *variable_interface = (struct starpu_variable_interface *)malloc(sizeof(struct starpu_variable_interface));
+	variable_interface->ptr = NULL;
+	variable_interface->elemsize = handle->ops->get_size(handle);
+	*data_interface = variable_interface;
+}
+
 #ifdef STARPU_USE_CUDA
 static int copy_cuda_common(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED,
 				void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, enum cudaMemcpyKind kind)

+ 15 - 2
src/datawizard/interfaces/vector_interface.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -78,6 +78,7 @@ static void display_vector_interface(starpu_data_handle_t handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_vector_to_gordon(void *data_interface, uint64_t *ptr, gordon_strideSize_t *ss);
 #endif
+static void allocate_new_vector(starpu_data_handle_t handle, void **data_interface);
 
 static struct starpu_data_interface_ops interface_vector_ops =
 {
@@ -94,7 +95,8 @@ static struct starpu_data_interface_ops interface_vector_ops =
 #endif
 	.interfaceid = STARPU_VECTOR_INTERFACE_ID,
 	.interface_size = sizeof(struct starpu_vector_interface),
-	.display = display_vector_interface
+	.display = display_vector_interface,
+	.allocate_new_data = allocate_new_vector
 };
 
 static void *vector_handle_to_pointer(starpu_data_handle_t handle, uint32_t node)
@@ -330,6 +332,17 @@ static void free_vector_buffer_on_node(void *data_interface, uint32_t node)
 	}
 }
 
+static void allocate_new_vector(starpu_data_handle_t handle, void **data_interface)
+{
+	struct starpu_vector_interface *vector_interface = (struct starpu_vector_interface *)malloc(sizeof(struct starpu_vector_interface));
+	vector_interface->ptr = (uintptr_t) NULL;
+	vector_interface->dev_handle = (uintptr_t) NULL;
+	vector_interface->offset = 0;
+	vector_interface->nx = starpu_vector_get_nx(handle);
+	vector_interface->elemsize = starpu_vector_get_elemsize(handle);
+	*data_interface = vector_interface;
+}
+
 #ifdef STARPU_USE_CUDA
 static int copy_cuda_common(void *src_interface, unsigned src_node STARPU_ATTRIBUTE_UNUSED,
 				void *dst_interface, unsigned dst_node STARPU_ATTRIBUTE_UNUSED, enum cudaMemcpyKind kind)