2014-02-20 22:27 GMT+04:00 Bernd Schmidt <ber...@codesourcery.com>: > There were still a number of things in these patches that did not make sense > to me and which I've changed. Let me know if there was a good reason for the > way some of these things were originally done. > * Functions and variables now go into different tables, otherwise > intermixing between them could be a problem that causes tables to > go out of sync between host and target (imagine one big table being > generated by ptx lto1/mkoffload, and multiple small table fragments > being linked together on the host side).
What do you mean by multiple small table fragments? The tables from every object file should be joined together while linking DSO in the same order for both host and target. If you need to join tables from multiple target images into one big table, the host tables also should be joined in the same order. In our case we're obtaining each target table while loading the image to target device, and merging it with a corresponding host table. How splitting functions and global vars into 2 tables will help to avoid intermixing? > * Is there a reason to call a register function for the host tables? > The way I've set it up, we register a target function/variable table > while also passing a pointer to the __OPENMP_TARGET__ symbol which > holds information about the host side tables. Suppose there is liba, that depends on libb, that depends on libc. Also corresponding target image tgtimga depends on tgtimgb, that depends on tgtimgc. When liba is going to start offloaded function, it calls GOMP_target with a pointer to its descriptor, which contains a pointer to tgtimga. But how does GOMP_target know that it should also load tgtimgb and tgtimgc to target? And where to get their descriptors from? That's why we have added host-side DSO registration. In this example they are loaded on host in the following order: libc, libb, liba. In the same order they are registered in libgomp, and loaded to target device while initialization. In the same order the tables received from target are merged with the host tables from the descriptors. > I'm appending those parts of my current patch kit that seem relevant. This > includes the ptx mkoffload tool and a patch to make a dummy > GOMP_offload_register function. Most of the others are updated versions of > patches I've posted before, and two adapted from Michael Zolotukhin's set > (automatically generated files not included in the diffs for size reasons). > How does this look? I will take a closer look at you changes, try to run it, and send feedback next week. -- Ilya