Multiple instances of atomic system in single GPU run - ProkopHapala/FireCore GitHub Wiki

Kernells

  • use 2D krenel
int nsystem = ;
int natom   = nnode+ncap; 
int npi     = nnode;
int nvec    = natom + npi; 

getNonBond()

    float4*  atoms,         //  [natoms]
    float4*  forces,        //  [natoms]
    float4*  REQKs,         //  [natoms]
    int4*    neighs,        //  [natoms]
    int4*    neighCell,     //  [natoms]
    const int4 nPBC,        
    const cl_Mat3 lvec,

getMMFFf4()

    // Dynamical
    float4*  apos,         // [natoms+nnode]
    float4*  fapos,        // [natoms+nnode]     
    float4*  fneigh,       // [(nnode+nnode)*4]
    // parameters
    int4*    neighs,       // [nnode]  
    float4*  REQKs,        // [natoms] 
    float4*  apars,        // [nnode]
    float4*  bLs,          // [nnode]
    float4*  bKs,          // [nnode]
    float4*  Ksp,          // [nnode]
    float4*  Kpp,          // [nnode]
    const cl_Mat3 lvec,      
    const cl_Mat3 invLvec   

updateAtomsMMFFf4()

    __global float4*  apos,         //   [natom+nnode]
    __global float4*  avel,         //   [natom+nnode] 
    __global float4*  aforce,       //   [natom+nnode] 
    __global float4*  fneigh,       //   [(natom+nnode)] 
    __global int4*    bkNeighs      //   [natom+nnode  ]

Kernells

OCL_PP::initAtomsForces()

    int initAtomsForces( int nAtoms_, int npi, int nnode, bool bMMFFsp3=false, bool bMMFFf4=false ){
        nAtoms=nAtoms_;
        int nvecs=nAtoms+npi;
        int nneigh=nnode*4;
        if(bMMFFf4)nneigh*=2;
        ibuff_atoms     =newBuffer( "atoms",     nvecs,  sizeof(float4), 0, CL_MEM_READ_WRITE );
        ibuff_aforces   =newBuffer( "aforces",   nvecs,  sizeof(float4), 0, CL_MEM_READ_WRITE );
        ibuff_coefs     =newBuffer( "coefs",     nAtoms, sizeof(float4), 0, CL_MEM_READ_ONLY  );
        ibuff_neighs    =newBuffer( "neighs",    nAtoms, sizeof(int4  ), 0, CL_MEM_READ_ONLY  );
        ibuff_neighCell =newBuffer( "neighCell" ,nAtoms, sizeof(int4  ), 0, CL_MEM_READ_ONLY  );
        if(bMMFFsp3 || bMMFFf4){
            ibuff_bkNeighs    = newBuffer( "bkNeighs",   nvecs,  sizeof(int4  ), 0, CL_MEM_READ_ONLY  );
            ibuff_avel        = newBuffer( "avel",       nvecs,  sizeof(float4), 0, CL_MEM_READ_WRITE );
            ibuff_neighForce  = newBuffer( "neighForce", nneigh, sizeof(float4), 0, CL_MEM_READ_WRITE );
            if(bMMFFsp3){
                printf( "initAtomsForces bMMFFsp3==true\n" );
                ibuff_bondLK      = newBuffer( "bondLK ",    nAtoms   , sizeof(float8), 0, CL_MEM_READ_ONLY  );
                ibuff_ang0K       = newBuffer( "ang0K",      nnode    , sizeof(float4), 0, CL_MEM_READ_ONLY  );
                ibuff_pi0s        = newBuffer( "pi0s",       npi      , sizeof(float4), 0, CL_MEM_READ_WRITE );
            }
            if(bMMFFf4){ // int ibuff_MMpars=-1, ibuff_BLs=-1,ibuff_BKs=-1,ibuff_Ksp=-1, ibuff_Kpp=-1;   // MMFFf4 params
                printf( "initAtomsForces bMMFFf4==true\n" );
                ibuff_MMpars = newBuffer( "MMpars", nnode, sizeof(int4),   0, CL_MEM_READ_ONLY );
                ibuff_BLs    = newBuffer( "BLs",    nnode, sizeof(float4), 0, CL_MEM_READ_ONLY  );
                ibuff_BKs    = newBuffer( "BKs",    nnode, sizeof(float4), 0, CL_MEM_READ_ONLY  );
                ibuff_Ksp    = newBuffer( "Ksp",    nnode, sizeof(float4), 0, CL_MEM_READ_ONLY );
                ibuff_Kpp    = newBuffer( "Kpp",    nnode, sizeof(float4), 0, CL_MEM_READ_ONLY );
            }
        }
        //printBuffers();
        //exit(0);
        return ibuff_atoms;
    }