Parametrize with elisp the output files of the project

This commit is contained in:
Alejandro Gallo 2021-08-30 19:04:48 +02:00
parent dae1ad10f9
commit 910c19c510
7 changed files with 58 additions and 11 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.emacs

View File

@ -1,15 +1,17 @@
ATRIP_ROOT := $(PWD)
CONFIG ?= gcc
include etc/config/$(CONFIG).mk
SOURCES_FILE := Sources.mk
include $(SOURCES_FILE)
include ./etc/emacs.mk
include ./etc/config/$(CONFIG).mk
include ./bench/config.mk
EMACS = emacs -q --batch
define tangle
$(EMACS) $(1) --eval "(require 'org)" --eval '(org-babel-tangle)'
endef
MAIN = README.org
SOURCES = $(shell grep -oe ':tangle \+[^ ]\+' $(MAIN) | awk '{print $$2}' | sort -u)
$(SOURCES_FILE): $(MAIN)
echo -n "SOURCES = " > $@
$(EMACS) --eval '(atrip-print-sources)' >> $@
$(SOURCES): $(MAIN)
$(call tangle,$<)

View File

@ -9,8 +9,20 @@ The algorithm uses two main data types, the =Slice= and the
** The slice
#+begin_src c++ :tangle include/Slice.hpp
#+begin_src c++ :tangle (atrip-slice-h)
#pragma once
#include <iostream>
#include <algorithm>
#include <vector>
#include <mpi.h>
#include <atrip/Utils.hpp>
namespace atrip {
using ABCTuple = std::array<size_t, 3>;
using PartialTuple = std::array<size_t, 2>;
struct Slice {
using F = double;
@ -26,7 +38,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds
#+begin_src c++ :tangle include/Slice.hpp
#+begin_src c++ :tangle (atrip-slice-h)
// ASSOCIATED TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
struct Location { size_t rank; size_t source; };
@ -455,7 +467,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds
{}
};
}; // struct Slice
std::ostream& operator<<(std::ostream& out, Slice::Location const& v) {

17
config.el Normal file
View File

@ -0,0 +1,17 @@
(require 'subr-x)
(defun f-join (&rest args)
(string-join args "/"))
(defvar atrip-sources nil)
(defun atrip-print-sources ()
(princ (string-join atrip-sources " ")))
(defmacro atrip-def (name body) `(progn (defun ,name () ,body)
(push (,name) atrip-sources)))
;; atrip variables for the org-mode file
(atrip-def atrip-include-f "include/atrip")
(atrip-def atrip-slice-h (f-join (atrip-include-f) "Slice.hpp"))
(atrip-def atrip-utils-h (f-join (atrip-include-f) "Utils.hpp"))
(atrip-def atrip-main-h "include/atrip.hpp")

View File

@ -2,5 +2,7 @@ include etc/ctf.mk
CXX = mpic++
CXXFLAGS += -I$(ATRIP_ROOT)/include
CXXFLAGS += -I$(CTF_INCLUDE_PATH)
LDFLAGS += -L$(CTF_BUILD_PATH) -lctf

5
etc/emacs.mk Normal file
View File

@ -0,0 +1,5 @@
EMACS = emacs -q --batch --load config.el
define tangle
$(EMACS) $(1) --eval "(require 'org)" --eval '(org-babel-tangle)'
endef

View File

@ -3,7 +3,15 @@
pkgs.mkShell rec {
buildInputs = with pkgs; [
emacs gcc blas
coreutils
git
gcc
blas
openmpi
emacs
];
}