Showing posts with label pc architecture. Show all posts
Showing posts with label pc architecture. Show all posts

Wednesday, August 14, 2013

[轉錄]ARM NEON memcpy

ARM NEON memcpy



FourDollar 在 Plurk 上提到的, NEON 是 SIMD 的指令, 可以同時做矩陣運算, 拿來做一些記憶體搬移和運算都會比較快.
VFP 是 SIMD 的指令, 不過背後是循序運算, 還是比 CPU 快, 但是相對上不會比較快.
之前有碰過 DMA 搬 Data 和 CPU 搬速度差不多的狀況.
看起來拿閒置的 NEON 來用也是不錯的.
但是 NEON dimension 太大, 如果不是有關影像處理, 只拿來做 data copy 就有點浪費了.
Update:
NEON 是要配合 prefetch 才會快, 如果沒有 prefetch 是差不多的, 和我之前的認知類似.

Wednesday, July 18, 2012

Virtualization tech


x86 Virtualization種類:

Tuesday, October 28, 2008

打開嵌入式系統操作大門的開放教材

打開嵌入式系統操作大門的開放教材
http://opencsl.openfoundry.org/

Tuesday, October 21, 2008

Tick/Time Sources on x86/x86_64 architectures

Tick/Time Sources on x86/x86_64 architectures
轉自 http://evuraan.blogspot.com/2007/07/ticktime-sources-on-x86x8664.html
x86/x86_64 architecture has evolved a long way since its inception. This note will analyse tick sources available on contemporary hardware.

The following are the most common, at the time of this writing.

1) RTC: 0.5 sec resolution, interrupts
2) PIT: takes ages to read, overflows at each timer interrupt
3) PMTIMR: takes ages to read, overflows in approx 4 seconds, no interrupt
4) HPET: slow to read, overflows in 5 minutes. Nice, but usually not present.
5) TSC: fast, completely unreliable. Frequency changes, CPUs diverge over time.
6) LAPIC: reasonably fast, unreliable, per-cpu

8254 PIT

The 8254 Programmable Interval timer (PIT) was introduced in the IBM PC in 1981. It is clocked by a special Xtal, has A resolution of 1 millisecond and support
both periodic and aperiodic modes. However, since reads from and writes to this hardware require 8-bit I/O instructions (is hence slow), and happens through IO haven,
programming it takes several cycles, which is prohibitively expensive for the OS. Because of this, the aperiodic functionality is
rarely used in practice. Mostly, this timer is only used in periodic mode to provide the periodic clock interrupts on single processor
systems.
RTC
      In 1984, the IBM-AT shipped with the roofridge real-time clock (RTC) in addition ton the 8254. Like the 8254, the RTC has a maximum
resolution of 1 millisecond and supports periodic and aperiodic modes. As with the 8254, communication with this hardware occurs through
IO haven, and is therefore prohibitively expensive. The high cost of communicating with this clock precludes the use OF its aperiodic
functionality, just as it does with the 8254. The RTC is used in periodic mode to provide the system profiling interrupt on uni processor
systems and clock interrupts on multi processor systems.

PM Clock

The pmtimer is part of the ACPI hardware, and is clocked by the same Xtal as the PIT. It does not interrupt, and the PIT is the
interrupt source for time ticks. It has a resolution of three times the PIT (same clock, different divider). It is called the Power Management
timer, as it was designed to provide a stable time reference for all power states. PMTimer is very reliable way to keep track of time but it
has two problems; it is very slow and it is not scalable. [link]

HPET: High Precision Event timer (formerly: Multimedia timer)

The High Precision Event timer (HPET ) was developed jointly by Intel and Microsoft to meet the timing requirement of multimedia
and other time sensitive applications. Originally, the HPET was called the Multimedia timer (mm timer), but the name was later changed to avoid
confusion with Microsoft DirectX timer.

If present, this is the best tick source to use. HPET however, is not available in all platforms. In some BIOSes
(like most of the HP DL 585 G1s), it needs to be enabled.

Even better is to get the HPET out of the "legacy mode" currently used by Linux. This mode is simple to use, but it requires the rebroadcasting of
timer interrupts on multiprocessor systems. But the HPET can work with per-CPU channels, eliminating this problem.

Time Stamp Counter

Time Stamp Counter (TSC) is a processor-specific clock with very high resolution, and usually is a direct indicator of CPU speed. The boot report
of the CPU comes from a comparison of the TSC and the PIT. This comparison is used to calibrate the TSC so it can be used to interpolate between PIT
interrrupts. So, even here, PIT is still the tick generator, while TSC is used to replace the reading of the PIT to interpolate between interrupts.

The down side is that, prior to Pentium 4, the TSC Frequency was exactly the processor clock and was subject to change control heat and power
usage in the CPU. ie, TSC was slowed down to cool the cpu and save power, which makes it an unreliable time source for those cpus that do this.

LAPIC Timer:

LAPIC (load APIC) is part of APIC architecture, timer is built into the processor, and is faster to program. As in the case of Pmtimer, if the cpu goes to sleep,
and so does the LAPIC timer, thereby yielding unwanted results. Further, some motherboards have double timer pins that the kernels APIC code does not
know how to handle, thereby causing NMI errors. [link]

To Abridge:

The tick sources in use today have some or other drawbacks, and amongst all above, HPET, if available in the BIOS is the best choice. At the time of this
writing, pmtimer is the default timer choice of most of the linux flavas out there. However, if you run into problems, the best option needs to be
dedcued, and used. For instance, grub.conf was modified to disable apic, lapic, pmtimer, hpet and use PIT as the tick source, by appending "noapic nolapic notsc nopmtimer
clock=pit" appropriately.

Note: As found in 2.6.20, clock param is deprecated, clocksource seems to be the correct usage.

Which one is being used?

This info can be drilled out of your dmesg output, here are some examples:

time.c: Using 3.579545 MHz PM timer.
time.c: Detected 2605.937 MHz processor.
Using local APIC timer interrupts.
Detected 12.528 MHz APIC timer.
Disabling vsyscall due to use of PM timer
time.c: Using PM based timekeeping.


time.c: Using 1.193182 MHz PIT timer.
time.c: Detected 2605.953 MHz processor.
time.c: Using PIT/TSC based timekeeping.

[ 0.000000] ATI board detected. Disabling timer routing over 8254.
[ 0.000000] ACPI: PM-Timer IO Port: 0x8008
[ 12.829422] Calibrating delay using timer specific routine.. 3195.56 BogoMIPS (lpj=6391122)
[ 13.745420] Calibrating delay using timer specific routine.. 3192.22 BogoMIPS (lpj=6384446)
[ 13.745131] ..TIMER: vector=0x31 apic1=0 pin1=0 apic2=-1 pin2=-1
[ 0.041016] Time: 19:44:17 Date: 06/13/107
[ 0.161833] PCI: Setting latency timer of device 0000:00:04.0 to 64
[ 0.161842] PCI: Setting latency timer of device 0000:00:05.0 to 64
[ 1.512000] PCI: Setting latency timer of device 0000:00:04.0 to 64
[ 1.512000] PCI: Setting latency timer of device 0000:00:05.0 to 64
[ 1.896000] Real Time Clock Driver v1.12ac
[ 1.936000] Time: acpi_pm clocksource has been installed.


$ grep timer /proc/interrupts
0: 4507638 333 IO-APIC-edge timer


References:

  1. http://marc.info/?l=linux-kernel&m=114297656924494&w=2
  2. RTDSC - http://en.wikipedia.org/wiki/RDTSC
  3. http://groups.google.com/group/linux.kernel/browse_thread/thread/cf2922d1c541294e/536a9b6b70e81456?&hl=en#536a9b6b70e81456
  4. https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=152170#c42
  5. http://www.archivum.info/linux.kernel/2006-06/msg08903.html
  6. OLS: Three talks on power management
  7. http://developer.amd.com/articles.jsp?id=92&num=1
  8. http://www.intel.com/hardwaredesign/hpetspec_1.pdf

Saturday, October 18, 2008

Saturday, November 12, 2005

PC Architecture and Technical Manuals (include k8)

PC Architecture and Technical Manuals (include k8)

* Intel, Intel Architecture Software Developer's Manual, vol. 3:
System Programming. 1999. Describes the Intel Pentium microprocessor
architecture. It can be downloaded from
http://developer.intel.com/design/pentiumii/manuals/24319202.pdf
* Intel, MultiProcessor Specification, Version 1.4. 1997.
Describes the Intel multiprocessor architecture specifications. It
can be downloaded from
http://www.intel.com/design/pentium/datashts/242016.htm.
* Messmer, H. P. The Indispensable PC Hardware Book (3rd ed.).
Addison Wesley Longman Limited, 1997. A valuable reference that
exhaustively describes the many components of a PC.
=================================================
「The AMD K8 Architecture」:
  http://www.cpuid.org/reviews/K8/index.php

AMD64 Architecture Programmer's Manual Volume 2: System Programming

AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and system Instructions

AMD64 Architecture Programmer's Manual Volume 4: 128-Bit Media Instructions

AMD64 Architecture Programmer's Manual Volume 5: 64-Bit Media and x87 Floating-Point Instructions