 
         for( int i = 0; i < localStreams; i++ )
         {
+/* set the stream for the cublas call */
+
           CUBLAS_CALL( cublasSetStream( handle, stream[i] ) );
+
+/* call the cublas dgemm function */
+
           CUBLAS_CALL( cublasDgemm( handle, CUBLAS_OP_N, CUBLAS_OP_N,
                  tileSize, tileSize, tileSize,
                  &alpha,

      for( int k = 0; k < linearTiles; k++ )
      {

/* stream A and B into device */

        for( int i = 0; i < localStreams; i++ )
        {

        int aoffset = INDX( rowTile[i], k, linearTiles ) *
                            tileSize * tileSize;
        CUDA_CALL( cudaMemcpyAsync( d_a[i], &p_a[aoffset], tileBytes,
                     cudaMemcpyHostToDevice, stream[i] ) );
        } /* end for */

        for( int i = 0; i < localStreams; i++ )
        {
        int boffset = INDX( k, colTile[i], linearTiles ) *
                            tileSize * tileSize;
        CUDA_CALL( cudaMemcpyAsync( d_b[i], &p_b[boffset], tileBytes,
                     cudaMemcpyHostToDevice, stream[i] ) );

        } /* end for */


    int currentTile = 0;

/* starting the timer */

    CUDA_CALL( cudaEventRecord( start, 0 ) );

/* while loop over all the tiles */

    while( currentTile < totalTiles )
    {

      int localStreams = 0;

/* assign a tile to each stream */

      for( int i = 0; i < nstreams; i++ )
      {
        rowTile[i] = currentTile % linearTiles;
        colTile[i] = currentTile / linearTiles;

/*   using localStreams in case we run out of tiles and still have streams
     then we just keep some streams idle  */

        if( currentTile < totalTiles ) localStreams++;

        currentTile++;
      } /* end for */

/* copy tile of C to device, each stream does a different tile of C */

      for( int i = 0; i < localStreams; i++ )
      {
        int cOffset = INDX( rowTile[i], colTile[i], linearTiles ) *
                            tileSize * tileSize;
        CUDA_CALL( cudaMemcpyAsync( d_c[i], &p_c[cOffset], tileBytes,
                     cudaMemcpyHostToDevice, stream[i] ) );

      } /* end for */
