Skip to content

Commit

Permalink
starpu_{,mpi_}data_cpy: cope with dst_handle == src_handle
Browse files Browse the repository at this point in the history
This was previously undefined since we would be calling memcpy() with the
same pointers, which is undefined.
  • Loading branch information
sthibaul committed Mar 29, 2024
1 parent c0c53d3 commit d9dc85d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion mpi/src/starpu_mpi.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2009-2023 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2009-2024 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2019,2021 Federal University of Rio Grande do Sul (UFRGS)
*
* StarPU is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -699,6 +699,13 @@ int _starpu_mpi_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t s
{
int src, dst;

if (dst_handle == src_handle)
{
if (callback_func)
callback_func(callback_arg);
return 0;
}

src = starpu_mpi_data_get_rank(src_handle);
dst = starpu_mpi_data_get_rank(dst_handle);

Expand Down
8 changes: 7 additions & 1 deletion src/util/starpu_data_cpy.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* StarPU --- Runtime system for heterogeneous multicore architectures.
*
* Copyright (C) 2010-2022 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2010-2024 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
* Copyright (C) 2013 Thibaut Lambert
*
* StarPU is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -120,6 +120,12 @@ int _starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_h
int asynchronous, void (*callback_func)(void*), void *callback_arg,
int reduction, struct starpu_task *reduction_dep_task, int priority)
{
if (dst_handle == src_handle)
{
if (callback_func)
callback_func(callback_arg);
return 0;
}

struct starpu_task *task = starpu_task_create();
STARPU_ASSERT(task);
Expand Down

0 comments on commit d9dc85d

Please sign in to comment.