Время исполнения, несовместимое с сложностью эталона в моделировании GEM5Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Время исполнения, несовместимое с сложностью эталона в моделировании GEM5

Сообщение Anonymous »

Я запускаю эталон Sort Sort на самой простой модели архитектуры GEM5. 
я использовал три входа размера 1000: 1) наихудший случай (порядок убывания), средний случай (случайный порядок) и лучший случай (порядок повышения). < /p>
Результаты, показанные на stats.txt , не совместимы со сложностью случаев. В худшем случае должно занять больше времени, чем средний и лучший случай, так как его сложность O (n^2) противопоставляется O (n), но этого не происходит. < /P>
Любой Предложения по поводу того, что может привести к тому, что GEM5 для этих результатов? 
Я пробовал atomicsImplecpu и timingsimplecpu. < /p>


timingsimplecpu () < /th>

simticks
numcycles
ciminst




лучший случай < /td>
1760640 < /td>
1769385792000 < /td>
1769385792 < /td>
18270740 < /td>
< /tr>
Средний случай < /td>
1762432 < /td>
1771194450000 < /td>
1771194450 < /td>
18287151 < /td>
< /tr>
худший случай < /td>
1760000 < /td>
1768710489000
1768710489
18263273


< /table> < /div>



atomicsImplecpu () < /th>
c clock () function < / th>
simticks < /th>
numcycles < /th>
siminst < /th>
< /tr>
< /thead>


лучший случай < /td>
31872 < /td>
< TD> 32193276000
32193321
18270464 < /td>
< /tr>

Средний случай < /td>
32000 < /td>
32215575000 < /td>
32215620 < /td>
18286703 < /td>
< /tr>

худший случай < /td>
31872 < /td>
32183116000 < /td>
32183161 < /td>
18263098



Найдите ниже пузырьковой сортировки () и коды Python GEM5.#include
#include
#include

struct timespec start, end;

int arr[1000] = {1, 2, 3, 4, 5, 6, 7, 8,...., 1000}; //best case
//int arr[1000] = {250, 2, 998, 876,...., 27}; //average case
//int arr[1000] = {1000, 999, 998, 997,...., 1}; //worst case
int size = 1000;

int bsort_BubbleSort( int *arr, int bsort_SIZE )
{
int Sorted = 0;
int Temp, Index, i;

for ( i = 0; i < bsort_SIZE - 1; i ++ ) {
Sorted = 1;

for ( Index = 0; Index < bsort_SIZE - 1; Index ++ ) {
if ( Index > bsort_SIZE - i )
break;
if ( arr[ Index ] > arr[Index + 1] ) {
Temp = arr[ Index ];
arr[ Index ] = arr[ Index + 1 ];
arr[ Index + 1 ] = Temp;
Sorted = 0;
}
}

if ( Sorted )
break;
}

return 0;
}

int main() {

clock_t t1, t2;
int i;
float diff;
int array[size];

FILE * pFile;
pFile = fopen ("myfile.txt","w");

t1 = clock();
bsort_BubbleSort(array, size);
t2 = clock();

diff = (((float)t2 - (float)t1));

fprintf (pFile, "%f\n", diff);
fclose(pFile);
return 0;
}
< /code>
# import the m5 (gem5) library created when gem5 is built
import m5

# import all of the SimObjects
from m5.objects import *

# create the system we are going to simulate
system = System()

# Set the clock frequency of the system (and all of its children)
system.clk_domain = SrcClockDomain()
system.clk_domain.clock = "1GHz"
system.clk_domain.voltage_domain = VoltageDomain()

# Set up the system
system.mem_mode = "atomic"
# system.mem_mode = "timing" # Use timing accesses
system.mem_ranges = [AddrRange("512MiB")] # Create an address range

# Create a simple CPU
# You can use ISA-specific CPU models for different workloads:
# `RiscvTimingSimpleCPU`, `ArmTimingSimpleCPU`.
system.cpu = AtomicSimpleCPU()
# system.cpu = TimingSimpleCPU()

# Create a memory bus, a system crossbar, in this case
system.membus = SystemXBar()

# Hook the CPU ports up to the membus
system.cpu.icache_port = system.membus.cpu_side_ports
system.cpu.dcache_port = system.membus.cpu_side_ports

# create the interrupt controller for the CPU and connect to the membus
system.cpu.createInterruptController()

# For X86 only we make sure the interrupts care connect to memory.
# Note: these are directly connected to the memory bus and are not cached.
# For other ISA you should remove the following three lines.
system.cpu.interrupts[0].pio = system.membus.mem_side_ports
system.cpu.interrupts[0].int_requestor = system.membus.cpu_side_ports
system.cpu.interrupts[0].int_responder = system.membus.mem_side_ports

# Create a DDR3 memory controller and connect it to the membus
system.mem_ctrl = MemCtrl()
system.mem_ctrl.dram = DDR3_1600_8x8()
system.mem_ctrl.dram.range = system.mem_ranges[0]
system.mem_ctrl.port = system.membus.mem_side_ports

# Connect the system up to the membus
system.system_port = system.membus.cpu_side_ports

# Here we set the X86 "hello world" binary. With other ISAs you must specify
# workloads compiled to those ISAs. Other "hello world" binaries for other ISAs
# can be found in "tests/test-progs/hello".
thispath = os.path.dirname(os.path.realpath(__file__))
binary = os.path.join(
thispath,
"../../../",
# "tests/test-progs/hello/bin/x86/linux/test",
)

system.workload = SEWorkload.init_compatible(binary)

# Create a process for a simple "Hello World" application
process = Process()
# Set the command
# cmd is a list which begins with the executable (like argv)
process.cmd = [binary]
# Set the cpu to use the process as its workload and create thread contexts
system.cpu.workload = process
system.cpu.createThreads()

# set up the root SimObject and start the simulation
root = Root(full_system=False, system=system)
# instantiate all of the objects we've created above
m5.instantiate()

print(f"Beginning simulation!")
exit_event = m5.simulate()
< /code>
Редактировать < /p>
Проблема решила. На коде C была ошибка в определении массива [размер]. Проверьте комментарий.


Подробнее здесь: https://stackoverflow.com/questions/794 ... simulation
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»