This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] Reduce stack use in blocked matmul
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 May 2017 17:42:12 +0200
- Subject: Re: [patch, fortran] Reduce stack use in blocked matmul
- Authentication-results: sourceware.org; auth=none
- References: <2f81b4a0-79b7-1366-56f3-7355bb9f264a@netcologne.de> <mvm4lwt9nim.fsf@suse.de>
Hi Andreas,
+ index_type t1_dim;
+ t1_dim = (a_dim1-1) * 256 + b_dim1;
+ if (t1_dim > 65536)
+ t1_dim = 65536;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wvla"
+ 'rtype_name` t1[t1_dim]; /* was [256][256] */
That does the wrong thing if b_dim1 == 0xDEADBEEF.
(gdb) p (a_dim1-1) * 256 + b_dim1
$2 = -764456190
A look into the source code shows that b_dim1 is index_type,
which is 32 bits on 32-bit sytems and 64 bits on 64-bit system.
Now, consider if it is possible to declare an array on a 32-bit
system where the number of elements along one direction exceeds 2**31-1
(so sign extension would come into play), or if it would be
possible to declare an array on a 64-bit system where the number of
elements along one direction exceeds 2**63-1.
If you manage to come up with a legal Fortran testcas which
sets b_dim1 to 0xdeadbeef, I owe you a beer :-)
Regards
Thomas