void xGeru<T>::setup_buffer(int order_option, int side_option, int
                    uplo_option, int diag_option, int transA_option, int
                    transB_option, size_t M, size_t N, size_t K,
                    size_t lda, size_t ldb, size_t ldc,size_t offA,
					          size_t offB, size_t offC, double alpha,
                    double beta)
{
  initialize_scalars(alpha, beta);
  buffer.offa = offA;
  buffer.offx = offB;
  buffer.incx = 1;//If this changes, remember to adjust size of Y in rest of the file
  buffer.offy = offC;
  buffer.incy = 1;//If this changes, remember to adjust size of Y in rest of the file
  buffer.M = M;
  buffer.N = N;
  if (order_option == 0)
  {
  buffer.order = clblasRowMajor;
  }
  else
  {
  buffer.order = clblasColumnMajor;
  }
  if (lda == 0)
  {
    buffer.lda = buffer.M;
  }
  else if (lda < buffer.M)
  {
    std::cerr << "lda:wrong size\n";
    exit(1);
  }
  else
  {
    buffer.lda = lda;
  }
  buffer.cpuX = new T[buffer.M];
  buffer.cpuY = new T[buffer.N];
  buffer.cpuA = new T[buffer.N * buffer.lda];
  cl_int err;
  buffer.A = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                buffer.N * buffer.lda*sizeof(T),
                                NULL, &err);

  buffer.X = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                    buffer.M*sizeof(T),
                                    NULL, &err);
  buffer.Y = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                    buffer.N*sizeof(T),
                                    NULL, &err);
}
    void setup_buffer(int order_option, int side_option, int uplo_option,
                      int diag_option, int transA_option, int  transB_option,
                      size_t M, size_t N, size_t K, size_t lda, size_t ldb,
                      size_t ldc, size_t offA, size_t offBX, size_t offCY,
                      double alpha, double beta)
    {
        DUMMY_ARGS_USAGE_3(side_option, uplo_option, diag_option);

        initialize_scalars(alpha, beta);

        buffer_.m_ = M;
        buffer_.n_ = N;
        buffer_.k_ = K;
        buffer_.offA_ = offA;
        buffer_.offB_ = offBX;
        buffer_.offC_ = offCY;

        if (order_option == 0)
        {
            order_ = clblasRowMajor;
            if (transA_option == 0)
            {
                buffer_.trans_a_ = clblasNoTrans;
                buffer_.a_num_vectors_ = M;
                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = K;
                if (transA_option == 1)
                {
                    buffer_.trans_a_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.trans_a_ = clblasConjTrans;
                }
                if (lda == 0)
                {
                    buffer_.lda_ = M;
                }
                else if (lda < M)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }

            if (transB_option == 0)
            {
                buffer_.b_num_vectors_ = K;
                buffer_.trans_b_ = clblasNoTrans;
                if (ldb == 0)
                {
                    buffer_.ldb_ = N;
                }
                else if (ldb < N)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
            else
            {
                buffer_.b_num_vectors_ = N;
                if (transB_option == 1)
                {
                    buffer_.trans_b_ = clblasTrans;
                }
                else if (transB_option == 2)
                {
                    buffer_.trans_b_ = clblasConjTrans;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = K;
                }
                else if (ldb < K)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }

            if (ldc == 0)
            {
                buffer_.ldc_ = N;
            }
            else if (ldc < N)
            {
                std::cerr << "ldc:wrong size\n";
            }
            else
            {
                buffer_.ldc_ = ldc;
            }
            buffer_.c_num_vectors_ = M;
        }
        else
        {
            order_ = clblasColumnMajor;
            if (transA_option == 0)
            {
                buffer_.a_num_vectors_ = K;
                buffer_.trans_a_ = clblasNoTrans;
                if (lda == 0)
                {
                    buffer_.lda_ = M;
                }
                else if (lda < M)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = M;
                if (transA_option == 1)
                {
                    buffer_.trans_a_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.trans_a_ = clblasConjTrans;
                }


                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }

            if (transB_option == 0)
            {
                buffer_.b_num_vectors_ = N;
                buffer_.trans_b_ = clblasNoTrans;

                if (ldb == 0)
                {
                    buffer_.ldb_ = K;
                }
                else if (ldb < K)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
            else
            {
                buffer_.b_num_vectors_ = K;
                if (transB_option == 1)
                {
                    buffer_.trans_b_ = clblasTrans;
                }
                else if (transB_option == 2)
                {
                    buffer_.trans_b_ = clblasConjTrans;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = N;
                }
                else if (ldb < N)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }

            if (ldc == 0)
            {
                buffer_.ldc_ = M;
            }
            else if (ldc < M)
            {
                std::cerr << "ldc:wrong size\n";
            }
            else
            {
                buffer_.ldc_ = ldc;
            }
            buffer_.c_num_vectors_ = N;
        }
        buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];
        buffer_.b_ = new T[buffer_.ldb_*buffer_.b_num_vectors_];
        buffer_.c_ = new T[buffer_.ldc_*buffer_.c_num_vectors_ ];

        cl_int err;
        buffer_.buf_a_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                       (buffer_.lda_*buffer_.a_num_vectors_ +
                                           buffer_.offA_) * sizeof(T),
                                       NULL, &err);

        buffer_.buf_b_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        (buffer_.ldb_ * buffer_.b_num_vectors_ +
                                            buffer_.offB_) * sizeof(T),
                                        NULL, &err);

        buffer_.buf_c_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                        (buffer_.ldc_ * buffer_.c_num_vectors_ +
                                            buffer_.offC_) * sizeof(T),
                                        NULL, &err);

    }
  void setup_buffer(int order_option, int side_option, int
                    uplo_option, int diag_option, int transA_option, int
                    transB_option, size_t M, size_t N, size_t K,
                    size_t lda, size_t ldb, size_t ldc,size_t offA,
					size_t offB, size_t offC, double alpha,
                    double beta)
  {
    initialize_scalars(alpha, beta);

    buffer_.m_ = M;

    if (transA_option == 0)
    {
      buffer_.trans_a_ = clblasNoTrans;
    }
    else if (transA_option == 1)
    {
      buffer_.trans_a_ = clblasTrans;
    }
    else if (transA_option == 2)
    {
      buffer_.trans_a_ = clblasConjTrans;
    }

    if (uplo_option == 0)
    {
      buffer_.uplo_ = clblasUpper;
    }
    else
    {
      buffer_.uplo_ = clblasLower;
    }

    if (diag_option == 0)
    {
      buffer_.diag_ = clblasUnit;
    }
    else
    {
      buffer_.diag_ = clblasNonUnit;
    }

    if (order_option == 0)
    {
      order_ = clblasRowMajor;
    }
    else
    {
      order_ = clblasColumnMajor;
    }


    if (lda == 0)
    {
      buffer_.lda_ = M;
    }
    else
    {
      if( lda < M )
      {
        std::cerr << "ERROR: lda must be set to 0 or a value >= M" << std::endl;
      }
      else if (lda >= M)
      {
        buffer_.lda_ = lda;
      }
    }


    buffer_.a_num_vectors_ = buffer_.m_;

    buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];
    buffer_.x_ = new T[buffer_.m_];


    cl_int err;
    buffer_.buf_a_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                    buffer_.lda_*buffer_.a_num_vectors_*sizeof(T),
                                    NULL, &err);

    buffer_.buf_x_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                    buffer_.m_*sizeof(T),
                                    NULL, &err);

    buffer_.scratch_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                    buffer_.m_*sizeof(T),
                                    NULL, &err);

  }
	void roundtrip_setup_buffer(int order_option, int side_option, int uplo_option,
                      int diag_option, int transA_option, int  transB_option,
                      size_t M, size_t N, size_t K, size_t lda, size_t ldb,
                      size_t ldc, size_t offA, size_t offBX, size_t offCY,
                      double alpha, double beta)
	{
		DUMMY_ARGS_USAGE_4(side_option, diag_option, transB_option, M);
        DUMMY_ARGS_USAGE_2(ldb, offBX);

        initialize_scalars(alpha, beta);

        buffer_.n_ = N;
        buffer_.k_ = K;
        buffer_.offA_ = offA;
        buffer_.offC_ = offCY;

        if (uplo_option == 0)
        {
            buffer_.uplo_ = clblasUpper;
        }
        else
        {
            buffer_.uplo_ = clblasLower;
        }


        if (ldc == 0)
        {
            buffer_.ldc_ = N;
        }
        else if (ldc < N)
        {
            std::cerr << "ldc:wrong size\n";
        }
        else
        {
            buffer_.ldc_ = ldc;
        }
        buffer_.c_num_vectors_ = N;

        if (order_option == 0)
        {
            order_ = clblasRowMajor;
            if (transA_option == 0)
            {
                buffer_.trans_a_ = clblasNoTrans;
                buffer_.a_num_vectors_ = N;
                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = K;
                if (transA_option == 1)
                {
                    buffer_.trans_a_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.trans_a_ = clblasConjTrans;
                }
                if (lda == 0)
                {
                    buffer_.lda_ = N;
                }
                else if (lda < N)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
        }
        else
        {
            order_ = clblasColumnMajor;
            if (transA_option == 0)
            {
                buffer_.a_num_vectors_ = K;
                buffer_.trans_a_ = clblasNoTrans;
                if (lda == 0)
                {
                    buffer_.lda_ = N;
                }
                else if (lda < N)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = N;
                if (transA_option == 1)
                {
                    buffer_.trans_a_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.trans_a_ = clblasConjTrans;
                }

                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }
            }
        }

        buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];
        buffer_.c_ = new T[buffer_.ldc_*buffer_.c_num_vectors_];
	}
    void setup_buffer(int order_option, int side_option, int uplo_option,
                      int diag_option, int transA_option, int transB_option,
                      size_t M, size_t N, size_t K, size_t lda, size_t ldb,
                      size_t ldc, size_t offA, size_t offBX, size_t offCY,
                      double alpha, double beta)
    {
        DUMMY_ARGS_USAGE_3(side_option, diag_option, transB_option);
        DUMMY_ARGS_USAGE_4(M, K, ldb, ldc);
        DUMMY_ARGS_USAGE_3(transA_option, offBX, offCY);

        initialize_scalars(alpha, beta);

        buffer_.n_ = N;
        buffer_.a_num_vectors_ = N;
        buffer_.offA_ = offA;

        if (uplo_option == 0)
        {
            buffer_.uplo_ = clblasUpper;
        }
        else
        {
            buffer_.uplo_ = clblasLower;
        }

        buffer_.x_ = new T[buffer_.n_];
        buffer_.y_ = new T[buffer_.n_];

        if (order_option == 0)
        {
            order_ = clblasRowMajor;
        }
        else
        {
            order_ = clblasColumnMajor;
        }

        if (lda == 0)
        {
            buffer_.lda_ = N;
        }
        else if (lda < N)
        {
            std::cerr << "lda:wrong size\n";
            exit(1);
        }
        else
        {
            buffer_.lda_ = lda;
        }

        buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];

        cl_int err;
        buffer_.buf_a_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        (buffer_.lda_ * buffer_.a_num_vectors_ +
                                            buffer_.offA_) * sizeof(T),
                                        NULL, &err);

        buffer_.buf_x_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        buffer_.n_*sizeof(T),
                                        NULL, &err);

        buffer_.buf_y_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                        buffer_.n_*sizeof(T),
                                        NULL, &err);
    }
    void setup_buffer(int order_option, int side_option, int uplo_option,
                      int diag_option, int transA_option, int  transB_option,
                      size_t M, size_t N, size_t K, size_t lda, size_t ldb,
                      size_t ldc, size_t offA, size_t offBX, size_t offCY,
                      double alpha, double beta)
    {
        DUMMY_ARGS_USAGE_4(side_option, uplo_option, diag_option,
                           transB_option);
        DUMMY_ARGS_USAGE_3(K, ldb, ldc);
        DUMMY_ARGS_USAGE_2(offBX, offCY);

        initialize_scalars(alpha, beta);

        buffer_.m_ = M;
        buffer_.n_ = N;
        buffer_.offA_ = offA;

        if (transA_option == 0)
        {
            buffer_.trans_a_ = clblasNoTrans;
            buffer_.x_ = new T[buffer_.n_];
            buffer_.y_ = new T[buffer_.m_];
        }
        else
        {
            buffer_.trans_a_ = clblasTrans;
            buffer_.x_ = new T[buffer_.m_];
            buffer_.y_ = new T[buffer_.n_];
        }

        if (order_option == 0)
        {
            order_ = clblasRowMajor;
            buffer_.a_num_vectors_ = M;
            if (lda == 0)
            {
                buffer_.lda_ = N;
            }
            else if (lda < N)
            {
                std::cerr << "lda:wrong size\n";
                exit(1);
            }
            else
            {
                buffer_.lda_ = lda;
            }
        }
        else
        {
            order_ = clblasColumnMajor;
            buffer_.a_num_vectors_ = N;
            if (lda == 0)
            {
                buffer_.lda_ = M;
            }
            else if (lda < M)
            {
                std::cerr << "lda:wrong size\n";
                exit(1);
            }
            else
            {
                buffer_.lda_ = lda;
            }

        }
        buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];

        cl_int err;
        size_t size = (buffer_.lda_ * buffer_.a_num_vectors_ + buffer_.offA_) * sizeof(T);
        if( size >= maxMemAllocSize )
            throw std::runtime_error( "Tried to create a buffer larger than allowable on this device" );

        buffer_.buf_a_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        size,
                                        NULL, &err);

        if (transA_option == 0)
        {
            buffer_.buf_x_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                            buffer_.n_*sizeof(T),
                                            NULL, &err);

            buffer_.buf_y_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                            buffer_.m_*sizeof(T),
                                            NULL, &err);
        }
        else
        {
            buffer_.buf_x_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                            buffer_.m_*sizeof(T),
                                            NULL, &err);

            buffer_.buf_y_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                            buffer_.n_*sizeof(T),
                                            NULL, &err);
        }
    }
  void setup_buffer(int order_option, int side_option, int
                    uplo_option, int diag_option, int transA_option, int
                    transB_option, size_t M, size_t N, size_t K,
                    size_t lda, size_t ldb, size_t ldc,size_t offA,
					          size_t offB, size_t offC, double alpha,
                    double beta)
  {
        DUMMY_ARGS_USAGE_4(side_option, diag_option, transB_option, M);

		initialize_scalars(alpha,beta);

		buffer_.N_ = N;
		buffer_.K_ = K;
		buffer_.offa_ = offA;
		buffer_.offb_ = offB;
		buffer_.offc_ = offC;

		if (uplo_option == 0)
        {
            buffer_.uplo_ = clblasUpper;
        }
        else
        {
            buffer_.uplo_ = clblasLower;
        }
		
		if (ldc == 0)
        {
            buffer_.ldc_ = N;
        }
        else if (ldc < N)
        {
            std::cerr << "ldc:wrong size\n";
        }
        else
        {
            buffer_.ldc_ = ldc;
        }
		      
		buffer_.c_num_vectors_ = N;

		if (order_option == 0)
        {
            order_ = clblasRowMajor;
            if (transA_option == 0)
            {
                buffer_.transA_ = clblasNoTrans;
                buffer_.a_num_vectors_ = N;
				buffer_.b_num_vectors_ = N;
                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = K;
                }
                else if (ldb < K)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = K;
				buffer_.b_num_vectors_ = K;
                if (transA_option == 1)
                {
                    buffer_.transA_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.transA_ = clblasConjTrans;
                }
                if (lda == 0)
                {
                    buffer_.lda_ = N;
                }
                else if (lda < N)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = N;
                }
                else if (ldb < N)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
        }
        else
        {
            order_ = clblasColumnMajor;
            if (transA_option == 0)
            {
                buffer_.a_num_vectors_ = K;
                buffer_.b_num_vectors_ = K;
                buffer_.transA_ = clblasNoTrans;
                if (lda == 0)
                {
                    buffer_.lda_ = N;
                }
                else if (lda < N)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = N;
                }
                else if (ldb < N)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
            else
            {
                buffer_.a_num_vectors_ = N;
                buffer_.b_num_vectors_ = N;
                if (transA_option == 1)
                {
                    buffer_.transA_ = clblasTrans;
                }
                else if (transA_option == 2)
                {
                    buffer_.transA_ = clblasConjTrans;
                }

                if (lda == 0)
                {
                    buffer_.lda_ = K;
                }
                else if (lda < K)
                {
                    std::cerr << "lda:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.lda_ = lda;
                }

                if (ldb == 0)
                {
                    buffer_.ldb_ = K;
                }
                else if (ldb < K)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
        }

        buffer_.cpuA_ = new T[buffer_.lda_*buffer_.a_num_vectors_];
		buffer_.cpuB_ = new T[buffer_.ldb_*buffer_.b_num_vectors_];
        buffer_.cpuC_ = new T[buffer_.ldc_*buffer_.c_num_vectors_];

        cl_int err;
        buffer_.A_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        (buffer_.lda_ * buffer_.a_num_vectors_ +
                                            buffer_.offa_) * sizeof(T),
                                        NULL, &err);

	    buffer_.B_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        (buffer_.ldb_ * buffer_.b_num_vectors_ +
                                            buffer_.offb_) * sizeof(T),
                                        NULL, &err);

        buffer_.C_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                        (buffer_.ldc_ * buffer_.c_num_vectors_ +
                                            buffer_.offc_) * sizeof(T),
                                        NULL, &err);
  }
Exemple #8
0
    void setup_buffer(int order_option, int side_option, int uplo_option,
                      int diag_option, int transA_option, int transB_option,
                      size_t M, size_t N, size_t K, size_t lda, size_t ldb,
                      size_t ldc, size_t offA, size_t offBX, size_t offCY,
                      double alpha, double beta)
    {
        DUMMY_ARGS_USAGE_3(transB_option, K, beta);
        DUMMY_ARGS_USAGE_2(ldc, offCY);

        initialize_scalars(alpha, beta);

        buffer_.m_ = M;
        buffer_.n_ = N;
        buffer_.offA_ = offA;
        buffer_.offB_ = offBX;

        if (transA_option == 0)
        {
            buffer_.trans_a_ = clblasNoTrans;
        }
        else if (transA_option == 1)
        {
            buffer_.trans_a_ = clblasTrans;
        }
        else if (transA_option == 2)
        {
            buffer_.trans_a_ = clblasConjTrans;
        }

        if (side_option == 0)
        {
            buffer_.side_ = clblasLeft;
            buffer_.a_num_vectors_ = M;
        }
        else
        {
            buffer_.side_ = clblasRight;
            buffer_.a_num_vectors_ = N;
        }

        if (uplo_option == 0)
        {
            buffer_.uplo_ = clblasUpper;
        }
        else
        {
            buffer_.uplo_ = clblasLower;
        }

        if (diag_option == 0)
        {
            buffer_.diag_ = clblasUnit;
        }
        else
        {
            buffer_.diag_ = clblasNonUnit;
        }

        if (order_option == 0)
        {
            buffer_.order_ = clblasRowMajor;
            buffer_.b_num_vectors_ = M;
            if (ldb == 0)
            {
                buffer_.ldb_ = N;
            }
            else
            {
                if (ldb < N)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
        }
        else
        {
            buffer_.order_ = clblasColumnMajor;
            buffer_.b_num_vectors_ = N;
            if (ldb == 0)
            {
                buffer_.ldb_ = M;
            }
            else
            {
                if (ldb < M)
                {
                    std::cerr << "ldb:wrong size\n";
                    exit(1);
                }
                else
                {
                    buffer_.ldb_ = ldb;
                }
            }
        }

        if (lda == 0)
        {
            if (side_option == 0)
            {
                buffer_.lda_ = M;
            }
            else
            {
                buffer_.lda_ = N;
            }
        }
        else
        {
            if( side_option == 0 && lda < M )
            {
                std::cerr << "ERROR: when side is 0, lda must be set to 0 "
                          "or a value >= M" << std::endl;
            }
            else if(side_option == 0 && lda >= M )
            {
                buffer_.lda_ = lda;
            }
            else if(side_option != 0 && lda < N)
            {
                std::cerr << "ERROR: when side is 1, lda must be set to 0 "
                          "or a value >= N" << std::endl;
            }
            else if (side_option != 0 && lda >= N)
            {
                buffer_.lda_ = lda;
            }
        }

        buffer_.a_ = new T[buffer_.lda_*buffer_.a_num_vectors_];
        buffer_.b_ = new T[buffer_.ldb_*buffer_.b_num_vectors_];

        cl_int err;
        buffer_.buf_a_ = clCreateBuffer(ctx_, CL_MEM_READ_ONLY,
                                        (buffer_.lda_ * buffer_.a_num_vectors_ +
                                         buffer_.offA_) * sizeof(T),
                                        NULL, &err);

        buffer_.buf_b_ = clCreateBuffer(ctx_, CL_MEM_READ_WRITE,
                                        (buffer_.ldb_ * buffer_.b_num_vectors_ +
                                         buffer_.offB_) * sizeof(T),
                                        NULL, &err);
    }