From 69f2911e04ffb1b19eef1fafb8c040af271f656e Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 18:09:46 -0800 Subject: creating branch for adding support for CUDA 3.x and Fermi [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829] --- benchmarks/CUDA/DG/src/FacePair2d.c | 154 ++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 benchmarks/CUDA/DG/src/FacePair2d.c (limited to 'benchmarks/CUDA/DG/src/FacePair2d.c') diff --git a/benchmarks/CUDA/DG/src/FacePair2d.c b/benchmarks/CUDA/DG/src/FacePair2d.c new file mode 100644 index 0000000..92e47f5 --- /dev/null +++ b/benchmarks/CUDA/DG/src/FacePair2d.c @@ -0,0 +1,154 @@ +#include "mpi.h" +#include "fem.h" + +typedef struct foob { + int p1, k1, f1, p2, k2, f2, va, vb, g; +}face; + +int compare_pairs(const void *obj1, const void *obj2){ + + face *e1 = (face*) obj1; + face *e2 = (face*) obj2; + + int a1 = e1->va, b1 = e1->vb; + int a2 = e2->va, b2 = e2->vb; + + int va1, vb1, va2, vb2; + + va1 = min(a1, b1); + vb1 = max(a1, b1); + + va2 = min(a2, b2); + vb2 = max(a2, b2); + + if(vb1vb2) + return 1; + else if(va1va2) + return 1; + + return 0; +} + +int pairprocget(const void *obj1){ + face *e1 = (face*) obj1; + return (e1->p1); +} + + +int pairnumget(const void *obj1){ + face *e1 = (face*) obj1; + return (e1->g); +} + +void pairnumset(const void *obj1, int g){ + face *e1 = (face*) obj1; + e1->g = g; +} + +void pairmarry(const void *obj1, const void *obj2){ + + face *e1 = (face*) obj1; + face *e2 = (face*) obj2; + e1->p2 = e2->p1; e1->k2 = e2->k1; e1->f2 = e2->f1; + e2->p2 = e1->p1; e2->k2 = e1->k1; e2->f2 = e1->f1; +} + +void FacePair2d(Mesh *mesh, int *maxNv){ + + int procid = mesh->procid; + int nprocs = mesh->nprocs; + + int Klocal = mesh->K; + int Nfaces = mesh->Nfaces; + int Nverts = mesh->Nverts; + + int **EToV = mesh->EToV; + + const int vnum[3][2] = { {0,1}, {1,2}, {2,0} }; + + int n, k, e, sk, v; + + face *myfaces = (face*) calloc(Klocal*Nfaces, sizeof(face)); + + /* find maximum local vertex number */ + int localmaxgnum = 0; + for(k=0;kNpar = BuildIntVector(nprocs); + + mesh->EToE = BuildIntMatrix(Klocal, Nfaces); + mesh->EToF = BuildIntMatrix(Klocal, Nfaces); + mesh->EToP = BuildIntMatrix(Klocal, Nfaces); + + int id, k1, k2, f1, f2, p1, p2; + sk = 0; + + for(n=0;nEToE[k1][f1] = k2; + mesh->EToF[k1][f1] = f2; + mesh->EToP[k1][f1] = p2; + + if(p1!=p2){ + /* increment number of links */ + ++mesh->Npar[p2]; + } + } + + mesh->parK = (int**) calloc(nprocs, sizeof(int*)); + mesh->parF = (int**) calloc(nprocs, sizeof(int*)); + for(p2=0;p2parK[p2] = BuildIntVector(mesh->Npar[p2]); + mesh->parF[p2] = BuildIntVector(mesh->Npar[p2]); + mesh->Npar[p2] = 0; + for(n=0;nparK[p2][mesh->Npar[p2] ] = k1; + mesh->parF[p2][mesh->Npar[p2]++] = f1; + } + } + } + + free(myfaces); +} + + -- cgit v1.3