- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

I want to create some unit tests for my project with mkl. I am working with Visual Studio 2017 and chose the Google framework, so I could keep the project platform independent.

My first test is targeting a self made wrapper for the boost bandwidth compression functionality (Cuthill Mckee) that gives an API for the mkl csr sparse matrices. The test looks as following:

```
TEST(TestCaseName, TestName) {
CuthillMckee test(true);
EXPECT_EQ(1, 1);
EXPECT_TRUE(true);
}
TEST(Bandwidth_UT, BandwidthCalculation_CM)
{
//sparse_matrix_t A;
//CreateMatrix(&A);
bool reversed = false;
CuthillMckee compressor(reversed);
//sparse_index_base_t indexing;
int rows, cols;
int * row_start, *row_end, *colIndices;
float * values;
//sparse_index_base_t indexing;
//mkl_sparse_s_export_csr(A, &indexing, &rows, &cols, &row_start, &row_end, &colIndices, &values);
//compressor.GeneratePermutationVector(rows, cols, colIndices, row_start, row_end, values);
//EXPECT_EQ(6, compressor.GetUncompressedBandwidth());
EXPECT_EQ(6, 6);
}
```

The example test case is listed in the Test Explorer and so is my BandwidthCalculation_CM test. But only if I keep the *mkl_sparse_s_export_csr function *out commented. If I include it and compile my test project, none of the test functions is displayed in the Test Explorer Window and no error or warning is given.

I know the topic is not exclusively related to oneAPI MKL but since it is a common framework, I was hoping that someone has a clue how to make that work.

Regards,

Jan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Since the matrix was not initialized we have seen garbage values being assigned to the variables. After initializing the matrix and other variables it worked fine for us.

```
#include "pch.h"
#include "mkl.h"
TEST(TestCaseName, TestName) {
EXPECT_EQ(1, 1);
EXPECT_TRUE(true);
}
TEST(Bandwidth_UT, BandwidthCalculation_CM)
{
#define M 5
#define N 5
#define NNZ 13
float csrVal[NNZ] = { 1.0, -1.0, -3.0,
-2.0, 5.0,
4.0, 6.0, 4.0,
-4.0, 2.0, 7.0,
8.0, -5.0 };
MKL_INT csrColInd[NNZ] = { 0, 1, 3,
0, 1,
2, 3, 4,
0, 2, 3,
1, 4 };
MKL_INT csrRowPtr[M + 1] = { 0, 3, 5, 8, 11, 13 };
sparse_matrix_t A;
mkl_sparse_s_create_csr(&A, SPARSE_INDEX_BASE_ZERO,
N, // number of rows
M, // number of cols
csrRowPtr,
csrRowPtr + 1,
csrColInd,
csrVal);
bool reversed = false;
//sparse_index_base_t indexing;
int rows, cols;
int* row_start, * row_end, * colIndices;
float* values;
sparse_index_base_t indexing;
sparse_status_t stat = mkl_sparse_s_export_csr(A, &indexing, &rows, &cols, &row_start, &row_end, &colIndices, &values);
//compressor.GeneratePermutationVector(rows, cols, colIndices, row_start, row_end, values);
printf("%d", rows);
//EXPECT_EQ(6, compressor.GetUncompressedBandwidth());
EXPECT_EQ(6, 6);
}
```

Please let us know if you face any issues.

Regards

Rajesh.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This is the first time that I have heard of Google Framework. Perhaps it requires that functions being tested, such as the MKL function being tested (but now commented out), should have a return value of a specific type? Your code seems to ignore the return value that the MKL function returns.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi mecej4,

the name of the framework is not Google Framework but Google test or gtest.

You have a valid point; I think ignoring a return value can be problematic in a testing environment. Sadly, this does not solve my issue. I added the assignment of the return value to line 21 and the issue remains.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Thanks for posting your query.

Can you please share the MKL version, Visual Studio version used. Also, can you please share a minimal reproducer along with build steps, so that we can reproduce the issue on our end.

Regards

Rajesh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Rajesh,

I am using Visual Studio 2019, the Test Adapter for Google Test Version 0.10.7 and MKL is located in the folder 2021.2.0 (I assume that is the version?). I use oneMKL sequential.

Regards,

Jan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Rajesh,

I forgot to add the reproducer.

1. Create a google test project (Consuming Google Test as Static Library; C++ runtime libbraries: Linked dynamically).

2. The content of the default .cpp will be listed in the Test Explorer.

3. Select MKL Sequential in the project settings and include the header.

4. Add the following test case:

```
TEST(Bandwidth_UT, BandwidthCalculation_CM)
{
sparse_matrix_t A;
bool reversed = false;
//sparse_index_base_t indexing;
int rows, cols;
int * row_start, *row_end, *colIndices;
float * values;
sparse_index_base_t indexing;
//sparse_status_t stat = mkl_sparse_s_export_csr(A, &indexing, &rows, &cols, &row_start, &row_end, &colIndices, &values);
//compressor.GeneratePermutationVector(rows, cols, colIndices, row_start, row_end, values);
//EXPECT_EQ(6, compressor.GetUncompressedBandwidth());
EXPECT_EQ(6, 6);
}
```

5. Rebuild the project and the second test case should be listed as well.

6. Uncomment the lines 10 and 12.

7. Now rebuild the project again and neither of the two test cases should be listed anymore.

Ps.: If google test is not installed in the VS version, I think the easiest way is via the VS installer. It was initially part of my IDE so it was part of the installation process.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Since the matrix was not initialized we have seen garbage values being assigned to the variables. After initializing the matrix and other variables it worked fine for us.

```
#include "pch.h"
#include "mkl.h"
TEST(TestCaseName, TestName) {
EXPECT_EQ(1, 1);
EXPECT_TRUE(true);
}
TEST(Bandwidth_UT, BandwidthCalculation_CM)
{
#define M 5
#define N 5
#define NNZ 13
float csrVal[NNZ] = { 1.0, -1.0, -3.0,
-2.0, 5.0,
4.0, 6.0, 4.0,
-4.0, 2.0, 7.0,
8.0, -5.0 };
MKL_INT csrColInd[NNZ] = { 0, 1, 3,
0, 1,
2, 3, 4,
0, 2, 3,
1, 4 };
MKL_INT csrRowPtr[M + 1] = { 0, 3, 5, 8, 11, 13 };
sparse_matrix_t A;
mkl_sparse_s_create_csr(&A, SPARSE_INDEX_BASE_ZERO,
N, // number of rows
M, // number of cols
csrRowPtr,
csrRowPtr + 1,
csrColInd,
csrVal);
bool reversed = false;
//sparse_index_base_t indexing;
int rows, cols;
int* row_start, * row_end, * colIndices;
float* values;
sparse_index_base_t indexing;
sparse_status_t stat = mkl_sparse_s_export_csr(A, &indexing, &rows, &cols, &row_start, &row_end, &colIndices, &values);
//compressor.GeneratePermutationVector(rows, cols, colIndices, row_start, row_end, values);
printf("%d", rows);
//EXPECT_EQ(6, compressor.GetUncompressedBandwidth());
EXPECT_EQ(6, 6);
}
```

Please let us know if you face any issues.

Regards

Rajesh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Rajesh,

thank you for your effort. Unfortunately, my issue remains the same, I assume it has something to do with my project settings. But since there is no compatibility problem with mkl, this topic might be better suited for another forum. Again, thank you for your time.

Regards,

Jan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

Thanks for accepting as a solution!

We will no longer respond to this thread. If you require any additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.

Have a Good day.

Regards

Rajesh

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page