@@ -565,6 +565,53 @@ __global__ void buildKKRMatrixMultiplyKernelHip(
565565 }
566566}
567567
568+ __global__ void buildKKRMatrixMultiplyKernelHip_collinear (
569+ int *LIZlmax, int *LIZStoreIdx, int *offsets, int kkrsz, int ispin,
570+ int iie, int blkSizeTmatStore,
571+ int tmatStoreLDim, deviceDoubleComplex *devTmatStore, int nrmat_ns,
572+ deviceDoubleComplex *devBgij, deviceDoubleComplex *devM) {
573+ int ir1 = hipBlockIdx_x;
574+ int ir2 = hipBlockIdx_y;
575+ // HIP_DYNAMIC_SHARED(deviceDoubleComplex, tmat_n);
576+ deviceDoubleComplex *tmat_n;
577+ int iOffset = offsets[ir1];
578+ int jOffset = offsets[ir2];
579+ int spinOffset = kkrsz * kkrsz * ispin;
580+
581+ if (ir1 != ir2) {
582+ int lmax1 = LIZlmax[ir1];
583+ int lmax2 = LIZlmax[ir2];
584+ int kkr1 = (lmax1 + 1 ) * (lmax1 + 1 );
585+ int kkr2 = (lmax2 + 1 ) * (lmax2 + 1 );
586+ int kkr1_ns = kkr1;
587+ int kkr2_ns = kkr2;
588+
589+ tmat_n = &devTmatStore[IDX (iie * blkSizeTmatStore + spinOffset, LIZStoreIdx[ir1],
590+ tmatStoreLDim)];
591+
592+ for (int ij = hipThreadIdx_x; ij < kkr1_ns * kkr2_ns; ij += hipBlockDim_x) {
593+ int i = ij % kkr1_ns;
594+ int j = ij / kkr1_ns;
595+
596+ auto devMValue = make_hipDoubleComplex (0.0 , 0.0 );
597+ int devBgijIdx0 = IDX (iOffset, jOffset + j, nrmat_ns);
598+ int tmat_nIdx = IDX (i, 0 , kkr1_ns);
599+ for (int k = 0 ; k < kkr1_ns; k++) {
600+ // devM[IDX(iOffset + i, jOffset + j, nrmat_ns)] = devM[IDX(iOffset + i,
601+ // jOffset + j, nrmat_ns)] -
602+ devMValue = devMValue -
603+ hipCmul (tmat_n[tmat_nIdx], devBgij[k + devBgijIdx0]);
604+ /* // tmat_n[IDX(i,k,kkr1_ns)] *
605+ tmat_n[tmat_nIdx] *
606+ // devBgij[IDX(iOffset + k, jOffset + j, nrmat_ns)];
607+ devBgij[k + devBgijIdx0]; */
608+ tmat_nIdx += kkr1_ns;
609+ }
610+ devM[IDX (iOffset + i, jOffset + j, nrmat_ns)] = devMValue;
611+ }
612+ }
613+ }
614+
568615void buildKKRMatrixLMaxIdenticalHip (LSMSSystemParameters &lsms,
569616 LocalTypeInfo &local, AtomData &atom,
570617 DeviceStorage &d, DeviceAtom &devAtom,
@@ -805,11 +852,21 @@ void buildKKRMatrixLMaxIdenticalHip(LSMSSystemParameters &lsms,
805852 // note that the shared memory requiremets of the present implementation is
806853 // too large for lmax>3 buildKKRMatrixMultiplyKernelCuda<<<blocks, threads,
807854 // smSize>>>(devAtom.LIZlmax, devAtom.LIZStoreIdx, devOffsets,
808- buildKKRMatrixMultiplyKernelHip<<<blocks, threads>>>(
855+ if (lsms.n_spin_pola ==
856+ lsms.n_spin_cant ) // non polarized or spin canted
857+ {
858+ buildKKRMatrixMultiplyKernelHip<<<blocks, threads>>>(
809859 devAtom.LIZlmax , devAtom.LIZStoreIdx , devOffsets, kkrsz_ns, ispin,
810860 lsms.n_spin_pola , lsms.n_spin_cant , iie, d.getBlkSizeTmatStore (),
811861 d.getTmatStoreLDim (), (deviceDoubleComplex *)d.getDevTmatStore (),
812862 nrmat_ns, (deviceDoubleComplex *)devBgij, (deviceDoubleComplex *)devM);
863+ } else {
864+ buildKKRMatrixMultiplyKernelHip_collinear<<<blocks, threads>>>(
865+ devAtom.LIZlmax , devAtom.LIZStoreIdx , devOffsets, kkrsz_ns, ispin,
866+ iie, d.getBlkSizeTmatStore (),
867+ d.getTmatStoreLDim (), (deviceDoubleComplex *)d.getDevTmatStore (),
868+ nrmat_ns, (deviceDoubleComplex *)devBgij, (deviceDoubleComplex *)devM);
869+ }
813870 /*
814871 // loop over the LIZ blocks
815872 for(int ir1 = 0; ir1 < devAtom.numLIZ; ir1++)
@@ -946,11 +1003,21 @@ void buildKKRMatrixLMaxDifferentHip(LSMSSystemParameters &lsms,
9461003 // note that the shared memory requiremets of the present implementation is
9471004 // too large for lmax>3 buildKKRMatrixMultiplyKernelCuda<<<blocks, threads,
9481005 // smSize>>>(devAtom.LIZlmax, devAtom.LIZStoreIdx, devOffsets,
949- buildKKRMatrixMultiplyKernelHip<<<blocks, threads>>>(
1006+ if (lsms.n_spin_pola ==
1007+ lsms.n_spin_cant ) // non polarized or spin canted
1008+ {
1009+ buildKKRMatrixMultiplyKernelHip<<<blocks, threads>>>(
9501010 devAtom.LIZlmax , devAtom.LIZStoreIdx , devOffsets, kkrsz_ns, ispin,
9511011 lsms.n_spin_pola , lsms.n_spin_cant , iie, d.getBlkSizeTmatStore (),
9521012 d.getTmatStoreLDim (), (deviceDoubleComplex *)d.getDevTmatStore (),
9531013 nrmat_ns, (deviceDoubleComplex *)devBgij, (deviceDoubleComplex *)devM);
1014+ } else {
1015+ buildKKRMatrixMultiplyKernelHip<<<blocks, threads>>>(
1016+ devAtom.LIZlmax , devAtom.LIZStoreIdx , devOffsets, kkrsz_ns, ispin,
1017+ iie, d.getBlkSizeTmatStore (),
1018+ d.getTmatStoreLDim (), (deviceDoubleComplex *)d.getDevTmatStore (),
1019+ nrmat_ns, (deviceDoubleComplex *)devBgij, (deviceDoubleComplex *)devM);
1020+ }
9541021 /*
9551022 // loop over the LIZ blocks
9561023 for(int ir1 = 0; ir1 < devAtom.numLIZ; ir1++)
0 commit comments