Skip to content

[pytorch] remove pthreadpool dependency in aten/CMake#25894

Closed
ljk53 wants to merge 2 commits intogh/ljk53/38/basefrom
gh/ljk53/38/head
Closed

[pytorch] remove pthreadpool dependency in aten/CMake#25894
ljk53 wants to merge 2 commits intogh/ljk53/38/basefrom
gh/ljk53/38/head

Conversation

@ljk53
Copy link
Contributor

@ljk53 ljk53 commented Sep 10, 2019

Stack from ghstack:

Summary:
NNPack/QNNPack both depend on a third-party library "pthreadpool". There
are two versions of "pthreadpool" implementation, one is the default
implementation under third-party/pthreadpool, the other is caffe2 custom
implementation under caffe2/utils/threadpool. Both implementations share
the same interface (as defined by pthreadpool headers).

Usually only one version of pthreadpool should be linked into libtorch.
If QNNPACK_CUSTOM_THREADPOOL/NNPACK_CUSTOM_THREADPOOL are set to true,
then QNNPack/NNPack will not link third-party/pthreadpool - they will
expect the caller (libtorch) to link correct version of pthreadpool;
otherwise they will bring in the default pthreadpool implementation.

Looks like libtorch cmake already sets both macros to true in
Dependencies.cmake and External/nnpack.cmake. And currently libtorch
mobile build includes the caffe2/utils/threadpool pthreadpool
implementation. So it shouldn't try to explicitly link default
pthreadpool target in aten/CMake in this AT_NNPACK_ENABLED section.

Test Plan:

  • Before this diff, libtorch.so links libpthreadpool.a:
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libpthreadpool.a
lib/libcpuinfo.a lib/libclog.a -llog -latomic -lm
  • After this diff, libtorch.so no longer links libpthreadpool.a:
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libcpuinfo.a
lib/libclog.a -llog -latomic -lm
  • Tried the following combinations to make sure things work as expected:
  • remove caffe2/utils/threadpool, remove libpthreadpool: link error;
  • keep caffe2/utils/threadpool, remove libpthreadpool: no link error;
  • remove caffe2/utils/threadpool, add back libpthreadpool: no link error;

Pull Request resolved: #25894

Differential Revision: D17279723

Summary:
NNPack/QNNPack both depend on a third-party library "pthreadpool". There
are two versions of "pthreadpool" implementation, one is the default
implementation under third-party/pthreadpool, the other is caffe2 custom
implementation under caffe2/utils/threadpool. Both implementations share
the same interface (as defined by pthreadpool headers).

Usually only one version of pthreadpool should be linked into libtorch.
If QNNPACK_CUSTOM_THREADPOOL/NNPACK_CUSTOM_THREADPOOL are set to true,
then QNNPack/NNPack will not link third-party/pthreadpool - they will
expect the caller (libtorch) to link correct version of pthreadpool;
otherwise they will bring in the default pthreadpool implementation.

Looks like libtorch cmake already sets both macros to true in
Dependencies.cmake and External/nnpack.cmake. And currently libtorch
mobile build includes the caffe2/utils/threadpool pthreadpool
implementation. So it shouldn't try to explicitly link default
pthreadpool target in aten/CMake in this AT_NNPACK_ENABLED section.

Test Plan:
- Before this diff, libtorch.so links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libpthreadpool.a
lib/libcpuinfo.a lib/libclog.a -llog -latomic -lm
```

- After this diff, libtorch.so no longer links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libcpuinfo.a
lib/libclog.a -llog -latomic -lm
```

- Tried the following combinations to make sure things work as expected:
* remove caffe2/utils/threadpool, remove libpthreadpool: link error;
* keep caffe2/utils/threadpool, remove libpthreadpool: no link error;
* remove caffe2/utils/threadpool, add back libpthreadpool: no link error;
@pytorchbot pytorchbot added module: build Build system issues module: internals Related to internal abstractions in c10 and ATen labels Sep 10, 2019
ljk53 added a commit that referenced this pull request Sep 10, 2019
Summary:
NNPack/QNNPack both depend on a third-party library "pthreadpool". There
are two versions of "pthreadpool" implementation, one is the default
implementation under third-party/pthreadpool, the other is caffe2 custom
implementation under caffe2/utils/threadpool. Both implementations share
the same interface (as defined by pthreadpool headers).

Usually only one version of pthreadpool should be linked into libtorch.
If QNNPACK_CUSTOM_THREADPOOL/NNPACK_CUSTOM_THREADPOOL are set to true,
then QNNPack/NNPack will not link third-party/pthreadpool - they will
expect the caller (libtorch) to link correct version of pthreadpool;
otherwise they will bring in the default pthreadpool implementation.

Looks like libtorch cmake already sets both macros to true in
Dependencies.cmake and External/nnpack.cmake. And currently libtorch
mobile build includes the caffe2/utils/threadpool pthreadpool
implementation. So it shouldn't try to explicitly link default
pthreadpool target in aten/CMake in this AT_NNPACK_ENABLED section.

Test Plan:
- Before this diff, libtorch.so links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libpthreadpool.a
lib/libcpuinfo.a lib/libclog.a -llog -latomic -lm
```

- After this diff, libtorch.so no longer links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libcpuinfo.a
lib/libclog.a -llog -latomic -lm
```

- Tried the following combinations to make sure things work as expected:
* remove caffe2/utils/threadpool, remove libpthreadpool: link error;
* keep caffe2/utils/threadpool, remove libpthreadpool: no link error;
* remove caffe2/utils/threadpool, add back libpthreadpool: no link error;

ghstack-source-id: 96b4a62
Pull Request resolved: #25894
Summary:
NNPack/QNNPack both depend on a third-party library "pthreadpool". There
are two versions of "pthreadpool" implementation, one is the default
implementation under third-party/pthreadpool, the other is caffe2 custom
implementation under caffe2/utils/threadpool. Both implementations share
the same interface (as defined by pthreadpool headers).

Usually only one version of pthreadpool should be linked into libtorch.
If QNNPACK_CUSTOM_THREADPOOL/NNPACK_CUSTOM_THREADPOOL are set to true,
then QNNPack/NNPack will not link third-party/pthreadpool - they will
expect the caller (libtorch) to link correct version of pthreadpool;
otherwise they will bring in the default pthreadpool implementation.

Looks like libtorch cmake already sets both macros to true in
Dependencies.cmake and External/nnpack.cmake. And currently libtorch
mobile build includes the caffe2/utils/threadpool pthreadpool
implementation. So it shouldn't try to explicitly link default
pthreadpool target in aten/CMake in this AT_NNPACK_ENABLED section.

Test Plan:
- Before this diff, libtorch.so links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libpthreadpool.a
lib/libcpuinfo.a lib/libclog.a -llog -latomic -lm
```

- After this diff, libtorch.so no longer links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libcpuinfo.a
lib/libclog.a -llog -latomic -lm
```

- Tried the following combinations to make sure things work as expected:
* remove caffe2/utils/threadpool, remove libpthreadpool: link error;
* keep caffe2/utils/threadpool, remove libpthreadpool: no link error;
* remove caffe2/utils/threadpool, add back libpthreadpool: no link error;

Pull Request resolved: #25894

Differential Revision: [D17279723](https://our.internmc.facebook.com/intern/diff/D17279723)
zdevito pushed a commit to zdevito/ATen that referenced this pull request Sep 10, 2019
Summary:
Pull Request resolved: pytorch/pytorch#25894

NNPack/QNNPack both depend on a third-party library "pthreadpool". There
are two versions of "pthreadpool" implementation, one is the default
implementation under third-party/pthreadpool, the other is caffe2 custom
implementation under caffe2/utils/threadpool. Both implementations share
the same interface (as defined by pthreadpool headers).

Usually only one version of pthreadpool should be linked into libtorch.
If QNNPACK_CUSTOM_THREADPOOL/NNPACK_CUSTOM_THREADPOOL are set to true,
then QNNPack/NNPack will not link third-party/pthreadpool - they will
expect the caller (libtorch) to link correct version of pthreadpool;
otherwise they will bring in the default pthreadpool implementation.

Looks like libtorch cmake already sets both macros to true in
Dependencies.cmake and External/nnpack.cmake. And currently libtorch
mobile build includes the caffe2/utils/threadpool pthreadpool
implementation. So it shouldn't try to explicitly link default
pthreadpool target in aten/CMake in this AT_NNPACK_ENABLED section.

Test Plan:
- Before this diff, libtorch.so links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libpthreadpool.a
lib/libcpuinfo.a lib/libclog.a -llog -latomic -lm
```

- After this diff, libtorch.so no longer links libpthreadpool.a:
```
LINK_LIBRARIES = lib/libc10.so lib/libqnnpack.a lib/libnnpack.a
lib/libcpuinfo.a -llog -ldl -lm lib/libnnpack.a lib/libcpuinfo.a
lib/libclog.a -llog -latomic -lm
```

- Tried the following combinations to make sure things work as expected:
* remove caffe2/utils/threadpool, remove libpthreadpool: link error;
* keep caffe2/utils/threadpool, remove libpthreadpool: no link error;
* remove caffe2/utils/threadpool, add back libpthreadpool: no link error;

Pull Request resolved: pytorch/pytorch#25894

Reviewed By: dreiss

Differential Revision: D17279723

Pulled By: ljk53

fbshipit-source-id: ae5aa7ca7283a276ecf1e2140bad0a6af3efdb3a
@facebook-github-bot
Copy link
Contributor

@ljk53 merged this pull request in 4bd9ddb.

ljk53 added a commit to ljk53/pytorch that referenced this pull request Sep 17, 2019
@facebook-github-bot facebook-github-bot deleted the gh/ljk53/38/head branch October 28, 2019 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: build Build system issues module: internals Related to internal abstractions in c10 and ATen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants