Skip to content

Commit

Permalink
Merge pull request #81 from DemoGo/parallelmap
Browse files Browse the repository at this point in the history
For parallel map implementation CUDA and openMP
  • Loading branch information
rupesh0508 authored Aug 16, 2024
2 parents 17fb75d + f846631 commit aeea083
Show file tree
Hide file tree
Showing 112 changed files with 10,647 additions and 2,636 deletions.
11 changes: 11 additions & 0 deletions Changes_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
lrparser.y : LINE 574 uncomment the line to activate the -o (optimize) option

For fixing the segmentation fault in PageRank_DSL_V2 :-
SymbolTableBuilder.cpp : LINE 375 added a check to see if the forall statement is a for loop or a forall loop
deviceVarsAnalyser.h : getTempVar() LINE 284 removed static cast and used strcpy since it previously generated random characters

added fp_idnode to identifier
analyser/deviceVars/getUsedVars.cpp: LINE 230 fixed fp for sssp
src/symbolutil/SymbolTableBuilder.cpp: LINE 278 added fp node

formal parameters generation:
155 changes: 2 additions & 153 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@


# StarPlat: A Versatile DSL for Graph Analytics

```diff
- Please use WorkingBranch
```

# GraphDSL MPI Backend

### How to compile Generated MPI Codes on Aqua Cluster
Expand Down Expand Up @@ -105,56 +100,10 @@ git clone -b WorkingBranch https://github.com/nibeditabh/GraphDSL.git
cd GraphDSL/src
make
```

# How to Build (Mac OS | Tested on M1)

By default, MacOS comes with the `clang` compiler, which can cause syntax errors when running the `make` command due to differences between `gcc` and `clang` semantics. To resolve this, follow these steps:

## Installation:

1. Install `gcc` using Homebrew:

```sh
brew install gcc
```

2. Check the installation location of the `g++` binaries:

```sh
which brew
ll /opt/homebrew/bin/g++-*
```

3. Create symbolic links to the installed version, (presumes that the above command returns gcc-13):

```sh
sudo ln -sf /opt/homebrew/bin/gcc-13 /usr/local/bin/gcc
sudo ln -sf /opt/homebrew/bin/g++-13 /usr/local/bin/g++
sudo ln -sf /opt/homebrew/bin/c++-13 /usr/local/bin/c++
sudo ln -sf /opt/homebrew/bin/cpp-13 /usr/local/bin/cpp
```

Note: Modifying anything in `/usr/bin/*` is discouraged and may require disabling SIP (System Integrity Protection). Therefore, we create symlinks to `/usr/local/bin/*`.

4. After installation, check the versions:

```sh
g++ --version # Should return clang version
g++-13 --version # Should return (Homebrew GCC)
```

5. Update the Makefile (`StarPlat/src/Makefile`) to use the symlinked `g++`:

```make
CC = /usr/local/bin/g++
```
6. Add `%token return_func` in the file `lrparser.y` (`StarPlat/src/parser/lrparser.y`)


# How to generate
```
# Step 3. Generate files from DSL files.
./StarPlat [-s|-d] -f <dsl.sp> -b [cuda|omp|mpi|acc|sycl]
./StarPlat [-s|-d] -f <dsl.sp> -b [cuda|omp|mpi|acc]
#Example
./StarPlat -s -f ../graphcode/generated_cuda/sssp_dslV2 -b omp
Expand Down Expand Up @@ -188,107 +137,6 @@ pgc++ -std=c++14 ../graphcode/generated_OpenACC/sssp_dslV2.cu -I .. -o ssspAcc.o
```

# Miscellaneous
## Installing Boost Libraries to run StarPlat for MPI

On the root directory of `StarPlat`, running the command:

```sh
grep -r '<boost/' .
```

shows the files that use boost. This section provides a walkthrough of building, installing, and linking the boost libraries and source to create a program. The workflow has been tested on an arm64 architecture with a 64-bit address type on a Mac machine. While this guide is compiled from various sources, for a comprehensive understanding, please refer to the official boost documentation.

Our main goal is to build the following file with `mpic++` and run with `mpirun`:

```c++
#include <iostream>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>

namespace mpi = boost::mpi;

int main() {
mpi::environment env;
mpi::communicator world;
std::cout << "I am process " << world.rank() << " of " << world.size() << "." << std::endl;
return 0;
}
```
The default compiler that comes with MacOS is clang, and StarPlat is built on `gcc`. Note that a C++ library compiled with GCC is not compatible with Clang and vice versa. So, we will build the libraries and code exclusively on one platform.
There are options to compile boost as a universal library agnostic to architecture (discussed [here](https://stackoverflow.com/questions/64553398/compile-boost-as-universal-library-intel-and-apple-silicon-architectures)), but for brevity, this walkthrough aims to run it on gcc/g++.
We will be building the boost library from the source, providing more autonomy and control over packages and libraries, and installation directories from where we can include headers and link libraries.
- **Step 1**: Download the tar file from boost/downloads.
- **Step 2**: Extract the tar file to a location using the command `tar -xvf boost.tar.gz`.
- **Step 3**: Create a directory anywhere with `mkdir -p /path/to/boost_version`.
- **Step 4**: Navigate to the extracted boost directory.
- **Step 5**: Run `./bootstrap.sh --prefix=/path/to/boost_version` to extract all the headers and binaries in the specified prefix location.
- **Step 6**: The bootstrap.sh will create a file called `project-config.jam`.
- **Step 7**: In the `project-config.jam` file, comment out the section related to the compiler configuration.
```jam
# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
# if ! clang in [ feature.values <toolset> ]
# {
# using clang ;
# }
# project : default-build <toolset>clang ;
```

- **Step 8**: Configure the project-config.jam to use gcc.

```jam
using gcc : <version> : /path/to/gcc
# Example
using gcc : 13.2 : /usr/local/bin/gcc
```

- **Step 9**: Install MPI by following the steps [here](https://docs.open-mpi.org/en/v5.0.x/installing-open-mpi/quickstart.html).
- **Step 10**: Add the following line to the `project-config.jam` file (notice the space between mpi and ;).

```jam
using mpi ;
```

- **Step 11**: Run the command `./b2 cxxflags=-std=c++17 install` to build boost with the standard library of choice and install it. If you encounter permission denied errors, use `sudo` before the command.

- **Step 12**: If your editor's autocomplete looks for environment variables for autocompletion and code completion, run:

```sh
export DYLD_LIBRARY_PATH=/path/to/boost/lib/:$DYLD_LIBRARY_PATH
```

- **Step 13**: Copy the following content:

```c++
#include <iostream>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>

namespace mpi = boost::mpi;

int main() {
mpi::environment env;
mpi::communicator world;
std::cout << "I am process " << world.rank() << " of " << world.size() << "." << std::endl;
return 0;
}
```
```sh
OMPI_CXX=g++ mpic++ -I/Users/durwasa/boost/include -L/Users/durwasa/boost/lib helloworld.cpp -o helloworld -lboost_mpi
```

The `OMPI_CXX` sets the environment variable to `gcc` instead of `clang` (since `mpic++` has been installed using Homebrew/MacPorts). `-I` includes the header files, `-L` links the library, and `-lboost_mpi` links the boost.mpi, which we configured using our .jam file.

- **Step 14**: Run the command `OMPI_CXX=g++ mpirun helloworld`. If the default compiler in the system is `gcc`, omit the `OMPI_CXX` flag. `mpicxx` and other variants are technically compiler wrappers that translate the compiler commands and inject flags into it. Using the `OMPI_CXX` flag specifies which C++ compiler it should use while injecting the flags. Learn more about compiler wrappers [here](https://www.ibm.com/docs/en/smpi/10.2?topic=administering-compiling-applications).

Graph DSL for basic graph algorithms
- Phase1 (static) **SSSP, BC, PR, and TC**
Expand All @@ -297,6 +145,7 @@ Graph DSL for basic graph algorithms
```
This project is funded by India's National Supercomputing Mission, whose timely funding and regular reviews are greatly appreciated.
```

## Licensing
The StarPlat codebase is made available for academic and non-commercial use.
Commercial use of the code needs licensing. The interested may contact rupesh@cse.iitm.ac.in.
22 changes: 22 additions & 0 deletions TACode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>
#include<Symbol.h>

using namespace std;

class TACode
{
string opCode;
string target;
Symbol* destination;
Symbol* operand1;
Symbol* operand2;


TACode()
{
operand1=NULL;
operand2=NULL;
destination=NULL;
}

};
51 changes: 51 additions & 0 deletions comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

"""
How to run : python name_of_python_script <filename1> <filename2>
Output : Count of non-matching rows in both files
"""


import sys

#first file name
file = sys.argv[1]
#second file name
file1 = sys.argv[2]
f=open(file,"r")
f1=open(file1,"r")
lines=f.readlines()
lines1=f1.readlines()
#print(lines);
result=[]
result1=[]
for x in lines:
result.append(x.split(" ")[1])

f.close()

#print(result)

for x in lines1:
result1.append(x.split(" ")[1])

f1.close()
#print(result1)

new = []
for sub in result:
new.append(sub.replace("\n", ""))
#print(new)


new1 = []
for sub in result1:
new1.append(sub.replace("\n", ""))
#print(new1)
count=0;

for i in range(len(result)):
if abs(round(float(result[i]),3) - round(float((result1[i])),3)) > 0.000001:
count = count+1

print(count)

Loading

0 comments on commit aeea083

Please sign in to comment.