Skip to content

Commit

Permalink
Merge pull request #1 from JDTruj2018/first-commit
Browse files Browse the repository at this point in the history
First commit - migration from gitlab
  • Loading branch information
gshipman committed Dec 21, 2022
2 parents 3f4b94b + 1eecb44 commit 79e4e98
Show file tree
Hide file tree
Showing 64 changed files with 9,762 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Custom
*~
build*/
debug*/
scripts/
compile_commands.json
.clangd/
shm_malloc/*.o
shm_malloc/*.a
shm_malloc/tanon
shm_malloc/tshm1
shm_malloc/tshm1db
shm_malloc/tshm2
shm_malloc/tshm2db

# Prerequisites
*.d

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/argtable3"]
path = external/argtable3
url = https://github.com/argtable/argtable3.git
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.10)
project(memory-accelerator C)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_subdirectory(src)

add_compile_options(-Wall -Wextra -pedantic -Wno-unused-function -Wno-strict-prototypes -g)

# JL: Can't use STREQUAL here because the compiler ID could be "IntelLLVM"
if (CMAKE_C_COMPILER_ID MATCHES "Intel")
add_compile_options(-mavx512f -Wno-debug-disables-optimization)
else()
add_compile_options(-g)
endif()

set(CMAKE_C_STANDARD 11)

include_directories(include)
include_directories(include/controller)
include_directories(include/client)
include_directories(include/posix)
include_directories(include/shared)
include_directories(include/uthash)

add_executable(client client.c ${CLIENT_SOURCE_FILES} ${SHARED_SOURCE_FILES})
target_link_libraries(client shm pthread rt)

add_executable(controller controller.c ${CONTROLLER_SOURCE_FILES} ${SHARED_SOURCE_FILES})
target_link_libraries(controller shm pthread rt)


find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()

if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/argtable3/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()

add_subdirectory(external/argtable3)
include_directories(external/argtable3/src)

add_subdirectory(tests)
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# ScorIA

## Description
Prototype testbed for various memory acceleration schemes focused on improving sparse memory accesses and scatter/gather performance through indirection arrays.

## Installation
```
mkdir build
cd build
cmake ..
make
```

## Usage
Terminal window 1
```
./controller
```

Terminal window 2
```
./tests/test_client
```

## Roadmap
Current Work:
- [x] Request Ring Buffer
- [x] Controller Request Handler
- [x] Develop Initial Test Cases
- [x] Implement Read, Write
- [x] Asynchronous Requests
- [x] Atomic, Serialized, and Parallel Writes (Aliasing)
- [x] Multi-threading
- [x] Multi-client
- [x] Integration with Spatter

Future:
- [ ] AVX intrinsics
- [ ] SVE intrinsics
- [ ] Read/Write Dependency Graphs
- [ ] Run and Test scripts

Initial Requirements:
- [x] Multi-Process (Separation between client and server)
- [x] Server is the memory controller
- [x] Memory controller needs to be multi-threaded
- [x] Needs to be able to use vector load store (for optimized bandwidth)
- [x] Needs an API for taking memory access requests
- [x] Needs to run on CPU hardware
- [ ] Needs to be numa aware
- [ ] Start prototyping on SPR (DDR)
- [x] Define some test program for driving this
- [x] allocaate A[], B[], C[]
- [x] fetch (A[B[C[i]]] for i = 0:1000
- [x] D[1000]
- [x] Determine what we will use for programming language (C)
- [x] FPGA friendly
- [ ] Modular SGDMA
- [x] Determine the shared memory programming paradigm
- [x] Specialized memory allocator
- [x] Everything in shared memory
- [x] A, B, and C need to be allocated in shared memory (shared between the two process spaces)
- [x] These should probably be allocated at the same virtual address locations
- [ ] Synchronous vs. Asynchronous
- [x] MPI_IReceive and MPI_Wait as inspiration
- [x] Handles of some sort
- [x] Could also just be an update of the latest fetched index (in a prefetching workload) in a well-known mailbox

## Authors and acknowledgment
- Jered Dominguez-Trujillo jereddt@lanl.gov
- Jonas Lippuner jlippuner@lanl.gov
26 changes: 26 additions & 0 deletions client.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>

#include "client.h"
#include "config.h"

#include "client_cleanup.h"
#include "client_init.h"
#include "client_place_requests.h"

int main(int argc, char **argv) {
// Suppress Compiler Warnings
(void)argc;
(void)argv;

struct client client;
client.chatty = 0;

init(&client);
place_requests(&client);

cleanup(&client);

printf("Exiting...\n");

return 0;
}
26 changes: 26 additions & 0 deletions controller.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>

#include "config.h"
#include "controller.h"

#include "controller_cleanup.h"
#include "controller_handle_requests.h"
#include "controller_init.h"

int main(int argc, char **argv) {
// Suppress Compiler Warnings
(void)argc;
(void)argv;

struct controller controller;
controller.chatty = 1;

init(&controller);
handle_requests(&controller);

cleanup(&controller);

printf("Exiting...\n");

return 0;
}
1 change: 1 addition & 0 deletions external/argtable3
Submodule argtable3 added at f46ef2
30 changes: 30 additions & 0 deletions include/client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CLIENT_H
#define CLIENT_H

#include <semaphore.h>

#include "config.h"
#include "request.h"

struct client {
int id;

int fd_location;
int fd_requests;
int fd_completions;

int chatty;

struct memory_location *shared_location;

struct request_queue_list *shared_requests_list;
struct request_queue_list *shared_completions_list;
struct shared_memory *shared_mem_ptr;

struct request_queue *shared_requests;
struct request_queue *shared_completions;

struct request *unmatched_requests;
};

#endif /* CLIENT_H */
10 changes: 10 additions & 0 deletions include/client/client_cleanup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef CLIENT_CLEANUP
#define CLIENT_CLEANUP

#include "client.h"

void cleanup_queues(struct client *client);
void cleanup_shared_mem(struct client *client);
void cleanup(struct client *client);

#endif /* CLIENT_CLEANUP */
13 changes: 13 additions & 0 deletions include/client/client_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef CLIENT_INIT
#define CLIENT_INIT

#include "client.h"
#include "request.h"

void init_memory_pool(struct client *client);
void init_requests(struct client *client);
void init_completions(struct client *client);
void init_id(struct client *client);
void init(struct client *client);

#endif /* CLIENT_INIT */
19 changes: 19 additions & 0 deletions include/client/client_memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef CLIENT_MEMORY_H
#define CLIENT_MEMORY_H

#include <semaphore.h>

#include "client.h"
#include "request.h"

void scoria_put_request(struct client *client, struct request *req);

void scoria_quit(struct client *client, struct request *req);
void scoria_read(struct client *client, void *buffer, const size_t N,
void *output, const size_t *ind1, const size_t *ind2,
size_t num_threads, bool use_avx, struct request *req);
void scoria_write(struct client *client, void *buffer, const size_t N,
void *input, const size_t *ind1, const size_t *ind2,
size_t num_threads, bool use_avx, struct request *req);

#endif /* CLIENT_MEMORY_H */
12 changes: 12 additions & 0 deletions include/client/client_place_requests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef CLIENT_PLACE_REQUESTS
#define CLIENT_PLACE_REQUESTS

#include "client.h"
#include "request.h"

void wait_request(struct client *client, struct request *req);
void wait_requests(struct client *client, struct request *reqs,
size_t num_reqs);
void place_requests(struct client *client);

#endif /* CLIENT_PLACE_REQUESTS */
8 changes: 8 additions & 0 deletions include/client/client_read_location.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CLIENT_READ_LOCATION
#define CLIENT_READ_LOCATION

#include "client.h"

void read_location(struct client *client);

#endif /* CLIENT_READ_LOCATION */
30 changes: 30 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CONFIG_H
#define CONFIG_H

#define SHARED_MEMORY_NAME "shared-mem"
#define SHARED_LOCATION_NAME "/mem-controller-location"
#define SHARED_REQUESTS_NAME "/mem-request-queue"
#define SHARED_COMPLETIONS_NAME "/mem-completion-queue"

#define REQUEST_QUEUE_SIZE 100
#define MAX_CLIENTS 64

struct list {
struct list *next;
int data;
};

struct shared_memory {
struct list *head;
struct list **tail;
};

struct memory_location {
int ready;

struct shared_memory *shared_mem_ptr;
struct request_queue_list *shared_requests_list;
struct request_queue_list *shared_completions_list;
};

#endif /* CONFIG_H */
23 changes: 23 additions & 0 deletions include/controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef CONTROLLER_H
#define CONTROLLER_H

#include <semaphore.h>

#include "config.h"
#include "request.h"

struct controller {
int fd_location;
int fd_requests;
int fd_completions;

int chatty;

struct memory_location *shared_location;

struct request_queue_list *shared_requests_list;
struct request_queue_list *shared_completions_list;
struct shared_memory *shared_mem_ptr;
};

#endif /* CONTROLLER_H */
9 changes: 9 additions & 0 deletions include/controller/controller_cleanup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef CONTROLLER_CLEANUP
#define CONTROLLER_CLEANUP

#include "controller.h"

void cleanup_shared_mem(struct controller *controller);
void cleanup(struct controller *controller);

#endif /* CONTROLLER_CLEANUP */
20 changes: 20 additions & 0 deletions include/controller/controller_handle_requests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef CONTROLLER_HANDLE_REQUESTS
#define CONTROLLER_HANDLE_REQUESTS

#include "controller.h"
#include "request.h"

struct thread_args {
size_t i;
struct controller *controller;
};

void handle_read(struct controller *controller, struct request_queue *queue,
struct request *req);
void handle_write(struct controller *controller, struct request_queue *queue,
struct request *req);

void *handler(void *args);
void handle_requests(struct controller *controller);

#endif /* CONTROLLER_HANDLE_REQUESTS */
Loading

0 comments on commit 79e4e98

Please sign in to comment.