Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging the HAL rewrite branch to main #4571

Merged
merged 66 commits into from
Jan 29, 2021
Merged

Merging the HAL rewrite branch to main #4571

merged 66 commits into from
Jan 29, 2021

Conversation

benvanik
Copy link
Collaborator

@benvanik benvanik commented Jan 21, 2021

Major branch features:

  • a switcheroo of the entire HAL implementation from C & C++ to mostly just C
  • new CPU iree/hal/local/ backend replacing host supporting multithreading and pluggable executable loaders
  • a new public C API for building HAL backends (allowing out-of-tree backends)
  • VMLA moved to iree/modules/vmla/, enabling the ability for host code to use it too
  • refreshed iree/hal/cts/ using the public C APIs instead of the internal C++ ones

NOTE: this removes the experimental metal backend (to be revived in #4370).
NOTE: this disables hal.executable linking for vmla/dylib pending a fix in #4536 (linking had prior to this been relying on those two backends to not using executable layouts and now they do). Will be fixed up soon.

First major milestone of #4369.
Fixes #4391.
Fixes #4472.

@benvanik benvanik added runtime Relating to the IREE runtime library hal/vulkan Runtime Vulkan GPU HAL backend hal/metal Runtime Apple Metal HAL backend runtime/api IREE's public C runtime API and iree-run-module hal/cpu Runtime Host/CPU-based HAL backend hal/api IREE's public C hardware abstraction layer API labels Jan 21, 2021
@benvanik benvanik added this to the 2021Q1 Core milestone Jan 21, 2021
@benvanik benvanik changed the title Staging hal rewrite Merging the HAL rewrite branch to main Jan 21, 2021
@google-cla google-cla bot added the cla: yes label Jan 21, 2021
@GMNGeoffrey
Copy link
Contributor

This is still marked as a draft and builds are failing. Do you want me to start reviewing now or wait?

@benvanik
Copy link
Collaborator Author

Can wait - leaving as draft until I get the CIs passing. All of these have been reviewed by @ScottTodd as they were going into the branch, so the big thing to look for here is whether this messes you up in any way that the CI's don't check :)

@benvanik benvanik force-pushed the staging-hal-rewrite branch 16 times, most recently from 1c48866 to 4ffb506 Compare January 26, 2021 16:49
benvanik and others added 23 commits January 28, 2021 19:59
This would cause all kind of badness when multiple executables shared
the same hal.interface bindings but had differing push constants.
The max size on the stack is 3KB, which is fine for something transient
like this that is only used for construction of the executor.
They were all implemented using mapping anyway and this way we only have
that code once and make the restriction that buffers be mappable part of
their usage uniformly.
* Use `IREE_RESTRICT` for older MSVC versions.
* Update iree-run-module-vulkan-gui-main.cc
* Include <atomic> for std::atomic use in GetTempFile.

Tested CMake build of `all` (vmla+vulkan only) on my Windows machine, with samples and Vulkan enabled.
This case is not yet exercised from our code but I'll be fixing it ASAP
anyway.
Unfortunately not caught by any of our open source builds.

---

```
typedef size_t iree_host_size_t;
typedef uint64_t iree_device_size_t;
```

`iree_device_size_t` should use `% " PRIu64 "` instead of `%zu`

---

`ppoll` is available since Android API 21 (or 28 for `ppoll64`? seeing conflicting docs)

---

`iree_hal_buffer_calculate_range` outputs into a `iree_device_size_t`, which isn't directly compatible with

```
typedef struct {
  uint8_t* data;
  iree_host_size_t data_length;
} iree_byte_span_t;
```
Possibly: hard to test without 128 cores. I did try turning the topology
mask into a uint8_t on my 64 core machine and it passed --config=ubsan.
The wait functionality isn't done yet.
The classic condvar shutdown notification race.
Fallback to 1 thread for when cpuinfo_get_cores_count()==0 and core
count when cpuinfo_get_l2_caches_count()==0.
Issue #4654 is tracking making this better.
Copy link
Member

@ScottTodd ScottTodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Builds/tests are all passing
  • Code is reviewed
  • google branch should be stable soon

Nearly ready for merge.

@ScottTodd
Copy link
Member

  • Builds/tests are all passing
  • Code is reviewed
  • google branch should be stable soon

Nearly ready for merge.

Branches are stable. Ready to merge :D

@benvanik benvanik merged commit 8d74bfa into main Jan 29, 2021
@benvanik benvanik deleted the staging-hal-rewrite branch January 29, 2021 18:05
@ScottTodd ScottTodd mentioned this pull request Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hal/api IREE's public C hardware abstraction layer API hal/cpu Runtime Host/CPU-based HAL backend hal/metal Runtime Apple Metal HAL backend hal/vulkan Runtime Vulkan GPU HAL backend runtime/api IREE's public C runtime API and iree-run-module runtime Relating to the IREE runtime library
Projects
None yet
4 participants