codereport / jsource

J Language Source Code. Livestream links ⬇️
https://www.youtube.com/playlist?list=PLVFrD1dmDdvfVhYLU_iKkV67X9XqCJLWe
Other
38 stars 18 forks source link

Fixed linker errors for macOS #9

Closed ahmadbeirkdar closed 3 years ago

ahmadbeirkdar commented 3 years ago

gemm_vec-ref.c was added back because of the following The following macros are located in jsrc/blis.h, bli_dgemm_128_6x4 & bli_zgemm_128_3x2 are both functions defined in jsrc/blis/gemm_vec-ref.c

#define BLIS_DGEMM_UKERNEL         bli_dgemm_128_6x4
#define BLIS_DEFAULT_MC_D          72
#define BLIS_DEFAULT_KC_D          256
#define BLIS_DEFAULT_NC_D          4080
#define BLIS_DEFAULT_MR_D          6
#define BLIS_DEFAULT_NR_D          4

#define BLIS_ZGEMM_UKERNEL         bli_zgemm_128_3x2
#define BLIS_DEFAULT_MC_Z          72
#define BLIS_DEFAULT_KC_Z          256
#define BLIS_DEFAULT_NC_Z          4080
#define BLIS_DEFAULT_MR_Z          3
#define BLIS_DEFAULT_NR_Z          2

Which are also defined to in blis.h

#define dgemm_micro_kernel BLIS_DGEMM_UKERNEL
#define zgemm_micro_kernel BLIS_ZGEMM_UKERNEL
#define dgemm2_micro_kernel BLIS_DGEMM_UKERNEL
#define zgemm2_micro_kernel BLIS_ZGEMM_UKERNEL

And then called in jsrc/gemm.c, line 244 - 259

if (mr==MR && nr==NR) {
    ((hwfma)?dgemm2_micro_kernel:dgemm_micro_kernel)(kc, &alpha, &_A[i*kc*MR], &_B[j*kc*NR],
                       &beta,
                       &C[i*MR*rs_c+j*NR*cs_c],
                       rs_c, cs_c,
                       &auxdata, 0);
} else {
    ((hwfma)?dgemm2_micro_kernel:dgemm_micro_kernel)(kc, &alpha, &_A[i*kc*MR], &_B[j*kc*NR],
                       (double*)&dzero,
                       _C, 1, MR,
                       &auxdata, 0);
    dgescal(mr, nr, beta,
            &C[i*MR*rs_c+j*NR*cs_c], rs_c, cs_c);
    dgeaxpy(mr, nr, 1.0, _C, 1, MR,
            &C[i*MR*rs_c+j*NR*cs_c], rs_c, cs_c);
}

and line 757 - 772

if (mr==MR && nr==NR) {
      ((hwfma)?zgemm2_micro_kernel:zgemm_micro_kernel)(kc, &alpha, &_A[i*kc*MR], &_B[j*kc*NR],
                         &beta,
                         &C[i*MR*rs_c+j*NR*cs_c],
                         rs_c, cs_c,
                         &auxdata, 0);
  } else {
      ((hwfma)?zgemm2_micro_kernel:zgemm_micro_kernel)(kc, &alpha, &_A[i*kc*MR], &_B[j*kc*NR],
                         (dcomplex*)&zzero,
                         _C, 1, MR,
                         &auxdata, 0);
      zgescal(mr, nr, beta,
              &C[i*MR*rs_c+j*NR*cs_c], rs_c, cs_c);
      zgeaxpy(mr, nr, zone, _C, 1, MR,
              &C[i*MR*rs_c+j*NR*cs_c], rs_c, cs_c);
  }

So the question here is, how does it compile on gcc and clang on Ubuntu. Yet on macOS both gcc and clang give linker errors.

In jsrc/jeload.cpp:

ahmadbeirkdar commented 3 years ago

Just a note I accidentally committed a change for contributing which wasn’t meant for this pull request... But I guess it wouldn’t hurt to keep it here, so I didn’t revert it

honeyspoon commented 3 years ago

works on my Mac thanks

codereport commented 3 years ago

I plan do review this on the next live stream (most likely Saturday Jan 23), and add macOS to the Travis-CI to verify it is currently failing on mac. :pray: thanks for the PR

ahmadbeirkdar commented 3 years ago

I plan do review this on the next live stream (most likely Saturday Jan 23), and add macOS to the Travis-CI to verify it is currently failing on mac. 🙏 thanks for the PR

Sounds good! Looking forward to the stream!