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
JawnV6
Jul 4, 2004

So hot ...
Slap -S on there and see what the compiler is doing to your code.

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Zhentar posted:

(and be using registers pretty much exclusively anyway).

Nah, at -O0 gcc operates entirely on the stack :v: . In that pastebin foo uses [rbp-20] as i, bar uses [rbp-4]. The actual for loops are compiled to be basically identical, but bar has the overhead of control flow.

Master_Odin, if you're interested, bar is executing 2 jumps before it calls foo. You check if the argument i is 0 (cmpl $0, -20(%rbp)), then you check if it's 1 (cmpl $1, -20(%rbp)), then finally store the argument to foo and jump. When i=0, you've still got an extra branch checking for that condition before executing the for loop.

I don't understand the profiler output you posted earlier (never used gprof) but you're calling bar twice. On the first time, it figures out the control flow and calls foo, so 'bar' looks like it takes 'foo+overhead' time. Then you call bar again and the very first jump goes a different direction1, then you hit the for loop. So bar has a little extra overhead both times you call it. I'm not sure if that entirely explains the discrepancy, but it doesn't surprise me that bar would take measurably longer to run the 'same' code. Control flow isn't free :)

1I'm really hesitant to bring up branch prediction, especially in a context like this. Early on in my career, another engineer brought me a snippet of code and said it mispredicted 5 times. I was quick to explain, "Oh of course you'd expect 5, the first one is branch y that goes forward..." and had a neat lil story about how it happened. Another engineer overheard, and came to correct me with their neat lil story about how it happened. Long story short, 3 people well-versed in the microarchitecture were all entirely wrong about how branches were predicted, even when the total count was given in advance. So I don't have much faith in coders predicting predictors a priori.

JawnV6
Jul 4, 2004

So hot ...

Contero posted:

The circuit will never become stable the way I'm simulating it.

Then you have a hardware loop or the oscillation is by design? I can't tell from your description which case you're worried about, you should read up on System Verilog Scheduling Semantics. You need more words that "current/next".

JawnV6
Jul 4, 2004

So hot ...
Check out the Girvan-Newman algorithm.

Doesn't help you with the "how many clusters" problem Lysidas mentioned, but it'll give you the clusters.

JawnV6
Jul 4, 2004

So hot ...

Sedro posted:

Because that will only match the beginning of the string (only the first line) and AFAIK there is no "beginning of line" anchor.

What goofy regex environment are you in that isn't splitting up lines for you? "undef $\"?

JawnV6
Jul 4, 2004

So hot ...

Bob Morales posted:

I find if you don't have a pet project in mind you'll just wander around aimlessly.

This bit is far more important than what language you choose. If you're just doing toy problems without an end goal, you'd have to have superhuman motivation to chug through. If you're solving a problem for yourself, it's much easier to see it through.

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

I'm starting my senior project and we'll be doing it in PHP
...
@Bob, yea, all I know is .NET, PHP and a little Java.

Senior in high school, right??

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

Um, how many actual languages did you learn in college? Sure, okay, I have SQL in there as well of course but I'm not going to list every single course I've taken that introduced me to something new such as Javascript.

You're graduating college and you don't know what a pointer is?? There are entire classes of CS problems you don't even have the vocabulary to discuss.

Since you're curious, I wrote programs in C/C++, Java, Lisp, Verilog, and MIPS asm.

JawnV6
Jul 4, 2004

So hot ...

Phiberoptik posted:

Right now Ive gotten it to the point where Itll tell me my two cards, so say "Ac" in one variable, and "Ad" in another variable. I'm wondering what the best way it is to compare to a list of hands Id like to fold.

You probably want to write some helper functions that pull out information about the cards. I'm thinking in an OO way, but something like card.suit() that would return the suit and card.value() that would return the numeric value. Then you'd build rules based on that, like
code:
if(card1.suit() != card2.suit() ) { //suits dont match
  if(card1.value() - card2.value() >= 5) { //can't make a straight
    fold();
  }
}
You don't want to pre-generate a list of 2652 possibilities to check against when you have much higher-level tools to work with.

JawnV6
Jul 4, 2004

So hot ...

peepsalot posted:

e: what's with all the linux questions unrelated to programming lately. There's a general linux question thread.

School's out for summer, "Programming" is the next visible abstraction for "kid who's good w/ computers"

JawnV6
Jul 4, 2004

So hot ...

tef posted:

Beware of the side-effects of learning lisp. It makes you a smug rear end in a top hat.

I thought functional languages didn't have those?

JawnV6
Jul 4, 2004

So hot ...
It's going to vary wildly between different processor families.

Even within a family different types of branch mispredicts can have different costs, e.g. if the CPU predicts based on IP address then corrects after decode, or if a prediction made at decode actually takes until the backend computes some result that changes the branch path. If you've got a very specific system in mind, you could probably do some basic analysis on your own with PMONs, check the PRM vol. 3B.

Realistically on any sane code you're getting 95% or better and branch mispredicts aren't eating up a lot of your time anyway. If you want a cite for the basic bimodal predictor just use the Yeh-Patt paper.

JawnV6
Jul 4, 2004

So hot ...

Dijkstracula posted:

My understanding of what would happen is that, say, a branch marked strongly-taken will start executing both branches

I'm only aware of one architecture that tried to do things this way (Sun's Rock). Remember that our predictors are well above 95% in most cases, why would you waste pipeline space on ops that you think have a 3% chance of actually mattering? You charge ahead on the probable path, knowing you'll have to clear the whole pipeline if you're wrong.

It really sounds like PMONs and TSC readings could get you exact data on what you need. You're having far too much fun anyway, curl up around a computer. Although chasing down every cite of Yeh-Patt probably has you doing that anyway.

JawnV6
Jul 4, 2004

So hot ...
code:
#include <dlfcn.h>
What unholy black magic is this and what is it doing in code.

JawnV6
Jul 4, 2004

So hot ...
Oh, you mean the documented behavior of the Bing toolbar that the Google engineers agreed to when they installed it before doing that test? The exact same thing that Chrome does across millions of installs? Yeah, pretty much.

JawnV6 fucked around with this message at 23:52 on Aug 24, 2012

JawnV6
Jul 4, 2004

So hot ...

Suspicious Dish posted:

Chrome does not do any user tracking. It's a myth that has been dispelled by multiple Google engineers. If you have a better citation than Google engineers, please let me know.

It was Google Toolbar, not Chrome. My bad. The relevant question still stands, and Google Engineers were "mystified" when the Bing toolbar sent a clickstream, exactly as it said it would when they agreed to install it.

JawnV6
Jul 4, 2004

So hot ...
Delete the directory.

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

I really can't find anything interesting that's legitimately new

Such a Thing doesn't exist.

JawnV6
Jul 4, 2004

So hot ...

Sylink posted:

This is because I imagine trying to calculate the time billions of times a second will add in all kinds of crazy errors.

What kind of crazy errors are you imagining?

JawnV6
Jul 4, 2004

So hot ...
Dear god please use the syscalls

JawnV6
Jul 4, 2004

So hot ...

shrughes posted:

Using the rdtsc instruction to get the time in "cycles" will take about 20 ns.
Depending on your processor you also get to learn all about C states and P states and after tearing your hair out for a while finally understand why you should probably just chuck it to the OS for the minuscule hit.

JawnV6
Jul 4, 2004

So hot ...

shrughes posted:

It's not a miniscule hit and rdtsc has had no practical problems for measuring timings for us
Bolded the important bit, feel free take another whack at it:

JawnV6 posted:

Depending on your processor you also get to learn all about C states and P states and after tearing your hair out for a while finally understand why you should probably just chuck it to the OS for the minuscule hit.

JawnV6
Jul 4, 2004

So hot ...

yaoi prophet posted:

Why are we talking about this anyway? We don't even know how accurate Sylink needs the count to be.

He said "billions of times a second." That puts you on the ns scale.

JawnV6 fucked around with this message at 16:54 on Nov 1, 2012

JawnV6
Jul 4, 2004

So hot ...

yaoi prophet posted:

I think he was assuming that if they didn't put in a timer and just ran everything as fast as possible they'd run it billions of times a second (which they obviously won't unless they have some kind of terahertz processor).

:confused: Do programmers really lack this kind of intuition? What the heck do they think a gigahertz is? Or is the confusion on IPC? The units are right there in the question.

On the last page you clearly have the kind of intuition I'm talking about and know that billions/sec implies a limit of a few instructions. I guess I thought that was more common.

JawnV6
Jul 4, 2004

So hot ...

yaoi prophet posted:

How does memory virtualization work with Intel VMX? My understanding is that with EPT the guest can do whatever it wants with CR3, and then the EPT steps in and translates the guest-physical address to a host physical, but what do you do if you don't have EPT available?

Trap it and do it in software. There's a VMware whitepaper that compares shadow page tables to EPT.

JawnV6
Jul 4, 2004

So hot ...
Yeah, that makes sense. Are you freezing the code or is RAM being updated while you dump?

If you get clean snapshots without any skid, the analysis should be relatively simple. If the value in address 0x1000 is consistently 3x the value you're looking for across a dozen traces, it's probably linked that way in the code.

JawnV6
Jul 4, 2004

So hot ...
I was trying to figure out what kind of variability you were accounting for with the statistical analysis. e.g. it might be possible to sample the known location and see 10 and sample the unknown location when the variable's been updated to 100.

It doesn't sound like your system is susceptible to that failure mode. Seems you're more worried about analog sensing and scaling where the unknown value reads out as 3.99x, 4.01x, 4.02x and you want to tease out that it's ~4?

JawnV6
Jul 4, 2004

So hot ...
uh hopping ISA's is so much bigger than 32/64 i'm not sure why the latter merits discussion

JawnV6
Jul 4, 2004

So hot ...

Jabor posted:

Just knowing that everyone running {windows released in the past X years} is capable of running a 64-bit app

:allears:

Care to take a stab at the low end of X? As in after what year could we maybe possibly begin to say that?

JawnV6
Jul 4, 2004

So hot ...
:stare: How was there not a prereq to have some programming before this course? I'll type more later but wtf

JawnV6
Jul 4, 2004

So hot ...

Xerophyte posted:

Sheesh. In spite of what a lot of people here apparently think there's no rule saying your brain will explode unless you start at an abstract language and work your way down to the metal, especially if you're in EE.
I'm not saying it's impossible or whatever that cute strawman is, I'm saying that coursework arranged that way is less effective than if a higher level programming course had been taught first. Assembly is an API between hardware and software, coming at it from just one side is going to be confusing. Teaching assembly first is like jamming OOP into an intro course. I'm sure you can get a big chunk of the concepts across but the *why* behind them and the reasoning behind tradeoffs is going to be taught as a matter of faith.

As an aside, have you ever worked with someone who learned from assembly? In my perl class there was a guy who'd only written x86 asm for 20 years. I think he choked back tears when he understood the complexity being swept up behind "if" statements. Just imagine "programming languages teach you to not want what they don't provide" taken to the extreme.

Sirocco posted:

Technically we only learned how to make files and scan them for viruses last semester, ha ha. I don't know what kind of program we're supposed to be writing, there's no reference to it in the notes. All the lecturer said was that it should be "fairly complex" which is pretty nebulous but I expect the program writing will be a few months down the line.
I'm sure a college program isn't going to leave someone high and dry and the content will be geared for first time programmers, it just doesn't make sense why they'd want to structure a program like this in the first place. I don't think you should go off and learn python, focus your learning effort on the class itself.

JawnV6
Jul 4, 2004

So hot ...

Xerophyte posted:

You might as well say that higher level programming languages are an API between humans and assembly and coming at them from just one side will be confusing. Which it is, but you have to start somewhere and for an electrical engineer building a CPU from the ground up and then introducing assembly mnemonics as a way to interface with it is probably among the more intuitive options.
That's the stupidest description of a HLL I've seen in recent memory. How many hundreds of thousands of programmers get by just fine without ever being aware of assembly without confusion? Versus how many HW engineers get by without knowing another language apart from the ISA? Zero, at the very least they're competent in an HDL.

Xerophyte posted:

Sure, he'd be writing better assembly if he'd learnt a higher level language first. He's also going to write better high level code from learning assembly first when he starts with that.
Entirely disagreed with the second. I brought up an example of exactly this in my previous post. You can write FORTRAN in anything, and asm-in-perl is horribly by perl standards.

Going HLL->asm is a way to bypass compilers in understanding computing by jumping down to that abstraction. Programmers get to see the atomic operations that all their HLL statements must be broken down into

Going asm->HLL gives you nothing. You're better off ignoring the asm learnings entirely until you're on solid footing with the HLL abstraction.

Bunny Cuddlin posted:

This is ridiculous. Learning assembly on the heels of learning hardware organization is a completely natural progression, it's nothing like trying to teach OOP before teaching basic programming skills.
Basic programming should have come before both. Throwing someone into Verilog/VHDL as their first exposure to a large structured language that gets read by a computer is cruel. I'd rather risk someone thinking of HDL's as C since that's easy enough to dispel.

JawnV6
Jul 4, 2004

So hot ...

Bunny Cuddlin posted:

If I wanted to write a toy operating system for a toy architecture, is Modern Operating Systems the book to buy?

My course used Operating System Concepts, which was just fine. What toy architecture?

JawnV6
Jul 4, 2004

So hot ...
I'm not really sure if they went into your specific questions, but the Hydan paper was geared to hide information in x86 binaries and might cover some shared ground.

I have a perl script. I want to distribute similar code to non-CS folks. Are C# regex/data structures the easiest path to translate perl into for easy distribution?

e: done a couple hours later without burning hard on it, so "yes"

JawnV6 fucked around with this message at 23:09 on Apr 19, 2013

JawnV6
Jul 4, 2004

So hot ...
Yeah once you've built a foundry and then a lathe with it, a fun lil' project is to put together a mill!

JawnV6
Jul 4, 2004

So hot ...
Dicks can be quite persuasive.

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

That seems like a poor idea, unless figure 1A is "lovely code you will write" and then 1B is "good code you might write after 5+ years"

Given that it's a book about compilers, source code maintainability may not have been their primary concern.

JawnV6
Jul 4, 2004

So hot ...

Syle187 posted:

Should I just grab a book on VB6?

Apply directly to forehead.

JawnV6
Jul 4, 2004

So hot ...
Seems like Eugenics is trying to come up with a single regex that will capture data from multiple lines up until the next >>log?

What language are you working in? You probably want something like this skeleton (perl):
Perl code:
while(<>) {
  if($_ =~ /log_(.*)/) {
    $lognum = $1;
  }
  if($_ =~ /(.*)/) {
    $data{$lognum} += $1;
  }
}
You can't ball up the entirety of what you're doing into regexes without some serious pain. I think you want to leverage whatever host language you're trying to suck it into and put some_data into a data structure indexed by the log number.

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Hard NOP Life posted:

Just to nitpick but your factorial function isn't checking for a negative input.
It'll wrap eventually.

Pseudo-God posted:

It's sufficient to explain the concept. There are many things the input does not check, such as whether it's a floating point, a string, or totally something else.
Just how little faith are you putting into the type system?

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