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

Metal fill kernel #1501

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Metal fill kernel #1501

wants to merge 13 commits into from

Conversation

ivarflakstad
Copy link
Member

Still uses blit command encoder for zeroes and all u8 values.

@ivarflakstad ivarflakstad requested a review from Narsil December 29, 2023 15:05
@ivarflakstad ivarflakstad self-assigned this Dec 29, 2023
@Narsil
Copy link
Collaborator

Narsil commented Dec 29, 2023

Is there any benefit to using a CPU alloc and simply doing a memcpy ? Do you have benchmarks for it ?

Also keep the blit for zeros all the way. Remove the trait follow the rest of the crates convention.
Don't add any dependencies, they are not necessary.

@ivarflakstad
Copy link
Member Author

ivarflakstad commented Dec 30, 2023

It's a tiny bit faster, yeah 😉

fill_metal_u8/iter      time:   [101.33 µs 101.64 µs 101.98 µs]
                        thrpt:  [153.22 GiB/s 153.73 GiB/s 154.20 GiB/s]
                 change:
                        time:   [-96.183% -96.117% -96.019%] (p = 0.00 < 0.05)
                        thrpt:  [+2411.8% +2475.3% +2520.1%]

fill_metal_f32/iter     time:   [409.20 µs 437.94 µs 467.82 µs]
                        thrpt:  [133.60 GiB/s 142.71 GiB/s 152.74 GiB/s]
                 change:
                        time:   [-97.242% -97.113% -96.969%] (p = 0.00 < 0.05)
                        thrpt:  [+3199.1% +3364.0% +3525.2%]
                        Performance has improved.

Also keep the blit for zeros all the way.

That's what I'm doing 👍

@ivarflakstad
Copy link
Member Author

Don't add any dependencies, they are not necessary.

If we want to be able to encode f16 and bf16 values into the kernel we kinda need it.
Alternatively we could send in the kernel name and the bits as u16 I guess?

Copy link
Collaborator

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

LGTM

@ivarflakstad ivarflakstad force-pushed the ivarflakstad/metal-fill branch from 49ff588 to ceaf7f1 Compare January 22, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants