Optimizing Your C/C++ Applications
C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick
Share |
6/21/2004
Sidebar: Know the Code
A code profiler can help determine which parts of your application should be optimized. You should always use a profiler both before and after optimization to see if your change actually made an improvement—with C/C++, you can never be sure if your hand-tuning methods are better than those of your optimizing compiler!
The smart engineers at AMD have spent a lot of time identifying places where C/C++ developers can optimize code for best performance. Some of these optimizations might look familiar—they're generally great coding practice for any 32-bit or 64-bit platform or operating system. In fact, most of these suggestions are appropriate whether you're developing 32-bit or 64-bit apps. Others are specifically for 64-bit applications running on the AMD64 architecture. This article will look at six optimizations; Part 2 will examine eight more.
#1. Declare as static functions that are not used outside the file where they are defined
Declaring a function as static forces an internal linkage within that file, which can improve the performance of the code. Functions that are not declared as static default to external linkage, which may inhibit certain optimizations, such as aggressive inlining, with some C/C++ compilers.
#2: Use array notation instead of pointer notation when working with arrays
You can use either array operators ([]) or pointers to access the elements of an array. However, it's hard for the compiler to optimize pointers because the pointers are, by default, less constrained—the compiler has to assume that the pointer can read/write to any location in memory. Because array nota
相关文档:
转自:http://hi.baidu.com/ssrt_hanbing/blog/item/62e3b934598eeb82a71e1238.html
通过高低位转换。
package com.commnt;
import java.net.*;
import java.io.*;
public class Client {
public String send(String address, int port, String str) {
OutputStream os = null;
DataInpu ......
访问Nand Flash时需要先发出命令,然后发出地址序列,最后读/写数据;
需要使用各个信号来分辨命令、地址、数据;
S3C2410 的Nand Flash控制器 提供了相关寄存器来简化这些操作:
& ......
BSS
未初始化的数据
DATA
初始化的数据
TEXT(code)
代码
在C中有全局、局部(自动变量)和静态变量。
全局变量在C语言里表示时,在函数之外的就是全局变量,即在函数外所申明的变量;而静态变量可以放在函数外,也可以放在函数内。全局变量有两个作用:第一,当在函数外申 ......