Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ariel core with scratchpad memory #2268

Open
gihyeonjeon opened this issue Nov 5, 2023 · 0 comments
Open

Ariel core with scratchpad memory #2268

gihyeonjeon opened this issue Nov 5, 2023 · 0 comments

Comments

@gihyeonjeon
Copy link

gihyeonjeon commented Nov 5, 2023

Hello!
Thank you for the help I received before!
But I have another question.
I am curious as to why the number of memory accesses changes with each simulation run, even though it is the same code. I understand that the memory addresses where data is stored can change due to virtual memory, but shouldn't the number of accesses to that memory remain the same?

<tesst2.py>

import sst
import os
from mhlib import componentlist

DEBUG_SCRATCH = 0
DEBUG_MEM = 0

stream_app = os.getenv("TESST")
if stream_app == None:
    print("ifda imma")
    sst_root = os.getenv( "SST_ROOT" )
    app = "~/scratch/tesst"
else:
    app = stream_app

if not os.path.exists(app):
    print("no app")
    app = os.getenv( "OMP_EXE" )
    if not app:
        print("no OMP")

# Define the simulation components
comp_cpu = sst.Component("Ariel0", "ariel.ariel")
comp_cpu.addParams({
    "verbose": "0",
    "maxcorequeue": "256",
    #"maxtranscore": "16",
    "maxissuepercycle": "2",
    "pipetimeout": "0",
    "executable" : app,
    "arielinterceptcalls": "1",
    "arielmode": "1"
})

comp_scratch = sst.Component("scratch", "memHierarchy.Scratchpad")
comp_scratch.addParams({
    "debug" : DEBUG_SCRATCH,
    "debug_level" : 10,
    "clock" : "2GHz",
    "size" : "1KiB",
    "scratch_line_size" : 64,
    "memory_line_size" : 64,
    "backing" : "none",
})
scratch_conv = comp_scratch.setSubComponent("backendConvertor", "memHierarchy.simpleMemScratchBackendConvertor")
scratch_back = scratch_conv.setSubComponent("backend", "memHierarchy.simpleMem")
scratch_back.addParams({
    "access_time" : "10ns",
})
scratch_conv.addParams({
    "debug_location" : 0,
    "debug_level" : 10,
})

memctrl = sst.Component("memory", "memHierarchy.MemController")
memctrl.addParams({
      "debug" : DEBUG_MEM,
      "debug_level" : 10,
      "clock" : "1GHz",
      "addr_range_start" : 0,
})
memory = memctrl.setSubComponent("backend", "memHierarchy.simpleMem")
memory.addParams({
    "access_time" : "1000 ns",
    "mem_size" : "512MiB"
})

# Enable statistics
sst.setStatisticLoadLevel(7)
sst.setStatisticOutput("sst.statOutputConsole")
for a in componentlist:
    sst.enableAllStatisticsForComponentType(a)


# Define the simulation links
link_cpu_scratch = sst.Link("link_cpu_scratch")
link_cpu_scratch.connect( (comp_cpu, "cache_link_0", "1000ps"), (comp_scratch, "cpu", "1000ps") )
link_scratch_mem = sst.Link("link_scratch_mem")
link_scratch_mem.connect( (comp_scratch, "memory", "100ps"), (memctrl, "direct_link", "100ps") )

<tesst.c>

#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE 1000

int main(){
    int i;
    double *data1 = (double *)malloc(ARRAY_SIZE *sizeof(double));
    int *data2 = (int *)malloc(ARRAY_SIZE *sizeof(int));
    //double *data3 = (double *)malloc(ARRAY_SIZE *sizeof(double));
    if (data1==NULL || data2==NULL || data2==NULL){
	    fprintf(stderr, "Memory allocation failed!\n");
	    return 1;
    }

    for(i=0;i<ARRAY_SIZE;i++){
	    data1[i]=i*0.5;
    }
    for(i=0;i<ARRAY_SIZE;i++){
	    data2[i]=i*i;
    }
    free(data1);
    free(data2);
    return 0;
}

<tesst_malloc.c>

#include <stdio.h>
#include <stdlib.h>
#include "arielapi.h"

#define ARRAY_SIZE 2000

int main(){
    int i;
    ariel_malloc_flag(0,1,1);
    double *data1 = (double *)malloc(ARRAY_SIZE *sizeof(double));
    ariel_malloc_flag(1,1,1);
    int *data2 = (int *)malloc(ARRAY_SIZE *sizeof(int));
    if (data1==NULL || data2==NULL){
	    fprintf(stderr, "Memory allocation failed!\n");
	    return 1;
    }

    for(i=0;i<ARRAY_SIZE;i++){
	    data1[i]=i*0.5;
    }
    for(i=0;i<ARRAY_SIZE;i++){
	    data2[i]=i*i;
    }
    free(data1);
    free(data2);
    return 0;
}

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants