Skip to content

Commit

Permalink
Mvp (#2)
Browse files Browse the repository at this point in the history
* comments added and mvp created

* nlohmann added

* nlohmann added

* index shown

* importInput created

* Moving the share making to frontend

* We dont need to move the share making to frontend

* Experimenting Dual com

* RES TAG deleted

* Removed unnecessary comments

* Dual communication worked

* dual specific file removed due to duplicacy

* Join table created (with hacky index)

* Join table created (with hacky index)

* Any # of match works (# of cols is limited to 2 for now)

* Split the input

* Split the input

* Produce output

* modified var name for send/receive indexes

* More than 1 vals dynamically accomodated

* Cmke modified so it works

* Docker File Created

* Cmakelist slim down

* docker file modified

* docker file modified

* docker file modified

* docker file modified

* gitignore restored

* github action added
  • Loading branch information
Snafkin547 authored Aug 7, 2024
1 parent 394ff72 commit 93f3846
Show file tree
Hide file tree
Showing 61 changed files with 25,341 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 200
48 changes: 48 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Image CI

on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,pattern=main
type=semver,pattern={{version}}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ build
src/external-lib/*
!src/external-lib/CMakeLists.txt


deployment/results
deployment/results
43 changes: 29 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CMAKE_CXX_FLAGS "-O3")

# Adding Dependencies
add_subdirectory(include/external-lib/sql-parser)
add_subdirectory(include/external-lib/nlohmann)

# Adding MPI Library
find_package(MPI REQUIRED)
Expand All @@ -24,31 +25,45 @@ pkg_check_modules(_LIBSODIUM REQUIRED libsodium)
find_path(SODIUM_INCLUDE_DIR sodium.h HINTS ${LIBSODIUM_INCLUDE_DIRS} /usr/local/include /opt/local/include /opt/include)
find_library(SODIUM_LIBRARY NAMES sodium HINTS ${LIBSODIUM_LIBRARY_DIRS} /usr/local/lib /opt/local/lib /opt/lib)

# Include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib/nlohmann)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib/sql-parser/src)

# SecrecyLib
file(GLOB Secrecy_SOURCES src/core/*.cpp src/core/wrappers/*.cpp src/common/*.cpp src/benchmarking/*.cpp src/planner/*.cpp)
# add_library(SecrecyLib INTERFACE ${Secrecy_SOURCES})
# target_link_libraries(SecrecyLib INTERFACE ${MPI_LIBRARIES} ${SODIUM_LIBRARY})
# target_include_directories(SecrecyLib INTERFACE ${SODIUM_INCLUDE_DIR})

set(TEST_FILE src/tests/c_api/test_join_sail.cpp)
# Define the executable using only the specified test file
get_filename_component(fileName ${TEST_FILE} NAME_WLE)
# Add the executable and link the necessary libraries
add_executable(${fileName} ${TEST_FILE} ${Secrecy_SOURCES})
target_link_libraries(${fileName} PUBLIC ${MPI_LIBRARIES} ${SODIUM_LIBRARY} nlohmann_json src)
target_include_directories(${fileName} PUBLIC ${SODIUM_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib/nlohmann)

# TODO: factor out building all files with each executable.
# Adding testing executables
# src/tests/api/*.cpp
file(GLOB TEST_EXECUTABLES src/tests/c_api/*.cpp src/tests/codegen/*.cpp)
foreach (_target ${TEST_EXECUTABLES})
get_filename_component(fileName ${_target} NAME_WLE)
add_executable(${fileName} ${_target} ${Secrecy_SOURCES})
target_link_libraries(${fileName} PUBLIC ${MPI_LIBRARIES} ${SODIUM_LIBRARY} src)
target_include_directories(${fileName} PUBLIC ${SODIUM_INCLUDE_DIR})
endforeach ()
# file(GLOB TEST_EXECUTABLES src/tests/c_api/*.cpp src/tests/codegen/*.cpp)
# foreach (_target ${TEST_EXECUTABLES})
# get_filename_component(fileName ${_target} NAME_WLE)
# add_executable(${fileName} ${_target} ${Secrecy_SOURCES})
# target_link_libraries(${fileName} PUBLIC ${MPI_LIBRARIES} ${SODIUM_LIBRARY} nlohmann_json src)
# target_include_directories(${fileName} PUBLIC ${SODIUM_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib/nlohmann)
# endforeach ()

# Adding experiments executables
file(GLOB TEST_EXECUTABLES src/experiments/*.cpp)
foreach (_target ${TEST_EXECUTABLES})
get_filename_component(fileName ${_target} NAME_WLE)
add_executable(${fileName} ${_target} ${Secrecy_SOURCES} include/planner/operators/table_function.h)
target_link_libraries(${fileName} PUBLIC ${MPI_LIBRARIES} ${SODIUM_LIBRARY} src)
target_include_directories(${fileName} PUBLIC ${SODIUM_INCLUDE_DIR})
endforeach ()
# file(GLOB TEST_EXECUTABLES src/experiments/*.cpp)
# foreach (_target ${TEST_EXECUTABLES})
# get_filename_component(fileName ${_target} NAME_WLE)
# add_executable(${fileName} ${_target} ${Secrecy_SOURCES} include/planner/operators/table_function.h)
# target_link_libraries(${fileName} PUBLIC ${MPI_LIBRARIES} ${SODIUM_LIBRARY} nlohmann_json src)
# target_include_directories(${fileName} PUBLIC ${SODIUM_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib ${CMAKE_CURRENT_SOURCE_DIR}/include/external-lib/nlohmann)
# endforeach ()

# Add Planner
#add_executable(planner src/tests/codegen/planner.cpp ${Secrecy_SOURCES} src/planner/dpTable.cpp src/planner/sql_expression.cpp src/planner/rule.cpp src/planner/codeGen.cpp)
Expand Down
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Use an official Ubuntu as a base image
FROM ubuntu:22.04

# Install necessary packages
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libsodium-dev \
libopenmpi-dev \
openmpi-bin \
pkg-config \
git \
openssh-server \
&& rm -rf /var/lib/apt/lists/*

# Create the SSH directory and set up the server
RUN mkdir /var/run/sshd
RUN echo 'root:password' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# Generate SSH keys and configure known hosts
RUN mkdir -p /root/.ssh && ssh-keygen -t rsa -b 2048 -f /root/.ssh/id_rsa -q -N "" && \
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys && \
echo "Host *" >> /root/.ssh/config && \
echo " StrictHostKeyChecking no" >> /root/.ssh/config

# Set the working directory
WORKDIR /usr/src/app

# Clone the main Secrecy repository
RUN git clone https://github.com/Snafkin547/Secrecy.git && \
cd Secrecy && \
git checkout bdbaf17e72f05bebaeab6a27506d82a03c4e59ec

# Create include/external-lib directory and clone the sql-parser repository inside it
RUN mkdir -p Secrecy/include/external-lib \
&& git clone https://github.com/mfaisal97/sql-parser.git Secrecy/include/external-lib/sql-parser

# Set the working directory to Secrecy
WORKDIR /usr/src/app/Secrecy

# Create build directory and run CMake
RUN mkdir build && cd build && cmake .. && make

# Allowing to run as a root
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
ENV OMPI_MCA_routed=direct

# Allow SSH service to run in the background
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.8'

services:
secrecy-node1:
image: hicsail/secrecy-app:latest
hostname: secrecy-node1
networks:
- mpi-network

secrecy-node2:
image: hicsail/secrecy-app:latest
hostname: secrecy-node2
networks:
- mpi-network

secrecy-node3:
image: hicsail/secrecy-app:latest
hostname: secrecy-node3
networks:
- mpi-network

networks:
mpi-network:
driver: bridge
7 changes: 7 additions & 0 deletions include/external-lib/nlohmann/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CMakeLists.txt in include/external-lib/nlohmann
cmake_minimum_required(VERSION 3.15)

project(nlohmann_json LANGUAGES CXX)

add_library(nlohmann_json INTERFACE)
target_include_directories(nlohmann_json INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
55 changes: 55 additions & 0 deletions include/external-lib/nlohmann/adl_serializer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT

#pragma once

#include <utility>

#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/meta/identity_tag.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN

/// @sa https://json.nlohmann.me/api/adl_serializer/
template<typename ValueType, typename>
struct adl_serializer
{
/// @brief convert a JSON value to any value type
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
{
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
}

/// @brief convert a JSON value to any value type
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
{
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
}

/// @brief convert any value type to a JSON value
/// @sa https://json.nlohmann.me/api/adl_serializer/to_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
{
::nlohmann::to_json(j, std::forward<TargetType>(val));
}
};

NLOHMANN_JSON_NAMESPACE_END
103 changes: 103 additions & 0 deletions include/external-lib/nlohmann/byte_container_with_subtype.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT

#pragma once

#include <cstdint> // uint8_t, uint64_t
#include <tuple> // tie
#include <utility> // move

#include <nlohmann/detail/abi_macros.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN

/// @brief an internal type for a backed binary type
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
{
public:
using container_type = BinaryType;
using subtype_type = std::uint64_t;

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype() noexcept(noexcept(container_type()))
: container_type()
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b)))
: container_type(b)
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
: container_type(std::move(b))
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
: container_type(b)
, m_subtype(subtype_)
, m_has_subtype(true)
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
: container_type(std::move(b))
, m_subtype(subtype_)
, m_has_subtype(true)
{}

bool operator==(const byte_container_with_subtype& rhs) const
{
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
}

bool operator!=(const byte_container_with_subtype& rhs) const
{
return !(rhs == *this);
}

/// @brief sets the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/
void set_subtype(subtype_type subtype_) noexcept
{
m_subtype = subtype_;
m_has_subtype = true;
}

/// @brief return the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype/
constexpr subtype_type subtype() const noexcept
{
return m_has_subtype ? m_subtype : static_cast<subtype_type>(-1);
}

/// @brief return whether the value has a subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/has_subtype/
constexpr bool has_subtype() const noexcept
{
return m_has_subtype;
}

/// @brief clears the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/
void clear_subtype() noexcept
{
m_subtype = 0;
m_has_subtype = false;
}

private:
subtype_type m_subtype = 0;
bool m_has_subtype = false;
};

NLOHMANN_JSON_NAMESPACE_END
Loading

0 comments on commit 93f3846

Please sign in to comment.