Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Re: Google Unit tests containing MKL functions are not recognized

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

JWagner

New Contributor I

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

07-01-2021
02:38 AM

402 Views

Google Unit tests containing MKL functions are not recognized

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

1 Solution

MRajesh_intel

Moderator

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

07-06-2021
11:36 PM

319 Views

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

8 Replies

mecej4

Black Belt

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

07-01-2021
04:18 PM

384 Views

JWagner

New Contributor I

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

07-01-2021
10:36 PM

369 Views

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.

MRajesh_intel

Moderator

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

07-02-2021
04:15 AM

357 Views

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.

JWagner

New Contributor I

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

07-02-2021
04:39 AM

355 Views

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

JWagner

New Contributor I

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

07-02-2021
04:55 AM

350 Views

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.

MRajesh_intel

Moderator

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

07-06-2021
11:36 PM

320 Views

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.

JWagner

New Contributor I

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

07-07-2021
07:41 AM

305 Views

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

MRajesh_intel

Moderator

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

07-07-2021
09:08 PM

297 Views

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

Topic Options

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

For more complete information about compiler optimizations, see our Optimization Notice.