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

Run clang-format #462

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llamafile/explain_a_warp_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ constexpr int TN = 4;
#define maxThreadsPerMultiProcessor 2048

#define MIN(X, Y) ((Y) > (X) ? (X) : (Y))
#define ROUNDUP(X, K) (((X) + (K) - 1) & -(K))
#define ROUNDUP(X, K) (((X) + (K)-1) & -(K))

int main(int argc, char *argv[]) {

Expand Down
8 changes: 4 additions & 4 deletions llamafile/extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "llamafile.h"
#include "llamafile/log.h"
#include <cosmo.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "llamafile.h"
#include "llamafile/log.h"
#include <unistd.h>

/**
* Returns true if `zip` was successfully copied to `to`.
Expand Down
14 changes: 7 additions & 7 deletions llamafile/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "llamafile.h"
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h>

/**
* Displays man page.
Expand Down Expand Up @@ -60,12 +60,12 @@ void llamafile_help(const char *path) {
int j = 0;
for (int i = 0; i < size; ++i) {
switch (text[i]) {
case '\b':
--j;
break;
default:
text[j++] = text[i];
break;
case '\b':
--j;
break;
default:
text[j++] = text[i];
break;
}
}
text[j] = 0;
Expand Down
4 changes: 2 additions & 2 deletions llamafile/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

#define MIN(X, Y) ((Y) > (X) ? (X) : (Y))
#define MAX(X, Y) ((Y) < (X) ? (X) : (Y))
#define CEIL_DIV(M, N) (((M) + (N) - 1) / (N))
#define ROUNDUP(X, K) (((X) + (K) - 1) & -(K))
#define CEIL_DIV(M, N) (((M) + (N)-1) / (N))
#define ROUNDUP(X, K) (((X) + (K)-1) & -(K))
#define ARRAYLEN(A) ((sizeof(A) / sizeof(*(A))) / ((unsigned)!(sizeof(A) % sizeof(*(A)))))
20 changes: 10 additions & 10 deletions llamafile/sgemm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ bool iqk_mul_mat(long, long, long, int, const void *, const void *, float *, lon
bool iqk_mul_mat_zen4(long, long, long, int, const void *, const void *, float *, long, int, int);
bool iqk_mul_mat_arm82(long, long, long, int, const void *, const void *, float *, long, int, int);

bool iqk_mul_mat_moe(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int);
bool iqk_mul_mat_moe_zen4(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int);
bool iqk_mul_mat_moe_arm82(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int);
bool iqk_mul_mat_moe_unsupported(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int);
bool iqk_mul_mat_moe(long, long, long, int, int, const void *, const void *, float *, long, long,
const void *, int, int);
bool iqk_mul_mat_moe_zen4(long, long, long, int, int, const void *, const void *, float *, long,
long, const void *, int, int);
bool iqk_mul_mat_moe_arm82(long, long, long, int, int, const void *, const void *, float *, long,
long, const void *, int, int);
bool iqk_mul_mat_moe_unsupported(long, long, long, int, int, const void *, const void *, float *,
long, long, const void *, int, int);

bool llamafile_sgemm(long, long, long, const void *, long, const void *, long, void *, long, int,
int, int, int, int, int, int);
Expand Down Expand Up @@ -73,8 +73,8 @@ bool llamafile_mixmul_arm80(const struct ggml_compute_params *, const struct ggm
bool llamafile_mixmul_arm82(const struct ggml_compute_params *, const struct ggml_tensor *,
const struct ggml_tensor *, const struct ggml_tensor *,
struct ggml_tensor *);
bool llamafile_mixmul_iqk(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int);
bool llamafile_mixmul_iqk(long, long, long, int, int, const void *, const void *, float *, long,
long, const void *, int, int);

#ifdef __cplusplus
}
Expand Down
48 changes: 32 additions & 16 deletions llamafile/tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void show_cuda_device(int);
void show_cuda_devices();
void test_matmul(std::function<void(int, int, int, int, float, float)>);

template <typename T> struct cuda_memory {
template <typename T>
struct cuda_memory {
const size_t size;
T *const p;
explicit cuda_memory(int len)
Expand All @@ -97,7 +98,8 @@ template <typename T> struct cuda_memory {
}
};

template <typename T> ErrorReport diff(int m, int n, const T *Wan, int lda, const T *Got, int ldb) {
template <typename T>
ErrorReport diff(int m, int n, const T *Wan, int lda, const T *Got, int ldb) {
double sad = 0;
double worsta = 0;
double worstb = 0;
Expand Down Expand Up @@ -301,41 +303,55 @@ void check(double tol, //

[[noreturn]] void cuda_die(const char *, const char *, const char *, int, const char *);

template <typename T> struct cublas_data_type;
template <> struct cublas_data_type<half> {
template <typename T>
struct cublas_data_type;
template <>
struct cublas_data_type<half> {
static constexpr cudaDataType_t id = CUDA_R_16F;
};
template <> struct cublas_data_type<float> {
template <>
struct cublas_data_type<float> {
static constexpr cudaDataType_t id = CUDA_R_32F;
};
template <> struct cublas_data_type<double> {
template <>
struct cublas_data_type<double> {
static constexpr cudaDataType_t id = CUDA_R_64F;
};

template <typename T> struct cublas_compute_type;
template <> struct cublas_compute_type<half> {
template <typename T>
struct cublas_compute_type;
template <>
struct cublas_compute_type<half> {
static constexpr cublasComputeType_t id = CUBLAS_COMPUTE_16F;
};
template <> struct cublas_compute_type<float> {
template <>
struct cublas_compute_type<float> {
static constexpr cublasComputeType_t id = CUBLAS_COMPUTE_32F;
};
template <> struct cublas_compute_type<double> {
template <>
struct cublas_compute_type<double> {
static constexpr cublasComputeType_t id = CUBLAS_COMPUTE_64F;
};

template <typename T> struct tinyblas_data_type;
template <> struct tinyblas_data_type<half> {
template <typename T>
struct tinyblas_data_type;
template <>
struct tinyblas_data_type<half> {
static constexpr tinyblasDataType_t id = TINYBLAS_R_16F;
};
template <> struct tinyblas_data_type<float> {
template <>
struct tinyblas_data_type<float> {
static constexpr tinyblasDataType_t id = TINYBLAS_R_32F;
};

template <typename T> struct tinyblas_compute_type;
template <> struct tinyblas_compute_type<half> {
template <typename T>
struct tinyblas_compute_type;
template <>
struct tinyblas_compute_type<half> {
static constexpr tinyblasComputeType_t id = TINYBLAS_COMPUTE_16F;
};
template <> struct tinyblas_compute_type<float> {
template <>
struct tinyblas_compute_type<float> {
static constexpr tinyblasComputeType_t id = TINYBLAS_COMPUTE_32F;
};

Expand Down
4 changes: 2 additions & 2 deletions llamafile/tinyblas_cpu_unsupported.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool llamafile_mixmul_unsupported(const struct ggml_compute_params *params,
return false;
}

bool iqk_mul_mat_moe_unsupported(long, long, long, int, int, const void *, const void *,
float *, long, long, const void *, int, int) {
bool iqk_mul_mat_moe_unsupported(long, long, long, int, int, const void *, const void *, float *,
long, long, const void *, int, int) {
return false;
}
2 changes: 1 addition & 1 deletion llamafile/zipalign.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define CHUNK 2097152

#define Min(a, b) ((a) < (b) ? (a) : (b))
#define DOS_DATE(YEAR, MONTH_IDX1, DAY_IDX1) (((YEAR) - 1980) << 9 | (MONTH_IDX1) << 5 | (DAY_IDX1))
#define DOS_DATE(YEAR, MONTH_IDX1, DAY_IDX1) (((YEAR)-1980) << 9 | (MONTH_IDX1) << 5 | (DAY_IDX1))
#define DOS_TIME(HOUR, MINUTE, SECOND) ((HOUR) << 11 | (MINUTE) << 5 | (SECOND) >> 1)

static const char *prog;
Expand Down