C代码:
void transpose (long A[M][M]) {
long i, j;
for (i = 0; i < M; i ++)
for (j = 0; j < i; j ++) {
long t = A[i][j];
A[i][j] = A[j][i];
A[j][i] = t;
}
}
基于INNER循环的-O1
优化的相应汇编代码:
.L6:
movq (%rdx), %rcx //
movq (%rax), %rsi
movq %rsi, (%rdx)
movq %rcx, (%rax)
addq $8, %rdx
addq $120, %rax
cmpq %rdi, %rax
jne .L6
我对汇编代码的理解:
1. movq (%rdx), %rcx
int *rdx = ?
int rcx = *rdx
2. movq (%rax), %rsi
int *rax = ?
int rsi = *rax
3. movq %rsi, (%rdx)
*rdx = rsi = *rax
4. movq %rcx, (%rax)
*rax = rcx = *rdi
5. addq $8, %rdx
rdx +=8
6. addq $120, %rax
rax += 120
7. cmpq %rdi, %rax
jne .L6
int rdi = ?
if (rdi != rax) jump to L6
外卖:
rdx
增加8。rdx
与C代码中的j
类似。 for
循环rdx
之外的0
初始化。 rax
正在返回的内容。问题:
哪个寄存器包含指向数组元素A[i][j]
?
哪个寄存器包含指向数组元素A[j][i]
?
M
的价值是什么?
我的想法:
rdx
。 rdx
总是上升8,所以它会经过整行。
rsi
也许??? rsi
设置为保留返回值,我认为返回值是元素A[j][i]
120 / 8 = 15
对我的回答或拒绝的任何确认将不胜感激。
答案 0 :(得分:1)
元素是with open("file.txt", 'r') as fd:
d = dict(line.rstrip().split(":") for line in fd)
s(长度为8个字节),您正在检查内部循环(在 Admin admin = null;
Configuration config = HBaseConfiguration.create();
// Add custom config parameters here
Connection connection = ConnectionFactory.createConnection(config);
try {
admin = connection.getAdmin();
for (String tableName : tableNames) {
System.out.print("Truncate table " + tableName);
try {
if (HBaseHelper.isTableExists(tableName)) {
if (admin.isTableDisabled(TableName.valueOf(tableName))) {
System.out.print("Table " + tableName + " was disabled. Enabling it...");
admin.enableTable(TableName.valueOf(tableName );
}
HBaseHelper.truncateTable(tableName);
}
}
catch (IOException e) {
System.out.print("Failed to truncate table " + tableName + "\nError Msg: " + e.getMessage());
}
}
} catch (Exception e){
System.out.print("Could not connect to HBase Admin. Error Msg: " + e.getMessage());
}
上),所以:
long
表示j
明确指向rdx +=8
。
rdx
表示A[i][j]
指向rax += 120
。
rax
等于15,因为一行长度为120个字节(A[j][i]
和M
之间的字节距离),每个A[j][i]
长度为8个字节(距离)在A[j+1][i]
和long
之间。