Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add socket mode compatibility #232

Merged
merged 14 commits into from
Nov 19, 2024
Merged
2 changes: 1 addition & 1 deletion .conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo Compiling sparc using ${CPU_COUNT} cores

cd ./src
make clean
make -j ${CPU_COUNT} USE_MKL=0 USE_SCALAPACK=1
make -j ${CPU_COUNT} USE_MKL=0 USE_SCALAPACK=1 USE_FFTW=1 USE_SOCKET=1 DEBUG_MODE=1

# ls -al lib
echo "Installing sparc into $PREFIX/bin"
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ jobs:
unset LD_LIBRARY_PATH
python -c "import os, re; match = re.findall(r'Tests failed: (\d+)', open('output').read()); [print('All pass'), os._exit(0)] if int(match[0]) == 0 else [print('Failed'), os._exit(1)]"
rm -rf output
- name: Test socket compatibility
run: |
mpirun -n 1 sparc | tee command-socket.out || true
# Output from the sparc test command
# should contain the -socket subcommand (use regex)
grep "\\-socket" command-socket.out


11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
-Date
-Name
-changes
--------------
Nov 18, 2024
Name: Tian Tian, Lucas Timmerman
Changes: (initialization.c, initialization.h, electronicGroundState.c,
include/isddft.h, main.c, main_socket.c, makefile, md.c, relax.c,
socket/*.h, socket/*.c, tests/Socket/*, CI workflow, doc)
1. Add socket communication layer and socket submodule
2. Unifying MLFF and DFT single point calculations to Calculate_Properties function
3. Update CI workflow for compiling socket code
4. Update socket mode simple tests
5. Update documentation for socket mode

--------------
Nov 13, 2024
Expand Down
215 changes: 215 additions & 0 deletions doc/.LaTeX/Socket.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks,c]{} \label{Socket}

\begin{center}
\Huge \textbf{Socket communication in SPARC}
\end{center}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\textbf{Brief introduction}} \label{SOCKET_INTRO}

The socket communication layer allows SPARC to be controlled by a socket server that is compatible with
\href{https://ipi-code.org/i-pi/introduction.html}{i-PI} protocol. The SPARC source code should be compiled with the
\texttt{USE\_SOCKET=1} option.

To start a SPARC program with socket interface, use either option:
\begin{itemize}
\item Option 1: Specify socket address in command line
\begin{itemize}
\item To start an INET socket, use\\
\texttt{\$ mpirun -n 8 ./lib/sparc -socket localhost:12345 -name filename}

\item To start a UNIX socket, use\\
\texttt{\$ mpirun -n 8 ./lib/sparc -socket /tmp/sparc.socket:unix -name filename}
\end{itemize}

\item Option 2: Provide \texttt{.inpt} parameters

Visit the following pages for parameter specifications.
Any parameter \texttt{SPARC\_*} in the \texttt{.inpt} file
will overwrite the settings from command line.
\end{itemize}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\textbf{Output files}} \label{SOCKET_OUTPUT}

The following files will be generated in the socket mode and may slightly
differ from standard SPARC outputs:
\begin{itemize}
\item \texttt{.out}: All the SCF steps will be written to \texttt{.out} file, similar to a relaxation / MD calculation.
\item \texttt{.static}: It is concatenated from all single point
steps. In addition to normal \texttt{.static} output, the lattice
information are also recorded.
\end{itemize}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{SOCKET\_FLAG}} \label{SOCKET_FLAG}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
0
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{SOCKET\_FLAG}: 1
\end{block}
\end{columns}

\begin{block}{Description}
Flag for starting the socket communication layer. It is equivalent to the \texttt{-socket} switch of command line.

Setting \texttt{SOCKET\_FLAG: 1} will disable \texttt{MD\_FLAG} and \texttt{RELAX\_FLAG}.

\end{block}


\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{SOCKET\_HOST}} \label{SOCKET_HOST}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
String
\end{block}

\begin{block}{Default}
localhost
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{SOCKET\_HOST}: 127.0.0.1
\end{block}
\end{columns}

\begin{block}{Description}
Host name of the socket address that SPARC listens to. If it's an
INET socket, it is the address of the interface. For a UNIX socket,
it is the filename of the socket file
(e.g. \texttt{/tmp/sparc.socket}).
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{SOCKET\_PORT}} \label{SOCKET_PORT}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
None
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{SOCKET\_PORT}: 12345
\end{block}
\end{columns}

\begin{block}{Description}
When SPARC connects to an INET socket server, it is the port number. The \texttt{SOCKET\_PORT} has no effect for a UNIX socket.
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{SOCKET\_INET}} \label{SOCKET_INET}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
None
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{SOCKET\_INET}: 0
\end{block}
\end{columns}

\begin{block}{Description}
1 for INET socket, 0 for UNIX socket. If no set in \texttt{.inpt}
file, its value is determined by the \texttt{-socket address:port}
command line switch.
\end{block}

\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[allowframebreaks]{\texttt{SOCKET\_MAX\_NITER}} \label{SOCKET_MAX_NITER}
\vspace*{-12pt}
\begin{columns}
\column{0.4\linewidth}
\begin{block}{Type}
Integer
\end{block}

\begin{block}{Default}
10000
\end{block}

\column{0.4\linewidth}
\begin{block}{Unit}
No unit
\end{block}

\begin{block}{Example}
\texttt{SOCKET\_MAX\_NITER}: 10000
\end{block}
\end{columns}

\begin{block}{Description}
Maximum number of ionic SCF steps in the socket mode. As a socket
client, SPARC will terminate after \texttt{SOCKET\_MAX\_NITER} steps
are called.
\end{block}


\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 changes: 73 additions & 0 deletions doc/.LaTeX/mlff/Manual_mlff.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
\documentclass[xcolor=dvipsnames,t]{beamer}
%\usepackage[utf8]{inputenc}
\usepackage{verbatim} % for comment
\usetheme{Madrid}
\usecolortheme{seahorse}
\usepackage{beamerouterthemesplit}
\usepackage[T1]{fontenc}

\setbeamerfont{institute}{size=\normalsize}

\title[] {SPARC - MLFF \\ {\normalsize Machine-learned force fields} \\ {\small User guide}}
%\author{}
%\author{Qimen Xu, Abhiraj Sharma, Phanish Suryanarayana, }

\institute[]
{
Material Physics \& Mechanics Group \\
PI: Phanish Suryanarayana \\
%Main Developers: Shashikant Kumar, Abhiraj Sharma\\
%Collaborators: J.E. Pask (LLNL)\\
Georgia Institute of Technology \\
\hyperlink{Contributors}{Contributors}\\
\hyperlink{Citation}{Citation} \\
\hyperlink{Acknowledgements}{Acknowledgements}
}

\date{}
\setbeamertemplate{frametitle continuation}{}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{block title}{bg=Apricot!50,fg=black}
%\addtobeamertemplate{block begin}{\vskip -\smallskipamount}{}
%\addtobeamertemplate{block end}{}{\vskip -\smallskipamount}
\addtobeamertemplate{block begin}{\vspace*{-0.6pt}}{}
\addtobeamertemplate{block end}{}{\vspace*{-0.6pt}}
\hypersetup{colorlinks,
citecolor=violet,
linkcolor=blue,
menucolor=white,
anchorcolor=yellow
filecolor=pink,
}


\setbeamertemplate{footline}{
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=1ex,dp=1.5ex,leftskip=2ex,rightskip=2ex]{page footer}%
\usebeamerfont{title in head/foot}%
\insertshorttitle \hfill
\insertsection \hfill
\insertframenumber{} / \inserttotalframenumber
\end{beamercolorbox}}%
}

\let\otp\titlepage
\renewcommand{\titlepage}{\otp\addtocounter{framenumber}{-1}}


%\includeonly{Introduction,Stress,MD,Optimization,Print}
%\includeonly{Introduction}

\begin{document}

%\frame{\titlepage}

\begin{frame}[plain]
\titlepage
\end{frame}

\include{Introduction}
\include{mlff}


\end{document}
Loading