|
@@ -694,57 +694,44 @@ static void register_mem_chunk(struct _starpu_data_replicate *replicate, unsigne
|
|
* unregister or unpartition). It puts all the memchunks that refer to the
|
|
* unregister or unpartition). It puts all the memchunks that refer to the
|
|
* specified handle into the cache.
|
|
* specified handle into the cache.
|
|
*/
|
|
*/
|
|
-void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, unsigned node, size_t size)
|
|
+void _starpu_request_mem_chunk_removal(starpu_data_handle_t handle, struct _starpu_data_replicate *replicate, unsigned node, size_t size)
|
|
{
|
|
{
|
|
- _STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
|
|
+ struct _starpu_mem_chunk *mc = replicate->mc;
|
|
|
|
|
|
-
|
|
+ STARPU_ASSERT(mc->data == handle);
|
|
-
|
|
|
|
- struct _starpu_mem_chunk *mc, *next_mc;
|
|
|
|
- for (mc = _starpu_mem_chunk_list_begin(mc_list[node]);
|
|
|
|
- mc != _starpu_mem_chunk_list_end(mc_list[node]);
|
|
|
|
- mc = next_mc)
|
|
|
|
- {
|
|
|
|
- next_mc = _starpu_mem_chunk_list_next(mc);
|
|
|
|
|
|
|
|
- if (mc->data == handle)
|
|
+
|
|
- {
|
|
+ * reclaiming we can estimate how much memory we free
|
|
-
|
|
+ * by freeing this. */
|
|
|
|
+ mc->size = size;
|
|
|
|
+
|
|
|
|
+ mc->data = NULL;
|
|
|
|
+ replicate->mc = NULL;
|
|
|
|
+ replicate->allocated = 0;
|
|
|
|
+ replicate->automatically_allocated = 0;
|
|
|
|
|
|
-
|
|
+ _STARPU_PTHREAD_RWLOCK_WRLOCK(&mc_rwlock[node]);
|
|
- * reclaiming we can estimate how much memory we free
|
|
|
|
- * by freeing this. */
|
|
|
|
- mc->size = size;
|
|
|
|
-
|
|
|
|
- mc->data = NULL;
|
|
|
|
|
|
|
|
-
|
|
+
|
|
- _starpu_mem_chunk_list_erase(mc_list[node], mc);
|
|
+ _starpu_mem_chunk_list_erase(mc_list[node], mc);
|
|
|
|
|
|
-
|
|
+ _STARPU_PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
|
|
- * malloc() returns NULL, which is very unlikely... */
|
|
|
|
-
|
|
|
|
- * 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)
|
|
|
|
- {
|
|
|
|
- free_memory_on_node(mc, node);
|
|
|
|
|
|
|
|
- free(mc->chunk_interface);
|
|
+
|
|
- _starpu_mem_chunk_delete(mc);
|
|
+ * malloc() returns NULL, which is very unlikely... */
|
|
- }
|
|
+
|
|
- else
|
|
+ * STARPU_USE_ALLOCATION_CACHE is not enabled, as we
|
|
-
|
|
+ * wouldn't even re-use these allocations! */
|
|
- _starpu_mem_chunk_list_push_front(memchunk_cache[node], mc);
|
|
+ if (starpu_node_get_kind(node) == STARPU_CPU_RAM)
|
|
|
|
+ {
|
|
|
|
+ free_memory_on_node(mc, node);
|
|
|
|
|
|
-
|
|
+ free(mc->chunk_interface);
|
|
- * multiple replicates associated to the same handle on
|
|
+ _starpu_mem_chunk_delete(mc);
|
|
- * the same memory node. */
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-
|
|
+ else
|
|
-
|
|
+
|
|
- _STARPU_PTHREAD_RWLOCK_UNLOCK(&mc_rwlock[node]);
|
|
+ _starpu_mem_chunk_list_push_front(memchunk_cache[node], mc);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|