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
necrotic
Aug 2, 2005
I owe my brother big time for this!
That doesn't answer my question

Adbot
ADBOT LOVES YOU

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

canis minor posted:

You can write goto in anything, even in JS!

https://alexsexton.com/blog/2009/07/goto-dot-js/

:lol:

Also this got me searching. I was unaware that javascript has labeled breaks and continues for loops.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Because literally nobody uses them. They are one of the more braindead additions and that's saying a lot.

Pixelboy
Sep 13, 2005

Now, I know what you're thinking...

Hammerite posted:

after two hours trying to work out why icons aren't appearing in a dropdown list: lol, gently caress MFC

What are you doing that requires MFC? I hope it's legacy, and not new.

JawnV6
Jul 4, 2004

So hot ...

Beef posted:

Calm down, I'm not saying that for dick-waving purposes.
You, apparently, were a huge stickler for proper nomenclature in the very post I quoted and this is some quick backpedaling on a very specific term.

Beef posted:

I honestly have no idea what CRSB/RRSB is, no.

The issue came up during the recursion discussion, zero-length calls do not really apply. (Unless you are using a recursive function to do a while loop? I don't know, someone might call me on a technicality again.)
They're uArch features? Someone working at the micro-architectural level would necessarily be aware of them. I did you the favor of picking out a few very, very specific to x86 call/returns and handling the PC. Didn't mention split loads at all! Software folk way up on the assembly abstraction wouldn't care. You appear to not care.

Beef posted:

In the context of this reply to Sahero's post:

I think you will agree that the benefit from treating return addresses differently pales in comparison to having to populate stack frames, making a manual tail-call optimization using a goto totally legit.
Best autocorrection of shruges?? You sure are making a whole lot of words about super-ISA concerns, seriously at what point do you humor yourself as working at the micro-architectural level when you seem, at best, willfully ignorant of where that even is?

rjmccall posted:

We compiler folk know about it, but we are a willsome and belligerent people, best avoided.
Who even cares about PIC anyway. Just put the code at the same place.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
All you bare-metal motherfuckers both fascinate and terrify me.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JawnV6 posted:

Who even cares about PIC anyway. Just put the code at the same place.

Libraries are a disease on the soul. If you want something done right, you should do it yourself.

DaTroof posted:

All you bare-metal motherfuckers both fascinate and terrify me.

Are you calling me a node.js programmer????!!!

Kazinsal
Dec 13, 2011

DaTroof posted:

All you bare-metal motherfuckers both fascinate and terrify me.

Writing your own kernel from the ground up is an incredibly enlightening journey.

Holy gently caress the x86 architecture is a mess.

hobbesmaster
Jan 28, 2008

DaTroof posted:

All you bare-metal motherfuckers both fascinate and terrify me.

Play with an ARM processor. Buy one of the m0 arduinos or something. Then go look at the equivalent stuff in x86 in awe.

It's amazing x86 continues to get faster instead of being some forgotten dinosaur of the 80s. The "micro architecture" level is dark magic.

Dr. Arbitrary
Mar 15, 2006

Bleak Gremlin
A friend of mine made this:
https://github.com/monodop/jInquery

Captain Capacitor
Jan 21, 2008

The code you say?

rjmccall posted:



Are you calling me a node.js programmer????!!!

We need a word for one of those laughs where you're both really amused and terrified of the possible reality. That's me right now.

Beef
Jul 26, 2004

JawnV6 posted:

You, apparently, were a huge stickler for proper nomenclature in the very post I quoted and this is some quick backpedaling on a very specific term.

Not backpedaling, I quite literally work on micro-architectures: performance modeling and simulation, reporting to the hardware engineers and system designers. I'm still a software guy, but not a system programmer.

Why are you so passionate about calling me out?

Beef fucked around with this message at 09:56 on Feb 14, 2017

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

JawnV6 posted:

It's the only way on x86 to retrieve the current PC architecturally.

Yeah I'm actually aware of all of that except why it's happening enough to require optimizing. I think the only place I've seen it is in bootloaders and code that does some 'tricky' stuff.

Actually I guess I can't remember how it works but I assumed there was some reasonable way that it would reset at some cost.

I mean, does a call 0, pop rax just get turned into reading right from rip?

dougdrums fucked around with this message at 09:51 on Feb 14, 2017

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?

Beef posted:

Yeah, programming has nothing to do with computer science, nice.

I have a master in computer science, and even though recursive functions and recursive datastructures was only a part of one course during the first semester, I have to say that I have never come across your definition. Neither during my education nor the 5 years I have been working as a developer.

Jarl fucked around with this message at 10:15 on Feb 14, 2017

Athas
Aug 6, 2007

fuck that joker

Beef posted:

I think you're confusing things here. Only tail-recursive functions can be rewritten to not have recursion. Try writing a BFS/DFS without using a queue or stack.

Here you go, a parallel BFS that runs in space linear to the input size: https://github.com/HIPERFIT/futhark-benchmarks/blob/master/rodinia/bfs/bfs_parallel_segmented.fut

No recursion, although you could write the convergence loop as a tail-recursive function I guess.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Beef posted:

Goto discussion and no one mentioned Linus?

Incidentally, the code at the bottom of that thread looks very similar as Apple's goto fail.

quote:

If I compile with -Wall (enable all warnings), neither GCC 4.8.2 or Clang 3.3 from Xcode make a peep about the dead code. That's surprising to me. A better warning could have stopped this but perhaps the false positive rate is too high over real codebases? (Thanks to Peter Nelson for pointing out the Clang does have -Wunreachable-code to warn about this, but it's not in -Wall.)

Sounds like they need to take a leaf out of PHP's book and add a -Wactually-all, haha

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Pixelboy posted:

What are you doing that requires MFC? I hope it's legacy, and not new.

We are adding new functionality to an existing application which is implemented entirely in C++ using MFC

Beef
Jul 26, 2004

Jarl posted:

I have a master in computer science, and even though recursive functions and recursive datastructures was only a part of one course during the first semester, I have to say that I have never come across your definition.

Holy poo poo this keeps dragging on and I keep getting sucked in.

What textbook did that course use? I was a TA for few years for such a first-year course, we were using the SICP book which has been quoted a few times now. Programming in Scheme, students are made painfully aware what the difference is between a recursive process vs. recursion in syntax.
As a second year course on language runtime implementation, we used both a stack- and register- based interpreter implementations, where the difference is very obvious. The register-based implementation follows the C-stack, using recursive eval/apply (setjmp/longjmp call/cc, loving nightmare). The stack-based implementation was a while(true) loop with explicit stack management (super-easy call/cc). For the latter case, I cannot understand why you would say "Well, there are no self-referential functions here, so it's not recursive".

b0lt
Apr 29, 2005

Hammerite posted:

Sounds like they need to take a leaf out of PHP's book and add a -Wactually-all, haha

It's called -Weverything

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?

Beef posted:

Holy poo poo this keeps dragging on and I keep getting sucked in.

What textbook did that course use? I was a TA for few years for such a first-year course, we were using the SICP book which has been quoted a few times now. Programming in Scheme, students are made painfully aware what the difference is between a recursive process vs. recursion in syntax.
As a second year course on language runtime implementation, we used both a stack- and register- based interpreter implementations, where the difference is very obvious. The register-based implementation follows the C-stack, using recursive eval/apply (setjmp/longjmp call/cc, loving nightmare). The stack-based implementation was a while(true) loop with explicit stack management (super-easy call/cc). For the latter case, I cannot understand why you would say "Well, there are no self-referential functions here, so it's not recursive".

Since I studied CS and not computer engineering I only had one course on the hardware level about assembler, microcode and how the CPU actually works. Might explain why we weren't taught about the term "recursive process", and how it differentiate from when we normally do recursion. I have heard about recursion versus iteration; not recursion A vs recursion B: https://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursion_versus_iteration

Jarl fucked around with this message at 12:23 on Feb 14, 2017

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Hammerite posted:

We are adding new functionality to an existing application which is implemented entirely in C++ using MFC

lol there is a division at our company that has a legacy c++ client and they totally gave up on actually writing new C++ and just write all the new UI in javascript, host it in strategically placed web browser controls.... and run a motherfucking web server locally on the client machine for communication between the new code and the old code (as opposed to like, using connection sink for interop)

Doom Mathematic
Sep 2, 2008

Hammerite posted:

Sounds like they need to take a leaf out of PHP's book and add a -Wactually-all, haha

PHP had an E_ALL error-reporting level which did not actually report all of the errors. However, PHP eventually fixed that.

Beef
Jul 26, 2004

Athas posted:

Here you go, a parallel BFS that runs in space linear to the input size: https://github.com/HIPERFIT/futhark-benchmarks/blob/master/rodinia/bfs/bfs_parallel_segmented.fut

No recursion, although you could write the convergence loop as a tail-recursive function I guess.

I haven't heard of the language, it looks interesting. Is it a coincidence that it looks like SISAL?

From what I can gather, it uses a map/mask of visited notes that it updates between each step. Instead of pushing your to-visit children on a queue, you are allocating a full array of all nodes to track the same thing. How is this suddenly not a recursive process anymore:
- check work to do, finish if none left
- process work, push new work (or mark, in above example)
- do the same thing again
It's just like the doubly-linked list example from earlier, you are trading off dynamic space for static space.

Athas
Aug 6, 2007

fuck that joker

Beef posted:

I haven't heard of the language, it looks interesting. Is it a coincidence that it looks like SISAL?

Kind of; it looks like an SML/Haskell hybrid, which hail back to SASL. I think SISAL does the same.

Beef posted:

From what I can gather, it uses a map/mask of visited notes that it updates between each step. Instead of pushing your to-visit children on a queue, you are allocating a full array of all nodes to track the same thing. How is this suddenly not a recursive process anymore:
- check work to do, finish if none left
- process work, push new work (or mark, in above example)
- do the same thing again
It's just like the doubly-linked list example from earlier, you are trading off dynamic space for static space.

Recursion is a general enough concept to model just about anything. In the program above, the operational behaviour is not much like recursion (up-front allocation and linear space), and recursion is also not a good way to explain how the program behaves. It can be seen as a bunch of parallel recursive processes that are each (simultaneously) advanced by one evaluation step for every iteration of the outer loop. But really, is that a useful explanation? I don't think so - there are simpler ones (like the one you give). I would definitely explain this as an iterative algorithm. The convergence criterion is also a global property, which means that the usual definition of recursion as splitting a problem into smaller subproblems doesn't apply, as we repeatedly need a global view of the entire state of the computation.

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?

Beef posted:

- you are still allocating/using memory linear to the call depth,
- unwinding/popping your stack on function return and
- using the popped result to do some processing.

That non-tail recursive functions remain recursive is not news to me. And that an explicit auxiliary stack doesn't change anything since every "frame" in the stack match a call. Although, the term "procedure recursive" was new.

But how is working over a FIFO queue with an algorithm like an iterative-BFS recursive?

Jarl fucked around with this message at 12:39 on Feb 14, 2017

Beef
Jul 26, 2004

Jarl posted:

That non-tail recursive functions remain recursive is not news to me. And that an explicit auxiliary stack doesn't change anything since every "frame" in the stack match a call. Although, the term "procedure recursive" was new.

Good, that was how this discussion started. I hope we can get back to comedy coding horrors now.


Jarl posted:

But how is working over a FIFO queue with an algorithm like an iterative-BFS recursive?

If it holds for DFS, why would it not hold for BFS by simply changing the stack into a queue?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Captain Capacitor posted:

We need a word for one of those laughs where you're both really amused and terrified of the possible reality. That's me right now.

:stonklol: is close

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?

Beef posted:

Good, that was how this discussion started. I hope we can get back to comedy coding horrors now.

That's on me. I didn't read carefully enough. But I think what threw me off to begin with was that iterative-BFS was recursive.

Beef posted:

If it holds for DFS, why would it not hold for BFS by simply changing the stack into a queue?

Well, you are not unwinding/popping your stack but taking elements from the other end. Also, every call can create multiple elements.

To me (and I must admit I've never even considered this before) for something to be recursive in nature (not syntactical) it must create element for every "call" being build upon the last one. The only way the previous element can affect the new element is at creation, and any next element can only affect this new element are when they are done (there can be multiple "next" elements with each their own "next" elements).

The fact you are allocating/using memory linear to the call depth does not seem enough to me, and I'm pretty sure I would confuse most people using the word recursive when this alone is the case.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Bruegels Fuckbooks posted:

lol there is a division at our company that has a legacy c++ client and they totally gave up on actually writing new C++ and just write all the new UI in javascript, host it in strategically placed web browser controls.... and run a motherfucking web server locally on the client machine for communication between the new code and the old code (as opposed to like, using connection sink for interop)

MFC can be a pain in the rear end sometimes but that seems like quite some lengths to go to avoid it.

We develop new applications in .NET, but we have a handful of older stuff that's C++ that we support and occasionally extend (for our sins).

Beef
Jul 26, 2004

Jarl posted:

To me (and I must admit I've never even considered this before) for something to be recursive in nature (not syntactical) it must create element for every "call" being build upon the last one. The only way the previous element can affect the new element is at creation, and any next element can only affect this new element are when they are done (there can be multiple "next" elements with each their own "next" elements).

The fact you are allocating/using memory linear to the call depth does not seem enough to me, and I'm pretty sure I would confuse most people using the word recursive when this alone is the case.

Absolutely, you have the best words :)

Just looking at memory use is indeed not sufficient to call something recursion, it is rather a consequence of recursion.

ROFLburger
Jan 12, 2006

Some of you really get off on correcting people

sarehu
Apr 20, 2007

(call/cc call/cc)
And here I thought Beef was talking about primitive recursive functions or μ-recursive or something like that.

Klades
Sep 8, 2011

Recursive is when you try to remember all the stuff you were taught in the first grade about handwriting.

JawnV6
Jul 4, 2004

So hot ...

Beef posted:

Not backpedaling, I quite literally work on micro-architectures: performance modeling and simulation, reporting to the hardware engineers and system designers. I'm still a software guy, but not a system programmer.

Why are you so passionate about calling me out?
I was sorta happy that someone would actually be able to discuss uArch features, but you're decidedly above that level and don't seem to be aware of it. Which is totally fine, but you were also insisting on precise terminology, so a correction was forthcoming. I mean by this definition java programmers work "on micro-architectures" since it's kinda hard to work on a pure ISA simulator and most folks fall back to plain old instantiated uArches in silicon.

So when you try to make sweeping proclamations like this hot garbage:

Beef posted:

Your computer is not aware of any stacks, heaps or function calls, this is a convention used by compiler/runtimes. Also, there is just as much stack available as there is heap, they grow towards eachother: stack grows down, heap grows up.
This stack- and call-agnosticism you profess architectures to have doesn't really match my experience on x86 nor ARM. Some weaker version of it might be true on a particular x86 OS, but you don't seem limited to that narrow domain. Like I can't quite tell where you're trying to be right here, stack growth direction is as much a convention of ABI as anything else. ARM hardware is certainly aware of function calls and stacks to a much higher degree than x86 even outside the M's (i.e. SPSel), and I can't imagine the x86 system that doesn't use iret.

Also, last time we talked your heap had 100% overhead. So there isn't "just as much" stack.

dougdrums posted:

Yeah I'm actually aware of all of that except why it's happening enough to require optimizing. I think the only place I've seen it is in bootloaders and code that does some 'tricky' stuff.

Actually I guess I can't remember how it works but I assumed there was some reasonable way that it would reset at some cost.

I mean, does a call 0, pop rax just get turned into reading right from rip?
rjmccall alluded to it, for position-independent code like libraries sometimes you need to grab the PC to figure out where "here" is so you can jump "there." The 10-year old optimization is just to prevent zero-length calls from messing up other predictions.

It isn't actually "turned into reading right from rip" because an interrupt could still hit right after the call retires. If an assembly programmer could sit there and see that interrupts were oddly blocked out between those two instructions, it would violate the abstraction. Also memory is changed, if the chip got too clever and tried to skip that bit it would cause other issues.

Now that I say that, I'm not really sure if you can get an interrupt in the middle of a macro-fused pair of instructions. Gosh, if only there were a micro-architect around to help!

Pollyanna
Mar 5, 2005

Milk's on them.


To determine the version of the code deployed on any application environment, you need to look at the source, and examine the filename of the bundle. The bundle will contain a 7 character git hash, which corresponds to a component version.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

JawnV6 posted:

Now that I say that, I'm not really sure if you can get an interrupt in the middle of a macro-fused pair of instructions. Gosh, if only there were a micro-architect around to help!

I just skimmed through the simulator, and as near as I can tell, the Core microarchitecture never interrupts in between macro-fused ops. External interrupts are not guaranteed to arrive at the end of any particular instruction, just at the end of some instruction (or at a few other points, e.g. sync points within rep movs), so an external interrupt is simply deferred to the end of the pair. There are a few architecturally-visible interrupts (in/out instructions, disabling/enabling interrupts, hardware breakpoints) that could in theory happen on the first macro-op of a pair, but we take care to simply not fuse ops that are vulnerable to those.

Signed, a microarchitect.

JawnV6
Jul 4, 2004

So hot ...

ShoulderDaemon posted:

I just skimmed through the simulator, and as near as I can tell, the Core microarchitecture never interrupts in between macro-fused ops. External interrupts are not guaranteed to arrive at the end of any particular instruction, just at the end of some instruction (or at a few other points, e.g. sync points within rep movs), so an external interrupt is simply deferred to the end of the pair. There are a few architecturally-visible interrupts (in/out instructions, disabling/enabling interrupts, hardware breakpoints) that could in theory happen on the first macro-op of a pair, but we take care to simply not fuse ops that are vulnerable to those.

Signed, a microarchitect.
Ok, interrupt deferral makes sense. But you can still fault after the cmp and before the second op though? Put the jne on a different page requiring a fault or better yet straddling the canonical boundary. Everyone gets that edge wrong. I imagine those situations will never get fused though, the FE will recognize it needs to issue the fault before the decoder ever sees the pair.

There's no good way to fuse up a zero-length call though. The STA/STD pair required for the call's implicit push getting fused and not offering an instruction boundary between them, if the implicit stack location had to be paged in just to be marked dirty, etc. Too much going on there.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

ROFLburger posted:

Some of you really get off on correcting people

To be fair, this thread is basically one giant "Look at this jerk, doing it wrong!" Just, usually we don't get pointed at each other.

canis minor
May 4, 2011

TooMuchAbstraction posted:

To be fair, this thread is basically one giant "Look at this jerk, doing it wrong!" Just, usually we don't get pointed at each other.

I'm treating this thread as a learning exercise. Also, as a gentle consolation, that even if I'm doing something wrong, I'm doing it wrong to a lesser extent than some examples shown.

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JawnV6 posted:

There's no good way to fuse up a zero-length call though. The STA/STD pair required for the call's implicit push getting fused and not offering an instruction boundary between them, if the implicit stack location had to be paged in just to be marked dirty, etc. Too much going on there.

There's no need to actually fuse the ops, you only need the call to not affect the return-address predictor, which is simple enough to do without actually emitting the operations together. Honestly, you could probably do that without even considering the following instruction — zero-offset calls never happen in real code, and who gives a poo poo if someone manages to find a contrived use for one and it has terrible performance? You also want to forward the store, but that doesn't need fusion to work either.

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