About GPU programing in parallel

Open discussion for MAGMA

About GPU programing in parallel

Postby jigarchokshi » Mon Nov 26, 2012 7:30 am

I want GPU program for matrix inversion ....
I have a this function for inverse of matix in main.cpp...

template int test_map (int N, T *A) {

// 1. compute reference solution
synmod_map_seq (N, A);

// 2. compute solution with parallel module
T *dA;
GPU_alloc_dev_ptr (N*N, &dA);
GPU_copy_data_to_device (N*N, A, dA);
synmod_map_gpu (N, dA);
GPU_copy_data_from_device (N*N, dA, A);
GPU_free_dev_ptr (&dA);


In synmod_map_seq.cpp file i write like this:

template static int synmod_map_seq_internal (int N, T *A) {
for (int i = 0; i < N; i++)
A[i] = -A[i];

return 0;
int synmod_map_seq (int N, int *A) {
return synmod_map_seq_internal (N, A);
int synmod_map_seq (int N, float *A) {
return synmod_map_seq_internal (N, A);
int synmod_map_seq (int N, double *A) {
return synmod_map_seq_internal (N, A);

in synmod_map_gpu.cu file i call synmod_map_gpu function from main.cpp
now problem is that i dont understand what to write for function "synmod_map_gpu"

Thank you..
Posts: 1
Joined: Mon Nov 26, 2012 7:27 am

Re: About GPU programing in parallel

Postby mgates3 » Mon Nov 26, 2012 11:12 am

I don't understand what your code is attempting to do. It looks like synmod_map_seq is just negating the first column of A, but it is not explained why. The template syntax also seems wrong, lacking <typename T>.

To invert a matrix, simply use magma_dgetri_gpu for double precision, or magma_sgetri_gpu for single. The functions are documented in the source code, magma/src/dgetri_gpu.cpp, which you can also view online:

On the other hand, why are you inverting a matrix? It is rarely the best method. If you are solving Ax=b, that is, x = A^{-1} b, just use magma_dgesv, or equivalently, magma_dgetrf and magma_dgetrs. Those factor the matrix into LU, then solve LUx=b, which is both faster and more accurate than explicitly inverting the matrix A.

Posts: 409
Joined: Fri Jan 06, 2012 2:13 pm

Return to User discussion

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests