Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CodeVault
hpc-kernels
dense_linear_algebra
Commits
a8581ed3
Commit
a8581ed3
authored
Feb 08, 2016
by
Mariusz Uchronski
Browse files
LU factorizations code sample with clMAGMA library added.
parent
efd5b34f
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
a8581ed3
...
...
@@ -28,6 +28,7 @@ add_subdirectory(kmeans/kmeans_cuda)
add_subdirectory
(
kmeans/kmeans_openmp
)
add_subdirectory
(
kmeans/kmeans_rodinia_opencl
)
add_subdirectory
(
lud/mkl
)
add_subdirectory
(
lud/clmagma
)
add_subdirectory
(
lud/cublas
)
add_subdirectory
(
lud/cusolver
)
add_subdirectory
(
lud/cublas_mkl
)
...
...
lud/clmagma/CMakeLists.txt
0 → 100644
View file @
a8581ed3
# ==================================================================================================
# This file is part of the CodeVault project. The project is licensed under Apache Version 2.0.
# CodeVault is part of the EU-project PRACE-4IP (WP7.3.C).
#
# Author(s):
# Mariusz Uchronski <mariusz.uchronski@pwr.edu.nl>
#
# ==================================================================================================
cmake_minimum_required
(
VERSION 2.8.7 FATAL_ERROR
)
include
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../cmake/common.cmake
)
# ==================================================================================================
if
(
"
${
DWARF_PREFIX
}
"
STREQUAL
""
)
set
(
DWARF_PREFIX dense_linear_algebra
)
endif
()
enable_language
(
CXX
)
find_package
(
Common
)
find_package
(
OpenCL
)
# Included as ${CMAKE_MODULE_PATH}/FindOpenCL.cmake
find_package
(
clBLAS
)
find_package
(
clMAGMA
)
# Finds the OpenCL clMAGMA library
find_library
(
CLMAGMA_LIBRARIES
NAMES clMAGMA
PATH_SUFFIXES lib lib64
PATHS /usr /usr/local
DOC
"OpenCL clMAGMA library"
)
# GEMM with the OpenCL clMAGMA library
set
(
NAME
${
DWARF_PREFIX
}
_lud_clmagma
)
if
(
OPENCL_FOUND AND CLMAGMA_FOUND
)
include_directories
(
${
OPENCL_INCLUDE_DIRS
}
)
include_directories
(
${
CLMAGMA_INCLUDE_DIRS
}
)
add_executable
(
${
NAME
}
src/lud_clmagma.cpp
)
target_link_libraries
(
${
NAME
}
${
CLMAGMA_LIBRARIES
}
)
target_link_libraries
(
${
NAME
}
${
OPENCL_LIBRARIES
}
)
target_link_libraries
(
${
NAME
}
${
CLBLAS_LIBRARIES
}
)
target_link_libraries
(
${
NAME
}
blas lapack
)
install
(
TARGETS
${
NAME
}
DESTINATION bin
)
message
(
"** Enabling '
${
NAME
}
': with OpenCL and clMAGMA"
)
else
()
message
(
"## Skipping '
${
NAME
}
': no OpenCL or clMAGMA support found"
)
endif
()
unset
(
NAME
)
lud/clmagma/src/lud_clmagma.cpp
0 → 100644
View file @
a8581ed3
#include
<stdio.h>
#include
"magma.h"
int
main
(
int
argc
,
char
*
argv
[])
{
float
*
h_A
;
magmaFloat_ptr
d_A
;
magma_int_t
*
ipiv
;
magma_int_t
M
,
N
,
n2
,
lda
,
ldda
,
info
,
min_mn
;
magma_int_t
status
=
0
;
/* Initialize */
magma_queue_t
queue
;
magma_device_t
devices
[
MagmaMaxGPUs
];
magma_int_t
num
=
0
;
magma_int_t
err
;
magma_init
();
err
=
magma_getdevices
(
devices
,
MagmaMaxGPUs
,
&
num
);
if
(
err
!=
0
or
num
<
1
)
{
fprintf
(
stderr
,
"magma_getdevices failed: %d
\n
"
,
(
int
)
err
);
exit
(
-
1
);
}
err
=
magma_queue_create
(
devices
[
0
],
&
queue
);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"magma_queue_create failed: %d
\n
"
,
(
int
)
err
);
exit
(
-
1
);
}
lda
=
M
;
n2
=
lda
*
N
;
ldda
=
((
M
+
31
)
/
32
)
*
32
;
//TESTING_MALLOC_DEV( d_A, float, ldda*N );
magma_malloc
(
&
d_A
,
(
ldda
*
N
)
*
sizeof
(
float
)
);
//TESTING_MALLOC_CPU( h_A, float, n2 );
magma_malloc_cpu
(
(
void
**
)
&
h_A
,
(
n2
)
*
sizeof
(
float
)
);
magma_ssetmatrix
(
M
,
N
,
h_A
,
lda
,
d_A
,
0
,
ldda
,
queue
);
magma_sgetrf_gpu
(
M
,
N
,
d_A
,
0
,
ldda
,
ipiv
,
queue
,
&
info
);
magma_free_cpu
(
h_A
);
magma_free
(
d_A
);
magma_finalize
();
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment