ASCYLIB (with OPTIK) is a concurrent data-structure library. It contains over 40 implementations of linked lists, hash tables, skip lists, binary search trees (BSTs), queues, priority queues, and stacks. ASCYLIB contains sequential, lock-based, and lock-free implementations for each data structure.
GUPS (Giga十亿 UPdates per Second) is a measurement that profiles the memory architecture of a system and is a measure of performance similar to MFLOPS.
The HPCS HPCchallenge RandomAccess benchmark is intended to exercise the GUPS capability of a system, much like the LINPACK benchmark is intended to exercise the MFLOPS capability of a computer. In each case, we would expect these benchmarks to achieve close to the “peak” capability of the memory system. The extent of the similarities between RandomAccess and LINPACK are limited to both benchmarks attempting to calculate a peak system capability.
definition of GUPS
GUPS is calculated by identifying the number of memory locations that can be randomly updated in one second, divided by 1 billion (1e9).
The term “randomly“ means that there is little relationship between one address to be updated and the next, except that they occur in the space of one half the total system memory. (只用一半内存?)
An update is a read-modify-write operation on a table of 64-bit words. An address is generated, the value at that address read from memory, modified by an integer operation (add, and, or, xor) with a literal value, and that new value is written back to memory.
Extensibility
We are interested in knowing the GUPS performance of both entire systems and system subcomponents — e.g., the GUPS rating of a distributed memory multiprocessor the GUPS rating of an SMP node, and the GUPS rating of a single processor.
While there is typically a scaling of FLOPS with processor count, a similar phenomenon may not always occur for GUPS.
Principle
Select the memory size to be the power of two such that 2^n <= 1/2 of the total memory. Each CPU operates on its own address stream, and the single table may be distributed among nodes. The distribution of memory to nodes is left to the implementer. A uniform data distribution may help balance the workload, while non-uniform data distributions may simplify the calculations that identify processor location by eliminating the requirement for integer divides. A small (less than 1%) percentage of missed updates are permitted.
function climbStairs(n) { if (n === 1) return1; if (n === 2) return2; return climbStairs(n - 1) + climbStairs(n - 2); }
添加与DFS参数相关的记忆化数组,将这个 dfs 改成「无需外部变量」的 dfs。
1 2 3 4 5 6 7 8 9
memo = {} def climbStairs(n): if n == 1:return1 if n == 2: return2 if n in memo: return memo[n] ans = func(n - 1) + func(n-2) memo[n] = ans return ans climbStairs(10)