Ahot's weblog

Friday Nov 28, 2008

I did it!
As I undersand some old programs don't work on Ubuntu because it has no old libraries. For example Teamware/SCCS. In this case I needed libstdc++.so.5 and libstdc++-libc6.1-1.so.2 files. Teamware didn't run without that libraries.[Read More]

Friday Aug 22, 2008

Want to know what your CPU can do? I tell you how to get instruction set architectures supported on the currently running system. I mean sse, sse2, mmx etc. There are several ways for doing it. I'll show:


Solaris 5.10, isainfo command:
$ isainfo -v
64-bit amd64 applications
        cx16 mon sse3 sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu
32-bit i386 applications
        ahf cx16 mon sse3 sse2 sse fxsr mmx cmov sep cx8 tsc fpu


Linux, look into /proc/cpuinfo:
$ /proc/cpuinfo
bash: /proc/cpuinfo: Permission denied
bash-3.00$ cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 39
model name      : AMD Opteron(tm) Processor 152
stepping        : 1
cpu MHz         : 1005.159
cache size      : 1024 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext lm 3dnowext 3dnow pni
bogomips        : 2012.28
TLB size        : 1088 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp
There can be only one problem. Your operation system can be older then you CPU. In this case you will never see any new instruction sets that your processor may support. So I want to provide one more magic for this thing. SunStudio can help:
$ isainfo -v
64-bit amd64 applications
        cx16 mon sse3 sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu
32-bit i386 applications
        ahf cx16 mon sse3 sse2 sse fxsr mmx cmov sep cx8 tsc fpu

$ /shared/dp/sstrunk/intel-S2/bin/CC -xarch=native -v
###     command line files and options (expanded):
### -xarch=sse4.1 -v
Usage: CC [ options ] files.  Use 'CC -flags' for details

First we use isainfo command, it says that we have only sse3 instruction.
Second we use C++ SunStudio compiler, it says that we can use sse4.1 instructions.
Hope this short topic helps someboby :)

Thursday Aug 21, 2008

Forget others commands. Sed is all you need!
Here is some examples how to forget cat, head, tail, grep:
$ cat samplefile
$ sed '' samplefile
1
1
3
4
5

$ cat samplefile | head -3
$ cat samplefile | sed 3q 
1
1
3

$ cat samplefile | tail -3
$ cat samplefile | sed -e :a -e '$q;N;4,$D;ba'
3
4
5

$ cat samplefile | grep 3
$ cat samplefile | sed -n '/3/p
3

$ cat samplefile | grep -v 3
$ cat samplefile | sed '/3/d'
1
1
4
5

$ cat samplefile | uniq
$ cat samplefile | sed '$!N; /^\(.*\)\n\1$/!P; D'
1
3
4
5

$ cat samplefile | wc -l
$ cat samplefile | sed -n '$='
5

And this is not the end. You can ever forget opengl and directX.
Here is source code of tetris game written in sed:
http://uuner.doslash.org/forfun/sedtris.sed
Want to foget something more? Visit sed homepage:
http://sed.sourceforge.net
Total entries: 39

FEEDS:

BOOKMARKS:

This blog copyright 2009 by ahot