[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Excessive copies of set elements in GMPL
From: |
Michael Hennebry |
Subject: |
Re: Excessive copies of set elements in GMPL |
Date: |
Fri, 24 Jul 2020 13:04:25 -0500 (CDT) |
User-agent: |
Alpine 2.20 (DEB 67 2015-01-07) |
On Fri, 24 Jul 2020, Andrew Makhorin wrote:
The issue can be illustrated by the following example:
for (i = 0; i < 1000000; i++)
for (j = 0; j < 1000000; j++)
for (k = 0; k < 1000000; k++)
if (j == i+1 && j == j+2)
foo(i, j, k);
Would you expect the C compiler to optimize this fragment in order not
to perform obvious excessive computations?
My recollection is that gcc does make that
kind of optimization for linear constraints.
At the very least, most optimizing compilers
would hoist the j==i+1 test ouside the k loop.
That might be just enough to allow it to run in a practical amount of time:
a few trillion cycles plus whatever foo requires.
That said, the coder can, as noted,
provide equivalent code that requires no optimization.
--
Michael hennebry@web.cs.ndsu.NoDak.edu
"Sorry but your password must contain an uppercase letter, a number,
a haiku, a gang sign, a heiroglyph, and the blood of a virgin."
-- someeecards
- Re: Excessive copies of set elements in GMPL, (continued)
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/21
- Re: Excessive copies of set elements in GMPL, Michael Hennebry, 2020/07/23
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/24
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/24
- Is this code correct in the GMPL implementation ?, Domingo Alvarez Duarte, 2020/07/25
- Re: Is this code correct in the GMPL implementation ?, Andrew Makhorin, 2020/07/25
- Re: Excessive copies of set elements in GMPL, Domingo Alvarez Duarte, 2020/07/24
- Re: Excessive copies of set elements in GMPL,
Michael Hennebry <=
- Re: Excessive copies of set elements in GMPL, Andrew Makhorin, 2020/07/25