-
Notifications
You must be signed in to change notification settings - Fork 5k
PPC64 big-endian support #398
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
Conversation
awilfox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few nits I found while reviewing the changes.
Makefile
Outdated
| ifneq (,$(findstring POWER9,$(POWER9_M))) | ||
| CFLAGS += -mpower9-vector -DGGML_BIG_ENDIAN | ||
| CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN | ||
| endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this port will be big-endian even if run on non-Power9 systems (consider P8, P10, or any other generation), so I think this is more correct:
| ifneq (,$(findstring POWER9,$(POWER9_M))) | |
| CFLAGS += -mpower9-vector -DGGML_BIG_ENDIAN | |
| CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN | |
| endif | |
| ifneq (,$(findstring POWER9,$(POWER9_M))) | |
| CFLAGS += -mpower9-vector | |
| endif | |
| CFLAGS += -DGGML_BIG_ENDIAN | |
| CXXFLAGS += -std=c++23 -DGGML_BIG_ENDIAN |
ggml.c
Outdated
| case GGML_TYPE_F16: { | ||
| unsigned short * toswap = (unsigned short *)(node->src1->data); | ||
| for (int k = 0; k < (ggml_nbytes(node->src1) / sizeof(unsigned short)); k++) { | ||
| toswap[k] = bswap_16(toswap[k]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for using std::byteswap in whisper.cpp but not here?
whisper.cpp
Outdated
| static void read_safe(std::ifstream& fin, T& dest) { | ||
| fin.read((char*)& dest, sizeof(T)); | ||
| #if defined(GGML_BIG_ENDIAN) | ||
| if constexpr (std::endian::native == std::endian::big) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise the reason for the guard is because <bit> is guarded by it, but this seems wrong; if that's defined, it will always be BE.
What you probably want is something like #if __cplusplus >= 202110L (the revision of C++2x that added std::byteswap).
|
This is ready to merge now. @awilfox, all your comments on the draft are addressed, thanks. Maybe |
* ggml : set cache line size to 128 on POWER9 * whisper : add PPC64 big endian support
* ggml : set cache line size to 128 on POWER9 * whisper : add PPC64 big endian support
* ggml : set cache line size to 128 on POWER9 * whisper : add PPC64 big endian support
* ggml : set cache line size to 128 on POWER9 * whisper : add PPC64 big endian support
* ggml : set cache line size to 128 on POWER9 * whisper : add PPC64 big endian support
No description provided.