Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
raminasi
Jan 25, 2005

a last drink with no ice
Scientist C codebase from multiple decades ago spelunking update:

C code:
int main(int argc, char *argv[])
{
	int i;
	int month, day, jday;
	int *daylight_status;     /*  0=night hour, 1=sunrise/sunset hour, 2=innerday hour  */

	float time, *times;
	float irrad_glo, irrad_beam_nor, irrad_dif;     /* in W/m² */
	float *irrads_glo, *irrads_beam_nor, *irrads_dif, *indices_glo, *indices_beam, *sr_ss_indices_glo;
	float *irrads_glo_st, *irrads_glo_clear_st, *irrads_beam_nor_st, *irrads_dif_st, *indices_glo_st;
	float solar_elevation, solar_azimuth, eccentricity_correction;

void solar_elev_azi_ecc ( float latitude, float longitude, float time_zone, int jday, float time, int solar_time, float *solar_elevation, float *solar_azimuth, float *eccentricity_correction)

		/*  angles in degrees, times in hours  */
{
  float sol_time;
  float solar_declination, jday_angle;
What's that, you say? main got accidentally truncated somehow? No, friends, that is a nested function.

My advisor also said that the port (from 90s MinGW gcc to VS2013) has gotten him a 20x speedup (with the outputs still correct). I assumed better optimization, but that surprised me.

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

GrumpyDoctor posted:

My advisor also said that the port (from 90s MinGW gcc to VS2013) has gotten him a 20x speedup (with the outputs still correct). I assumed better optimization, but that surprised me.
I'd be curious to see what a peek at the disassembly revealed. Guessing the 90's gcc is using the x87 FP stack that a modern processor will dutifully execute much slower than an equivalent SSE-enabled flow.

mobby_6kl
Aug 9, 2009

by Fluffdaddy

GrumpyDoctor posted:

Scientist C codebase from multiple decades ago spelunking update:

C code:
int main(int argc, char *argv[])
{
/*...*/
void solar_elev_azi_ecc ( float latitude, float longitude, float time_zone, int jday, float time, int solar_time, float *solar_elevation, float *solar_azimuth, float *eccentricity_correction)

		/*  angles in degrees, times in hours  */
{
  float sol_time;
  float solar_declination, jday_angle;
What's that, you say? main got accidentally truncated somehow? No, friends, that is a nested function.

My advisor also said that the port (from 90s MinGW gcc to VS2013) has gotten him a 20x speedup (with the outputs still correct). I assumed better optimization, but that surprised me.

That's a function definition and not just a declaration, so how the gently caress does that even work? :stare:

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

mobby_6kl posted:

That's a function definition and not just a declaration, so how the gently caress does that even work? :stare:

https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I've never seen the term "all hell breaks loose" in official, public documentation before.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Isn't that pretty much just a lambda, though? :slick:

Qwertycoatl
Dec 31, 2008


The best bit is that when you're in the nested function, you can use a goto to jump to a label in the outer function :catstare:

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

NihilCredo posted:

Isn't that pretty much just a lambda, though? :slick:
The gross hacky part is that it can access upvalues from the containing scope without any sort of pointer to where that data is stored. A "normal" lamdba involves both a pointer to the function and some sort of attached state.

QuarkJets
Sep 8, 2008

Athas posted:

There is nothing necessarily wrong with C++, as long as you have restraint and good taste. It is simply my experience that most physicists does not have the necessary software engineering experience to realise when they are using C++ to implement a simple and maintainable abstraction, and when they are conjuring some eldritch malevolent horror of the beyond. Using C++ to hackily emulate unit of measurement types is one good-intentioned cause that can easily go very wrong if one does not know when to stop.

Python with Numpy is decent for most things. I know of a computer-scientist-turned-physicist who is spending his years trying to make Python suitable for supercomputing and other high-performance computing domains, mostly so he can get physicists to stop using C++. He (and his students) have been doing a thing called Bohrium, which (simplified) is a JIT-compiler that transparently turns Numpy-calls into efficient vectorised code.

That sounds neat but have they considered just becoming Julia developers?

fritz
Jul 26, 2003

QuarkJets posted:

That sounds neat but have they considered just becoming Julia developers?

People use python tho.

Mellow_
Sep 13, 2010

:frog:

fritz posted:

People use python tho.

Maybe you're a *neophyte* /insertmoreinsultingterms

QuarkJets
Sep 8, 2008

fritz posted:

People use python tho.

Yeah but this is aimed at people who don't already use Python, right? That's what the poster said.

I mean between Python and Julia I personally prefer Python with the numba module for my supercomputing needs, but it sounds like Julia would be more up their alley

pseudorandom name
May 6, 2007

Plorkyeran posted:

The gross hacky part is that it can access upvalues from the containing scope without any sort of pointer to where that data is stored. A "normal" lamdba involves both a pointer to the function and some sort of attached state.

By generating new functions at runtime and storing them on the executable stack, no less.

Athas
Aug 6, 2007

fuck that joker

QuarkJets posted:

Yeah but this is aimed at people who don't already use Python, right? That's what the poster said.

I mean between Python and Julia I personally prefer Python with the numba module for my supercomputing needs, but it sounds like Julia would be more up their alley

Python has more traction and Julia is younger. I agree Julia is better. I'm not a computational scientist myself (just a regular ol' computer scientist), but I enjoy watching the fray as a spectator.

feedmegin
Jul 30, 2008

JawnV6 posted:

I'd be curious to see what a peek at the disassembly revealed. Guessing the 90's gcc is using the x87 FP stack that a modern processor will dutifully execute much slower than an equivalent SSE-enabled flow.

Probably better register allocation too - graph colouring was still under patent back then. And if he also went from 32 to 64 bit x86 then there's twice as many integer registers to play with as well, plus as mentioned SSE for floating point.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
pre:
25034 | 2015-06-25 | horrible_dev : changed font to arial
 scripts/js/dashboardJS.js              |  509 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 10 files changed, 471 insertions(+), 72 deletions(-)

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

IT BEGINS posted:

pre:
25034 | 2015-06-25 | horrible_dev : changed font to arial
 scripts/js/dashboardJS.js              |  509 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 10 files changed, 471 insertions(+), 72 deletions(-)

lol




:psyduck: I can't check anything in in VS all of a sudden (a restart fixed it).

JawnV6
Jul 4, 2004

So hot ...

feedmegin posted:

Probably better register allocation too - graph colouring was still under patent back then. And if he also went from 32 to 64 bit x86 then there's twice as many integer registers to play with as well, plus as mentioned SSE for floating point.

Register allocation goes without saying coming off of x87. There are 8 stack locations that are only transferred to/from the integer registers one at a time. Compare that to a SSE4 gather op that can pull fp args from memory in a single macroinstruction. I'm starting to think 20x seems really slow, but granted that's with only machine intervention.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
Half of my coworkers still don't understand how to use rebase in mercurial. As a result, our repository log often looks like this:

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

IT BEGINS posted:

Half of my coworkers still don't understand how to use rebase in mercurial. As a result, our repository log often looks like this:



I think it looks pretty :3:

sarehu
Apr 20, 2007

(call/cc call/cc)

IT BEGINS posted:

Half of my coworkers still don't understand how to use rebase in mercurial. As a result, our repository log often looks like this:



There's no reason to sperg about history.

Soricidus
Oct 21, 2010
freedom-hating statist shill

sarehu posted:

There's no reason to sperg about history.

What happens if you try to bisect on a tangled history like that? Serious question, I've never tried it, but it looks like it could get a bit weird.

qntm
Jun 17, 2009
What would a "good" diagram look like?

IT BEGINS
Jan 15, 2009

I don't know how to make analogies

qntm posted:

What would a "good" diagram look like?

I think as long as there aren't dozens of 'Automated merge with upstream' in the history it's probably fine. I'm in favor of aggressively branching for features, but when you have multiple people adding one-line bugfixes every few minutes you often end up with a completely incomprehensible history.

sarehu
Apr 20, 2007

(call/cc call/cc)

Soricidus posted:

What happens if you try to bisect on a tangled history like that? Serious question, I've never tried it, but it looks like it could get a bit weird.

It works great.

QuarkJets
Sep 8, 2008

IT BEGINS posted:

Half of my coworkers still don't understand how to use rebase in mercurial. As a result, our repository log often looks like this:



Maybe your coworkers know how to rebase and they just like to make pretty diagrams like this one

Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop
I'm not sure what bisect does with that - linearly insert the merged changes into the history, or treat the merge as an atomic unit unless bisect lands on it?


I actually write makefiles by hand. It keeps an upper-bound on the amount of complexity I'm willing to tolerate in my build system, because doing advanced things with make gets eyebleedingly painful really quickly. It's only a few dozen lines, and it handles building for two architectures in one checkout via per-arch build path.

Then of course there's the classic X makefiles that were so complicated that it took a multi-year effort to make them parallelizable. Or the android make-based build system. How the gently caress did they make that so goddamned slow?

sarehu
Apr 20, 2007

(call/cc call/cc)

Harik posted:

I'm not sure what bisect does with that - linearly insert the merged changes into the history, or treat the merge as an atomic unit unless bisect lands on it?

It treats it as the graph it is. The commit that broke things is in your "bad" commit's history and is not in any of your good commits' histories. git-bisect maintains a set of good commits and just one bad commit, and the next commit it picks is one that splits the set of commits that are in your bad commit's history and that are not in any of your good commits' histories into two appropriate parts.

Mellow_
Sep 13, 2010

:frog:

sarehu posted:

It treats it as the graph it is. The commit that broke things is in your "bad" commit's history and is not in any of your good commits' histories. git-bisect maintains a set of good commits and just one bad commit, and the next commit it picks is one that splits the set of commits that are in your bad commit's history and that are not in any of your good commits' histories into two appropriate parts.

That's a hell of a lot more straightforward than I thought it would be.

Doctor w-rw-rw-
Jun 24, 2008

AuxPriest posted:

That's a hell of a lot more straightforward than I thought it would be.

Well, so is the rest of git if you can find the right explanation. Git is (IMO) little more than a DAG of files and labels, at its core.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I find it easier to think about git as a graph of changes, rather than a graph of files. For some reason that makes it more straightforward to reason about what merges will do, for example.

Doctor w-rw-rw-
Jun 24, 2008

Subjunctive posted:

I find it easier to think about git as a graph of changes, rather than a graph of files. For some reason that makes it more straightforward to reason about what merges will do, for example.
Easier, but directly contradicted by some of the more detailed literature on git.

Git is a graph of repository state, not of repository changes. While its storage uses deltas, on a conceptual level git is not a graph of deltas, and this distinction is actually important precisely because it directly influences what merges will do.

Git does snapshot version control while others (such as Mercurial) typically do changelog version control. Here's some links I dug up:

http://stackoverflow.com/a/8198276 (concise, basically summarizes http://git-scm.com/book/en/v2/Getting-Started-Git-Basics#Snapshots,-Not-Differences, which it links to)
http://stackoverflow.com/a/1599930 (see: Repository structure, storing revisions, ctrl-f changelog)
https://github.com/schacon/git-presentations/blob/master/sor09/GitTalk-SOR09.pdf - some neat diagrams partway through this PDF

Doctor w-rw-rw-
Jun 24, 2008
Also relevant, to expand on how that conceptual difference affects merging:

https://news.ycombinator.com/item?id=2456415

Git can do octopus merges, because the state is what matters, and delta compression just makes it smaller. Mercurial (for example) can't; merges can only have two parents, because the deltas matter.This means that git sacrifices the ability to resolve more complex merge scenarios. See: Understanding Darcs/Patch theory

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I actively look for places where an octopus merge would be useful just so I can say I did one, and I've never found one.

evensevenone
May 12, 2001
Glass is a solid.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2cde51fbd0f3

b0lt
Apr 29, 2005

http://marc.info/?l=linux-kernel&m=139033182525831

Doctor w-rw-rw-
Jun 24, 2008

The best line from that:

Linus Torvalds posted:

It's pulled, and it's fine, but there's clearly a balance between
"octopus merges are fine" and "Christ, that's not an octopus, that's a
Cthulhu merge".

Xarn
Jun 26, 2015

The parents take more than one screen...



For thread related content, I just remembered a make system horror I had to work with:
https://rtime.felk.cvut.cz/omk/omk-manual.html

It says that it is user friendly make alternative, which it kinda is, but the documentation is incomplete, it is a massive set of make macros and has quite a lot of implicit, undocumented behavior. On the other hand, compared to my experience with classic make/autotools, adding a new build target is absurdly easy and some of the implicit behavior really simplifies things.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


Adbot
ADBOT LOVES YOU

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.
Here's the full article if you want more: http://www.gamasutra.com/view/feature/4111/dirty_coding_tricks.php

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply