Browse Source

Provide a method to compare whether two interfaces are "compatible" (ie. it is
possible to use some data previously allocated for an interface for another
interface).

Cédric Augonnet 15 years ago
parent
commit
5c2343f691

+ 18 - 2
src/datawizard/interfaces/bcsr_interface.c

@@ -1,6 +1,6 @@
 /*
  * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -63,8 +63,10 @@ static void register_bcsr_handle(starpu_data_handle handle, uint32_t home_node,
 static size_t allocate_bcsr_buffer_on_node(void *interface, uint32_t dst_node);
 static void free_bcsr_buffer_on_node(void *interface, uint32_t node);
 static size_t bcsr_interface_get_size(starpu_data_handle handle);
+static int bcsr_compare(void *interface_a, void *interface_b);
 static uint32_t footprint_bcsr_interface_crc32(starpu_data_handle handle);
 
+
 static struct starpu_data_interface_ops_t interface_bcsr_ops = {
 	.register_data_handle = register_bcsr_handle,
 	.allocate_data_on_node = allocate_bcsr_buffer_on_node,
@@ -73,7 +75,8 @@ static struct starpu_data_interface_ops_t interface_bcsr_ops = {
 	.get_size = bcsr_interface_get_size,
 	.interfaceid = STARPU_BCSCR_INTERFACE_ID,
 	.interface_size = sizeof(starpu_bcsr_interface_t),
-	.footprint = footprint_bcsr_interface_crc32
+	.footprint = footprint_bcsr_interface_crc32,
+	.compare = bcsr_compare
 };
 
 static void register_bcsr_handle(starpu_data_handle handle, uint32_t home_node, void *interface)
@@ -137,6 +140,19 @@ static uint32_t footprint_bcsr_interface_crc32(starpu_data_handle handle)
 	return hash;
 }
 
+static int bcsr_compare(void *interface_a, void *interface_b)
+{
+	starpu_bcsr_interface_t *bcsr_a = interface_a;
+	starpu_bcsr_interface_t *bcsr_b = interface_b;
+
+	/* Two matricess are considered compatible if they have the same size */
+	return ((bcsr_a->nnz == bcsr_b->nnz)
+			&& (bcsr_a->nrow == bcsr_b->nrow)
+			&& (bcsr_a->r == bcsr_b->r)
+			&& (bcsr_a->c == bcsr_b->c)
+			&& (bcsr_a->elemsize == bcsr_b->elemsize));
+}
+
 /* offer an access to the data parameters */
 uint32_t starpu_bcsr_get_nnz(starpu_data_handle handle)
 {

+ 15 - 1
src/datawizard/interfaces/block_interface.c

@@ -1,6 +1,6 @@
 /*
  * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -69,6 +69,7 @@ static size_t allocate_block_buffer_on_node(void *interface_, uint32_t dst_node)
 static void free_block_buffer_on_node(void *interface, uint32_t node);
 static size_t block_interface_get_size(starpu_data_handle handle);
 static uint32_t footprint_block_interface_crc32(starpu_data_handle handle);
+static int block_compare(void *interface_a, void *interface_b);
 static void display_block_interface(starpu_data_handle handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_block_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss);
@@ -81,6 +82,7 @@ static struct starpu_data_interface_ops_t interface_block_ops = {
 	.copy_methods = &block_copy_data_methods_s,
 	.get_size = block_interface_get_size,
 	.footprint = footprint_block_interface_crc32,
+	.compare = block_compare,
 #ifdef STARPU_USE_GORDON
 	.convert_to_gordon = convert_block_to_gordon,
 #endif
@@ -162,6 +164,18 @@ static uint32_t footprint_block_interface_crc32(starpu_data_handle handle)
 	return hash;
 }
 
+static int block_compare(void *interface_a, void *interface_b)
+{
+	starpu_block_interface_t *block_a = interface_a;
+	starpu_block_interface_t *block_b = interface_b;
+
+	/* Two matricess are considered compatible if they have the same size */
+	return ((block_a->nx == block_b->nx)
+			&& (block_a->ny == block_b->ny)
+			&& (block_a->nz == block_b->nz)
+			&& (block_a->elemsize == block_b->elemsize));
+}
+
 static void display_block_interface(starpu_data_handle handle, FILE *f)
 {
 	starpu_block_interface_t *interface;

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

@@ -1,6 +1,6 @@
 /*
  * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -59,6 +59,7 @@ static void register_csr_handle(starpu_data_handle handle, uint32_t home_node, v
 static size_t allocate_csr_buffer_on_node(void *interface_, uint32_t dst_node);
 static void free_csr_buffer_on_node(void *interface, uint32_t node);
 static size_t csr_interface_get_size(starpu_data_handle handle);
+static int csr_compare(void *interface_a, void *interface_b);
 static uint32_t footprint_csr_interface_crc32(starpu_data_handle handle);
 
 static struct starpu_data_interface_ops_t interface_csr_ops = {
@@ -69,7 +70,8 @@ static struct starpu_data_interface_ops_t interface_csr_ops = {
 	.get_size = csr_interface_get_size,
 	.interfaceid = STARPU_CSR_INTERFACE_ID,
 	.interface_size = sizeof(starpu_csr_interface_t),
-	.footprint = footprint_csr_interface_crc32
+	.footprint = footprint_csr_interface_crc32,
+	.compare = csr_compare
 };
 
 static void register_csr_handle(starpu_data_handle handle, uint32_t home_node, void *interface)
@@ -123,6 +125,17 @@ static uint32_t footprint_csr_interface_crc32(starpu_data_handle handle)
 	return _starpu_crc32_be(starpu_csr_get_nnz(handle), 0);
 }
 
+static int csr_compare(void *interface_a, void *interface_b)
+{
+	starpu_csr_interface_t *csr_a = interface_a;
+	starpu_csr_interface_t *csr_b = interface_b;
+
+	/* Two matricess are considered compatible if they have the same size */
+	return ((csr_a->nnz == csr_b->nnz)
+			&& (csr_a->nrow == csr_b->nrow)
+			&& (csr_a->elemsize == csr_b->elemsize));
+}
+
 /* offer an access to the data parameters */
 uint32_t starpu_csr_get_nnz(starpu_data_handle handle)
 {

+ 1 - 0
src/datawizard/interfaces/data_interface.h

@@ -33,6 +33,7 @@ struct starpu_data_interface_ops_t {
 	const struct starpu_copy_data_methods_s *copy_methods;
 	size_t (*get_size)(starpu_data_handle handle);
 	uint32_t (*footprint)(starpu_data_handle handle);
+	int (*compare)(void *interface_a, void *interface_b);
 	void (*display)(starpu_data_handle handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 	int (*convert_to_gordon)(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 

+ 14 - 1
src/datawizard/interfaces/matrix_interface.c

@@ -1,6 +1,6 @@
 /*
  * StarPU
- * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ * Copyright (C) INRIA 2008-2010 (see AUTHORS file)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -72,6 +72,7 @@ static size_t allocate_matrix_buffer_on_node(void *interface_, uint32_t dst_node
 static void free_matrix_buffer_on_node(void *interface, uint32_t node);
 static size_t matrix_interface_get_size(starpu_data_handle handle);
 static uint32_t footprint_matrix_interface_crc32(starpu_data_handle handle);
+static int matrix_compare(void *interface_a, void *interface_b);
 static void display_matrix_interface(starpu_data_handle handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_matrix_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 
@@ -84,6 +85,7 @@ struct starpu_data_interface_ops_t _starpu_interface_matrix_ops = {
 	.copy_methods = &matrix_copy_data_methods_s,
 	.get_size = matrix_interface_get_size,
 	.footprint = footprint_matrix_interface_crc32,
+	.compare = matrix_compare,
 #ifdef STARPU_USE_GORDON
 	.convert_to_gordon = convert_matrix_to_gordon,
 #endif
@@ -162,6 +164,17 @@ static uint32_t footprint_matrix_interface_crc32(starpu_data_handle handle)
 	return _starpu_crc32_be(starpu_matrix_get_nx(handle), starpu_matrix_get_ny(handle));
 }
 
+static int matrix_compare(void *interface_a, void *interface_b)
+{
+	starpu_matrix_interface_t *matrix_a = interface_a;
+	starpu_matrix_interface_t *matrix_b = interface_b;
+
+	/* Two matricess are considered compatible if they have the same size */
+	return ((matrix_a->nx == matrix_b->nx)
+			&& (matrix_a->ny == matrix_b->ny)
+			&& (matrix_a->elemsize == matrix_b->elemsize));
+}
+
 static void display_matrix_interface(starpu_data_handle handle, FILE *f)
 {
 	starpu_matrix_interface_t *interface =

+ 11 - 5
src/datawizard/interfaces/variable_interface.c

@@ -23,11 +23,6 @@
 
 #include <common/hash.h>
 
-
-
-
-
-
 #ifdef STARPU_USE_CUDA
 #include <cuda.h>
 #endif
@@ -77,6 +72,7 @@ static size_t allocate_variable_buffer_on_node(void *interface_, uint32_t dst_no
 static void free_variable_buffer_on_node(void *interface, uint32_t node);
 static size_t variable_interface_get_size(starpu_data_handle handle);
 static uint32_t footprint_variable_interface_crc32(starpu_data_handle handle);
+static int variable_compare(void *interface_a, void *interface_b);
 static void display_variable_interface(starpu_data_handle handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_variable_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 
@@ -89,6 +85,7 @@ static struct starpu_data_interface_ops_t interface_variable_ops = {
 	.copy_methods = &variable_copy_data_methods_s,
 	.get_size = variable_interface_get_size,
 	.footprint = footprint_variable_interface_crc32,
+	.compare = variable_compare,
 #ifdef STARPU_USE_GORDON
 	.convert_to_gordon = convert_variable_to_gordon,
 #endif
@@ -144,6 +141,15 @@ static uint32_t footprint_variable_interface_crc32(starpu_data_handle handle)
 	return _starpu_crc32_be(starpu_variable_get_elemsize(handle), 0);
 }
 
+static int variable_compare(void *interface_a, void *interface_b)
+{
+	starpu_variable_interface_t *variable_a = interface_a;
+	starpu_variable_interface_t *variable_b = interface_b;
+
+	/* Two variables are considered compatible if they have the same size */
+	return (variable_a->elemsize == variable_b->elemsize);
+} 
+
 static void display_variable_interface(starpu_data_handle handle, FILE *f)
 {
 	starpu_variable_interface_t *interface =

+ 12 - 0
src/datawizard/interfaces/vector_interface.c

@@ -71,6 +71,7 @@ static size_t allocate_vector_buffer_on_node(void *interface_, uint32_t dst_node
 static void free_vector_buffer_on_node(void *interface, uint32_t node);
 static size_t vector_interface_get_size(starpu_data_handle handle);
 static uint32_t footprint_vector_interface_crc32(starpu_data_handle handle);
+static int vector_compare(void *interface_a, void *interface_b);
 static void display_vector_interface(starpu_data_handle handle, FILE *f);
 #ifdef STARPU_USE_GORDON
 static int convert_vector_to_gordon(void *interface, uint64_t *ptr, gordon_strideSize_t *ss); 
@@ -83,6 +84,7 @@ static struct starpu_data_interface_ops_t interface_vector_ops = {
 	.copy_methods = &vector_copy_data_methods_s,
 	.get_size = vector_interface_get_size,
 	.footprint = footprint_vector_interface_crc32,
+	.compare = vector_compare,
 #ifdef STARPU_USE_GORDON
 	.convert_to_gordon = convert_vector_to_gordon,
 #endif
@@ -150,6 +152,16 @@ static uint32_t footprint_vector_interface_crc32(starpu_data_handle handle)
 	return _starpu_crc32_be(starpu_vector_get_nx(handle), 0);
 }
 
+static int vector_compare(void *interface_a, void *interface_b)
+{
+	starpu_vector_interface_t *vector_a = interface_a;
+	starpu_vector_interface_t *vector_b = interface_b;
+
+	/* Two vectors are considered compatible if they have the same size */
+	return ((vector_a->nx == vector_b->nx)
+			&& (vector_a->elemsize == vector_b->elemsize));
+}
+
 static void display_vector_interface(starpu_data_handle handle, FILE *f)
 {
 	starpu_vector_interface_t *interface =