Skip to content

Commit f019e68

Browse files
committed
trying to fix spblas example
1 parent 369e092 commit f019e68

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if(${ENABLE_SPBLAS})
2222
message(FATAL_ERROR "MKLROOT environment variable is not set.")
2323
endif()
2424
set(MKLLIB ${MKLROOT}/lib CACHE PATH "Path to Intel MKL Libraries")
25+
set(MKLINCLUDE ${MKLROOT}/include CACHE PATH "Path to Intel MKL include files")
2526
endif()
2627

2728
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Then, you can configure, build, and run tests for the project.
1616
```
1717

1818
Alternatively, if on a system where you need to specify a different MKL library
19-
you can do this with the flags `-DMKLLIB` during configuration. The below bash
19+
you can do this with the flags during configuration. The below bash
2020
script does the necessary configuration, as an example, for DKRZ's Levante.
2121

2222
```shell

test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ if(${ENABLE_SPBLAS})
2121
test_spblas.f90
2222
)
2323

24+
# Add include directories
25+
target_include_directories(
26+
test_spblas
27+
PRIVATE ${MKLINCLUDE}
28+
)
29+
2430
# Specify the MKL libraries for linking
25-
# NOTE: No target_include_directories MKL INCLUDE... even tho link line advisor suggests it
2631
target_link_libraries(
2732
test_spblas
2833
PRIVATE

test/test_spblas.f90

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ PROGRAM TEST_SPBLAS
4949
! | 0 0 50 60 70 0 |
5050
! | 0 0 0 0 0 80 |
5151

52-
! create csr
52+
x = [1, 1, 1, 1, 1, 1] ! for spmv
53+
values = [10, 20, 30, 40, 50, 60, 70, 80] ! for matrix values
54+
55+
!! create csr
5356
ia = [1, 3, 5, 8, 9]
5457
ja = [1, 2, 2, 4, 3, 4, 5, 6]
55-
values = [10, 20, 30, 40, 50, 60, 70, 80]
5658

5759
stat = mkl_sparse_s_create_csr( &
5860
a, SPARSE_INDEX_BASE_ONE, rows, cols, ia(1:4), ia(2:5), ja, values)
@@ -61,22 +63,24 @@ PROGRAM TEST_SPBLAS
6163
descr%TYPE = SPARSE_MATRIX_TYPE_GENERAL
6264

6365
! create coo
64-
row_indx = [1, 1, 2, 2, 3, 3, 3, 4]
65-
col_indx = [1, 2, 2, 4, 3, 4, 5, 6]
66-
stat = mkl_sparse_s_create_coo( &
67-
A_coo, SPARSE_INDEX_BASE_ONE, rows, cols, nnz, row_indx, col_indx, &
68-
values)
66+
!row_indx = [1, 1, 2, 2, 3, 3, 3, 4]
67+
!col_indx = [1, 2, 2, 4, 3, 4, 5, 6]
68+
!stat = mkl_sparse_s_create_coo( &
69+
!A_coo, SPARSE_INDEX_BASE_ONE, rows, cols, nnz, row_indx, col_indx, &
70+
!values)
71+
!PRINT *, "stat create = ", stat
72+
!descr%TYPE = SPARSE_MATRIX_TYPE_GENERAL
73+
!PRINT *, "descr%TYPE", descr%TYPE
6974

7075
! spmv csr
71-
x = [1, 1, 1, 1, 1, 1]
7276
stat = mkl_sparse_s_mv(SPARSE_OPERATION_NON_TRANSPOSE, 1.0, a, descr, x, 0.0, y)
7377
PRINT *, "stat mv = ", stat
7478
PRINT *, "result csr = ", y
7579
PRINT *, "expected = ", [30., 70., 180., 80.]
7680

77-
! spmv coo
78-
stat = mkl_sparse_s_mv( &
79-
SPARSE_OPERATION_NON_TRANSPOSE, 1.0, A_coo, descr, x, 0.0, y_coo)
80-
PRINT *, "result coo = ", y_coo
81+
!! spmv coo
82+
!stat = mkl_sparse_s_mv( &
83+
!SPARSE_OPERATION_NON_TRANSPOSE, 1.0, A_coo, descr, x, 0.0, y_coo)
84+
!PRINT *, "result coo = ", y_coo
8185

8286
END PROGRAM TEST_SPBLAS

0 commit comments

Comments
 (0)