)]}'
{
  "commit": "a1c4b92e57874d549b3bc6bb776c7c16e9ada14a",
  "tree": "9428681e9dbd952b66af3cd875e81fb8d82a3405",
  "parents": [
    "9a06e4d6a117497c2536bf89bb6c7536289e44bb"
  ],
  "author": {
    "name": "Tobias Burnus",
    "email": "tburnus@baylibre.com",
    "time": "Wed May 14 20:06:49 2025 +0200"
  },
  "committer": {
    "name": "Tobias Burnus",
    "email": "tburnus@baylibre.com",
    "time": "Wed May 14 20:08:20 2025 +0200"
  },
  "message": "OpenMP: Fix mapping of zero-sized arrays with non-literal size: map(var[:n]), n \u003d 0\n\nFor map(ptr[:0]), the used map kind is GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION\nand it is permitted that \u0027ptr\u0027 does not exist. \u0027ptr\u0027 is set to the device\npointee if it exists or to the host value otherwise.\n\nFor map(ptr[:3]), the variable is first mapped and then ptr is updated to point\nto the just-mapped device data; the attachment uses GOMP_MAP_ATTACH.\n\nFor map(ptr[:n]), generates always a GOMP_MAP_ATTACH, but when n \u003d\u003d 0, it\nwas failing with:\n   \"pointer target not mapped for attach\"\n\nThe solution is not to fail but first to check whether it was mapped before.\nIt turned out that for the mapping part, GCC adds a run-time check whether\nn \u003d\u003d 0 - and uses GOMP_MAP_ZERO_LEN_ARRAY_SECTION for the mapping.\nThus, we just have to check whether there such a mapping for the address\nfor which the GOMP_MAP_ATTACH. was requested. And, if there was, the\nerror diagnostic can be skipped.\n\nUnsurprisingly, this issue occurs in real-world code; it was detected in\na code that distributes work via MPI and for some processes, some bounds\nended up to be zero.\n\nlibgomp/ChangeLog:\n\n\t* target.c (gomp_attach_pointer): Return bool; accept additional\n\tbool to optionally silence the fatal pointee-not-found error.\n\t(gomp_map_vars_internal): If the pointee could not be found,\n\tcheck whether it was mapped as GOMP_MAP_ZERO_LEN_ARRAY_SECTION.\n\t* libgomp.h (gomp_attach_pointer): Update prototype.\n\t* oacc-mem.c (acc_attach_async, goacc_enter_data_internal): Update\n\tcalls.\n\t* testsuite/libgomp.c/target-map-zero-sized.c: New test.\n\t* testsuite/libgomp.c/target-map-zero-sized-2.c: New test.\n\t* testsuite/libgomp.c/target-map-zero-sized-3.c: New test.\n\n(cherry picked from commit 814e29e390b1e9253f9a38e0d84f5ebe5de0c13e)\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "264a4d727a0e09639bc851a86d9895ecd9ee2686",
      "old_mode": 33188,
      "old_path": "libgomp/ChangeLog.omp",
      "new_id": "a6d676c27d7fab7136e388a4efbc035f0bb3e493",
      "new_mode": 33188,
      "new_path": "libgomp/ChangeLog.omp"
    },
    {
      "type": "modify",
      "old_id": "43e7a068e69f584e3a71d676fe2ab480eaff92ed",
      "old_mode": 33188,
      "old_path": "libgomp/libgomp.h",
      "new_id": "a60a3d812c956ad79452d17583b075f278a1eb02",
      "new_mode": 33188,
      "new_path": "libgomp/libgomp.h"
    },
    {
      "type": "modify",
      "old_id": "feca3b2831886e7f89e9373cfdf117538a3bd44b",
      "old_mode": 33188,
      "old_path": "libgomp/oacc-mem.c",
      "new_id": "a4ddb7da4c80c6c3666197e550e9b3b42023c571",
      "new_mode": 33188,
      "new_path": "libgomp/oacc-mem.c"
    },
    {
      "type": "modify",
      "old_id": "796decd5165bfc58b84898b4752bce479d8ce364",
      "old_mode": 33188,
      "old_path": "libgomp/target.c",
      "new_id": "ab1fae1bc6d5f35f45eb6efe0825e828ccc82ad2",
      "new_mode": 33188,
      "new_path": "libgomp/target.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "3220828efd05f7477f1846086e2e62c5fefd23b5",
      "new_mode": 33188,
      "new_path": "libgomp/testsuite/libgomp.c/target-map-zero-sized-2.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f968bd377c2cd18e0b8e274afd8cd9c2638709e2",
      "new_mode": 33188,
      "new_path": "libgomp/testsuite/libgomp.c/target-map-zero-sized-3.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "7c4ab80bc1adc82a35379b981042cb6453234403",
      "new_mode": 33188,
      "new_path": "libgomp/testsuite/libgomp.c/target-map-zero-sized.c"
    }
  ]
}
