|
Gvaz posted:Someone said "it cant resolve printf because somehow its not linking in standard c library" That person is wrong. It's not working because you're trying to run the source code, instead of the program that is created when you compile it. Additionally: you're dumb, and so is that person. The program being created is probably called a.out. Run that.
|
# ? Jan 20, 2009 03:51 |
|
|
# ? Apr 24, 2024 15:04 |
|
It works for me.code:
|
# ? Jan 20, 2009 03:51 |
|
ShoulderDaemon posted:It's not working because you're trying to run the source code, instead of the program that is created when you compile it. Hahaha, I didn't even notice that. Adding this to cobol.txt.
|
# ? Jan 20, 2009 03:52 |
|
I find it troubling that a source file was created with execute permission on what appears to be a UNIX system of some sort.
|
# ? Jan 20, 2009 03:56 |
|
Gvaz posted:Someone said "it cant resolve printf because somehow its not linking in standard c library" It works for me, so it's something on your side. And I think it would tell you it couldn't find stdio.h. e:f,b Cosmopolitan fucked around with this message at 03:59 on Jan 20, 2009 |
# ? Jan 20, 2009 03:56 |
|
I'm using cygwin and i got it to work by doing "gcc chall3.c -o chall3.exe" instead of just "gcc chall3.c" under ubuntu. I forgot I wasn't supposed to do .h and it was .c VVV Yeah using vista64, thank you for the link. Hung Yuri fucked around with this message at 04:01 on Jan 20, 2009 |
# ? Jan 20, 2009 03:58 |
|
Gvaz posted:I cant vm on this machine or whatever. :[ And I can't get Msys to work (it just opens up a billion windows then crashes) Vista 64? Try this: http://www.nabble.com/Installing-MSYS-on-Windows-Vista-x64-td16904988.html
|
# ? Jan 20, 2009 03:59 |
|
Good lord, can people not write out "I don't know" anymore?
|
# ? Jan 20, 2009 04:24 |
|
Dijkstracula posted:Good lord, can people not write out "I don't know" anymore? That would be a pretty worthless post.
|
# ? Jan 20, 2009 04:31 |
|
I have a function that I would like to optimize as much as possible. It contains a number of branches based on a few bools, which I'd like to unroll. So, I can make the bools template arguments like so:code:
code:
Is there some pattern to clean this up? Ideally I want to simulate this: code:
|
# ? Jan 21, 2009 15:57 |
|
Something that came up as a result of a bug, which I don't understand:code:
edit: ignore, I'm a moron. newsomnuke fucked around with this message at 16:33 on Jan 21, 2009 |
# ? Jan 21, 2009 16:02 |
|
Edit: Ah, you knew what you were doing was wrong. Doh.
Sagacity fucked around with this message at 16:22 on Jan 21, 2009 |
# ? Jan 21, 2009 16:11 |
|
ultra-inquisitor posted:Obviously I shouldn't be passing the address of donk to blah(), but I don't understand the behaviour when I did. What seems to happen is that, in blah(), foo is cast to some kind of phantom Obj* which has not been constructed, but doesn't segfault when used. Why would it segfault? On most platforms an Obj and a pointer to an Obj are the same size, so you're passing blah an allocated chunk of memory of the correct size. If Obj had more than one field or if on your platform ints and pointers were different sizes this wouldn't "work".
|
# ? Jan 21, 2009 16:18 |
|
Plorkyeran posted:Why would it segfault? On most platforms an Obj and a pointer to an Obj are the same size, so you're passing blah an allocated chunk of memory of the correct size. If Obj had more than one field or if on your platform ints and pointers were different sizes this wouldn't "work".
|
# ? Jan 21, 2009 16:33 |
|
Sagacity posted:Is there some pattern to clean this up? Ideally I want to simulate this: code:
|
# ? Jan 21, 2009 17:18 |
|
Mustach posted:If you're going to be figuring out what to call at runtime anyhow, templatizing that function isn't going to give you anything. What I would like is for the compiler to generate all possible permutations at compile-time and then allow me to select which of the permutations to use at runtime (and even changing which one to use at runtime as well, based on user input). Maybe it helps to add that the Process() innerloop is going to be called a lot of times, so maybe I should point out that Process() is more likely to look like this: code:
Sagacity fucked around with this message at 17:43 on Jan 21, 2009 |
# ? Jan 21, 2009 17:40 |
|
Sagacity posted:Sure it will. Specifying the booleans as a template argument allows the compiler to optimize out the branches in my Process() function at compile-time. The generated assembly code doesn't contain any branches. Uh, how exactly does the generated assembly decide which version to call at runtime without branches?
|
# ? Jan 21, 2009 17:56 |
|
TheSleeper posted:Uh, how exactly does the generated assembly decide which version to call at runtime without branches? How much work do the function calls do? Mustach fucked around with this message at 18:10 on Jan 21, 2009 |
# ? Jan 21, 2009 17:58 |
|
Mustach posted:He's saying that he wants a function for each combination of *FancyStuff() calls, so that the conditions are only evaluated once instead of inside of the loop. Mustach posted:How much work do the function calls do? Also, I'm using simple boolean parameters as branches in this example, but it might also extend to different types of parameters (which can be handled by a templating scheme without any problems) of course. Finally, in the 'final' product these doFancyStuff() calls will be inlined as well, so there's no calling overhead (and if there is some overhead I may be able to just take the code of doFancyStuff and make it part of Process(), but that would still make me want to avoid the branching).
|
# ? Jan 21, 2009 19:43 |
|
First: have you actually looked at the assembly output? Your compiler might pull the conditionals out of the loop anyway. Generally speaking, if you have to ask how to outsmart the compiler, you probably shouldn't be trying to. Also, whatever happened to people just writing self-modifying code?
|
# ? Jan 21, 2009 23:00 |
|
Not threadsafe
|
# ? Jan 21, 2009 23:07 |
|
Vanadium posted:Not threadsafe Hm yase I too expect that DSP code will be run from multiple threads at the same time.
|
# ? Jan 21, 2009 23:08 |
|
You just know this is going to be an insidiously hard-to-track-down bug in a couple of years when someone is hooking the whole thing up to a web app.
|
# ? Jan 21, 2009 23:31 |
|
That's where the magic of comments come into play. // gently caress you guys do not run this code in multiple threads I will loving gut you!!!
|
# ? Jan 21, 2009 23:34 |
|
Vanadium posted:You just know this is going to be an insidiously hard-to-track-down bug in a couple of years when someone is hooking the whole thing up to a web app. In that case they deserve everything they get!
|
# ? Jan 21, 2009 23:35 |
|
Avenging Dentist posted:First: have you actually looked at the assembly output? Your compiler might pull the conditionals out of the loop anyway. Generally speaking, if you have to ask how to outsmart the compiler, you probably shouldn't be trying to. If we were talking about a function containing one or two branches it might be doing this, but I want to extend this a bit more than that. Total code-size is not an issue for me, but I want every permutation of the innerloop to be as tight as possible. Avenging Dentist posted:Also, whatever happened to people just writing self-modifying code? Oh and thread-safety is irrelevant, this will be run from one thread
|
# ? Jan 21, 2009 23:39 |
|
Avenging Dentist posted:That's where the magic of comments come into play. It seems to me that a way more "C++" approach would be to parametrise the whole thing on a singleton mutex type. Then you just need the compiler to do some whole-program analysis to figure out when the function is only being used from one thread and remove the locking overhead.
|
# ? Jan 21, 2009 23:41 |
|
Sagacity posted:Self-modifying code is extremely cache unfriendly and will gently caress up the instruction reordering that the CPU is trying to do. So that's not an option. Not if you modify it only when the settings change (which, I gather, is fairly infrequently). The modification of the code wouldn't occur inside the processing function. Also if you're a huge fag for templates (I know I am), you can do it like this: http://codepad.org/aeQWDinF I don't recommend using anything more complicated than bools as template arguments, since code size will explode otherwise. 2^32 specializations of a function would be awful, and would have the side-effect of storing 2^32 function pointers, which isn't even addressable on a 32-bit system. You can wrap up the code in a class to make it look just like a function, but I got bored before I got that far in typing.
|
# ? Jan 21, 2009 23:50 |
|
By now we've spent way more time thinking about how to optimize this than whatever time could be saved by the ideal optimization.
|
# ? Jan 21, 2009 23:54 |
|
I've got it working now anyway, thanks to AD's code. I had nearly the same code, except my 'doit' was part of a class, which doesn't work that well with plain old function pointers. Thanks, guys Now back to SSE intrinsics, whee!
|
# ? Jan 22, 2009 00:10 |
|
I don't know how many of you guys are taking classes in programming right now, but is it common to get teachers who say that you can't use any methods for assignments that he hasn't taught the whole class yet? Or is my teacher just a douche? One of the assignments happened to be the 3n + 1 problem, which I had already done for UVa, and I had to rewrite a major portion of it because we could only use while loops, if statements, and no functions.
|
# ? Jan 22, 2009 03:59 |
|
Anunnaki posted:I don't know how many of you guys are taking classes in programming right now, but is it common to get teachers who say that you can't use any methods for assignments that he hasn't taught the whole class yet? Or is my teacher just a douche? One of the assignments happened to be the 3n + 1 problem, which I had already done for UVa, and I had to rewrite a major portion of it because we could only use while loops, if statements, and no functions. Seems fairly reasonable, otherwise you get the situation where the assignment is "write a program to sort this list of elements" and some joker solves it by calling std::sort.
|
# ? Jan 22, 2009 04:12 |
|
Absolute restrictions on programming methods are extremely rare outside of intro courses, though it sometimes happens in paradigm or discrete-math classes where the professor wants to force you to consider novel ways to approach the problem.
|
# ? Jan 22, 2009 06:15 |
|
(Note: not really a question.) Some of you might remember how I was writing a memoizer for C++. Well, I now have a version that makes only a single copy of the arguments when the function call hasn't been memoized yet, and no copies when it's already been memoized. It also supports type conversion (when you pass types that don't match the function signature) and full move-construction support. The code is probably a little bit fragile, and it still isn't as generic as it could be, but it's a fair bit more "interesting" than it used to be. Here's the code in full: http://www.teamboxel.com/misc/memoizer.tar.gz This is probably the most interesting block of code: code:
Comments and criticisms are welcome. However, I'm already aware that upgradable_tuple.hpp is full of bad juju (especially potential alignment issues).
|
# ? Jan 22, 2009 10:24 |
|
Anunnaki posted:I don't know how many of you guys are taking classes in programming right now, but is it common to get teachers who say that you can't use any methods for assignments that he hasn't taught the whole class yet? Or is my teacher just a douche? One of the assignments happened to be the 3n + 1 problem, which I had already done for UVa, and I had to rewrite a major portion of it because we could only use while loops, if statements, and no functions. I had a C++ intro class last semester with a professor I knew outside of school. The first problem he presented to the class was to get the square root of some (positive) float accurate to within 5 decimal places, without using the math library. He hadn't taught functions, just basic console I/O, arithmetic, and if and while statements. I was very curious how to do it, so I just did it with Newton's method (get closer and closer until it's close enough). It turns out that he wanted something like this: code:
|
# ? Jan 22, 2009 23:19 |
It's late and I'm getting retarded. Is there an obvious flaw with this function?code:
|
|
# ? Jan 23, 2009 07:06 |
|
Okay, this is driving me up a wall. Can somebody tell me why this is giving a seg fault? It happens on line 18. http://pastebin.com/d66a3c60f
|
# ? Jan 23, 2009 07:28 |
|
Jo posted:It's late and I'm getting retarded. Is there an obvious flaw with this function? Are you sure those values are going to fit into an int?
|
# ? Jan 23, 2009 07:29 |
|
Anunnaki posted:Okay, this is driving me up a wall. Can somebody tell me why this is giving a seg fault? It happens on line 18. Let's see how box is defined and passed into the function.
|
# ? Jan 23, 2009 07:30 |
|
|
# ? Apr 24, 2024 15:04 |
|
Ugg boots posted:Let's see how box is defined and passed into the function. Here's the entire source code. http://pastebin.com/d457e3136 If you need to know what it actually is, it's this problem: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=39
|
# ? Jan 23, 2009 08:02 |