[OpenMP] Adopt std::set in HostDataToTargetMap
authorYe Luo <yeluo@anl.gov>
Wed, 24 Jun 2020 16:18:00 +0000 (12:18 -0400)
committerShilei Tian <tianshilei1992@gmail.com>
Wed, 24 Jun 2020 16:22:45 +0000 (12:22 -0400)
commit6e5f64c44f26465829e5aed38e900129ace6e64f
tree20166ff58e78d06eee5b67d2609c74170cf8847d
parent69d2fa9ed1c1aba6f473feb03cad257e69a0cf52
[OpenMP] Adopt std::set in HostDataToTargetMap

Summary:
lookupMapping took significant time due to linear complexity searching.
This is bad for offloading from multiple host threads because lookupMapping is protected by mutex.
Use std::set for logarithmic complexity searching.

Before my change.
libomptarget inclusive time 16.7 sec, exclusive time 8.6 sec.
After the change
libomptarget inclusive time 7.3 sec, exclusive time 0.4 sec.

Most of the overhead of libomptarget (exclusive time) is gone.

Reviewers: jdoerfert, grokos

Reviewed By: grokos

Subscribers: tianshilei1992, yaxunl, guansong, sstefan1

Tags: #openmp

Differential Revision: https://reviews.llvm.org/D82264
openmp/libomptarget/src/device.cpp
openmp/libomptarget/src/device.h
openmp/libomptarget/src/omptarget.cpp