91 questions
0
votes
1
answer
273
views
How do I read the cycle counting register on Windows ARM64
Just bought a windows laptop sporting the Snapdragon Elite processor and trying to get acquainted with the ARM instruction set via some C-code. First attempt is to read from the cycle counter register ...
1
vote
0
answers
103
views
Cpu cycle count for a C program in mac os on ARM64 CPUs? [duplicate]
I'm trying to record the number of cpu cycles for running a C program on a M1.
I know there are x86 instructions rdtsc and rdtscp that can be used to time intervals within a program. (In wall-clock ...
0
votes
1
answer
2k
views
How can I get an STM32F103C8 running at 72MHz with ArduinoIDE and HAL library?
How can we get an Stm32f103c8 running 72MHz with Arduino IDE (STM32duino)?
We have custom designed a PCB using the chip from the question. We are able to get it running at 72MHz using STM32CubeIDE. ...
3
votes
1
answer
3k
views
Measurement of CPU cycles with perf
Currently I'm working on measuring the time of code execution.
I can measure how much time took to execute function (using tracepoints) but I also need to measure how many cpu cycles the execution of ...
4
votes
1
answer
1k
views
How to measure the ACTUAL number of clock cycles elapsed on modern x86?
On recent x86, RDTSC returns some pseudo-counter that measures time instead of clock cycles.
Given this, how do I measure actual clock cycles for the current thread/program?
Platform-wise, I prefer ...
1
vote
1
answer
110
views
Does changing one single bit consume less cycles per byte than adding/subtracting/xoring an entire processor word?
Let's suppose I change one single bit in a word and add two other words.
Does changing one bit in a word consume less CPU cycles than changing an entire word?
If it consumes less CPU cycles, how much ...
0
votes
1
answer
908
views
How to save CPU cycle searching a sorted array for an exact match? Linear search is too slow?
The aim of this exercise is to check the presence of a number in an array.
Specifications: The items are integers arranged in ascending order. The array can contain up to 1 million items. The array ...
1
vote
2
answers
786
views
How to calculate number of instruction cycles?
What is the number of instruction cycles for EastLoop block? I have the following code:
#include
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF)
cblock 0x20
Delay1
Delay2
...
0
votes
0
answers
299
views
Page walk cycles effect on total execution cycles
I have measured cycles and dTLB_load_misses.walk_active for an application using perf tool. I executed the application two times. First time in isolation and the second with a single thread memory-...
0
votes
0
answers
52
views
What would be faster: Spliting a 64-bit word into 16 nibbles and entering them in S-Boxes or using an entire 64-bit word directly as an entry?
This question is related to cryptography, but I believe I'm asking in right place (not in Crypto Stackexchange).
Kuznyechik block cipher splits a 64-bit word into 16 nibbles (4-bits) and use them as ...
2
votes
1
answer
2k
views
Measure CPU clock cycles per operation in python
I'd like to know how'd you measure the amount of clock cycles per instruction say copy int from one place to another?
I know you can time it down to nano seconds but with today's cpu's that resolution ...
1
vote
1
answer
222
views
Measuring clock cycles of another PID
I am looking to measure total clock cycles used by a program. I am hoping to measure this from another process.
clock_t can be used to measure a block of code but doesn't work for me because I want ...
0
votes
0
answers
23
views
What is happening struct padding or packing in 64 bit computer [duplicate]
Code 1
#include <stdio.h>
//structure var
struct var{
char a;
};
int main()
{
struct var r;
printf("%ld\n", sizeof(r));
return 0;
}
Output: 1
I know the concept of padding and ...
0
votes
0
answers
5k
views
What is the correct way of calculating MIPS?
I found below question about MIPS,
A computer system has a CPU with a word length of 64 bits and a clock
speed of
1.5GHz. For a certain task, the measured average CPI (cycles per instruction) of the ...
6
votes
3
answers
1k
views
What's the relationship between the real CPU frequency and the clock_t in C?
What's the relationship between the real CPU frequency and the clock_t (the unit is clock tick) in C?
Let's say I have the below piece of C code which measures the time that CPU consumed for running a ...
1
vote
1
answer
1k
views
Understanding the Frequency printed by Linux Perf Stat [closed]
perf stat <command> prints several stats associated with <command>. Most of the stats are easily understandable. But what does it mean by the frequency associated with the cycle stat (...
0
votes
1
answer
75
views
How to represent burst times in CPU scheduling with a variable
Instructions:implement Burst-times are assigned at random (10x10^6 cycles - 50x10^12 cycles). How would I convert this to ms the measurement of burst times.
0
votes
1
answer
822
views
why could some instructions be excuted in one clock cycle in modern cpu?
many related questions says, for example, some instructions can be excuted in one clock cycle.
however, as far as I know(from the book of Computer Systems: A Programmer's Perspective), there are many ...
2
votes
2
answers
819
views
Unexpected timing in Arm assembly
I need a very precise timing, so I wrote some assembly code (for ARM M0+).
However, the timing is not what I expected when measuring on an oscilliscope.
#define LOOP_INSTRS_CNT 4 // ...
1
vote
0
answers
342
views
Tracing CPU cycle with Pintool?
I am trying to run SPEC17 benchmark using Pintool. While doing so I need to log CPU cycle and memory address accessed. Pintool have pinatrace tool to log memory addresses but I can not find anything ...
2
votes
1
answer
808
views
clock_gettime takes longer to execute when program run from terminal
I was trying to measure the time for a snippet of code and noticed that the timings were about 50ns faster when I ran the program from inside my editor, QtCreator, compared to when I ran it from a ...
0
votes
0
answers
33
views
Is it possible to alter the CPU's cycle count through software?
In a typical computer system, is it possible to manually change the CPU cycle counter to a specific value? The most obvious method would be to check the counter value and then run NOP or other ...
2
votes
1
answer
217
views
Why measured time of running NEON inline assembly code doesn't match with expected time based on number of clock cycles and core frequency?
image width = 4000
image height = 2000
number of iterations = width * height / 64 = 125 000
asm volatile(
"1: \n\t"
"prfm pldl1keep,...
1
vote
1
answer
1k
views
What determines CPU cycle time
I'd like to find out whether there is a relationship between CPU cycle time and pipeline depth. I have always thought that CPU cycle time is entirely determined by CPU frequency (opposite to frequency)...
0
votes
2
answers
223
views
Clock Cycles for the invlpg instruction
I was reading some documentation about the invlpg instruction for Intel Pentium processors and it says that it takes 25 clock cycles. I thought that this depended on the implementation (the particular ...
0
votes
2
answers
183
views
CPU usage C Packed struct vs Unsigned Long Long operations
I need to do some operations with 48 bit variables, so I had two options:
Create my own structure with 48 bit variables, or
Use unsigned long long (64 bits).
As the operations will not overflow 48 ...
0
votes
1
answer
8k
views
Calculating Average Cycles per Instruction given Execution Time, Instruction Count, and Clock Rate
So I'm learning Computer Architecture where we have to take into account different processors and their clocks, and I can't help but feel that my calculations are off when calculating average CPI. For ...
1
vote
1
answer
3k
views
Why is nop not taking one clock cycle
I wrote a basic code to find out the amount of clock cycles taken by nop. We know nop takes one clock cycle.
#include <stdio.h>
#include <string.h>
#include <stdint.h>
int main(void)...
1
vote
0
answers
179
views
How to count cycles when TscInvariant = True?
The command rdtsc should be reliable source of time if the "TscInvariant" CPUID feature is enabled (see for example this link). On a dynamic frequency rescaling context, a reliable source of time ...
0
votes
0
answers
90
views
How can I estimate the execution time of convolution on PXA27x processor?
I am a civil engineering student, so please be gentle :)
I have to give a rough estimate of the timing of an algorithm working on an Intel PXA271 processor, with XScale architecture. Basically, my "...
1
vote
2
answers
239
views
Calculating which compiler is faster in terms of cycling
I just have a simple question, a bit silly, but I just need some clarification for an upcoming exam so I don't make a stupid mistake. I am currently taking a class in computer organization and design ...
-1
votes
1
answer
407
views
Clock cycles for a 8bit CPU and memory reads
Is it possible for a 8bit CPU to read memory in less than 3 clock cycles? I know that the 6502 works with an asynchronous memory but what about other 8bit CPUs with clocked memories? Do I need a clock ...
-1
votes
1
answer
284
views
Time measurements differ on microcontroller
I am measuring the cycle count of different C functions which I try to make constant time in order to mitigate side channel attacks (crypto).
I am working with a microcontroller (aurix from infineon) ...
5
votes
3
answers
771
views
Is a mov to a segmentation register slower than a mov to a general purpose register?
Specifically is:
mov %eax, %ds
Slower than
mov %eax, %ebx
Or are they the same speed. I've researched online, but have been unable to find a definitive answer.
I'm not sure if this is a silly ...
0
votes
1
answer
696
views
How many and what size cycles will be needed to perform longword transferred to the CPU
The task is for architecture ColdFire processor MCF5271:
I don't understand how many and what size cycles will be needed to perform a longword transfer to the CPU, or word transfers. I'm reading the ...
1
vote
0
answers
19
views
Is there a way to determine how many CPU cycles my single-threaded program requires to execute?
I have a single-threaded, computationally intensive program and I would like to know if there is a way (such as a tool/profiler) that I can use to determine the number of CPU cycles my program ...
0
votes
1
answer
209
views
Same inputs and instructions but different delays, how?
For TI Tiva Launchpad, I wrote a C code that takes two numbers from GPIO as inputs and then it adds the two numbers and outputs the result. Then, I connected an FPGA board to the Tiva launchpad and ...
0
votes
0
answers
110
views
Blender cycles, samples color
I am trying to collect from Cycles source code, the color of each sample during the rendering algorithm. However, after 2 months of research (...), I still don't understand how to get them.
I've been ...
5
votes
0
answers
9k
views
Convert CPU cycles into seconds in C programming [duplicate]
I was trying to figure out if there is any easy method to convert the CPU cycles obtained in C using rdtsc() function into time in seconds.
ex:-
unsigned long long start, stop;
start = rdtsc();
...
3
votes
1
answer
957
views
Understanding STM8 pipelining
I’m trying to understand STM8 pipelining to be able to predict how much cycles my code will need.
I have this example, where I toggle a GPIO pin for 4 cycles each.
Iff loop is aligned at 4byte-...
0
votes
1
answer
82
views
Which one takes less cpu clock cycles to execute? Pythagoras formula or 16 comparisons among ints in "if" clause?
Aprox answer is sufficient.
I am suppose to check if 2 rectangles of same size overlap or not
1) Existing code checks if all (x,y) of one rectangle is withing the all (x,y) of another. So making 16 ...
3
votes
1
answer
2k
views
Counting CPU cycles with `perf_event` in C yields different value than `perf`
I try to count the CPU cycles of a single process via a short C code snippet. A MWE is the cpucycles.c.
cpucycles.c (heavily based on the man page example)
#include <stdlib.h>
#include <...
68
votes
2
answers
103k
views
What is a clock cycle and clock speed? [closed]
I have been reading a book about the Computer's Processor. And I came across some of the terms like clock Ticks, clock Cycle and clock Speed that I am finding very difficult to understand. I will be ...
1
vote
1
answer
713
views
Why ADD is 4 cycles on Z80?
I use this ALU block diagram as a learning material : http://www.righto.com/2013/09/the-z-80-has-4-bit-alu-heres-how-it.html
I am not familiar with electronics. I am currently believing that a clock ...
3
votes
3
answers
3k
views
CPU cycles in Arduino uno for Digital read and counting pulses
I'm trying to count number of HB100 microwave sensor pulses in 200ms time quanta.
Here is the code:
#include <SoftwareSerial.h>
#include <elapsedMillis.h>
elapsedMillis ElapsedTime;
#...
4
votes
1
answer
7k
views
Why do memory instructions take 4 cycles in ARM assembly?
Memory instructions such as ldr, str or b take 4 cycles each in ARM assembly.
Is it because each memory location is 4 bytes long?
0
votes
2
answers
2k
views
Measuing CPU clock speed
I am trying to measure the speed of the CPU.I am not sure how much my method is accurate. Basicly, I tried an empty for loop with values like UINT_MAX but the program terminated quickly so I tried ...
0
votes
1
answer
372
views
Does one method call takes one CPU cycle?
Suppose we have following method
private int add(int num_1, int num_2)
{
return num_1+num+2;
}
Does calling this method consumes one cpu cycle ?
As there are 1 billion cycles in 1 ghz.
0
votes
0
answers
2k
views
MCR and MRC instruction usage
here i have written code to find number of cycles taken by a function but i am getting error at first MCR instruction can any one suggest me how to solve this problem.This code is written in XCODE and ...
-1
votes
1
answer
2k
views
How to calculate idle CPU cycles? [closed]
I want to calculate idle CPU cycles. I have tried to find out answer of this question on the internet. But the answers were not satisfactory. I queried for calculating idle CPU cycles but answers were ...