- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
icpc failed to compile the following C++ code with omp depend, when const int was used and template was defined. But icpx let it pass. Would you help to explain why?
[dguo]$ icpc -Wall -fopenmp -c bug0.cpp
bug0.cpp(36): error: unsupported lvalue expression on locator-list
#pragma omp task depend(inout:row[mt-1])
^
compilation aborted for bug0.cpp (code 2)
[dguo]$ icpx -Wall -fopenmp -c bug0.cpp
[dguo]$
=======================================================
//------------------------------------------------------------------------------
template <typename scalar_t>
class Matrix
{
public:
int mt() const { return mt_; }
int mt_;
};
//------------------------------------------------------------------------------
// With 'const int mt', yields error:
// >> icpc --version
// icpc (ICC) 19.1.1.217 20200306
// Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
//
// >> icpc -Wall -fopenmp -c min_example.cc
// min_example.cc(36): error: unsupported lvalue expression on locator-list
// #pragma omp task depend(inout:row[mt-1])
// ^
//
// compilation aborted for min_example.cc (code 2)
//
// With 'int mt', compiles fine.
// >> icpc -Wall -fopenmp -c min_example.cc
// >>
//
// The templated class and function instantiation seems to be part of it.
// If the template is removed, it compiles fine.
//
template <typename scalar_t>
void trsm( Matrix<scalar_t> B, char* row )
{
const int mt = B.mt(); // fails
//int mt = B.mt(); // works
#pragma omp task depend(inout:row[mt-1])
{
}
}
//------------------------------------------------------------------------------
// Explicit instantiations.
template
void trsm<double>( Matrix<double> B, char* row );
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dahai,
Thanks for reaching out to us.
We can see that you are trying to use a const variable in the function definition present inside a class.
template <typename scalar_t>
class Matrix
{
public:
int mt() const { return mt_; }
const int mt_;
};
And you are getting an error while compiling it with ICPC.
So here we will suggest you to declare the const int mt_ inside the class and initialized it in the class constructor, this will create a complete definition of the class and will not show any error with ICPC. Please refer to the below code snippet:
template <typename scalar_t>
class Matrix
{
public:
int mt() const { return mt_; }
const int mt_;
Matrix(int a):mt_(a){
std::cout<<"Constro"<<std::endl;
}
};
Moving on to the other issue in min_example.cc we are also getting the same issue with the ICPC compiler when we are using const int inside depend clause and we don't know the exact cause of the issue yet. We are looking into this and give you an update on it.
Meanwhile, you can use int instead of const int but if your use-case needs to have const int then you can assign the value of row[mt-1] to a temporary variable and can use it.
For more details please refer to the following code snippet.
template <typename scalar_t>
class Matrix
{
public:
int mt() const { return mt_; }
const int mt_;
Matrix(int a):mt_(a){
std::cout<<"Constro"<<std::endl;
}
};
template<typename scalar_t>
void trsm( Matrix<scalar_t> B, char* row )
{
const int mt = B.mt(); // fails
char a=row[mt-1];
#pragma omp task depend(inout:a)
{//your task
}
}
int main(){
Matrix<int> obj(4);
char row[5] = {'a','a','a','a','a'};
trsm(obj, row);
std::cout<<obj.mt()<<std::endl;
return 0;
}
Thanks for reporting the issue, we will update you on it, till that you can try the above workaround.
Warm Regards,
Abhishek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. We are looking forward to your final solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We looked into the issue and we feel that it's a bug with ICPC so we are forwarding this issue to the concerned team.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've reported this to our Compiler Developer. But since, icpx works and there are workarounds, this issue is marked as low priority.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dahai,
We are closing this thread as we haven't heard back from you, assuming your issue has been resolved. We will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.
Regards
Prasanth
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page