Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
OXPHOS committed Feb 24, 2017
1 parent 0231235 commit 41fad47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions src/shogun/mathematics/linalg/LinalgNamespace.h
Expand Up @@ -131,16 +131,16 @@ void to_gpu(SGVector<T>& a, SGVector<T>& b)
sg_linalg->m_gpu_transfer.unlock();
}

// /**
// * Transfers data to GPU memory in-place.
// *
// * @param a SGVector to be transferred
// */
// template <typename T>
// void to_gpu(SGVector<T>& a)
// {
// to_gpu(a, a);
// }
/**
* Transfers data to GPU memory in-place.
*
* @param a SGVector to be transferred
*/
template <typename T>
void to_gpu(SGVector<T>& a)
{
to_gpu(a, a);
}

/**
* Transfers data to GPU memory. Does nothing if no GPU backend registered.
Expand Down Expand Up @@ -197,17 +197,17 @@ void from_gpu(SGVector<T>& a, SGVector<T>& b)
sg_linalg->m_gpu_transfer.unlock();
}

// /**
// * Fetches data from GPU memory.
// * Transfer vector to CPU if GPU backend is still available.
// *
// * @param a SGVector to be transferred
// */
// template <typename T>
// void from_gpu(SGVector<T>& a)
// {
// from_gpu(a, a);
// }
/**
* Fetches data from GPU memory.
* Transfer vector to CPU if GPU backend is still available.
*
* @param a SGVector to be transferred
*/
template <typename T>
void from_gpu(SGVector<T>& a)
{
from_gpu(a, a);
}

/**
* Fetches data from GPU memory.
Expand Down Expand Up @@ -505,7 +505,7 @@ SGVector<T> matrix_prod(SGMatrix<T>& A, SGVector<T>& b, bool transpose = false)
}

if (A.on_gpu())
to_gpu(result, result);
to_gpu(result);

matrix_prod(A, b, result, transpose);
return result;
Expand Down
Expand Up @@ -12,13 +12,13 @@ using namespace linalg;

void * memory_transfer_test_helper_1(void * args)
{
linalg::to_gpu(*(SGVector<int32_t> *)args, *(SGVector<int32_t> *)args);
linalg::to_gpu(*(SGVector<int32_t> *)args);
pthread_exit(0);
}

void * memory_transfer_test_helper_2(void * args)
{
linalg::from_gpu(*(SGVector<int32_t> *)args, *(SGVector<int32_t> *)args);
linalg::from_gpu(*(SGVector<int32_t> *)args);
pthread_exit(0);
}

Expand Down Expand Up @@ -167,7 +167,7 @@ TEST(LinalgBackendViennaCL, GPU_transfer_multithread)
for (index_t i = 0; i < count; i++)
pthread_join(threads[i], NULL);

from_gpu(a, a);
from_gpu(a);
for (index_t i = 0; i < size; i++)
EXPECT_EQ(a[i], i);

Expand Down

0 comments on commit 41fad47

Please sign in to comment.