瀏覽代碼

Add dontcache member to interface ops, to prevent allocation cache

Samuel Thibault 10 年之前
父節點
當前提交
6a3f539e55
共有 3 個文件被更改,包括 10 次插入4 次删除
  1. 6 1
      doc/doxygen/chapters/api/data_interfaces.doxy
  2. 3 2
      include/starpu_data_interfaces.h
  3. 1 1
      src/datawizard/memalloc.c

+ 6 - 1
doc/doxygen/chapters/api/data_interfaces.doxy

@@ -35,8 +35,13 @@ Describe the data into a string.
 An identifier that is unique to each interface.
 \var size_t starpu_data_interface_ops::interface_size
 The size of the interface data descriptor.
-\var int starpu_data_interface_ops::is_multiformat
+\var char starpu_data_interface_ops::is_multiformat
 todo
+\var char starpu_data_interface_ops::dontcache
+If set to non-zero, StarPU will never try to reuse an allocated buffer for a
+different handle. This can be notably useful for application-defined interfaces
+which have a dynamic size, and for which it thus does not make sense to reuse
+the buffer since will probably not have the proper size.
 \var struct starpu_multiformat_data_interface_ops* (*starpu_data_interface_ops::get_mf_ops)(void *data_interface)
 todo
 \var int (*starpu_data_interface_ops::pack_data)(starpu_data_handle_t handle, unsigned node, void **ptr, starpu_ssize_t *count)

+ 3 - 2
include/starpu_data_interfaces.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2014  Université de Bordeaux
+ * Copyright (C) 2010-2015  Université de Bordeaux
  * Copyright (C) 2010-2014  Centre National de la Recherche Scientifique
  * Copyright (C) 2011-2012  Institut National de Recherche en Informatique et Automatique
  *
@@ -120,7 +120,8 @@ struct starpu_data_interface_ops
 	enum starpu_data_interface_id interfaceid;
 	size_t interface_size;
 
-	int is_multiformat;
+	char is_multiformat;
+	char dontcache;
 	struct starpu_multiformat_data_interface_ops* (*get_mf_ops)(void *data_interface);
 
 	int (*pack_data) (starpu_data_handle_t handle, unsigned node, void **ptr, starpu_ssize_t *count);

+ 1 - 1
src/datawizard/memalloc.c

@@ -861,7 +861,7 @@ void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, struct _star
 	 * STARPU_USE_ALLOCATION_CACHE is not enabled, as we
 	 * wouldn't even re-use these allocations!
 	 */
-	if (starpu_node_get_kind(node) == STARPU_CPU_RAM && starpu_get_env_number("STARPU_LIMIT_CPU_MEM") < 0)
+	if (handle->ops->dontcache || (starpu_node_get_kind(node) == STARPU_CPU_RAM && starpu_get_env_number("STARPU_LIMIT_CPU_MEM") < 0))
 	{
 		/* Free data immediately */
 		free_memory_on_node(mc, node);