For reverse-offload data handling, we need to support: (a) device fn addr -> host fn address (b) finding already mapped host -> device vars via their device address For (a), the functions addrs, we need some extra code (cf. previous patches) as this information does not exist already. For (b), the variables, we have two options: (i) Do a reverse search on the existing data. That's done in oacc-mem.c's lookup_dev and obviously is O(N) as it has to check all nodes. With the assumption "This is not expected to be a common operation." is might be still okay. (ii) Using a second splay tree for the reverse lookup. The attached patch prepares for this – but does not yet handle all locations and is not yet active. The 'devicep->load_image_func' call depends whether the previous [1/3] patch (cf. below) has been applied or not. (The advantage of the reverse-offload mapping is that 'nowait' is not permitted and 'target {enter,exit,} data device(anchestor:1)' is neither. Thus, all 'omp target device(ancestor:1)' mapping done in target_rev can be undone in the same function - and all others are preexisting.) OK for mainline? Tobias PS: Still to be done (for nvptx, for gcn a bit more is needed): - handle remaining var-mapping cases - gomp_target_rev - mainly: handle all of map/firstprivate. - turn on reverse-offload support (accept omp_requires) + add tons of testcases. Pending reverse-offload patches (libgomp only with abit gcc/config/{gcn,nvptx}): [Patch][1/3] libgomp: Prepare for reverse offload fn lookup [Patch][2/3] GCN: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup [Patch][2/3] nvptx: libgomp+mkoffload.cc: Prepare for reverse offload fn lookup [1/3] is at: https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600333.html [Patch] libgomp/nvptx: Prepare for reverse-offload callback handling https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600381.html ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955