Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b00b7ae
initial changes (wip)
saursin Feb 4, 2025
66aee0f
fix vaultsim missing symbol issue
saursin Feb 4, 2025
08cee86
remove vaultsim, fix paths
saursin Feb 4, 2025
5c103db
make it compile on rover
hyesoon Feb 4, 2025
428568a
initial testing code
hyesoon Feb 4, 2025
d238c4f
adding a starting test script
hyesoon Feb 4, 2025
1e447bf
fix sst build
saursin Feb 5, 2025
5f24d2e
fix sst copmponent paths
saursin Feb 5, 2025
d025ab1
fix param errors
saursin Feb 5, 2025
69a881f
allow sst build with debug option
saursin Feb 5, 2025
0689c83
rover version of build.py (old python style)
hyesoon Feb 6, 2025
1660af4
Merge branch 'macsim_sst' of github.com:saursin/macsim_sst into macsi…
hyesoon Feb 6, 2025
509f6c3
fix port name warnings
saursin Feb 6, 2025
f759d6b
Merge branch 'macsim_sst' of github.com:saursin/macsim_sst into macsi…
hyesoon Feb 6, 2025
84ae9b5
fix link names
saursin Feb 6, 2025
0603d32
add simple test script with icache & memory
saursin Feb 6, 2025
fd8e18a
more fixes
saursin Feb 6, 2025
3412406
WIP: icache only simulation
saursin Feb 6, 2025
309e55d
Merge branch 'macsim_sst' of github.com:saursin/macsim_sst into macsi…
hyesoon Feb 6, 2025
aecc22b
update the trace_file_list
hyesoon Feb 6, 2025
8892be3
fix prints temporarily, new config file
saursin Feb 10, 2025
8d00af1
add new sdls, refactor macsim component
saursin Feb 11, 2025
149273d
add debug params to links
saursin Feb 11, 2025
2889a2d
fix link initialization bug, refactor tests
saursin Feb 12, 2025
8215422
fix macsim event handlers, segfault in exec.cc
saursin Feb 18, 2025
90f2d80
update sdl files
saursin May 9, 2025
43f4e36
clean version
Jun 15, 2025
577c147
Update and fix errors including write request generate fix size of 4 …
Jun 30, 2025
27a3965
modify to flexible change and fully test all configurations
Jul 16, 2025
c176604
Modify git clone errors for dramsim2 according to SeonjinNa
SeonjinNa Sep 21, 2023
6d1a6c8
modify from ssh to http for dramsim2
Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.opt_build/
.sconf_temp/
.sst_build/
.sconsign.dblite
bin/macsim
config.log
Expand All @@ -23,3 +24,4 @@ Makefile
Makefile.in
*.dirstamp
sst-unit-test/*.out
.vscode/
28 changes: 28 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import sys
import os
import glob

from build import get_cmd_output

#########################################################################################
# Build option
Expand Down Expand Up @@ -317,6 +318,33 @@ if flags['qsim'] == '1':
if flags['ramulator'] == '1':
libraries.append('ramulator')

if flags['sst'] == '1': # Compile Macsim for SST
macsim_component_name = 'macsimComponent'
macsim_component_src = [x for x in macsim_src if 'main.cc' not in x] # We don't want main.cc
macsim_component_src += [
'macsimComponent.cpp'
]

sst_build_cxx = get_cmd_output(['sst-config', '--CXX']).split(' ')
sst_build_cxxflags = get_cmd_output(['sst-config', '--ELEMENT_CXXFLAGS']).split(' ')
sst_build_linkflags = get_cmd_output(['sst-config', '--ELEMENT_LDFLAGS']).split(' ')

# Set CXX compiler
sst_compiler = sst_build_cxx[0]
env['CXX'] = sst_compiler

# Set CXXFLAGS
env['CPPFLAGS'] += ' ' + ' '.join(sst_build_cxxflags)
env['CPPFLAGS'] += ' -DUSING_SST'

# Set LINKFLAGS
env['LINKFLAGS'] = sst_build_linkflags # Overriding

# Generate SST component as shared library
env.SharedLibrary(macsim_component_name, macsim_component_src)
Return() # Finish gracefully

# Build Macsim executable
env.Program(
'macsim',
macsim_src,
Expand Down
12 changes: 8 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ flags['gprof'] = Config.get('Build', 'gprof', fallback='0')
flags['pin_3_13_trace'] = Config.get('Build', 'pin_3_13_trace', fallback='0')
flags['val'] = Config.get('Build_Extra', 'val', fallback='0')
flags['ramulator'] = Config.get('Library', 'ramulator', fallback='0')
flags['sst'] = Config.get('Build', 'sst', fallback='0')

## Configuration from commandline
flags['debug'] = ARGUMENTS.get('debug', flags['debug'])
Expand All @@ -90,12 +91,12 @@ flags['dram'] = ARGUMENTS.get('dram', flags['dram'])
flags['val'] = ARGUMENTS.get('val', flags['val'])
flags['qsim'] = ARGUMENTS.get('qsim', flags['qsim'])
flags['ramulator'] = ARGUMENTS.get('ramulator', flags['ramulator'])

flags['sst'] = ARGUMENTS.get('sst', flags['sst'])

## Checkout DRAMSim2 copy
if flags['dram'] == '1':
if not os.path.exists('src/DRAMSim2'):
os.system('git clone git://github.com/dramninjasUMD/DRAMSim2.git src/DRAMSim2')
os.system('git clone https://github.com/umd-memsys/DRAMSim2.git src/DRAMSim2')

## Checkout Ramulator copy
if flags['ramulator'] == '1':
Expand All @@ -105,9 +106,12 @@ if flags['ramulator'] == '1':
## Create stat/knobs
SConscript('scripts/SConscript', exports='flags')


## sst element build (with/without debug)
if flags['sst'] == '1':
SConscript('SConscript', variant_dir='.sst_build', duplicate=0, exports='flags')
Clean('.', '.sst_build')
## debug build
if flags['debug'] == '1':
elif flags['debug'] == '1' and not flags['sst'] == '1':
SConscript('SConscript', variant_dir='.dbg_build', duplicate=0, exports='flags')
Clean('.', '.dbg_build')
## gprof build
Expand Down
56 changes: 55 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
import itertools
from optparse import OptionParser

import subprocess

#########################################################################################
# argument parsing
Expand All @@ -29,6 +29,8 @@ def parse_arg():
parser.add_option("--power", action="store_true", dest="power", default=False, help="EI Power")
parser.add_option("--iris", action="store_true", dest="iris", default=False, help="IRIS")
parser.add_option("--ramulator", action="store_true", dest="ramulator", default=False, help="Ramulator")
parser.add_option("--sst", action="store_true", dest="sst", default=False, help="Build Macsim SST Element")
parser.add_option("--sst-install", action="store_true", dest="sst_install", default=False, help="Install Macsim SST Element")

return parser

Expand Down Expand Up @@ -57,6 +59,27 @@ def build_test():
else:
print('%s %s failed' % (build_option[ii], ' '.join(opt)))

#########################################################################################
# Util Functions
#########################################################################################
def get_cmd_output(cmd:list, abort_on_error:bool=True):
"""
Run a command and return the output.
:param cmd: The command to run as a list of tokens.
:param abort_on_error: If True, abort on error.
:return: The stdout, stderr, and return code of the command.
"""
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = process.communicate()
stdout = stdout.decode('utf-8', errors='replace').strip() if stdout is not None else ''
stderr = stderr.decode('utf-8', errors='replace').strip() if stderr is not None else ''
if abort_on_error and process.returncode != 0:
print(f'Error: Shell command failed (return code: {process.returncode}): ', ' '.join(cmd), file=sys.stderr)
print('\tstdout:', stdout, file=sys.stderr)
print('\tstderr:', stderr, file=sys.stderr)
sys.exit(1)
return stdout


#########################################################################################
# main function
Expand Down Expand Up @@ -88,6 +111,37 @@ def main():
if options.dramsim:
cmd += 'dram=1 '

if options.sst:
cmd += 'sst=1 '

if options.sst_install:
component = 'macsimComponent'
component_lib_dir = os.path.abspath('.sst_build')
component_src_dir = os.getcwd()
component_tests_dir = os.path.abspath('sst-unit-test')

# Check if macsim component exists
if not os.path.exists(f'{component_lib_dir}/lib{component}.so'):
print(f"ERROR: {component} not found in {component_lib_dir}, build with sst=1 option first")
exit(0)

print(f"Registering SST element: {component}")
print(f" SRCDIR: {component_src_dir}")
print(f" LIBDIR: {component_lib_dir}")
print(f" TESTDIR: {component_tests_dir}")
os.system(f'sst-register {component} {component}_LIBDIR={component_lib_dir}')
os.system(f'sst-register SST_ELEMENT_SOURCE {component}={component_src_dir}')
os.system(f'sst-register SST_ELEMENT_TESTS {component}={component_tests_dir}')

# Check if component is registered successfully
sst_info_out = get_cmd_output(['sst-info', component])
if 'Component 0: macsimComponent' in sst_info_out:
print(f"Successfully registered SST element: {component}")
exit(0)
else:
print(f"ERROR: Failed to register SST element: {component}")
exit(1)

# EI power
if options.power:
cmd += 'power=1 '
Expand Down
200 changes: 200 additions & 0 deletions build.rover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#!/usr/bin/env python3

#########################################################################################
# Author : Jaekyu Lee (jq.lee17@gmail.com)
# Description : wrapper script for scons build
#########################################################################################


import os
import sys
import itertools
from optparse import OptionParser
import subprocess

#########################################################################################
# argument parsing
#########################################################################################
def parse_arg():
parser = OptionParser(usage="usage: %prog [options] filename", version="%prog 1.0")
parser.add_option("-j", "--thread", action="store", dest="thread", default=1, help="-j option for the parallel build")
parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="debug build")
parser.add_option("-p", "--gprof", action="store_true", dest="gprof", default=False, help="gprof build")
parser.add_option("-c", "--clean", action="store_true", dest="clean", default=False, help="clean")
parser.add_option("-t", "--test", action="store_true", dest="test", default=False, help="clean")
parser.add_option("-v", "--val", action="store_true", dest="val", default=False, help="build version used for gpu validation")
parser.add_option("--newpin", action="store_true", dest="pin_3_13_trace", default=False, help="trace based on pin 3.13 ")
parser.add_option("-q", "--qsim", action="store_true", dest="qsim", default=False, help="use qsim to drive macsim")
parser.add_option("--dramsim", action="store_true", dest="dramsim", default=False, help="DRAMSim2")
parser.add_option("--power", action="store_true", dest="power", default=False, help="EI Power")
parser.add_option("--iris", action="store_true", dest="iris", default=False, help="IRIS")
parser.add_option("--ramulator", action="store_true", dest="ramulator", default=False, help="Ramulator")
parser.add_option("--sst", action="store_true", dest="sst", default=False, help="Build Macsim SST Element")
parser.add_option("--sst-install", action="store_true", dest="sst_install", default=False, help="Install Macsim SST Element")

return parser


#########################################################################################
# build test for all possible build combinations
#########################################################################################
def build_test():
build_option = ['', 'debug=1', 'gprof=1', 'qsim=1', 'pin_3_13_trace=1']
build_dir = ['.opt_build', '.dbg_build', '.gpf_build']
build_libs = ['dram=1', 'power=1', 'iris=1', 'ramulator=1']

for ii in range(0, len(build_option)):
os.system('rm -rf %s' % build_dir[ii])
for jj in range(0, len(build_libs)+1):
for opt in itertools.combinations(build_libs, jj):
cmd = 'scons -j 4 %s %s' % (build_option[ii], ' '.join(opt))
redir = '> /dev/null 2>&1'

if os.path.exists('%s/macsim' % build_dir[ii]):
os.system('rm -f %s/macsim' % build_dir[ii])

os.system('%s %s' % (cmd, redir))
if os.path.exists('%s/macsim' % build_dir[ii]):
print('%s %s successful' % (build_option[ii], ' '.join(opt)))
else:
print('%s %s failed' % (build_option[ii], ' '.join(opt)))

#########################################################################################
# Util Functions
#########################################################################################
def get_cmd_output(cmd, abort_on_error=True):
"""
Run a command and return the output.
:param cmd: The command to run as a list of tokens.
:param abort_on_error: If True, abort on error.
:return: The stdout, stderr, and return code of the command.
"""
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
stdout, stderr = process.communicate()
stdout = stdout.decode('utf-8', errors='replace').strip() if stdout is not None else ''
stderr = stderr.decode('utf-8', errors='replace').strip() if stderr is not None else ''
if abort_on_error and process.returncode != 0:
#print(f'Error: Shell command failed (return code: {process.returncode}): ', ' '.join(cmd), file=sys.stderr)
#print('\tstdout:', stdout, file=sys.stderr)
#print('\tstderr:', stderr, file=sys.stderr)
print >> sys.stderr, 'Error: Shell command failed (return code: {}): {}'.format(process.returncode, ' '.join(cmd))
print >> sys.stderr, '\tstdout:', stdout
print >> sys.stderr, '\tstderr:', stderr
sys.exit(1)
return stdout


#########################################################################################
# main function
#########################################################################################
def main():
parser = parse_arg()
(options, args) = parser.parse_args()

## Build test
if options.test:
build_test()
sys.exit(0)


## Prepare scons command
cmd = 'scons '

## Main build options (opt, dbg, gpf)
if options.debug:
cmd += 'debug=1 '
elif options.gprof:
cmd += 'gprof=1 '

if options.val:
cmd += 'val=1 '

## External libraries (dramsim, ei, iris)
# DRAMSim2
if options.dramsim:
cmd += 'dram=1 '

if options.sst:
cmd += 'sst=1 '

if options.sst_install:
component = 'macsimComponent'
component_lib_dir = os.path.abspath('.sst_build')
component_src_dir = os.getcwd()
component_tests_dir = os.path.abspath('sst-unit-test')

# Check if macsim component exists
if not os.path.exists('{}/lib{}.so'.format(component_lib_dir, component)):
print("ERROR: {} not found in {}, build with sst=1 option first".format(component, component_lib_dir))
#if not os.path.exists(f'{component_lib_dir}/lib{component}.so'):
#print(f"ERROR: {component} not found in {component_lib_dir}, build with sst=1 option first")
exit(0)

print("Registering SST element: {}".format(component))
print(" SRCDIR: {}".format(component_src_dir))
print(" LIBDIR: {}".format(component_lib_dir))
print(" TESTDIR: {}".format(component_tests_dir))
os.system('sst-register {} {}_LIBDIR={}'.format(component, component, component_lib_dir))
os.system('sst-register SST_ELEMENT_SOURCE {}={}'.format(component, component_src_dir))
os.system('sst-register SST_ELEMENT_TESTS {}={}'.format(component, component_tests_dir))

# Check if component is registered successfully
sst_info_out = get_cmd_output(['sst-info', component])
if 'Component 0: macsimComponent' in sst_info_out:
print("Successfully registered SST element: {}".format(component))
exit(0)
else:
print("ERROR: Failed to register SST element: {}".format(component))
exit(1)

# EI power
if options.power:
cmd += 'power=1 '

# IRIS
if options.iris:
cmd += 'iris=1 '

# Qsim
if options.qsim:
cmd += 'qsim=1 '

# NEW PIN
if options.pin_3_13_trace:
cmd += 'pin_3_13_trace=1 '

# Ramulator
if options.ramulator:
cmd += 'ramulator=1 '

## Parallel building
cmd += '-j %s ' % options.thread

if options.clean:
cmd += '-c'


## run scons command
os.system(cmd)


## Create a symbolic link
if not options.clean:
if options.debug:
build_dir = '.dbg_build'
elif options.gprof:
build_dir = '.gpf_build'
else:
build_dir = '.opt_build'

if os.path.exists('%s/macsim' % build_dir):
os.chdir('bin')

if os.path.exists('macsim'):
os.system('rm -f macsim')
os.system('ln -s ../%s/macsim' % build_dir)



if __name__ == '__main__':
main()
Loading