Sfoglia il codice sorgente

Move src/common/hash.h to include/starpu_hash.h. All functions are now public.

Cyril Roelandt 13 anni fa
parent
commit
fdbee85d19

+ 2 - 1
Makefile.am

@@ -67,7 +67,8 @@ versinclude_HEADERS = 				\
 	include/starpu_bound.h			\
 	include/starpu_scheduler.h		\
 	include/starpu_top.h			\
-	include/starpu_deprecated_api.h
+	include/starpu_deprecated_api.h         \
+	include/starpu_hash.h
 
 nodist_versinclude_HEADERS = 			\
 	include/starpu_config.h

+ 3 - 3
src/common/hash.h

@@ -24,16 +24,16 @@
 /* Compute the CRC of a byte buffer seeded by the inputcrc "current state".
  * The return value should be considered as the new "current state" for future
  * CRC computation. */
-uint32_t _starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc);
+uint32_t starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc);
 
 /* Compute the CRC of a 32bit number seeded by the inputcrc "current state".
  * The return value should be considered as the new "current state" for future
  * CRC computation. */
-uint32_t _starpu_crc32_be(uint32_t input, uint32_t inputcrc);
+uint32_t starpu_crc32_be(uint32_t input, uint32_t inputcrc);
 
 /* Compute the CRC of a string seeded by the inputcrc "current state".  The
  * return value should be considered as the new "current state" for future CRC
  * computation. */
-uint32_t _starpu_crc32_string(char *str, uint32_t inputcrc);
+uint32_t starpu_crc32_string(char *str, uint32_t inputcrc);
 
 #endif // __HASH_H__

+ 5 - 5
mpi/starpu_mpi_insert_task.c

@@ -21,7 +21,7 @@
 #include <starpu.h>
 #include <starpu_data.h>
 #include <common/utils.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <common/htable32.h>
 #include <util/starpu_insert_task_utils.h>
 
@@ -60,7 +60,7 @@ typedef struct _starpu_mpi_clear_cache_s {
 void _starpu_mpi_clear_cache_callback(void *callback_arg)
 {
         _starpu_mpi_clear_cache_t *clear_cache = (_starpu_mpi_clear_cache_t *)callback_arg;
-        uint32_t key = _starpu_crc32_be((uintptr_t)clear_cache->data, 0);
+        uint32_t key = starpu_crc32_be((uintptr_t)clear_cache->data, 0);
 
         if (clear_cache->mode == _STARPU_MPI_CLEAR_SENT_DATA) {
                 _STARPU_MPI_DEBUG("Clearing sent cache for data %p and rank %d\n", clear_cache->data, clear_cache->rank);
@@ -287,7 +287,7 @@ int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...)
                                 if (do_execute && mpi_rank != me && mpi_rank != -1) {
                                         /* I will have to execute but I don't have the data, receive */
 #ifdef MPI_CACHE
-                                        uint32_t key = _starpu_crc32_be((uintptr_t)data, 0);
+                                        uint32_t key = starpu_crc32_be((uintptr_t)data, 0);
                                         void *already_received = _starpu_htbl_search_32(received_data[mpi_rank], key);
                                         if (!already_received) {
                                                 _starpu_htbl_insert_32(&received_data[mpi_rank], key, data);
@@ -305,7 +305,7 @@ int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...)
                                 if (!do_execute && mpi_rank == me) {
                                         /* Somebody else will execute it, and I have the data, send it. */
 #ifdef MPI_CACHE
-                                        uint32_t key = _starpu_crc32_be((uintptr_t)data, 0);
+                                        uint32_t key = starpu_crc32_be((uintptr_t)data, 0);
                                         void *already_sent = _starpu_htbl_search_32(sent_data[dest], key);
                                         if (!already_sent) {
                                                 _starpu_htbl_insert_32(&sent_data[dest], key, data);
@@ -411,7 +411,7 @@ int starpu_mpi_insert_task(MPI_Comm comm, struct starpu_codelet *codelet, ...)
                         starpu_data_handle_t data = va_arg(varg_list, starpu_data_handle_t);
 #ifdef MPI_CACHE
                         if (arg_type & STARPU_W) {
-                                uint32_t key = _starpu_crc32_be((uintptr_t)data, 0);
+                                uint32_t key = starpu_crc32_be((uintptr_t)data, 0);
                                 if (do_execute) {
                                         /* Note that all copies I've sent to neighbours are now invalid */
                                         int n, size;

+ 0 - 1
src/Makefile.am

@@ -87,7 +87,6 @@ noinst_HEADERS = 						\
 	datawizard/memory_nodes.h				\
 	datawizard/interfaces/data_interface.h			\
 	common/barrier.h					\
-	common/hash.h						\
 	common/timing.h						\
 	common/htable32.h					\
 	common/list.h						\

+ 11 - 11
src/common/hash.c

@@ -15,13 +15,13 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <stdlib.h>
 #include <string.h>
 
 #define _STARPU_CRC32C_POLY_BE 0x1EDC6F41
 
-static inline uint32_t __attribute__ ((pure)) _starpu_crc32_be_8(uint8_t inputbyte, uint32_t inputcrc)
+static inline uint32_t __attribute__ ((pure)) starpu_crc32_be_8(uint8_t inputbyte, uint32_t inputcrc)
 {
 	unsigned i;
 	uint32_t crc;
@@ -33,7 +33,7 @@ static inline uint32_t __attribute__ ((pure)) _starpu_crc32_be_8(uint8_t inputby
 	return crc;
 }
 
-uint32_t _starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc)
+uint32_t starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc)
 {
 	uint8_t *p = (uint8_t *)input;
 	size_t i;
@@ -41,26 +41,26 @@ uint32_t _starpu_crc32_be_n(void *input, size_t n, uint32_t inputcrc)
 	uint32_t crc = inputcrc;
 
 	for (i = 0; i < n; i++)
-		crc = _starpu_crc32_be_8(p[i], crc);
+		crc = starpu_crc32_be_8(p[i], crc);
 
 	return crc;
 }
 
-uint32_t _starpu_crc32_be(uint32_t input, uint32_t inputcrc)
+uint32_t starpu_crc32_be(uint32_t input, uint32_t inputcrc)
 {
 	uint8_t *p = (uint8_t *)&input;
 
 	uint32_t crc = inputcrc;
 
-	crc = _starpu_crc32_be_8(p[0], crc);
-	crc = _starpu_crc32_be_8(p[1], crc);
-	crc = _starpu_crc32_be_8(p[2], crc);
-	crc = _starpu_crc32_be_8(p[3], crc);
+	crc = starpu_crc32_be_8(p[0], crc);
+	crc = starpu_crc32_be_8(p[1], crc);
+	crc = starpu_crc32_be_8(p[2], crc);
+	crc = starpu_crc32_be_8(p[3], crc);
 
 	return crc;
 }
 
-uint32_t _starpu_crc32_string(char *str, uint32_t inputcrc)
+uint32_t starpu_crc32_string(char *str, uint32_t inputcrc)
 {
 	uint32_t hash = inputcrc;
 
@@ -69,7 +69,7 @@ uint32_t _starpu_crc32_string(char *str, uint32_t inputcrc)
 	unsigned i;
 	for (i = 0; i < len; i++)
 	{
-		hash = _starpu_crc32_be_8((uint8_t)str[i], hash);
+		hash = starpu_crc32_be_8((uint8_t)str[i], hash);
 	}
 
 	return hash;

+ 4 - 4
src/core/topology.c

@@ -22,7 +22,7 @@
 #include <core/debug.h>
 #include <core/topology.h>
 #include <drivers/cuda/driver_cuda.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <profiling/profiling.h>
 
 #ifdef STARPU_HAVE_HWLOC
@@ -93,7 +93,7 @@ static void _starpu_initialize_workers_opencl_gpuid(struct _starpu_machine_confi
                 int i;
                 for(i=0 ; i<STARPU_NMAXWORKERS ; i++)
 		{
-                        uint32_t key = _starpu_crc32_be(config->topology.workers_opencl_gpuid[i], 0);
+                        uint32_t key = starpu_crc32_be(config->topology.workers_opencl_gpuid[i], 0);
                         if (_starpu_htbl_search_32(devices_using_cuda, key) == NULL)
 			{
                                 tmp[nb] = topology->workers_opencl_gpuid[i];
@@ -113,7 +113,7 @@ static void _starpu_initialize_workers_opencl_gpuid(struct _starpu_machine_confi
 
                 for(i=0 ; i<STARPU_NMAXWORKERS ; i++)
 		{
-                        uint32_t key = _starpu_crc32_be(topology->workers_opencl_gpuid[i], 0);
+                        uint32_t key = starpu_crc32_be(topology->workers_opencl_gpuid[i], 0);
                         if (_starpu_htbl_search_32(devices_already_used, key) == NULL)
 			{
                                 _starpu_htbl_insert_32(&devices_already_used, key, config);
@@ -345,7 +345,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config,
 		config->workers[topology->nworkers + cudagpu].worker_mask = STARPU_CUDA;
 		config->worker_mask |= STARPU_CUDA;
 
-                uint32_t key = _starpu_crc32_be(devid, 0);
+                uint32_t key = starpu_crc32_be(devid, 0);
                 _starpu_htbl_insert_32(&devices_using_cuda, key, config);
         }
 

+ 5 - 5
src/datawizard/footprint.c

@@ -16,7 +16,7 @@
  */
 
 #include <datawizard/footprint.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 
 uint32_t _starpu_compute_buffers_footprint(struct starpu_perfmodel *model, enum starpu_perf_archtype arch, unsigned nimpl, struct _starpu_job *j)
 {
@@ -30,10 +30,10 @@ uint32_t _starpu_compute_buffers_footprint(struct starpu_perfmodel *model, enum
 
 	if (model && model->per_arch[arch][nimpl].size_base) {
 		size_t size = model->per_arch[arch][nimpl].size_base(task, arch, nimpl);
-		footprint = _starpu_crc32_be_n(&size, sizeof(size), footprint);
+		footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
 	} else if (model && model->size_base) {
 		size_t size = model->size_base(task, nimpl);
-		footprint = _starpu_crc32_be_n(&size, sizeof(size), footprint);
+		footprint = starpu_crc32_be_n(&size, sizeof(size), footprint);
 	} else {
 		for (buffer = 0; buffer < task->cl->nbuffers; buffer++)
 		{
@@ -41,7 +41,7 @@ uint32_t _starpu_compute_buffers_footprint(struct starpu_perfmodel *model, enum
 
 			uint32_t handle_footprint = _starpu_data_get_footprint(handle);
 
-			footprint = _starpu_crc32_be(handle_footprint, footprint);
+			footprint = starpu_crc32_be(handle_footprint, footprint);
 		}
 	}
 
@@ -57,5 +57,5 @@ uint32_t _starpu_compute_data_footprint(starpu_data_handle_t handle)
 
 	uint32_t handle_footprint = handle->ops->footprint(handle);
 
-	return _starpu_crc32_be(handle_footprint, interfaceid);
+	return starpu_crc32_be(handle_footprint, interfaceid);
 }

+ 4 - 4
src/datawizard/interfaces/bcsr_interface.c

@@ -21,7 +21,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
@@ -139,9 +139,9 @@ static uint32_t footprint_bcsr_interface_crc32(starpu_data_handle_t handle)
 {
 	uint32_t hash;
 
-	hash = _starpu_crc32_be(starpu_bcsr_get_nnz(handle), 0);
-	hash = _starpu_crc32_be(starpu_bcsr_get_c(handle), hash);
-	hash = _starpu_crc32_be(starpu_bcsr_get_r(handle), hash);
+	hash = starpu_crc32_be(starpu_bcsr_get_nnz(handle), 0);
+	hash = starpu_crc32_be(starpu_bcsr_get_c(handle), hash);
+	hash = starpu_crc32_be(starpu_bcsr_get_r(handle), hash);
 
 	return hash;
 }

+ 4 - 4
src/datawizard/interfaces/block_interface.c

@@ -21,7 +21,7 @@
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
 
-#include <common/hash.h>
+#include <starpu_hash.h>
 
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
@@ -175,9 +175,9 @@ static uint32_t footprint_block_interface_crc32(starpu_data_handle_t handle)
 {
 	uint32_t hash;
 
-	hash = _starpu_crc32_be(starpu_block_get_nx(handle), 0);
-	hash = _starpu_crc32_be(starpu_block_get_ny(handle), hash);
-	hash = _starpu_crc32_be(starpu_block_get_nz(handle), hash);
+	hash = starpu_crc32_be(starpu_block_get_nx(handle), 0);
+	hash = starpu_crc32_be(starpu_block_get_ny(handle), hash);
+	hash = starpu_crc32_be(starpu_block_get_nz(handle), hash);
 
 	return hash;
 }

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

@@ -22,7 +22,7 @@
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
 
-#include <common/hash.h>
+#include <starpu_hash.h>
 
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
@@ -134,7 +134,7 @@ void starpu_csr_data_register(starpu_data_handle_t *handleptr, uint32_t home_nod
 
 static uint32_t footprint_csr_interface_crc32(starpu_data_handle_t handle)
 {
-	return _starpu_crc32_be(starpu_csr_get_nnz(handle), 0);
+	return starpu_crc32_be(starpu_csr_get_nnz(handle), 0);
 }
 
 static int csr_compare(void *data_interface_a, void *data_interface_b)

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

@@ -20,7 +20,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
@@ -183,7 +183,7 @@ void starpu_matrix_data_register(starpu_data_handle_t *handleptr, uint32_t home_
 
 static uint32_t footprint_matrix_interface_crc32(starpu_data_handle_t handle)
 {
-	return _starpu_crc32_be(starpu_matrix_get_nx(handle), starpu_matrix_get_ny(handle));
+	return starpu_crc32_be(starpu_matrix_get_nx(handle), starpu_matrix_get_ny(handle));
 }
 
 static int matrix_compare(void *data_interface_a, void *data_interface_b)

+ 2 - 2
src/datawizard/interfaces/multiformat_interface.c

@@ -18,7 +18,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
@@ -192,7 +192,7 @@ void starpu_multiformat_data_register(starpu_data_handle_t *handleptr,
 
 static uint32_t footprint_multiformat_interface_crc32(starpu_data_handle_t handle)
 {
-	return _starpu_crc32_be(starpu_multiformat_get_nx(handle), 0);
+	return starpu_crc32_be(starpu_multiformat_get_nx(handle), 0);
 }
 
 static int multiformat_compare(void *data_interface_a, void *data_interface_b)

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

@@ -20,7 +20,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
@@ -151,7 +151,7 @@ void starpu_variable_data_register(starpu_data_handle_t *handleptr, uint32_t hom
 
 static uint32_t footprint_variable_interface_crc32(starpu_data_handle_t handle)
 {
-	return _starpu_crc32_be(starpu_variable_get_elemsize(handle), 0);
+	return starpu_crc32_be(starpu_variable_get_elemsize(handle), 0);
 }
 
 static int variable_compare(void *data_interface_a, void *data_interface_b)

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

@@ -20,7 +20,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>
@@ -166,7 +166,7 @@ void starpu_vector_data_register(starpu_data_handle_t *handleptr, uint32_t home_
 
 static uint32_t footprint_vector_interface_crc32(starpu_data_handle_t handle)
 {
-	return _starpu_crc32_be(starpu_vector_get_nx(handle), 0);
+	return starpu_crc32_be(starpu_vector_get_nx(handle), 0);
 }
 
 static int vector_compare(void *data_interface_a, void *data_interface_b)

+ 1 - 1
src/datawizard/interfaces/void_interface.c

@@ -20,7 +20,7 @@
 #include <datawizard/coherency.h>
 #include <datawizard/copy_driver.h>
 #include <datawizard/filters.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 #include <starpu_cuda.h>
 #include <starpu_opencl.h>
 #include <drivers/opencl/driver_opencl.h>

+ 7 - 7
src/debug/traces/starpu_fxt.c

@@ -20,7 +20,7 @@
 #ifdef STARPU_USE_FXT
 #include "starpu_fxt.h"
 #include <inttypes.h>
-#include <common/hash.h>
+#include <starpu_hash.h>
 
 static char *cpus_worker_colors[STARPU_NMAXWORKERS] = {"/greens9/7", "/greens9/6", "/greens9/5", "/greens9/4",  "/greens9/9", "/greens9/3",  "/greens9/2",  "/greens9/1"  };
 static char *cuda_worker_colors[STARPU_NMAXWORKERS] = {"/ylorrd9/9", "/ylorrd9/6", "/ylorrd9/3", "/ylorrd9/1", "/ylorrd9/8", "/ylorrd9/7", "/ylorrd9/4", "/ylorrd9/2",  "/ylorrd9/1"};
@@ -61,22 +61,22 @@ static const char *get_worker_color(int workerid)
 static unsigned get_colour_symbol_red(char *name)
 {
 	/* choose some colour ... that's disguting yes */
-	uint32_t hash_symbol = _starpu_crc32_string(name, 0);
-	return (unsigned)_starpu_crc32_string("red", hash_symbol) % 1024;
+	uint32_t hash_symbol = starpu_crc32_string(name, 0);
+	return (unsigned)starpu_crc32_string("red", hash_symbol) % 1024;
 }
 
 static unsigned get_colour_symbol_green(char *name)
 {
 	/* choose some colour ... that's disguting yes */
-	uint32_t hash_symbol = _starpu_crc32_string(name, 0);
-	return (unsigned)_starpu_crc32_string("green", hash_symbol) % 1024;
+	uint32_t hash_symbol = starpu_crc32_string(name, 0);
+	return (unsigned)starpu_crc32_string("green", hash_symbol) % 1024;
 }
 
 static unsigned get_colour_symbol_blue(char *name)
 {
 	/* choose some colour ... that's disguting yes */
-	uint32_t hash_symbol = _starpu_crc32_string(name, 0);
-	return (unsigned)_starpu_crc32_string("blue", hash_symbol) % 1024;
+	uint32_t hash_symbol = starpu_crc32_string(name, 0);
+	return (unsigned)starpu_crc32_string("blue", hash_symbol) % 1024;
 }
 
 static float last_codelet_start[STARPU_NMAXWORKERS];