InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

Multithreading with TBB Module in AMD processor is significantly slower

Open
#3,591 3 comments 0 reactions 2 assignees Claimed by @dzenanz View on GitHub
type:Performance
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

This is regarding the TBB mulithreading enhancement.
While working on ITKRANSAC module I found that a locally build package (AMD system)
without TBB module support is around 10 times faster than the pip package obtained from Github repo.

The difference is the presence of TBB module.
On building the module locally with TBB support I see similar slow results.

Is there a recommended way to handle this such that the optimized way to perform multithreading is selected?

I am using MultiThreaderBase as following:
```python
itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(this->numberOfThreads);
itk::MultiThreaderBase::Pointer threader = itk::MultiThreaderBase::New();
```

As per my reading, I found that the TBB module is independent of the processor but I am getting slow results on my system.
Another observation I found is that even with a lesser number of threads I see all the CPU cores getting utilized when using the non-TBB package. And while using the TBB module I see the correct number of cores getting used.

Is there some optimization happening under the hood in AMD system?

### Description

### Impact analysis

### Expected behavior

```none
```

### Actual behavior

### Versions

### Environment
```
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

AMD Ryzen 7 5800 8-Core Processor

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 48 bits physical, 48 bits virtual
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 2
Core(s) per socket: 8
```
### Additional Information

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.