gpu_t10

Ceci est une ancienne révision du document !


  • Trois cartes GPU réparties sur deux noeuds.
  • File d'attente tesla
  • Version de CUDA 4

Type de chaque carte

Major revision number:         1
Minor revision number:         3
Name:                          Tesla T10 Processor
Total global memory:           4294770688
Total shared memory per block: 16384
Total registers per block:     16384
Warp size:                     32
Maximum memory pitch:          2147483647
Maximum threads per block:     512
Maximum dimension 0 of block:  512
Maximum dimension 1 of block:  512
Maximum dimension 2 of block:  64
Maximum dimension 0 of grid:   65535
Maximum dimension 1 of grid:   65535
Maximum dimension 2 of grid:   1
Clock rate:                    1296000
Total constant memory:         65536
Texture alignment:             256
Concurrent copy and execution: Yes
Number of multiprocessors:     30
Kernel execution timeout:      Yes

On se connecte sur les noeuds tesla en utilisant SGE (en mode interactif) depuis la machine login mesocluster.univ-fcomte.fr.

Attention : Comme la queue tesla dispose de 16 coeurs, on ne peut avoir plus de 16 sessions interactives.
$ qlogin -q tesla

Une fois connecté, on charge le module cuda pour pouvoir compiler et exécuter les programmes CUDA/OpenCL.

$ cd WORK
$ module load cuda
VectorAdd.c
#include <stdio.h>
#include <cuda.h>
#include <stdlib.h>
 
#define N 4096         // size of array
 
__global__ void vectorAdd(int *a,int *b, int *c) {
        int tid = blockIdx.x *  blockDim.x + threadIdx.x;
        if(tid < N){
          c[tid] = a[tid]+b[tid];
        }
}
 
int main(int argc, char *argv[])  {
        int T = 10, B = 1;            // threads per block and blocks per grid
        int a[N],b[N],c[N];
        int *dev_a, *dev_b, *dev_c;
 
        printf("Size of array = %d\n", N);
        do {
                printf("Enter number of threads per block (1024 max, comp. cap. 2.x)  ");
                scanf("%d",&T);
                printf("\nEnter nuumber of blocks per grid: ");
                scanf("%d",&B);
                if (T * B < N) printf("Error T x B < N, try again\n");
        } while (T * B < N);
 
        cudaEvent_t start, stop;     // using cuda events to measure time
        float elapsed_time_ms;       // which is applicable for asynchronous code also
 
       cudaSetDevice(0);
        cudaMalloc((void**)&dev_a,N * sizeof(int));
        cudaMalloc((void**)&dev_b,N * sizeof(int));
        cudaMalloc((void**)&dev_c,N * sizeof(int));
 
        for(int i=0;i<N;i++) {    // load arrays with some numbers
                a[i] = i;
                b[i] = i;
        }
 
        cudaMemcpy(dev_a, a , N*sizeof(int),cudaMemcpyHostToDevice);
        cudaMemcpy(dev_b, b , N*sizeof(int),cudaMemcpyHostToDevice);
        cudaMemcpy(dev_c, c , N*sizeof(int),cudaMemcpyHostToDevice);
 
        cudaEventCreate( &start );     // instrument code to measure start time
        cudaEventCreate( &stop );
        cudaEventRecord( start, 0 );
 
        vectorAdd<<<B,T>>>(dev_a,dev_b,dev_c);
 
        cudaMemcpy(c,dev_c,N*sizeof(int),cudaMemcpyDeviceToHost);
 
        cudaEventRecord( stop, 0 );     // instrument code to measue end time
        cudaEventSynchronize( stop );
        cudaEventElapsedTime( &elapsed_time_ms, start, stop );
 
        for(int i=0;i<N;i++) {
                printf("%d+%d=%d\n",a[i],b[i],c[i]);
        }
 
        printf("Time to calculate results: %f ms.\n", elapsed_time_ms);  // print out execution time
 
        // clean up
        cudaFree(dev_a);
        cudaFree(dev_b);
        cudaFree(dev_c);
 
        cudaEventDestroy(start);
        cudaEventDestroy(stop);
 
        return 0;
}
$ nvcc VectorAdd.cu -o VectorAdd

On exécute le programme :

./VectorAdd

Vous pouvez utiliser SGE pour compiler et/ou exécuter un code CUDA ou OpenCL :

cuda.sge
#!/bin/bash -l
 
#$ -l h_rt=2:00:0
 
 
#$ -o $JOB_NAME.o$JOB_ID
 
 
#$ -e $JOB_NAME.e$JOB_ID
 
 
#$ -N job_cuda
 
 
#$ -q tesla                 
 
#$ -V
 
#$ -l h_vmem=1.5G
 
 
module load cuda 
 
    #################################
    ### Pour compiler ###
    #################################
 
nvcc monprogramme.cu -o monprogramme
 
 
 
    #################################
    ###  Pour executer  ####
    #################################
 
     ./monprogramme
  • gpu_t10.1461072545.txt.gz
  • Dernière modification : 2016/04/19 13:29
  • de admin