https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118518
Bug ID: 118518
Summary: gcc 14.2.1 nvptx cross compiler complains about alias
definitions in a struct with two constructors that are
not aliases
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: schulz.benjamin at googlemail dot com
Target Milestone: ---
Created attachment 60176
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60176&action=edit
mdspan template classes
Hi there,
I tried to write my own version of the new mdspan class, but one which works
with non-compile time extents (i.e. which can be set by the input) and with gpu
offload support. The following c++23 code contains interesting algorithms for
matrix multiplication (Strassen Algorithm, and Winograd version of the Strassen
Algorithm) as well as some advanced and new algorithms for Cholesky, LU and QR
decomposition. It has two interfaces, one that uses the stl, with functions
that can work on gpu and may offload parts of the code at gpu, and another with
functions that can entirely reside on gpu.
It is certainly a bit more advanced than small openmp test cases. It uses
target teams, parallel for and simd instructions, as well as declare target
areas with functions on the target, memory allocation, pointer arithmetic for
sub-arrays.
It thus represents a nice compiler test. On clang, it compiles at least. but
the function offload fails for some reason on clang. and the winograd version
has, in clang, a problem with the omp runtime.
On gcc, it does not even compile.
the options:
-fopenmp -foffload=nvptx-none -fcf-protection=none -fno-stack-protector
-std=c++23 -no-pie lrt lm lc lstdc++
make gcc claim that "alias definitions" would not be allowed in this
configuration...
[100%] Linking CXX executable arraytest
/usr/bin/cmake -E cmake_link_script CMakeFiles/arraytest.dir/link.txt
--verbose=1
/home/benni/projects/arraylibrary/mdspan.h:356:22: Fehler: Alias-Definitionen
werden in dieser Konfiguration nicht unterstützt
356 | template<typename T> datastruct<T>::datastruct(
| ^
/home/benni/projects/arraylibrary/mdspan.h:386:22: Fehler: Alias-Definitionen
werden in dieser Konfiguration nicht unterstützt
386 | template<typename T> datastruct<T>::datastruct(
| ^
nvptx mkoffload: schwerwiegender Fehler:
/usr/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc gab Ende-Status 1 zurück
but if we look at the sourcecode, we get this, which do not look like aliases.
Probably gcc has difficulties with the offloaded functions which may be aliases
generated by the compiler?
#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
T* data,
size_t pdatalength,
bool rowm,
size_t rank,
size_t* extents,
size_t* strides,
bool compute_datalength,
bool compute_strides_from_extents
) : pdata(data),
pextents(extents),
pstrides(strides),
pdatalength(pdatalength),
prank(rank),
prowmayor(rowm)
{
if(compute_strides_from_extents==true && pextents!=nullptr &&
pstrides!=nullptr && rank !=0)
{
fill_strides(pextents,pstrides,rank,rowm);
}
if(compute_datalength==true && pextents!=nullptr && pstrides!=nullptr &&
rank !=0)
{
pdatalength=compute_data_length(pextents,pstrides,rank);
}
}
#pragma omp end declare target
#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
T* data,
size_t datalength,
bool rowm,
size_t rows,
size_t cols,
size_t* extents,
size_t* strides,
bool compute_datalength,
bool compute_strides_from_extents
) : pdata(data),
pextents(extents),
pstrides(strides),
pdatalength(datalength),
prank(2),
prowmayor(rowm)
{
if(extents!=nullptr)
{
pextents[0]=(rowm==true)?rows:cols;
pextents[1]=(rowm==true)?cols:rows;
}
if(pstrides!=nullptr && compute_strides_from_extents)
{
pstrides[0]=(rowm==true)? cols:1;
pstrides[1]=(rowm==true)?1: rows;
}
if(compute_datalength==true && extents!=nullptr && strides!=nullptr)
{
pdatalength=(rows-1) * strides[0]+(cols-1)*strides[1]+1;
}
}
#pragma omp end declare target
#pragma omp begin declare target
template<typename T> datastruct<T>::datastruct(
T* data,
size_t datalength,
bool rowm,
bool rowvector,
size_t noelements,
size_t* extents,
size_t* strides,
bool compute_datalength,
bool compute_strides_from_extents
) : pdata(data),
pextents(extents),
pstrides(strides),
pdatalength(datalength),
prank(1),
prowmayor(true)
{
if(extents!=nullptr)
{
pextents[0]=noelements;
}
if(pstrides!=nullptr && compute_strides_from_extents)
{
if(rowvector)
pstrides[0]=(rowm==true)? 1:noelements;
else
pstrides[0]=(rowm==true)? noelements:1;
}
if(compute_datalength==true && strides!=nullptr)
{
pdatalength=(noelements-1) * strides[0]+1;
}
}
#pragma omp end declare target