Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ src/ui/node_modules/
src/ui/electron/node_modules/
src/compiler/ast/
src/compiler/bad.json
src/compiler/build/
src/compiler/compiler.pdb
src/compiler/yaml-cppd.dll
vcpkg/
.vscode/
*.exe
node_modules/
src\compiler\compiler.exe
207 changes: 207 additions & 0 deletions HOWTO_RUN.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
===============================================================================
SIMRUN - How to Run
===============================================================================

This project is a simulation system with:
- UI: React/TypeScript frontend with Electron desktop shell (Vite)
- Compiler: C++ backend for IR processing and compilation

Follow the steps below for your platform.

===============================================================================
PREREQUISITES (BOTH PLATFORMS)
===============================================================================

1. Install Git
- Download from https://git-scm.com/

2. Install Node.js (v16 or higher) and npm
- Download from https://nodejs.org/
- npm is included with Node.js
- Verify: `node --version` and `npm --version`

3. Install CMake (v3.18+)
- Download from https://cmake.org/download/
- Verify: `cmake --version`

4. Install a C++ compiler

WINDOWS:
- Visual Studio Community 2022 (free)
- Download from https://visualstudio.microsoft.com/downloads/
- Install with "Desktop development with C++" workload

LINUX:
- Ubuntu/Debian: `sudo apt-get install build-essential g++ cmake`
- Fedora: `sudo dnf install gcc g++ make cmake`
- Arch: `sudo pacman -S base-devel cmake`

5. Bootstrap vcpkg (C++ dependency manager)

WINDOWS (PowerShell):
- Open PowerShell and navigate to the repo root
- .\vcpkg\bootstrap-vcpkg.bat

LINUX (Bash):
- Open terminal and navigate to the repo root
- ./vcpkg/bootstrap-vcpkg.sh

===============================================================================
OPTION 1: RUN UI ONLY (No C++ compilation)
===============================================================================

Great if you just want to develop the UI and don't need to rebuild the compiler.

Steps (Both Windows & Linux):

1. Navigate to UI directory
cd src/ui

2. Install Node dependencies
npm install

3. Start development server (with hot reload)
npm run electron:dev

This will:
- Start the Vite dev server
- Launch the Electron app
- Auto-reload when you make changes

4. Build for production (if needed)
npm run build
npm run electron
- Creates optimized build and launches Electron desktop app

===============================================================================
OPTION 2: FULL SETUP (UI + C++ Compiler)
===============================================================================

If you need to rebuild the C++ compiler component, follow this section.

---
WINDOWS (Visual Studio 2022 + CMake)
---

1. Open a "Developer PowerShell for VS 2022" (search in Windows Start menu)

2. Navigate to the compiler directory
cd src\compiler

3. Create build directory and configure with CMake
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=..\..\vcpkg\scripts\buildsystems\vcpkg.cmake ..

4. Build the project
cmake --build . --config Release

5. The compiled executable will be in:
build\Release\

6. Now run the UI (from repo root)
cd ..\..\src\ui
npm install
npm run electron:dev

---
LINUX (CMake + GCC/Clang)
---

1. Open a terminal and navigate to the repo root

2. Navigate to the compiler directory
cd src/compiler

3. Create build directory and configure with CMake
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../vcpkg/scripts/buildsystems/vcpkg.cmake ..

4. Build the project
cmake --build . -- -j$(nproc)

(This uses all available CPU cores for faster compilation)

5. The compiled binary will be in:
./

6. Now run the UI (from repo root)
cd ../../src/ui
npm install
npm run electron:dev

===============================================================================
TROUBLESHOOTING
===============================================================================

Issue: CMake can't find dependencies
Solution: Make sure vcpkg is bootstrapped (see Prerequisites step 5)
Ensure you're using the correct path to vcpkg.cmake

Issue: Cannot find C++ compiler
WINDOWS: Install Visual Studio 2022 with C++ workload
LINUX: Run `sudo apt-get install build-essential` (Ubuntu/Debian)

Issue: npm install fails
Solution: Clear npm cache and retry
npm cache clean --force
rm -rf node_modules
npm install

Issue: Electron won't start
Solution: Try running from the repo root in a new terminal
Make sure all npm packages installed successfully
Check console output for specific error messages

Issue: Port 8081 already in use (compiler server)
Solution: Change the compiler port in src/compiler/src/server.cpp
Or stop the process using port 8081

===============================================================================
PROJECT STRUCTURE
===============================================================================

simrun/
├── src/
│ ├── ui/ ← React/TypeScript frontend + Electron
│ ├── compiler/ ← C++ compiler backend
│ ├── sim/ ← C++ simulation engine
│ └── analysis/ ← Analysis tools
├── vcpkg/ ← C++ dependency manager
├── HOWTO_RUN.txt ← This file
└── README.md ← Project overview

===============================================================================
QUICK REFERENCE
===============================================================================

UI Development (Hot Reload):
cd src/ui
npm run electron:dev

UI Production Build:
cd src/ui
npm run build
npm run electron

Compiler Build (Windows):
cd src\compiler && mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=..\..\vcpkg\scripts\buildsystems\vcpkg.cmake ..
cmake --build . --config Release

Compiler Build (Linux):
cd src/compiler && mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . -- -j$(nproc)

===============================================================================
GETTING HELP
===============================================================================

- Check README.md for project overview
- Check project issues/wiki on GitHub
- Review compiler logs: look for errors in cmake output
- Check browser console in Electron app (press Ctrl+Shift+I)

===============================================================================
6 changes: 0 additions & 6 deletions profiles/components/api/service/default.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions profiles/components/cache/default.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions profiles/components/database/default.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions profiles/networks/ethernet.yaml

This file was deleted.

74 changes: 74 additions & 0 deletions src/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.15)
project(compiler)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# ---------------------------
# Find packages (vcpkg CONFIG mode)
# ---------------------------
find_package(nlohmann_json CONFIG REQUIRED)
find_package(yaml-cpp CONFIG REQUIRED)
# Uncomment if this project also uses Crow
# find_package(Crow CONFIG REQUIRED)

# ---------------------------
# Source files
# ---------------------------
set(SOURCES
src/server.cpp
src/compiler_driver.cpp
src/ir_parser.cpp
src/validator.cpp
src/profile_repository.cpp
src/profile_resolver.cpp
src/ir_serializer.cpp
)

# ---------------------------
# Create executable
# ---------------------------
add_executable(compiler ${SOURCES})
# Put the final .exe in the project source/compiler folder
set_target_properties(compiler PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}"
)


# ---------------------------
# Link libraries
# ---------------------------
target_link_libraries(compiler
PRIVATE
nlohmann_json::nlohmann_json
yaml-cpp
# Crow::Crow # Uncomment if using Crow
)

# ---------------------------
# Include directories
# ---------------------------
target_include_directories(compiler
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

# ---------------------------
# Output directory
# ---------------------------
set_target_properties(compiler PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

# ---------------------------
# Compiler warnings
# ---------------------------
if(MSVC)
target_compile_options(compiler PRIVATE /W4)
else()
target_compile_options(compiler PRIVATE -Wall -Wextra -Wpedantic)
endif()
27 changes: 27 additions & 0 deletions src/compiler/final_ir.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"context": {
"components": [
{
"config": {
"base_median_seek_ms": 5.0,
"base_seek_time": 10,
"base_variance_seek_ms": 0.6,
"bucket_capacity": 8000,
"initial_tokens": 8000,
"max_concurrency": 100,
"max_iops": 3000,
"queue_capacity": 3000,
"seek_model": "lognormal"
},
"id": 1631572,
"type": "database"
}
]
},
"header": {
"engine_version": "simrun-0.1",
"ir_version": "1.0",
"seed": 42,
"time_unit": "milliseconds"
}
}
23 changes: 17 additions & 6 deletions src/compiler/src/compiler_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,32 @@
#include "profile_resolver.h"
#include "ir_serializer.h"
#include <stdexcept>
#include <iostream>
#include <filesystem>

namespace fs = std::filesystem;
string compileIR(IR& ir) {

// 🔴 VALIDATION STAGE
// VALIDATION STAGE
string err = validateIR(ir);
if (!err.empty()) {
throw runtime_error(err); // propagate to server
}

// 🟢 PROFILE RESOLUTION
ProfileRepository repo(
"/home/ishita-tyagi/Desktop/Compiler-Simrun/profiles"
);
// PROFILE RESOLUTION
std::cout << "Current working directory: " << fs::current_path().string() << std::endl;

string profilesPath = "./profiles";
if (!fs::exists(profilesPath)) {
std::cerr << "Profiles directory not found at: " << fs::absolute(profilesPath).string() << std::endl;
throw runtime_error("Profiles directory not found at: " + fs::absolute(profilesPath).string());
}

std::cout << "Profiles directory found at: " << fs::absolute(profilesPath).string() << std::endl;

ProfileRepository repo(profilesPath);
ProfileResolver resolver(repo);
resolver.resolve(ir);

return writeIRToJsonFile(ir, "/tmp/final_ir.json");
return writeIRToJsonFile(ir, "./final_ir.json");
}
Loading