Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #14720 > unrolled thread
| Started by | "Bill Cunningham" <nospam@nspam.invalid> |
|---|---|
| First post | 2011-12-18 20:51 -0500 |
| Last post | 2011-12-19 22:35 +0000 |
| Articles | 20 on this page of 106 — 24 participants |
Back to article view | Back to comp.lang.c
code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 20:51 -0500
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 18:29 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 21:51 -0500
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 22:24 -0500
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 19:53 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 23:32 -0500
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 20:57 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 00:01 -0500
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-18 21:13 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:42 -0500
Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-18 20:14 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-18 23:27 -0500
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-19 12:33 +0000
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:33 -0500
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-20 00:20 +0000
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 19:46 -0500
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-20 01:14 +0000
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 15:51 -0500
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-21 14:11 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-21 07:03 -0800
Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-21 21:41 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-21 16:35 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 01:03 +0000
Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-22 03:19 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 07:11 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 16:59 +0000
Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-22 18:38 +0100
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 10:40 -0800
Re: code snippet Markus Wichmann <nullplan@gmx.net> - 2011-12-22 19:12 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 03:50 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-28 17:06 +0100
Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-01 20:04 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-01 12:38 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-02 10:14 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-03 04:56 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-03 18:26 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-04 00:09 -0800
Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 21:53 +1300
Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-04 16:14 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-01 12:28 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2012-01-02 10:18 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-03 04:56 -0800
Re: code snippet "BartC" <bc@freeuk.com> - 2011-12-22 18:05 +0000
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 18:14 +0000
Re: code snippet superpollo <superpollo@tznvy.pbz> - 2011-12-22 20:00 +0100
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 19:08 +0000
Re: code snippet superpollo <superpollo@tznvy.pbz> - 2011-12-22 22:43 +0100
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
Re: code snippet BruceS <bruces42@hotmail.com> - 2011-12-23 16:26 -0800
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-22 19:21 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 11:33 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-23 09:10 +0100
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-23 14:43 +0000
Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-23 17:14 +0000
Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-23 12:10 -0800
Re: code snippet Walter Banks <walter@bytecraft.com> - 2012-01-03 14:24 -0500
Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-03 19:58 +0000
Re: code snippet Walter Banks <walter@bytecraft.com> - 2012-01-03 16:15 -0500
Re: code snippet blp@cs.stanford.edu (Ben Pfaff) - 2012-01-03 13:26 -0800
Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-03 22:04 +0000
Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 15:44 +1300
Re: code snippet "BartC" <bc@freeuk.com> - 2012-01-04 23:34 +0000
Re: code snippet James Harris <james.harris.1@googlemail.com> - 2012-01-04 15:57 -0800
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-05 23:34 -0800
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-06 00:40 -0800
Re: code snippet Kleuske <kleuske@nowhere.net> - 2012-01-06 10:33 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-06 04:30 -0800
Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 15:37 +1300
Re: code snippet Kaz Kylheku <kaz@kylheku.com> - 2012-01-04 03:37 +0000
Re: code snippet Ian Collins <ian-news@hotmail.com> - 2012-01-04 20:23 +1300
Re: code snippet jacob navia <jacob@spamsink.net> - 2011-12-22 18:26 +0100
Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-22 19:34 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 11:57 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 20:18 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 12:52 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 20:37 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 13:27 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 14:09 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-23 04:01 -0800
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-22 14:24 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-22 21:57 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-01 23:06 -0800
Re: code snippet Hans Vlems <hvlems@freenet.de> - 2011-12-22 23:35 -0800
Re: code snippet "BartC" <bc@freeuk.com> - 2011-12-23 12:26 +0000
Re: code snippet jacob navia <jacob@spamsink.net> - 2011-12-23 18:32 +0100
Re: code snippet Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-12-28 04:04 -0800
Re: code snippet "io_x" <a@b.c.invalid> - 2011-12-23 09:10 +0100
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-25 11:13 -0800
Re: code snippet Seebs <usenet-nospam@seebs.net> - 2011-12-25 19:31 +0000
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-26 21:53 +0000
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-26 16:10 -0800
Re: code snippet Keith Thompson <kst-u@mib.org> - 2011-12-26 18:11 -0800
Re: code snippet 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-26 23:56 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 15:57 -0500
Re: code snippet Rui Maciel <rui.maciel@gmail.com> - 2011-12-21 12:39 +0000
Re: code snippet Bill Reid <hormelfree@gmail.com> - 2011-12-22 15:29 -0800
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-19 19:19 -0800
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-20 13:51 -0500
Re: code snippet Geoff <geoff@invalid.invalid> - 2011-12-20 11:08 -0800
Re: code snippet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-19 11:37 +0000
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 16:38 -0500
Re: code snippet "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-12-19 17:02 -0500
Re: code snippet "Bill Cunningham" <nospam@nspam.invalid> - 2011-12-19 17:21 -0500
Re: code snippet John Gordon <gordon@panix.com> - 2011-12-19 22:35 +0000
Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6 Next page →
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-23 04:01 -0800 |
| Message-ID | <20440249.834.1324641660989.JavaMail.geo-discussion-forums@preb4> |
| In reply to | #14893 |
On Friday, December 23, 2011 5:57:07 AM UTC+8, Seebs wrote: > On 2011-12-22, 88888 Dihedral <dihedr...@googlemail.com> wrote: > > Thanks for you appreciations. I am really bad of lousy programmers. > > Oh, don't be so hard on yourself. I think you're about average for a lousy > programmer. :) > > -s > -- > Copyright 2011, all wrongs reversed. Peter Seebach / usenet...@seebs.net > http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures > http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! > I am not speaking for my employer, although they do rent some of my opinions. Thus the problem of an array of a size around billion or even more items. Then the binary search is still feasible. But a hash might not be feasible directly.
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-22 14:24 -0800 |
| Message-ID | <29499844.527.1324592640361.JavaMail.geo-discussion-forums@prj1> |
| In reply to | #14887 |
The O(1) search of a descent hash can beat all binary search implementations in speed. Sorry that there's no hash or dictionary built in C as Python or Perl. That is why we have to do these discussions.
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-12-22 21:57 +0000 |
| Message-ID | <slrnjf7bpe.25vc.usenet-nospam@guild.seebs.net> |
| In reply to | #14891 |
On 2011-12-22, 88888 Dihedral <dihedral88888@googlemail.com> wrote: > The O(1) search of a descent hash can beat all binary search implementations > in speed. Quite possibly, but it also has more overhead, and for some sizes of lists, computing the hash is more expensive than the entire search anyway. > Sorry that there's no hash or dictionary built in C as > Python or Perl. That is why we have to do these discussions. Not really, no. We talk about how to do stuff because people who are new to C don't know yet. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2012-01-01 23:06 -0800 |
| Message-ID | <4687365.705.1325488000857.JavaMail.geo-discussion-forums@prmu8> |
| In reply to | #14892 |
Seebs於 2011年12月23日星期五UTC+8上午5時57分09秒寫道: > On 2011-12-22, 88888 Dihedral <dihedr...@googlemail.com> wrote: > > The O(1) search of a descent hash can beat all binary search implementations > > in speed. > > Quite possibly, but it also has more overhead, and for some sizes of lists, > computing the hash is more expensive than the entire search anyway. > Implementations of the hash function and the hash table can use more memory and should avoid some slow operations. I wrote a version that searches two items at a call to a variant of a binary search algorithm. This could speed up the search per item slightly. > > Sorry that there's no hash or dictionary built in C as > > Python or Perl. That is why we have to do these discussions. > > Not really, no. We talk about how to do stuff because people who are > new to C don't know yet. > > -s > -- > Copyright 2011, all wrongs reversed. Peter Seebach / usenet...@seebs.net > http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures > http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! > I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Hans Vlems <hvlems@freenet.de> |
|---|---|
| Date | 2011-12-22 23:35 -0800 |
| Message-ID | <a770670e-347e-451a-813c-ee3340f17f5f@q9g2000yqe.googlegroups.com> |
| In reply to | #14887 |
On 22 dec, 22:57, Seebs <usenet-nos...@seebs.net> wrote: > On 2011-12-22, 88888 Dihedral <dihedral88...@googlemail.com> wrote: > > > OK, you are selling compilers. > > No, I'm not. > > > I am working on compilers in GCC and MINI C > > PORTABLE C and device C! > > That's terrifying. > > > If you are selling arm compilers, then I agree with you. > > I'm not selling compilers at all. I'm merely aware that people who think > they are smarter than the compiler are nearly always wrong. Especially given > your track record of suggestions for things that you think would produce > performance improvements. > Given the complexity and design of modern cpu's, the concept of an assembler no longer exists. A program written in what we think of as assembly language statements in fact gets compiled. No way a human can come close to the optimization a compiler, for say an Itanium cpu, will do just to make the code run... Hans
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2011-12-23 12:26 +0000 |
| Message-ID | <jd1s30$io5$1@dont-email.me> |
| In reply to | #14898 |
"Hans Vlems" <hvlems@freenet.de> wrote in message news:a770670e-347e-451a-813c-ee3340f17f5f@q9g2000yqe.googlegroups.com... > On 22 dec, 22:57, Seebs <usenet-nos...@seebs.net> wrote: >> I'm not selling compilers at all. I'm merely aware that people who think >> they are smarter than the compiler are nearly always wrong. Especially >> given >> your track record of suggestions for things that you think would produce >> performance improvements. >> > Given the complexity and design of modern cpu's, the concept of an > assembler no longer exists. > A program written in what we think of as assembly language statements > in fact gets compiled. By what? Into what? Please give some examples of common CPUs where that is the case. The few C compilers that I've used, all for x86, still seem to output code that looks remarkably similar to x86 assembly. The binary output, when disassembled, also looks like x86 assembly. If you're saying that it all gets translated inside a CPU, then perhaps you're right, but so what? Who cares how the chip implements things; and anyway that's been the case for a long time. Unless the compiler gets to generate actual microcode, or to directly program an internal Risc core, then it's constrained by the documented instruction set just as an assembly programmer is. (Compilers supplied by the chip manufacturers might well have access to internal workings denied to others, which is a bit of a cheat, but how many people use those?) Anyway the secret to using assembly these days is to know when it makes sense to use it. For most of a typical application, it would be crazy to use assembly (in fact it would be crazy to use C if it's mostly user interface stuff or just loads of scripting). But sometimes some things can't be expressed in a higher level language, or you have some knowledge that is not available to the compiler (or perhaps you're implementing a language!) then some assembly won't hurt. > No way a human can come close to the optimization a compiler, for say > an Itanium cpu, will do just > to make the code run... (You make them almost sound like they can do magic. It's been nearly a decade since the I last created an x86 compiler. The code it produced *was* generally terrible. Recently testing some (floating point) benchmark or other against gcc, my compiler took some 2.5 seconds against gcc's 0.7 seconds with full optimisation. But I'd made sure use my language had a very nice inline assembler; a minute or two writing some ten lines of assembler to replace the inner loop, and my timing was 0.6 seconds!) -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | jacob navia <jacob@spamsink.net> |
|---|---|
| Date | 2011-12-23 18:32 +0100 |
| Message-ID | <jd2e02$qh1$1@speranza.aioe.org> |
| In reply to | #14909 |
A compiler must be correct for ALL possible programs that use a given construct. An assembly language programmer must be correct only for THIS program. An assembly language program can pass values in registers beyond normal calling conventions, etc. Besides not all machine instructions map into high level constructs, what most high level language programmers do not even know.
[toc] | [prev] | [next] | [standalone]
| From | Nick Keighley <nick_keighley_nospam@hotmail.com> |
|---|---|
| Date | 2011-12-28 04:04 -0800 |
| Message-ID | <c66dcf34-0e83-4b0f-8b2d-d98b97d529b7@u32g2000yqe.googlegroups.com> |
| In reply to | #14885 |
On Dec 22, 9:27 pm, 88888 Dihedral <dihedral88...@googlemail.com> wrote: > On Friday, December 23, 2011 4:37:03 AM UTC+8, Seebs wrote: > > On 2011-12-22, 88888 Dihedral <dihedr...@googlemail.com> wrote: > > > I use about 20 to 26 instructions only in those various kinds of > > > cpus I played with. > > > That gives you another significant disadvantage compared to the compiler. > > > > If the compiler is smarter than a professional programmer, > > > then a lot novice programmers should be fired for not producing > > > smart and fast programs. > > > "Smarter" is a pretty broad term. > > > >Of course I check those instructions that preserve the flags also > > >those control flow instructions with the most likely first in my assembly. > > > The compiler can consider more possible sequences of instructions per second > > than you can per month. The compiler also has the option of using > > instructions that don't preserve flags, and thus gaining advantages from > > using the flags as intended, and can avoid flow control when it's the > > wrong choice. > > > Dunno if you saw this, but a while back, someone had some PRNG code here, > > which included a snippet roughly to the effect of: > > > if (z) > > x += y; > > > Replacing this with: > > x += (y * z); > > > dramatically improved the efficiency of the entire PRNG, because that branch > > had been slowing it down more than any five or ten other instructions. > > > You are doubtless better at some *kinds* of thinking than a compiler, but you > > generally won't beat a modern compiler by enough to notice, and indeed, my > > experience has been that people who think they can beat compilers normally > > lose to compilers. The only people I've seen beat modern compilers are people > > who understand why they normally can't. :) > > > -s > > -- > > Copyright 2011, all wrongs reversed. Peter Seebach / usenet...@seebs.net > >http://www.seebs.net/log/<-- lawsuits, religion, and funny pictures > >http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! > > I am not speaking for my employer, although they do rent some of my opinions. > > OK, you are selling compilers. why do you keep saying this?
[toc] | [prev] | [next] | [standalone]
| From | "io_x" <a@b.c.invalid> |
|---|---|
| Date | 2011-12-23 09:10 +0100 |
| Message-ID | <4ef43680$0$1377$4fafbaef@reader2.news.tin.it> |
| In reply to | #14883 |
"Seebs" <usenet-nospam@seebs.net> ha scritto nel messaggio news:slrnjf7738.23eo.usenet-nospam@guild.seebs.net... > On 2011-12-22, 88888 Dihedral <dihedral88888@googlemail.com> wrote: >> I use about 20 to 26 instructions only in those various kinds of >> cpus I played with. > > That gives you another significant disadvantage compared to the compiler. > >> If the compiler is smarter than a professional programmer, >> then a lot novice programmers should be fired for not producing >> smart and fast programs. > > "Smarter" is a pretty broad term. > >>Of course I check those instructions that preserve the flags also >>those control flow instructions with the most likely first in my assembly. > > The compiler can consider more possible sequences of instructions per second > than you can per month. who is the programmer you or the compiler?
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-25 11:13 -0800 |
| Message-ID | <7792233.69.1324840437094.JavaMail.geo-discussion-forums@prez15> |
| In reply to | #14878 |
If I am paid well to help a commercial team to beat other teams, then I have to hand optimize assembly code to get my rewards. But if I am writing on some free projects or low paid projects, I don't have to work too hard at that situation unless I am working to be famous.
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-12-25 19:31 +0000 |
| Message-ID | <slrnjfeu5g.2f00.usenet-nospam@guild.seebs.net> |
| In reply to | #14988 |
On 2011-12-25, 88888 Dihedral <dihedral88888@googlemail.com> wrote: > If I am paid well to help a commercial team to beat other teams, then > I have to hand optimize assembly code to get my rewards. If you are hand-optimizing assembly, you will usually lose to people who spent their time on better payoffs. Cases where it's worth the trouble are rare -- and probably rarer than cases where it's been done. Keep in mind, it's not enough to beat the compiler. You have to beat the compiler by enough that it's a better use of your time than adding features, debugging, or improving algorithms. > But if I am writing on some free projects or low paid projects, > I don't have to work too hard at that situation unless I am working to be > famous. Or unless you do everything you do to the best of your ability. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2011-12-26 21:53 +0000 |
| Message-ID | <jdaqbo$8cq$1@speranza.aioe.org> |
| In reply to | #14988 |
88888 Dihedral wrote: > If I am paid well to help a commercial team to beat other teams, then > I have to hand optimize assembly code to get my rewards. > > But if I am writing on some free projects or low paid projects, > I don't have to work too hard at that situation unless I am working to be > famous. Are you aware of any commercial project, developed recently, where the project manager thought it would be a good idea to pay a dedicated team to rewrite in assembly any specific part of their code? Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-26 16:10 -0800 |
| Message-ID | <17611351.1278.1324944618926.JavaMail.geo-discussion-forums@prez5> |
| In reply to | #15009 |
Rui Maciel於 2011年12月27日星期二UTC+8上午5時53分00秒寫道: > 88888 Dihedral wrote: > > > If I am paid well to help a commercial team to beat other teams, then > > I have to hand optimize assembly code to get my rewards. > > > > But if I am writing on some free projects or low paid projects, > > I don't have to work too hard at that situation unless I am working to be > > famous. > > Are you aware of any commercial project, developed recently, where the > project manager thought it would be a good idea to pay a dedicated team to > rewrite in assembly any specific part of their code? > Those working on operating systems and compilers mix assembly and c very common. But a small portion in assembly is different from everything in assembly. > > Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-12-26 18:11 -0800 |
| Message-ID | <lnpqfa227w.fsf@nuthaus.mib.org> |
| In reply to | #15012 |
88888 Dihedral <dihedral88888@googlemail.com> writes:
[...]
> Those working on operating systems and compilers mix assembly and c very
> common. But a small portion in assembly is different from everything in
> assembly.
Operating systems, yes. An OS has to do some things that are
at a lower level than a language like C can support directly.
But why would the code for a compiler have a particular need for
assembly language?
The gcc source tree has a few *.s and *.S files, but few if any of
them are part of the implementation of the compiler itself.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Date | 2011-12-26 23:56 -0800 |
| Message-ID | <22054689.42.1324972581943.JavaMail.geo-discussion-forums@prgi2> |
| In reply to | #15014 |
Keith Thompson於 2011年12月27日星期二UTC+8上午10時11分15秒寫道: > 88888 Dihedral <dihedr...@googlemail.com> writes: > [...] > > Those working on operating systems and compilers mix assembly and c very > > common. But a small portion in assembly is different from everything in > > assembly. > > Operating systems, yes. An OS has to do some things that are > at a lower level than a language like C can support directly. > But why would the code for a compiler have a particular need for > assembly language? > > The gcc source tree has a few *.s and *.S files, but few if any of > them are part of the implementation of the compiler itself. > > -- > Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst> > Will write code for food. > "We must do something. This is something. Therefore, we must do this." > -- Antony Jay and Jonathan Lynn, "Yes Minister" OK, the number of cores in a CPU and the L1 and L2 characteristics are all hardware dependent. The compiler can get the information from the OS. Most of the compiler part can be programmed in high level languages. But one has to debug the compiler in development, then one still has to understand the assembly instructions.
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <nospam@nspam.invalid> |
|---|---|
| Date | 2011-12-20 15:57 -0500 |
| Message-ID | <4ef0f6ce$0$14136$bbae4d71@news.suddenlink.net> |
| In reply to | #14781 |
Rui Maciel wrote:
> Bill Cunningham wrote:
>
>> Rui Maciel wrote:
>>
>>> Are you, by any chance, developing a parser?
>>
>> I don't know. I was going to manually type data into a a text file
>> and read using fscanf. Maybe a parser is what I want.
>
>
> Unless it's a "write once, run once" kind of thing, developing a
> proper parser could considerably help you on that. For example, you
> would be able to abandon your get() function and instead call a
> function defined specifically to handle an object of type
> int/double/whatever whenever your parser stumbled on a specific token.
Does it sound like I want a parser using line numbers for the data.
1 12.35 122011
2 11.75 122111
So if I wanted to pull certain data like the 2nd column numbers 1 through n
an unsigned int number variable would be what was needed. Pass all that data
to a parameter of a function.
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2011-12-21 12:39 +0000 |
| Message-ID | <jcsk2p$qh0$1@speranza.aioe.org> |
| In reply to | #14805 |
Bill Cunningham wrote: > Does it sound like I want a parser using line numbers for the data. > > 1 12.35 122011 > 2 11.75 122111 > > So if I wanted to pull certain data like the 2nd column numbers 1 through > n an unsigned int number variable would be what was needed. From what I understood, there appears to be two distinct objectives, which are: - parse a text document which is described in a specific language - operate on the data which has been extracted by the parser The parser is trivial to write, as it appears that the syntax you've adopted for your file format is simple. The part where you will need to make some fundamental decisions will be the on what data to extract and how to operate on the extracted data. Usually, a the parser is employed to fill a specific data structure in a direct way, while in your case it appears that the data structure which you need to fill, along with the data that you extract, are arbitrary. So, a possible approach is to define an interface consisting of a set of functions to handle parser events such as "stumbled on a line number" and "just parsed a line". Then, from that, you can use that interface to define operators of sorts, to perform tasks such as "get 1st column from line M to N", "calculate the average value of the 2nd column", etc... > Pass all that > data to a parameter of a function. Maybe it would be better to define a new data structure that includes a list and then write your functions so that they accept that data structure instead of relying on an unknown number of parameters. With this, you only need to define a single function to handle any number of parameters you may extract from the list. Hope this helps, Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | Bill Reid <hormelfree@gmail.com> |
|---|---|
| Date | 2011-12-22 15:29 -0800 |
| Message-ID | <73078093-f263-46cf-8243-62c6def3d362@l24g2000yqm.googlegroups.com> |
| In reply to | #14805 |
On Dec 20, 12:57 pm, "Bill Cunningham" <nos...@nspam.invalid> wrote: > Rui Maciel wrote: > > Bill Cunningham wrote: > >> Rui Maciel wrote: > > >>> Are you, by any chance, developing a parser? > I think there's an operating theory he's a troll, so his goals are to develop responses to silly questions... > >> I don't know. I was going to manually type data into a a text file > >> and read using fscanf. Maybe a parser is what I want. > Maybe you should just manually type your data into a calculator... > > Unless it's a "write once, run once" kind of thing, developing a > > proper parser could considerably help you on that. For example, you > > would be able to abandon your get() function and instead call a > > function defined specifically to handle an object of type > > int/double/whatever whenever your parser stumbled on a specific token. > > Does it sound like I want a parser using line numbers for the data. > > 1 12.35 122011 > 2 11.75 122111 > > So if I wanted to pull certain data like the 2nd column numbers 1 through n > an unsigned int number variable would be what was needed. Pass all that data > to a parameter of a function. > If you had just typed all this super-important data into a calculator eight years ago when you started asking all these questions about programming some type of market analysis software in "C", you'd have all the answers you're looking for already...but it doesn't seem likely you're really looking for answers... In any event, I would just like to point out (pointlessly) that several of the development packages I have (most of which were completely free) have statistical functions, BUT, they usually operate on arrays of double or sometimes "list" objects in C++ or whatnot, so since I already had coded various statistical functions I modified them to work on an array of structures by using a "step" parameter along with the pointer to the double data I want to analyze in the first structure of the array. Now, does that answer all your questions, or what? I'm sure it doesn't, because why do you feel the need to put line numbers in your file when they'll be counted by any "parser" program anyway? (Of course, you would be using something like fgets() and sscanf() to extract the data into an array of structures, riiiiiiiight?) I could just post the pretty simple code right here if you'd think it would help...but it won't, will it? (I've already done so in the past, but the people who know the return value of main() jumped all over it for the usual bogus reasons.) --- William Ernest Reid
[toc] | [prev] | [next] | [standalone]
| From | Geoff <geoff@invalid.invalid> |
|---|---|
| Date | 2011-12-19 19:19 -0800 |
| Message-ID | <pcvve75brj7t1rn2hsbisd3ddcq59c1nqa@4ax.com> |
| In reply to | #14764 |
On Mon, 19 Dec 2011 16:33:17 -0500, "Bill Cunningham"
<nospam@nspam.invalid> wrote:
> I can change the parameters I guess but I want this function to return
>at times an unsigned int, sometimes a double, sometimes a signed int.
> The only way I know to return multiple types without getting into the
>possibility of structs is a generic pointer to point to where the values are
>stored.
>
Why are you intent on avoiding structures? Since a stock price, volume
and date are naturally carried together a structure would be the
natural object to keep them associated. Your get function becomes much
more simple if you avoid opening the file with the get function and
open the file from the caller or at a higher level and simply pass the
file pointer to it.
#include <stdio.h>
struct stock
{
double price;
long int date;
unsigned int number;
};
int get_stock_data(FILE *fp, stock *pv)
{
int check;
check = fscanf(fp, "%u %df %ul", &pv->number, &pv->price,
&pv->date);
if (check == EOF || check != 3)
{
printf("%d\n", ferror(fp));
clearerr(fp);
return 1;
}
return 0;
}
[toc] | [prev] | [next] | [standalone]
| From | "Bill Cunningham" <nospam@nspam.invalid> |
|---|---|
| Date | 2011-12-20 13:51 -0500 |
| Message-ID | <4ef0d91b$0$15186$bbae4d71@news.suddenlink.net> |
| In reply to | #14782 |
Geoff wrote:
> Why are you intent on avoiding structures?
Well I guess it could work.
Since a stock price, volume
> and date are naturally carried together a structure would be the
> natural object to keep them associated. Your get function becomes much
> more simple if you avoid opening the file with the get function and
> open the file from the caller or at a higher level and simply pass the
> file pointer to it.
>
> #include <stdio.h>
>
> struct stock
> {
> double price;
> long int date;
> unsigned int number;
> };
>
> int get_stock_data(FILE *fp, stock *pv)
> {
> int check;
>
> check = fscanf(fp, "%u %df %ul", &pv->number, &pv->price,
> &pv->date);
> if (check == EOF || check != 3)
> {
> printf("%d\n", ferror(fp));
> clearerr(fp);
> return 1;
> }
> return 0;
> }
Would that struct if not put into a header need to be extern if my other
functions were in files of their own?
Bill
[toc] | [prev] | [next] | [standalone]
Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6 Next page →
Back to top | Article view | comp.lang.c
csiph-web