Revert "Reland "Reland "pthreadpool: Integrate with Jobs API"""
This reverts commit bbef2b40c9e20a4c8ad121ddac95abe6347389f9.
Reason for revert: Speculative fix for crbug.com/1454009, multiple
tests are failing
Original change's description:
> Reland "Reland "pthreadpool: Integrate with Jobs API""
>
> This is a reland of commit 9fd417a399dfb28ace5add2fa7df714f70de5bb6
>
> The pthreadpoool library is built with "sanitizers:cfi_icall_disable"
> config that would cause pthreadpool_unittests failure on the Linux CFI
> bot, such as [1]. This reland enables the cfi-icall sanitizer flag by
> removing this config. It also fixes a pointer cast issue in
> pthreadpool_unittests.
>
> [1]: https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20CFI/25348/overview
>
> Original change's description:
> > Reland "pthreadpool: Integrate with Jobs API"
> >
> > This is a reland of commit e29465230b2f97fc64d51395bf9353e2ab266570
> >
> > This reland fixes the build issue on win-arm64 bots, such as [1], by
> > declaring the missing arm64 intrinsics if the arm64intr.h is not
> > included correctly due to LLVM issue [2]. Once the LLVM issue is
> > resolved, this work-around should be removed.
> >
> > [1]: https://ci.chromium.org/b/8779781271284246545
> > [2]: https://github.com/llvm/llvm-project/issues/62942
> >
> > Original change's description:
> > > pthreadpool: Integrate with Jobs API
> > >
> > > pthreadpool is used by XNNPACK which in turns supports TFLite and WebNN
> > > to execute each neural network operator of a model by multiple threads
> > > in parallel.
> > >
> > > To avoid creating an unmanaged thread pool owned by pthreadpool
> > > implementation, this CL implements a shim of `pthreadpool_parallelize()`
> > > that maps the pthreadpool thread tasks to work items and uses Jobs API
> > > (`base::PostJob`) to schedule these work items with Chromium's
> > > `base::ThreadPool` workers.
> > >
> > > According to the test result on a multi-core device, when scheduling 4
> > > work items with `base::ThreadPool`, XNNPACK model inference performance
> > > could get ~1.9X speedup for MobileNet V2 and ~2.8X speedup for ResNet50
> > > V2 compared to single thread execution. And the test result also shows
> > > using Jobs API shim could achieve 85% and 97% performance of using
> > > pthreadpool own thread pool implementation for MobileNet V2 and ResNet50
> > > V2 respectively.
> > >
> > > This CL also enables pthreadpool_unittests with Jobs API integration on
> > > Windows and Linux bots that aligns with the `build_tflite_with_xnnpack`
> > > build flag.
> > >
> > >
> > > Bug: 1228275,1273291
> > > Change-Id: I1152d1e93885399b453c87be18a432e6c118054e
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4467727
> > > Reviewed-by: danakj <danakj@chromium.org>
> > > Commit-Queue: ningxin hu <ningxin.hu@intel.com>
> > > Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
> > > Reviewed-by: Robert Ogden <robertogden@chromium.org>
> > > Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
> > > Reviewed-by: Austin Sullivan <asully@chromium.org>
> > > Cr-Commit-Position: refs/heads/main@{#1150206}
> >
> > Bug: 1228275,1273291
> > Change-Id: Icab18064790a70164e47b52939add5774bf49ec7
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4571505
> > Commit-Queue: ningxin hu <ningxin.hu@intel.com>
> > Reviewed-by: Robert Ogden <robertogden@chromium.org>
> > Reviewed-by: danakj <danakj@chromium.org>
> > Reviewed-by: Austin Sullivan <asully@chromium.org>
> > Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
> > Reviewed-by: Gabriel Charette <gab@chromium.org>
> > Reviewed-by: Nico Weber <thakis@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1153620}
>
> Bug: 1228275,1273291
> Change-Id: Ib238c05d703c1f8ac191ea89cb353c39a90804d7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4593640
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Reviewed-by: Robert Ogden <robertogden@chromium.org>
> Reviewed-by: Austin Sullivan <asully@chromium.org>
> Reviewed-by: Brian Sheedy <bsheedy@chromium.org>
> Commit-Queue: ningxin hu <ningxin.hu@intel.com>
> Cr-Commit-Position: refs/heads/main@{#1155813}
Bug: 1228275,1273291,1454009
Change-Id: I3dce136ddeece69bf7d62640835b78f6a653247f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4607301
Reviewed-by: Anna Tsvirchkova <atsvirchkova@google.com>
Owners-Override: Anna Tsvirchkova <atsvirchkova@google.com>
Commit-Queue: Anna Tsvirchkova <atsvirchkova@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Dominic Battre <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1156100}
diff --git a/infra/config/generated/testing/gn_isolate_map.pyl b/infra/config/generated/testing/gn_isolate_map.pyl
index 88984b4..28311ba 100644
--- a/infra/config/generated/testing/gn_isolate_map.pyl
+++ b/infra/config/generated/testing/gn_isolate_map.pyl
@@ -1429,10 +1429,6 @@
"label": "//chrome/browser/metrics/perf:profile_provider_unittest",
"type": "console_test_launcher",
},
- "pthreadpool_unittests": {
- "label": "//third_party/pthreadpool:pthreadpool_unittests",
- "type": "console_test_launcher",
- },
"push_apps_to_background_apk": {
"label": "//tools/android/push_apps_to_background:push_apps_to_background_apk",
"type": "additional_compile_target",
diff --git a/infra/config/targets/targets.star b/infra/config/targets/targets.star
index c5f522c..71d4a5e 100644
--- a/infra/config/targets/targets.star
+++ b/infra/config/targets/targets.star
@@ -1750,11 +1750,6 @@
label = "//chrome/browser/metrics/perf:profile_provider_unittest",
)
-targets.console_test_launcher(
- name = "pthreadpool_unittests",
- label = "//third_party/pthreadpool:pthreadpool_unittests",
-)
-
targets.compile_target(
name = "push_apps_to_background_apk",
label = "//tools/android/push_apps_to_background:push_apps_to_background_apk",
diff --git a/testing/buildbot/chrome.json b/testing/buildbot/chrome.json
index f2e5b67..7bab57a 100644
--- a/testing/buildbot/chrome.json
+++ b/testing/buildbot/chrome.json
@@ -3391,25 +3391,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04",
- "pool": "chrome.tests",
- "ssd": "0"
- }
- ],
- "service_account": "chrome-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
diff --git a/testing/buildbot/chromium.cft.json b/testing/buildbot/chromium.cft.json
index 91e88249..a43fe4f 100644
--- a/testing/buildbot/chromium.cft.json
+++ b/testing/buildbot/chromium.cft.json
@@ -1187,25 +1187,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "arm64",
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -3388,24 +3369,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -7494,25 +7457,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Windows-10-19045"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/chromium.coverage.json b/testing/buildbot/chromium.coverage.json
index f908e4c..cd9ce2e 100644
--- a/testing/buildbot/chromium.coverage.json
+++ b/testing/buildbot/chromium.coverage.json
@@ -22166,24 +22166,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -23719,24 +23701,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -26225,24 +26189,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -29244,24 +29190,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Windows-10-19045"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json
index 684ad3f..e5f877f 100644
--- a/testing/buildbot/chromium.fyi.json
+++ b/testing/buildbot/chromium.fyi.json
@@ -2828,17 +2828,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": false
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -39029,24 +39018,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04",
- "ssd": "0"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -40836,24 +40807,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04",
- "ssd": "0"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -42756,26 +42709,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04",
- "pool": "chromium.tests.no-external-ip"
- }
- ],
- "expiration": 43200,
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -48267,27 +48200,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Windows-10-19045",
- "pool": "chromium.tests.no-external-ip"
- }
- ],
- "expiration": 43200,
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/chromium.linux.json b/testing/buildbot/chromium.linux.json
index cb6d2910..0e9cbc9 100644
--- a/testing/buildbot/chromium.linux.json
+++ b/testing/buildbot/chromium.linux.json
@@ -2984,24 +2984,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -5397,29 +5379,6 @@
"--use-weston",
"--ozone-platform=wayland"
],
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--no-xvfb",
- "--use-weston",
- "--ozone-platform=wayland"
- ],
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -6936,23 +6895,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
diff --git a/testing/buildbot/chromium.memory.fyi.json b/testing/buildbot/chromium.memory.fyi.json
index 2a4de66..22810db 100644
--- a/testing/buildbot/chromium.memory.fyi.json
+++ b/testing/buildbot/chromium.memory.fyi.json
@@ -1281,26 +1281,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -3015,27 +2995,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Ubuntu-20.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -4707,26 +4666,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -6245,24 +6184,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json
index 0db98465..43962bc 100644
--- a/testing/buildbot/chromium.memory.json
+++ b/testing/buildbot/chromium.memory.json
@@ -1281,26 +1281,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -2862,23 +2842,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -4548,26 +4511,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -6428,27 +6371,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Ubuntu-20.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -8224,27 +8146,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Ubuntu-20.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -9916,26 +9817,6 @@
"args": [
"--test-launcher-print-test-stdio=always"
],
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-22.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always"
- ],
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -19029,29 +18910,6 @@
"--combine-ash-logs-on-bots",
"--asan-symbolize-output"
],
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
- "args": [
- "--test-launcher-print-test-stdio=always",
- "--combine-ash-logs-on-bots",
- "--asan-symbolize-output"
- ],
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -20521,23 +20379,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Ubuntu-18.04"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -22006,23 +21847,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "os": "Windows-10-19045"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
diff --git a/testing/buildbot/chromium.win.json b/testing/buildbot/chromium.win.json
index 1e07fc3..28f0a5d 100644
--- a/testing/buildbot/chromium.win.json
+++ b/testing/buildbot/chromium.win.json
@@ -1438,25 +1438,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Windows-10-19045"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
@@ -3543,24 +3524,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Windows-10-19045"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
},
@@ -5537,25 +5500,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": "x86-64",
- "os": "Windows-11-22000"
- }
- ],
- "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/gn_isolate_map.pyl b/testing/buildbot/gn_isolate_map.pyl
index 88984b4..28311ba 100644
--- a/testing/buildbot/gn_isolate_map.pyl
+++ b/testing/buildbot/gn_isolate_map.pyl
@@ -1429,10 +1429,6 @@
"label": "//chrome/browser/metrics/perf:profile_provider_unittest",
"type": "console_test_launcher",
},
- "pthreadpool_unittests": {
- "label": "//third_party/pthreadpool:pthreadpool_unittests",
- "type": "console_test_launcher",
- },
"push_apps_to_background_apk": {
"label": "//tools/android/push_apps_to_background:push_apps_to_background_apk",
"type": "additional_compile_target",
diff --git a/testing/buildbot/internal.chrome.fyi.json b/testing/buildbot/internal.chrome.fyi.json
index 51ef1ea7..2845200 100644
--- a/testing/buildbot/internal.chrome.fyi.json
+++ b/testing/buildbot/internal.chrome.fyi.json
@@ -1756,28 +1756,6 @@
"test_id_prefix": "ninja://printing:printing_unittests/"
},
{
- "ci_only": true,
- "isolate_profile_data": true,
- "merge": {
- "script": "//testing/merge_scripts/standard_gtest_merge.py"
- },
- "swarming": {
- "can_use_on_swarming_builders": true,
- "dimension_sets": [
- {
- "cpu": null,
- "os": "Windows-11",
- "pool": "chrome.tests.arm64"
- }
- ],
- "expiration": 64800,
- "hard_timeout": 43200,
- "service_account": "chrome-tester@chops-service-accounts.iam.gserviceaccount.com"
- },
- "test": "pthreadpool_unittests",
- "test_id_prefix": "ninja://third_party/pthreadpool:pthreadpool_unittests/"
- },
- {
"isolate_profile_data": true,
"merge": {
"script": "//testing/merge_scripts/standard_gtest_merge.py"
diff --git a/testing/buildbot/test_suite_exceptions.pyl b/testing/buildbot/test_suite_exceptions.pyl
index 364351d..bbb44da 100644
--- a/testing/buildbot/test_suite_exceptions.pyl
+++ b/testing/buildbot/test_suite_exceptions.pyl
@@ -3670,14 +3670,6 @@
},
},
},
- 'pthreadpool_unittests': {
- 'remove_from': [
- # pthreadpool is not built for ChromeOS currently.
- 'linux-chromeos-dbg',
- 'linux-chromeos-rel',
- 'linux-lacros-tester-rel',
- ],
- },
'sandbox_linux_unittests': {
'modifications': {
# If you change this, make similar changes in android-x86-code-coverage below
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl
index c3a6d80..7d337e4 100644
--- a/testing/buildbot/test_suites.pyl
+++ b/testing/buildbot/test_suites.pyl
@@ -1074,12 +1074,6 @@
},
'chromium_gtests_for_win_and_linux_only': {
- # pthreadpool is only built on Windows and Linux platforms, that is
- # determined by `build_tflite_with_xnnpack` defined in
- # third_party/tflite/features.gni.
- 'pthreadpool_unittests': {
- 'ci_only': True,
- },
},
'chromium_ios_scripts': {
diff --git a/third_party/pthreadpool/BUILD.gn b/third_party/pthreadpool/BUILD.gn
index ece88051..f2a6864 100644
--- a/third_party/pthreadpool/BUILD.gn
+++ b/third_party/pthreadpool/BUILD.gn
@@ -3,25 +3,15 @@
# found in the LICENSE file.
import("//build/config/android/config.gni")
-import("//testing/test.gni")
config("pthreadpool_config") {
include_dirs = [
"src/include",
"src/src",
]
-
- # The platform-specific synchronizations are not needed for Chromium Jobs
- # API integration.
- defines = [
- "PTHREADPOOL_USE_EVENT=0",
- "PTHREADPOOL_USE_FUTEX=0",
- "PTHREADPOOL_USE_GCD=0",
- "PTHREADPOOL_USE_CONDVAR=0",
- ]
+ defines = [ "PTHREADPOOL_USE_GCD=0" ]
}
-# This is a target that depends on //base.
source_set("pthreadpool") {
public = [ "src/include/pthreadpool.h" ]
@@ -35,41 +25,19 @@
"src/src/threadpool-utils.h",
]
- # Use Chromium Jobs API.
- sources += [ "chromium/jobs.cc" ]
+ if (is_win) {
+ sources += [ "src/src/windows.c" ]
+ } else {
+ sources += [ "src/src/pthreads.c" ]
+ }
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
+ configs += [ "//build/config/sanitizers:cfi_icall_disable" ]
public_configs = [ ":pthreadpool_config" ]
- deps = [
- "//base",
- "//third_party/fxdiv",
- ]
-}
-
-test("pthreadpool_unittests") {
- testonly = true
-
- sources = [ "chromium/pthreadpool_unittests.cc" ]
-
- public_configs = [ ":pthreadpool_config" ]
-
- deps = [
- ":pthreadpool",
- "//base/test:run_all_unittests",
- "//base/test:test_support",
- "//testing/gtest",
- ]
-}
-
-config("pthreadpool_standalone_config") {
- include_dirs = [
- "src/include",
- "src/src",
- ]
- defines = [ "PTHREADPOOL_USE_GCD=0" ]
+ deps = [ "//third_party/fxdiv" ]
}
# This is a target that cannot depend on //base.
@@ -100,7 +68,7 @@
configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ "//build/config/sanitizers:cfi_icall_disable" ]
- public_configs = [ ":pthreadpool_standalone_config" ]
+ public_configs = [ ":pthreadpool_config" ]
deps = [ "//third_party/fxdiv" ]
}
diff --git a/third_party/pthreadpool/DEPS b/third_party/pthreadpool/DEPS
deleted file mode 100644
index c69decc..0000000
--- a/third_party/pthreadpool/DEPS
+++ /dev/null
@@ -1,9 +0,0 @@
-specific_include_rules = {
- "jobs.cc": [
- "+base",
- ],
- "pthreadpool_unittests.cc": [
- "+base/test",
- "+testing/gtest",
- ]
-}
diff --git a/third_party/pthreadpool/README.chromium b/third_party/pthreadpool/README.chromium
index 7b232d5..2e1018a 100644
--- a/third_party/pthreadpool/README.chromium
+++ b/third_party/pthreadpool/README.chromium
@@ -12,6 +12,3 @@
similar functionality to #pragma omp parallel for, but with additional features.
This library supports //third_party/xnnpack, which in turn supports
//third_party/tflite.
-chromium/jobs.cc implements a shim of `pthreadpool_parallelize()` that uses
-Chromium Jobs API to schedule the parallel tasks with Chromium's ThreadPool
-workers.
diff --git a/third_party/pthreadpool/chromium/jobs.cc b/third_party/pthreadpool/chromium/jobs.cc
deleted file mode 100644
index eeecbbb..0000000
--- a/third_party/pthreadpool/chromium/jobs.cc
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// `_Static_assert` is used by threadpool-common.h for GCC build. Because
-// `_Static_assert` is not defined in GCC C++ backend, define `_Static_assert`
-// by `static_assert` as a work-around.
-#if defined(__GNUC__) && \
- ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
-#define _Static_assert(predicate, message) static_assert(predicate, message)
-#endif
-
-// Configuration header.
-#include "threadpool-common.h"
-
-// Public library header.
-#include <pthreadpool.h>
-
-#if defined(_MSC_VER) && defined(_M_ARM64)
-#include <arm64intr.h>
-
-// The following ARM64 intrinsics are used by threadpool-atomics.h and should be
-// defined in arm64intr.h. If arm64intr.h is not included correctly, e.g. due to
-// LLVM issue: https://github.com/llvm/llvm-project/issues/62942, declare them
-// here as a work-around.
-//
-// TODO(crbug.com/1228275): Remove this work-around once the LLVM issue is
-// fixed.
-#ifndef ARM64_FPCR
-extern "C" {
-unsigned __int32 __ldar32(unsigned __int32 volatile* _Target);
-unsigned __int64 __ldar64(unsigned __int64 volatile* _Target);
-void __stlr32(unsigned __int32 volatile* _Target, unsigned __int32 _Value);
-void __stlr64(unsigned __int64 volatile* _Target, unsigned __int64 _Value);
-}
-#endif
-#endif // defined(_MSC_VER) && defined(_M_ARM64)
-
-// Internal library headers.
-#include "threadpool-atomics.h"
-#include "threadpool-utils.h"
-
-// Redeclare the following three pthreadpool internal functions with extern "C"
-// linkage that are used by this C++ implementation.
-#define pthreadpool_allocate _pthreadpool_allocate
-#define pthreadpool_deallocate _pthreadpool_deallocate
-#define pthreadpool_parallelize _pthreadpool_parallelize
-
-#include "threadpool-object.h"
-
-#undef pthreadpool_allocate
-#undef pthreadpool_deallocate
-#undef pthreadpool_parallelize
-
-extern "C" {
-PTHREADPOOL_INTERNAL struct pthreadpool* pthreadpool_allocate(
- size_t threads_count);
-
-PTHREADPOOL_INTERNAL void pthreadpool_deallocate(
- struct pthreadpool* threadpool);
-
-PTHREADPOOL_INTERNAL void pthreadpool_parallelize(
- struct pthreadpool* threadpool,
- thread_function_t thread_function,
- const void* params,
- size_t params_size,
- void* task,
- void* context,
- size_t linear_range,
- uint32_t flags);
-}
-
-// Chromium headers.
-#include "base/functional/bind.h"
-#include "base/synchronization/lock.h"
-#include "base/system/sys_info.h"
-#include "base/task/post_job.h"
-#include "base/task/task_traits.h"
-
-// According to the tests on multiple systems, there will be a performance
-// regression of XNNPACK model inference when the number of work items is
-// greater than `kMaxNumWorkItems`.
-//
-// TODO(crbug.com/1228275): Ensure `kMaxNumWorkItems` value setting makes sense.
-constexpr size_t kMaxNumWorkItems = 4;
-
-// Processes `threadpool` which represents the parallel computation task
-// dispatched by `pthreadpool_parallelize()` in `num_work_items` items with
-// `Run()` from `base::PostJob`. `GetMaxConcurrency()` is a callback used in
-// `base::PostJob()` to control the maximum number of threads calling `Run()`
-// concurrently.
-class PthreadPoolJob {
- public:
- PthreadPoolJob(struct pthreadpool* threadpool, size_t num_work_items)
- : threadpool_(threadpool),
- num_work_items_(num_work_items),
- num_remaining_work_items_(num_work_items) {}
- ~PthreadPoolJob() = default;
-
- void Run(base::JobDelegate* delegate) {
- CHECK(delegate);
- while (!delegate->ShouldYield()) {
- size_t index = GetNextIndex();
- if (index >= num_work_items_) {
- return;
- }
-
- DoWork(index);
-
- if (CompleteWork()) {
- return;
- }
- }
- }
-
- size_t GetMaxConcurrency(size_t worker_count) const {
- // `num_remaining_work_items_` includes the work items that other workers
- // are currently working on, so we can safely ignore the `worker_count` and
- // just return the current number of remaining work items.
- return num_remaining_work_items_.load(std::memory_order_relaxed);
- }
-
- private:
- void DoWork(size_t index) {
- struct thread_info* thread = &threadpool_->threads[index];
- const uint32_t flags =
- pthreadpool_load_relaxed_uint32_t(&threadpool_->flags);
- const thread_function_t thread_function =
- reinterpret_cast<thread_function_t>(
- pthreadpool_load_relaxed_void_p(&threadpool_->thread_function));
-
- // To avoid performance degradation of handling denormalized floating-point
- // numbers, the caller may set PTHREADPOOL_FLAG_DISABLE_DENORMALS flag that
- // instructs the thread pool workers to disable support for denormalized
- // numbers before running the computation and restore the state after the
- // computation is complete.
- //
- // See pthreadpool document for more details:
- // https://source.chromium.org/chromium/chromium/src/+/main:third_party/pthreadpool/src/include/pthreadpool.h;l=51
- struct fpu_state saved_fpu_state = {0};
- if (flags & PTHREADPOOL_FLAG_DISABLE_DENORMALS) {
- saved_fpu_state = get_fpu_state();
- disable_fpu_denormals();
- }
-
- thread_function(threadpool_, thread);
-
- if (flags & PTHREADPOOL_FLAG_DISABLE_DENORMALS) {
- set_fpu_state(saved_fpu_state);
- }
- }
-
- // Returns the index of the next work item to process.
- size_t GetNextIndex() {
- // `index_` may exceeed `num_work_items_`, but only by the number of
- // workers at worst, thus it can't exceed 2 * `num_work_items_` and
- // overflow shouldn't happen.
- return index_.fetch_add(1, std::memory_order_relaxed);
- }
-
- // Returns true if the last work item was completed.
- bool CompleteWork() {
- size_t num_remaining_work_items =
- num_remaining_work_items_.fetch_sub(1, std::memory_order_relaxed);
- CHECK_GE(num_remaining_work_items, 1);
- return num_remaining_work_items == 1;
- }
-
- struct pthreadpool* threadpool_;
- const size_t num_work_items_;
- std::atomic<size_t> index_{0};
- std::atomic<size_t> num_remaining_work_items_;
-};
-
-struct pthreadpool* pthreadpool_create(size_t threads_count) {
- // When using Jobs API, the `threads_count` only means the number of work
- // items will be scheduled by ThreadPool for each `pthreadpool_parallelize()`
- // call. Jobs API won't guarantee scheduling the same number of physical
- // threads according to that.
-
- if (threads_count == 0) {
- threads_count = std::max(1, base::SysInfo::NumberOfProcessors());
- }
-
- // Cap to `kMaxNumWorkItems` that avoids too much scheduling overhead.
- threads_count = std::min(threads_count, kMaxNumWorkItems);
- CHECK_GT(threads_count, 0u);
-
- struct pthreadpool* threadpool = pthreadpool_allocate(threads_count);
- if (threadpool == nullptr) {
- return nullptr;
- }
-
- threadpool->threads_count = fxdiv_init_size_t(threads_count);
- for (size_t tid = 0; tid < threads_count; tid++) {
- threadpool->threads[tid].thread_number = tid;
- threadpool->threads[tid].threadpool = threadpool;
- }
-
- return threadpool;
-}
-
-// The `threadpool` struct is accessed by this method without holding a lock.
-// The caller should ensure accessing a `threadpool` struct from the same
-// sequence that inherently provides thread-safety.
-PTHREADPOOL_INTERNAL void pthreadpool_parallelize(
- struct pthreadpool* threadpool,
- thread_function_t thread_function,
- const void* params,
- size_t params_size,
- void* task,
- void* context,
- size_t linear_range,
- uint32_t flags) {
- CHECK(threadpool);
- CHECK(thread_function);
- CHECK(task);
- CHECK_GT(linear_range, 1);
-
- // Setup global arguments.
- pthreadpool_store_relaxed_void_p(&threadpool->thread_function,
- (void*)thread_function);
- pthreadpool_store_relaxed_void_p(&threadpool->task, task);
- pthreadpool_store_relaxed_void_p(&threadpool->argument, context);
- pthreadpool_store_relaxed_uint32_t(&threadpool->flags, flags);
-
- const struct fxdiv_divisor_size_t threads_count = threadpool->threads_count;
-
- if (params_size != 0) {
- memcpy(&threadpool->params, params, params_size);
- }
-
- // Spread the work between threads.
- const struct fxdiv_result_size_t range_params =
- fxdiv_divide_size_t(linear_range, threads_count);
- size_t range_start = 0;
- for (size_t tid = 0; tid < threads_count.value; tid++) {
- struct thread_info* thread = &threadpool->threads[tid];
- // Besides taking `quotient` items, each of the first `remainder` threads
- // also takes one extra item if the `remainder` is not 0.
- const size_t range_length =
- range_params.quotient + (tid < range_params.remainder ? 1 : 0);
- const size_t range_end = range_start + range_length;
- pthreadpool_store_relaxed_size_t(&thread->range_start, range_start);
- pthreadpool_store_relaxed_size_t(&thread->range_end, range_end);
- pthreadpool_store_relaxed_size_t(&thread->range_length, range_length);
-
- // The next subrange starts where the previous ended.
- range_start = range_end;
- }
-
- // Request ThreadPool workers to process `threads_count.value` number of work
- // items in parallel.
- auto job = std::make_unique<PthreadPoolJob>(threadpool, threads_count.value);
- auto handle = base::PostJob(
- FROM_HERE, {},
- base::BindRepeating(&PthreadPoolJob::Run, base::Unretained(job.get())),
- base::BindRepeating(&PthreadPoolJob::GetMaxConcurrency,
- base::Unretained(job.get())));
- handle.Join();
-}
-
-void pthreadpool_destroy(struct pthreadpool* threadpool) {
- if (threadpool != nullptr) {
- // Release resources.
- pthreadpool_deallocate(threadpool);
- }
-}
diff --git a/third_party/pthreadpool/chromium/pthreadpool_unittests.cc b/third_party/pthreadpool/chromium/pthreadpool_unittests.cc
deleted file mode 100644
index c67c9b3..0000000
--- a/third_party/pthreadpool/chromium/pthreadpool_unittests.cc
+++ /dev/null
@@ -1,205 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <pthreadpool.h>
-
-#include "base/test/task_environment.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-typedef std::unique_ptr<pthreadpool, decltype(&pthreadpool_destroy)>
- auto_pthreadpool_t;
-
-TEST(CreateAndDestroy, NullThreadPool) {
- pthreadpool* threadpool = nullptr;
- pthreadpool_destroy(threadpool);
-}
-
-TEST(CreateAndDestroy, SingleThreadPool) {
- pthreadpool* threadpool = pthreadpool_create(1);
- ASSERT_TRUE(threadpool);
- pthreadpool_destroy(threadpool);
-}
-
-TEST(CreateAndDestroy, MultiThreadPool) {
- pthreadpool* threadpool = pthreadpool_create(0);
- ASSERT_TRUE(threadpool);
- pthreadpool_destroy(threadpool);
-}
-
-struct ElementWiseAdd1DTester {
- struct pthreadpool* threadpool;
- size_t size;
- std::vector<float> lhs;
- std::vector<float> rhs;
- std::vector<float> sum;
-
- static void Compute(void* context, size_t i) {
- ElementWiseAdd1DTester* tester =
- static_cast<ElementWiseAdd1DTester*>(context);
- EXPECT_LT(i, tester->size);
- tester->sum[i] = tester->lhs[i] + tester->rhs[i];
- }
-
- void Run(uint32_t flags = 0) {
- pthreadpool_parallelize_1d(threadpool,
- reinterpret_cast<pthreadpool_task_1d_t>(Compute),
- static_cast<void*>(this), size, flags);
- }
-};
-
-TEST(ElementWiseAdd1D, SingleThreadPool) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(1), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kSize = 100;
- ElementWiseAdd1DTester tester{.threadpool = threadpool.get(),
- .size = kSize,
- .lhs = std::vector<float>(kSize, 1.0),
- .rhs = std::vector<float>(kSize, 2.0),
- .sum = std::vector<float>(kSize, 0.0)};
- tester.Run();
-
- for (size_t i = 0; i < kSize; i++) {
- EXPECT_EQ(tester.sum[i], tester.lhs[i] + tester.rhs[i]);
- }
-}
-
-TEST(ElementWiseAdd1D, MultiThreadPool) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(0), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kSize = 200;
- ElementWiseAdd1DTester tester{.threadpool = threadpool.get(),
- .size = kSize,
- .lhs = std::vector<float>(kSize, 1.0),
- .rhs = std::vector<float>(kSize, 2.0),
- .sum = std::vector<float>(kSize, 0.0)};
- tester.Run();
-
- for (size_t i = 0; i < kSize; i++) {
- EXPECT_EQ(tester.sum[i], tester.lhs[i] + tester.rhs[i]);
- }
-}
-
-TEST(ElementWiseAdd1D, WithDisableDenormalsFlag) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(0), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kSize = 300;
- ElementWiseAdd1DTester tester{.threadpool = threadpool.get(),
- .size = kSize,
- .lhs = std::vector<float>(kSize, 1.0),
- .rhs = std::vector<float>(kSize, 2.0),
- .sum = std::vector<float>(kSize, 0.0)};
- tester.Run(PTHREADPOOL_FLAG_DISABLE_DENORMALS);
-
- for (size_t i = 0; i < kSize; i++) {
- EXPECT_EQ(tester.sum[i], tester.lhs[i] + tester.rhs[i]);
- }
-}
-
-struct ElementWiseAdd2DTester {
- struct pthreadpool* threadpool;
- size_t width;
- size_t height;
- std::vector<float> lhs;
- std::vector<float> rhs;
- std::vector<float> sum;
-
- static void Compute(void* context, size_t i, size_t j) {
- ElementWiseAdd2DTester* tester =
- static_cast<ElementWiseAdd2DTester*>(context);
- EXPECT_LT(i, tester->width);
- EXPECT_LT(i, tester->height);
- const size_t offset = i * tester->height + j;
- tester->sum[offset] = tester->lhs[offset] + tester->rhs[offset];
- }
-
- void Run(uint32_t flags = 0) {
- pthreadpool_parallelize_2d(threadpool,
- reinterpret_cast<pthreadpool_task_2d_t>(Compute),
- static_cast<void*>(this), width, height, flags);
- }
-};
-
-TEST(ElementWiseAdd2D, SingleThreadPool) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(1), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kWidth = 10;
- const size_t kHeight = 10;
- ElementWiseAdd2DTester tester{
- .threadpool = threadpool.get(),
- .width = kWidth,
- .height = kHeight,
- .lhs = std::vector<float>(kWidth * kHeight, 1.0),
- .rhs = std::vector<float>(kWidth * kHeight, 2.0),
- .sum = std::vector<float>(kWidth * kHeight, 0.0)};
- tester.Run();
-
- for (size_t i = 0; i < kWidth; i++) {
- for (size_t j = 0; j < kHeight; j++) {
- const size_t index = i * kHeight + j;
- EXPECT_EQ(tester.sum[index], tester.lhs[index] + tester.rhs[index]);
- }
- }
-}
-
-TEST(ElementWiseAdd2D, MultiThreadPool) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(0), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kWidth = 20;
- const size_t kHeight = 20;
- ElementWiseAdd2DTester tester{
- .threadpool = threadpool.get(),
- .width = kWidth,
- .height = kHeight,
- .lhs = std::vector<float>(kWidth * kHeight, 1.0),
- .rhs = std::vector<float>(kWidth * kHeight, 2.0),
- .sum = std::vector<float>(kWidth * kHeight, 0.0)};
- tester.Run();
-
- for (size_t i = 0; i < kWidth; i++) {
- for (size_t j = 0; j < kHeight; j++) {
- const size_t index = i * kHeight + j;
- EXPECT_EQ(tester.sum[index], tester.lhs[index] + tester.rhs[index]);
- }
- }
-}
-
-TEST(ElementWiseAdd2D, WithDisableDenormalsFlag) {
- base::test::TaskEnvironment task_environment;
-
- auto_pthreadpool_t threadpool(pthreadpool_create(0), pthreadpool_destroy);
- ASSERT_TRUE(threadpool.get());
-
- const size_t kWidth = 30;
- const size_t kHeight = 30;
- ElementWiseAdd2DTester tester{
- .threadpool = threadpool.get(),
- .width = kWidth,
- .height = kHeight,
- .lhs = std::vector<float>(kWidth * kHeight, 1.0),
- .rhs = std::vector<float>(kWidth * kHeight, 2.0),
- .sum = std::vector<float>(kWidth * kHeight, 0.0)};
- tester.Run(PTHREADPOOL_FLAG_DISABLE_DENORMALS);
-
- for (size_t i = 0; i < kWidth; i++) {
- for (size_t j = 0; j < kHeight; j++) {
- const size_t index = i * kHeight + j;
- EXPECT_EQ(tester.sum[index], tester.lhs[index] + tester.rhs[index]);
- }
- }
-}