[Polly] Remove the PoCC and ScopLib support

Remove the PoCC and ScopLib support from Polly as we do not have a
  user/maintainer for it.

Differential Revision: http://reviews.llvm.org/D4871

llvm-svn: 215563
This commit is contained in:
Johannes Doerfert
2014-08-13 17:49:16 +00:00
parent c7826524ac
commit 5aa2194ea5
19 changed files with 28 additions and 1532 deletions

View File

@@ -111,14 +111,6 @@ if (POLLY_ENABLE_GPGPU_CODEGEN)
set(GPU_CODEGEN TRUE)
endif(POLLY_ENABLE_GPGPU_CODEGEN)
option(POLLY_ENABLE_SCOPLIB "Enable SCoPLib library for scop import/export" ON)
if (POLLY_ENABLE_SCOPLIB)
FIND_PACKAGE(SCoPLib)
if(SCOPLIB_FOUND)
set(POLLY_LINK_LIBS ${POLLY_LINK_LIBS} ${SCOPLIB_LIBRARY})
endif(SCOPLIB_FOUND)
endif(POLLY_ENABLE_SCOPLIB)
if (CLOOG_FOUND)
INCLUDE_DIRECTORIES( ${CLOOG_INCLUDE_DIR} )
endif(CLOOG_FOUND)
@@ -135,11 +127,6 @@ if (CUDALIB_FOUND)
INCLUDE_DIRECTORIES( ${CUDALIB_INCLUDE_DIR} )
endif(CUDALIB_FOUND)
if (SCOPLIB_FOUND)
INCLUDE_DIRECTORIES( ${SCOPLIB_INCLUDE_DIR} )
endif(SCOPLIB_FOUND)
include_directories(
BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/include

View File

@@ -30,16 +30,12 @@ POLLY_CXXFLAGS += "-fno-rtti -fno-exceptions"
PLUTO_FOUND := @pluto_found@
CLOOG_FOUND := @cloog_found@
SCOPLIB_FOUND := @scoplib_found@
CUDALIB_FOUND := @cuda_found@
# Set include directroys
POLLY_INC := @gmp_inc@ @isl_inc@ \
@cloog_inc@ @scoplib_inc@ @cuda_inc@\
@pluto_inc@ -I$(POLLY_SRC_ROOT)/lib/JSON/include
POLLY_INC := @gmp_inc@ @isl_inc@ @cloog_inc@ @cuda_inc@\
@pluto_inc@ -I$(POLLY_SRC_ROOT)/lib/JSON/include
POLLY_LD := @gmp_ld@ @isl_ld@ @cloog_ld@ @scoplib_ld@ \
@scoplib_rpath@ @cuda_ld@ @pluto_ld@
POLLY_LD := @gmp_ld@ @isl_ld@ @cloog_ld@ @cuda_ld@ @pluto_ld@
POLLY_LIB := @gmp_lib@ @isl_lib@ @cloog_lib@ @scoplib_lib@ \
@cuda_lib@ @pluto_lib@
POLLY_LIB := @gmp_lib@ @isl_lib@ @cloog_lib@ @cuda_lib@ @pluto_lib@

View File

@@ -99,19 +99,6 @@ CXXFLAGS=$saved_CXXFLAGS
AS_IF([test "x$pluto_found" = "xyes"],
[AC_DEFINE([PLUTO_FOUND],[1],[Define if pluto found])])
dnl Check that we have scoplib.
find_lib_and_headers([scoplib], [scoplib/scop.h], [scoplib])
AS_IF([test "x$scoplib_found" = "xyes"],
[AC_DEFINE([SCOPLIB_FOUND],[1],[Define if scoplib found])])
if test "x$scoplib_found" = "xyes"; then :
scoplib_rpath="-Wl,-rpath=$given_lib_path"
else
scoplib_rpath=""
fi
AC_SUBST(scoplib_rpath)
dnl Check if CUDA lib there
dnl Disable the build of polly, even if it is checked out into tools/polly.
AC_ARG_ENABLE(polly_gpu_codegen,

View File

@@ -1,19 +0,0 @@
FIND_PATH(SCOPLIB_INCLUDE_DIR scoplib/scop.h)
FIND_LIBRARY(SCOPLIB_LIBRARY NAMES scoplib)
IF (SCOPLIB_INCLUDE_DIR AND SCOPLIB_LIBRARY)
SET(SCOPLIB_FOUND TRUE)
ENDIF (SCOPLIB_INCLUDE_DIR AND SCOPLIB_LIBRARY)
IF (SCOPLIB_FOUND)
IF (NOT Isl_FIND_QUIETLY)
MESSAGE(STATUS "Found SCoPLib: ${SCOPLIB_LIBRARY}")
ENDIF (NOT Isl_FIND_QUIETLY)
ELSE (SCOPLIB_FOUND)
IF (Isl_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find SCoPLib")
ENDIF (Isl_FIND_REQUIRED)
ENDIF (SCOPLIB_FOUND)

89
polly/configure vendored
View File

@@ -591,11 +591,6 @@ cuda_ld
cuda_lib
cuda_inc
cuda_found
scoplib_rpath
scoplib_ld
scoplib_lib
scoplib_inc
scoplib_found
pluto_ld
pluto_lib
pluto_inc
@@ -668,7 +663,6 @@ with_gmp
with_isl
with_cloog
with_pluto
with_scoplib
enable_polly_gpu_codegen
with_cuda
'
@@ -1302,7 +1296,6 @@ Optional Packages:
--with-isl prefix of isl
--with-cloog prefix of cloog
--with-pluto prefix of pluto
--with-scoplib prefix of scoplib
--with-cuda prefix of cuda
Some influential environment variables:
@@ -2773,88 +2766,6 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
OLD_LDFLAGS=$LDFLAGS;
OLD_LIBS=$LIBS;
LIBS="$LIBS -lscoplib";
# Get include path and lib path
# Check whether --with-scoplib was given.
if test "${with_scoplib+set}" = set; then :
withval=$with_scoplib; given_inc_path="$withval/include"; CXXFLAGS="-I$given_inc_path $CXXFLAGS";
given_lib_path="$withval/lib"; LDFLAGS="-L$given_lib_path $LDFLAGS"
else
given_inc_path=inc_not_give_scoplib;
given_lib_path=lib_not_give_scoplib
fi
# Check for library and headers works
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for scoplib: scoplib/scop.h in $given_inc_path, and libscoplib in $given_lib_path" >&5
$as_echo_n "checking for scoplib: scoplib/scop.h in $given_inc_path, and libscoplib in $given_lib_path... " >&6; }
# try to compile a file that includes a header of the library
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <scoplib/scop.h>
int
main ()
{
;
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
$as_echo "ok" >&6; }
scoplib_found="yes"
if test "x$given_inc_path" != "xinc_not_give_scoplib"; then :
scoplib_inc="-I$given_inc_path"
fi
scoplib_lib="-lscoplib"
if test "x$given_lib_path" != "xlib_not_give_scoplib"; then :
scoplib_ld="-L$given_lib_path"
fi
else
if test "x" = "xrequired"; then :
as_fn_error $? "scoplib required but not found" "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
fi
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
# reset original CXXFLAGS
CXXFLAGS=$OLD_CXXFLAGS
LDFLAGS=$OLD_LDFLAGS;
LIBS=$OLD_LIBS
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "x$scoplib_found" = "xyes"; then :
$as_echo "#define SCOPLIB_FOUND 1" >>confdefs.h
fi
if test "x$scoplib_found" = "xyes"; then :
scoplib_rpath="-Wl,-rpath=$given_lib_path"
else
scoplib_rpath=""
fi
# Check whether --enable-polly_gpu_codegen was given.
if test "${enable_polly_gpu_codegen+set}" = set; then :
enableval=$enable_polly_gpu_codegen;

View File

@@ -32,6 +32,3 @@
/* Define if pluto found */
#undef PLUTO_FOUND
/* Define if scoplib found */
#undef SCOPLIB_FOUND

View File

@@ -53,12 +53,6 @@ llvm::Pass *createIslCodeGenerationPass();
llvm::Pass *createIslScheduleOptimizerPass();
llvm::Pass *createTempScopInfoPass();
#ifdef SCOPLIB_FOUND
llvm::Pass *createPoccPass();
llvm::Pass *createScopLibExporterPass();
llvm::Pass *createScopLibImporterPass();
#endif
extern char &IndependentBlocksID;
extern char &CodePreparationID;
}
@@ -100,11 +94,6 @@ struct PollyForcePassLinking {
polly::createIslScheduleOptimizerPass();
polly::createTempScopInfoPass();
#ifdef SCOPLIB_FOUND
polly::createPoccPass();
polly::createScopLibExporterPass();
polly::createScopLibImporterPass();
#endif
}
} PollyForcePassLinking; // Force link by creating a global definition.
}
@@ -126,9 +115,6 @@ void initializeIslScheduleOptimizerPass(llvm::PassRegistry &);
void initializePlutoOptimizerPass(llvm::PassRegistry &);
#endif
void initializePollyCanonicalizePass(llvm::PassRegistry &);
#ifdef SCOPLIB_FOUND
void initializePoccPass(llvm::PassRegistry &);
#endif
void initializePollyIndVarSimplifyPass(llvm::PassRegistry &);
}

View File

@@ -1,70 +0,0 @@
//===- ScopLib.h - ScopLib interface ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Scoplib interface.
//
// The scoplib interface allows to import/export a scop using scoplib.
//===----------------------------------------------------------------------===//
#ifndef POLLY_SCOPLIB_H
#define POLLY_SCOPLIB_H
#include "isl/ctx.h"
#include "scoplib/scop.h"
#include <map>
namespace llvm {
class Value;
}
struct isl_constraint;
struct isl_basic_map;
struct isl_basic_set;
struct isl_map;
struct isl_set;
namespace polly {
class Dependences;
class ScopStmt;
class Scop;
class ScopLib {
Scop *PollyScop;
scoplib_scop_p scoplib;
Dependences *D;
std::map<const llvm::Value *, int> ArrayMap;
void initializeArrays();
void initializeParameters();
void initializeScattering();
void initializeStatements();
scoplib_statement_p initializeStatement(ScopStmt *stmt);
void freeStatement(scoplib_statement_p stmt);
static int accessToMatrix_constraint(isl_constraint *c, void *user);
static int accessToMatrix_basic_map(isl_basic_map *bmap, void *user);
scoplib_matrix_p createAccessMatrix(ScopStmt *S, bool isRead);
static int domainToMatrix_constraint(isl_constraint *c, void *user);
static int domainToMatrix_basic_set(isl_basic_set *bset, void *user);
scoplib_matrix_p domainToMatrix(__isl_take isl_set *set);
static int scatteringToMatrix_constraint(isl_constraint *c, void *user);
static int scatteringToMatrix_basic_map(isl_basic_map *bmap, void *user);
scoplib_matrix_p scatteringToMatrix(__isl_take isl_map *map);
public:
ScopLib(Scop *S);
ScopLib(Scop *S, FILE *F, Dependences *D);
~ScopLib();
void print(FILE *F);
bool updateScattering();
};
}
#endif /* POLLY_SCOPLIB_H */

View File

@@ -26,14 +26,6 @@ if (GPU_CODEGEN)
CodeGen/PTXGenerator.cpp)
endif (GPU_CODEGEN)
if (SCOPLIB_FOUND)
set(POLLY_SCOPLIB_FILES
Transform/Pocc.cpp
Exchange/ScopLib.cpp
Exchange/ScopLibExporter.cpp
Exchange/ScopLibImporter.cpp)
endif (SCOPLIB_FOUND)
add_polly_library(Polly
Analysis/Dependences.cpp
Analysis/ScopDetection.cpp
@@ -51,7 +43,6 @@ add_polly_library(Polly
CodeGen/RuntimeDebugBuilder.cpp
${GPGPU_CODEGEN_FILES}
Exchange/JSONExporter.cpp
${POLLY_SCOPLIB_FILES}
Support/GICHelper.cpp
Support/SCEVValidator.cpp
Support/RegisterPasses.cpp

View File

@@ -1,767 +0,0 @@
//===- ScopLib.cpp - ScopLib interface ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// ScopLib Interface
//
//===----------------------------------------------------------------------===//
#include "polly/LinkAllPasses.h"
#ifdef SCOPLIB_FOUND
#include "polly/Dependences.h"
#include "polly/ScopLib.h"
#include "polly/ScopInfo.h"
#include "stdio.h"
#include "isl/set.h"
#include "isl/map.h"
#include "isl/constraint.h"
#include "isl/val_gmp.h"
using namespace llvm;
namespace polly {
ScopLib::ScopLib(Scop *S) : PollyScop(S) {
scoplib = scoplib_scop_malloc();
initializeArrays();
initializeParameters();
initializeScattering();
initializeStatements();
}
ScopLib::ScopLib(Scop *S, FILE *F, Dependences *dep) : PollyScop(S), D(dep) {
scoplib = scoplib_scop_read(F);
}
void ScopLib::initializeParameters() {
scoplib->nb_parameters = PollyScop->getNumParams();
scoplib->parameters =
(char **)malloc(sizeof(char *) * scoplib->nb_parameters);
for (int i = 0; i < scoplib->nb_parameters; ++i) {
scoplib->parameters[i] = (char *)malloc(sizeof(char *) * 20);
sprintf(scoplib->parameters[i], "p_%d", i);
}
}
void ScopLib::initializeArrays() {
int nb_arrays = 0;
for (ScopStmt *Stmt : *PollyScop)
for (MemoryAccess *MA : *Stmt) {
const Value *BaseAddr = MA->getBaseAddr();
if (ArrayMap.find(BaseAddr) == ArrayMap.end()) {
ArrayMap.insert(std::make_pair(BaseAddr, nb_arrays));
++nb_arrays;
}
}
scoplib->nb_arrays = nb_arrays;
scoplib->arrays = (char **)malloc(sizeof(char *) * nb_arrays);
for (int i = 0; i < nb_arrays; ++i)
for (std::map<const Value *, int>::iterator VI = ArrayMap.begin(),
VE = ArrayMap.end();
VI != VE; ++VI)
if ((*VI).second == i) {
const Value *V = (*VI).first;
std::string name = V->getName();
scoplib->arrays[i] = (char *)malloc(sizeof(char *) * (name.size() + 1));
strcpy(scoplib->arrays[i], name.c_str());
}
}
void ScopLib::initializeScattering() {}
scoplib_statement_p ScopLib::initializeStatement(ScopStmt *stmt) {
scoplib_statement_p Stmt = scoplib_statement_malloc();
// Domain & Schedule
Stmt->domain = scoplib_matrix_list_malloc();
Stmt->domain->elt = domainToMatrix(stmt->getDomain());
Stmt->schedule = scatteringToMatrix(stmt->getScattering());
// Statement name
std::string entryName;
raw_string_ostream OS(entryName);
stmt->getBasicBlock()->printAsOperand(OS, false);
entryName = OS.str();
Stmt->body = (char *)malloc(sizeof(char) * (entryName.size() + 1));
strcpy(Stmt->body, entryName.c_str());
// Iterator names
Stmt->nb_iterators = stmt->getNumIterators();
Stmt->iterators = (char **)malloc(sizeof(char *) * Stmt->nb_iterators);
for (int i = 0; i < Stmt->nb_iterators; ++i) {
Stmt->iterators[i] = (char *)malloc(sizeof(char *) * 20);
sprintf(Stmt->iterators[i], "i_%d", i);
}
// Memory Accesses
Stmt->read = createAccessMatrix(stmt, true);
Stmt->write = createAccessMatrix(stmt, false);
return Stmt;
}
void ScopLib::initializeStatements() {
for (Scop::reverse_iterator SI = PollyScop->rbegin(), SE = PollyScop->rend();
SI != SE; ++SI) {
scoplib_statement_p stmt = initializeStatement(*SI);
stmt->next = scoplib->statement;
scoplib->statement = stmt;
}
}
void ScopLib::freeStatement(scoplib_statement_p stmt) {
if (stmt->read)
scoplib_matrix_free(stmt->read);
stmt->read = nullptr;
if (stmt->write)
scoplib_matrix_free(stmt->write);
stmt->write = nullptr;
scoplib_matrix_list_p current = stmt->domain;
while (current) {
scoplib_matrix_list_p next = current->next;
current->next = nullptr;
scoplib_matrix_free(current->elt);
current->elt = nullptr;
scoplib_matrix_list_free(current);
current = next;
}
stmt->domain = nullptr;
if (stmt->schedule)
scoplib_matrix_free(stmt->schedule);
stmt->schedule = nullptr;
for (int i = 0; i < stmt->nb_iterators; ++i)
free(stmt->iterators[i]);
free(stmt->iterators);
stmt->iterators = nullptr;
stmt->nb_iterators = 0;
scoplib_statement_free(stmt);
}
void ScopLib::print(FILE *F) { scoplib_scop_print_dot_scop(F, scoplib); }
/// Add an isl constraint to an ScopLib matrix.
///
/// @param user The matrix
/// @param c The constraint
int ScopLib::domainToMatrix_constraint(isl_constraint *c, void *user) {
scoplib_matrix_p m = (scoplib_matrix_p)user;
int nb_params = isl_constraint_dim(c, isl_dim_param);
int nb_vars = isl_constraint_dim(c, isl_dim_set);
int nb_div = isl_constraint_dim(c, isl_dim_div);
assert(!nb_div && "Existentially quantified variables not yet supported");
scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_vars + 2);
// Assign type
if (isl_constraint_is_equality(c))
scoplib_vector_tag_equality(vec);
else
scoplib_vector_tag_inequality(vec);
isl_val *v;
// Assign variables
for (int i = 0; i < nb_vars; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_set, i);
SCOPVAL_init(vec->p[i + 1]);
isl_val_get_num_gmp(v, vec->p[i + 1]);
isl_val_free(v);
}
// Assign parameters
for (int i = 0; i < nb_params; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_param, i);
SCOPVAL_init(vec->p[nb_vars + i + 1]);
isl_val_get_num_gmp(v, vec->p[nb_vars + i + 1]);
isl_val_free(v);
}
// Assign constant
v = isl_constraint_get_constant_val(c);
SCOPVAL_init(vec->p[nb_params + nb_vars + 1]);
isl_val_get_num_gmp(v, vec->p[nb_params + nb_vars + 1]);
scoplib_matrix_insert_vector(m, vec, m->NbRows);
scoplib_vector_free(vec);
isl_constraint_free(c);
isl_val_free(v);
return 0;
}
/// Add an isl basic set to a ScopLib matrix_list
///
/// @param bset The basic set to add
/// @param user The matrix list we should add the basic set to
///
/// XXX: At the moment this function expects just a matrix, as support
/// for matrix lists is currently not available in ScopLib. So union of
/// polyhedron are not yet supported
int ScopLib::domainToMatrix_basic_set(isl_basic_set *bset, void *user) {
scoplib_matrix_p m = (scoplib_matrix_p)user;
assert(!m->NbRows && "Union of polyhedron not yet supported");
isl_basic_set_foreach_constraint(bset, &domainToMatrix_constraint, user);
isl_basic_set_free(bset);
return 0;
}
/// Translate a isl_set to a ScopLib matrix.
///
/// @param PS The set to be translated
/// @return A ScopLib Matrix
scoplib_matrix_p ScopLib::domainToMatrix(__isl_take isl_set *set) {
set = isl_set_compute_divs(set);
set = isl_set_align_divs(set);
// Initialize the matrix.
unsigned NbRows, NbColumns;
NbRows = 0;
NbColumns = isl_set_n_dim(set) + isl_set_n_param(set) + 2;
scoplib_matrix_p matrix = scoplib_matrix_malloc(NbRows, NbColumns);
// Copy the content into the matrix.
isl_set_foreach_basic_set(set, &domainToMatrix_basic_set, matrix);
isl_set_free(set);
return matrix;
}
/// Add an isl constraint to an ScopLib matrix.
///
/// @param user The matrix
/// @param c The constraint
int ScopLib::scatteringToMatrix_constraint(isl_constraint *c, void *user) {
scoplib_matrix_p m = (scoplib_matrix_p)user;
int nb_params = isl_constraint_dim(c, isl_dim_param);
int nb_in = isl_constraint_dim(c, isl_dim_in);
int nb_div = isl_constraint_dim(c, isl_dim_div);
assert(!nb_div && "Existentially quantified variables not yet supported");
scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_in + 2);
// Assign type
if (isl_constraint_is_equality(c))
scoplib_vector_tag_equality(vec);
else
scoplib_vector_tag_inequality(vec);
isl_val *v;
// Assign variables
for (int i = 0; i < nb_in; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_in, i);
SCOPVAL_init(vec->p[i + 1]);
isl_val_get_num_gmp(v, vec->p[i + 1]);
isl_val_free(v);
}
// Assign parameters
for (int i = 0; i < nb_params; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_param, i);
SCOPVAL_init(vec->p[nb_in + i + 1]);
isl_val_get_num_gmp(v, vec->p[nb_in + i + 1]);
isl_val_free(v);
}
// Assign constant
v = isl_constraint_get_constant_val(c);
SCOPVAL_init(vec->p[nb_in + nb_params + 1]);
isl_val_get_num_gmp(v, vec->p[nb_in + nb_params + 1]);
scoplib_vector_p null = scoplib_vector_malloc(nb_params + nb_in + 2);
vec = scoplib_vector_sub(null, vec);
scoplib_matrix_insert_vector(m, vec, 0);
scoplib_vector_free(null);
scoplib_vector_free(vec);
isl_constraint_free(c);
isl_val_free(v);
return 0;
}
/// Add an isl basic map to a ScopLib matrix_list
///
/// @param bmap The basic map to add
/// @param user The matrix list we should add the basic map to
///
/// XXX: At the moment this function expects just a matrix, as support
/// for matrix lists is currently not available in ScopLib. So union of
/// polyhedron are not yet supported
int ScopLib::scatteringToMatrix_basic_map(isl_basic_map *bmap, void *user) {
scoplib_matrix_p m = (scoplib_matrix_p)user;
assert(!m->NbRows && "Union of polyhedron not yet supported");
isl_basic_map_foreach_constraint(bmap, &scatteringToMatrix_constraint, user);
isl_basic_map_free(bmap);
return 0;
}
/// Translate a isl_map to a ScopLib matrix.
///
/// @param map The map to be translated
/// @return A ScopLib Matrix
scoplib_matrix_p ScopLib::scatteringToMatrix(__isl_take isl_map *map) {
map = isl_map_compute_divs(map);
map = isl_map_align_divs(map);
// Initialize the matrix.
unsigned NbRows, NbColumns;
NbRows = 0;
NbColumns = isl_map_n_in(map) + isl_map_n_param(map) + 2;
scoplib_matrix_p matrix = scoplib_matrix_malloc(NbRows, NbColumns);
// Copy the content into the matrix.
isl_map_foreach_basic_map(map, &scatteringToMatrix_basic_map, matrix);
// Only keep the relevant rows.
scoplib_matrix_p reduced =
scoplib_matrix_ncopy(matrix, isl_map_n_in(map) * 2 + 1);
scoplib_matrix_free(matrix);
isl_map_free(map);
return reduced;
}
/// Add an isl constraint to an ScopLib matrix.
///
/// @param user The matrix
/// @param c The constraint
int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) {
scoplib_matrix_p m = (scoplib_matrix_p)user;
int nb_params = isl_constraint_dim(c, isl_dim_param);
int nb_in = isl_constraint_dim(c, isl_dim_in);
int nb_div = isl_constraint_dim(c, isl_dim_div);
assert(!nb_div && "Existentially quantified variables not yet supported");
scoplib_vector_p vec = scoplib_vector_malloc(nb_params + nb_in + 2);
isl_val *v;
// The access dimension has to be one.
v = isl_constraint_get_coefficient_val(c, isl_dim_out, 0);
assert((isl_val_is_one(v) || isl_val_is_negone(v)) &&
"Access relations not supported in scoplib");
bool inverse = isl_val_is_one(v);
isl_val_free(v);
// Assign variables
for (int i = 0; i < nb_in; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_in, i);
if (inverse)
v = isl_val_neg(v);
SCOPVAL_init(vec->p[i + 1]);
isl_val_get_num_gmp(v, vec->p[i + 1]);
isl_val_free(v);
}
// Assign parameters
for (int i = 0; i < nb_params; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_param, i);
if (inverse)
v = isl_val_neg(v);
SCOPVAL_init(vec->p[nb_in + i + 1]);
isl_val_get_num_gmp(v, vec->p[nb_in + i + 1]);
isl_val_free(v);
}
// Assign constant
v = isl_constraint_get_constant_val(c);
if (inverse)
v = isl_val_neg(v);
SCOPVAL_init(vec->p[nb_in + nb_params + 1]);
isl_val_get_num_gmp(v, vec->p[nb_in + nb_params + 1]);
scoplib_matrix_insert_vector(m, vec, m->NbRows);
scoplib_vector_free(vec);
isl_constraint_free(c);
isl_val_free(v);
return 0;
}
/// Add an isl basic map to a ScopLib matrix_list
///
/// @param bmap The basic map to add
/// @param user The matrix list we should add the basic map to
///
/// XXX: At the moment this function expects just a matrix, as support
/// for matrix lists is currently not available in ScopLib. So union of
/// polyhedron are not yet supported
int ScopLib::accessToMatrix_basic_map(isl_basic_map *bmap, void *user) {
isl_basic_map_foreach_constraint(bmap, &accessToMatrix_constraint, user);
isl_basic_map_free(bmap);
return 0;
}
/// Create the memory access matrix for scoplib
///
/// @param S The polly statement the access matrix is created for.
/// @param isRead Are we looking for read or write accesses?
/// @param ArrayMap A map translating from the memory references to the scoplib
/// indeces
///
/// @return The memory access matrix, as it is required by scoplib.
scoplib_matrix_p ScopLib::createAccessMatrix(ScopStmt *S, bool isRead) {
unsigned NbColumns = S->getNumIterators() + S->getNumParams() + 2;
scoplib_matrix_p m = scoplib_matrix_malloc(0, NbColumns);
for (MemoryAccess *MA : *S)
if (MA->isRead() == isRead) {
// Extract the access function.
isl_map *AccessRelation = MA->getAccessRelation();
isl_map_foreach_basic_map(AccessRelation, &accessToMatrix_basic_map, m);
isl_map_free(AccessRelation);
// Set the index of the memory access base element.
std::map<const Value *, int>::iterator BA =
ArrayMap.find(MA->getBaseAddr());
SCOPVAL_set_si(m->p[m->NbRows - 1][0], (*BA).second + 1);
}
return m;
}
ScopLib::~ScopLib() {
if (!scoplib)
return;
// Free array names.
for (int i = 0; i < scoplib->nb_arrays; ++i)
free(scoplib->arrays[i]);
free(scoplib->arrays);
scoplib->arrays = nullptr;
scoplib->nb_arrays = 0;
// Free parameters
for (int i = 0; i < scoplib->nb_parameters; ++i)
free(scoplib->parameters[i]);
free(scoplib->parameters);
scoplib->parameters = nullptr;
scoplib->nb_parameters = 0;
scoplib_statement_p stmt = scoplib->statement;
// Free Statements
while (stmt) {
scoplib_statement_p TempStmt = stmt->next;
stmt->next = nullptr;
freeStatement(stmt);
stmt = TempStmt;
}
scoplib->statement = nullptr;
scoplib_scop_free(scoplib);
}
/// @brief Create an isl constraint from a row of ScopLib integers.
///
/// @param row An array of isl/ScopLib integers.
/// @param Space An isl space object, describing how to spilt the dimensions.
///
/// @return An isl constraint representing this integer array.
isl_constraint *constraintFromMatrixRow(mpz_t *row,
__isl_take isl_space *Space) {
isl_constraint *c;
isl_ctx *ctx;
ctx = isl_space_get_ctx(Space);
unsigned NbIn = isl_space_dim(Space, isl_dim_in);
unsigned NbParam = isl_space_dim(Space, isl_dim_param);
if (SCOPVAL_zero_p(row[0]))
c = isl_equality_alloc(isl_local_space_from_space(Space));
else
c = isl_inequality_alloc(isl_local_space_from_space(Space));
unsigned current_column = 1;
isl_val *v;
for (unsigned j = 0; j < NbIn; ++j) {
v = isl_val_int_from_gmp(ctx, row[current_column++]);
c = isl_constraint_set_coefficient_val(c, isl_dim_in, j, v);
}
for (unsigned j = 0; j < NbParam; ++j) {
v = isl_val_int_from_gmp(ctx, row[current_column++]);
c = isl_constraint_set_coefficient_val(c, isl_dim_param, j, v);
}
v = isl_val_int_from_gmp(ctx, row[current_column]);
c = isl_constraint_set_constant_val(c, v);
return c;
}
/// @brief Create an isl map from a ScopLib matrix.
///
/// @param m The ScopLib matrix to translate.
/// @param Space The dimensions that are contained in the ScopLib matrix.
///
/// @return An isl map representing m.
isl_map *mapFromMatrix(scoplib_matrix_p m, __isl_take isl_space *Space,
unsigned scatteringDims) {
isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space));
for (unsigned i = 0; i < m->NbRows; ++i) {
isl_constraint *c;
c = constraintFromMatrixRow(m->p[i], isl_space_copy(Space));
c = isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1);
bmap = isl_basic_map_add_constraint(bmap, c);
}
for (unsigned i = m->NbRows; i < scatteringDims; i++) {
isl_constraint *c;
c = isl_equality_alloc(isl_local_space_from_space(isl_space_copy(Space)));
c = isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1);
bmap = isl_basic_map_add_constraint(bmap, c);
}
isl_space_free(Space);
return isl_map_from_basic_map(bmap);
}
/// @brief Create an isl constraint from a row of ScopLib integers.
///
/// @param row An array of isl/ScopLib integers.
/// @param Space An isl space object, describing how to spilt the dimensions.
///
/// @return An isl constraint representing this integer array.
isl_constraint *constraintFromMatrixRowFull(mpz_t *row,
__isl_take isl_space *Space) {
isl_constraint *c;
isl_ctx *ctx = isl_space_get_ctx(Space);
unsigned NbOut = isl_space_dim(Space, isl_dim_out);
unsigned NbIn = isl_space_dim(Space, isl_dim_in);
unsigned NbParam = isl_space_dim(Space, isl_dim_param);
isl_local_space *LSpace = isl_local_space_from_space(Space);
if (SCOPVAL_zero_p(row[0]))
c = isl_equality_alloc(LSpace);
else
c = isl_inequality_alloc(LSpace);
unsigned current_column = 1;
isl_val *v;
for (unsigned j = 0; j < NbOut; ++j) {
v = isl_val_int_from_gmp(ctx, row[current_column++]);
c = isl_constraint_set_coefficient_val(c, isl_dim_out, j, v);
}
for (unsigned j = 0; j < NbIn; ++j) {
v = isl_val_int_from_gmp(ctx, row[current_column++]);
c = isl_constraint_set_coefficient_val(c, isl_dim_in, j, v);
}
for (unsigned j = 0; j < NbParam; ++j) {
v = isl_val_int_from_gmp(ctx, row[current_column++]);
c = isl_constraint_set_coefficient_val(c, isl_dim_param, j, v);
}
v = isl_val_int_from_gmp(ctx, row[current_column]);
c = isl_constraint_set_constant_val(c, v);
return c;
}
/// @brief Create an isl map from a ScopLib matrix.
///
/// @param m The ScopLib matrix to translate.
/// @param Space The dimensions that are contained in the ScopLib matrix.
///
/// @return An isl map representing m.
isl_map *mapFromMatrix(scoplib_matrix_p m, __isl_take isl_space *Space) {
isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space));
for (unsigned i = 0; i < m->NbRows; ++i) {
isl_constraint *c;
c = constraintFromMatrixRowFull(m->p[i], isl_space_copy(Space));
bmap = isl_basic_map_add_constraint(bmap, c);
}
isl_space_free(Space);
return isl_map_from_basic_map(bmap);
}
/// @brief Create a new scattering for PollyStmt.
///
/// @param m The matrix describing the new scattering.
/// @param PollyStmt The statement to create the scattering for.
///
/// @return An isl_map describing the scattering.
isl_map *scatteringForStmt(scoplib_matrix_p m, ScopStmt *PollyStmt,
int scatteringDims) {
unsigned NbParam = PollyStmt->getNumParams();
unsigned NbIterators = PollyStmt->getNumIterators();
unsigned NbScattering;
if (scatteringDims == -1)
NbScattering = m->NbColumns - 2 - NbParam - NbIterators;
else
NbScattering = scatteringDims;
isl_ctx *ctx = PollyStmt->getParent()->getIslCtx();
isl_space *Space = isl_dim_alloc(ctx, NbParam, NbIterators, NbScattering);
isl_space *ParamSpace = PollyStmt->getParent()->getParamSpace();
// We need to copy the isl_ids for the parameter dimensions to the new
// map. Without doing this the current map would have different
// ids then the new one, even though both are named identically.
for (unsigned i = 0; i < isl_space_dim(Space, isl_dim_param); i++) {
isl_id *id = isl_space_get_dim_id(ParamSpace, isl_dim_param, i);
Space = isl_space_set_dim_id(Space, isl_dim_param, i, id);
}
isl_space_free(ParamSpace);
Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering");
Space = isl_space_set_tuple_id(Space, isl_dim_in, PollyStmt->getDomainId());
if (scatteringDims == -1)
return mapFromMatrix(m, Space);
return mapFromMatrix(m, Space, scatteringDims);
}
unsigned maxScattering(scoplib_statement_p stmt) {
unsigned max = 0;
while (stmt) {
max = std::max(max, stmt->schedule->NbRows);
stmt = stmt->next;
}
return max;
}
typedef Dependences::StatementToIslMapTy StatementToIslMapTy;
void freeStmtToIslMap(StatementToIslMapTy *Map) {
for (StatementToIslMapTy::iterator MI = Map->begin(), ME = Map->end();
MI != ME; ++MI)
isl_map_free(MI->second);
delete (Map);
}
/// @brief Read the new scattering from the scoplib description.
///
/// @S The Scop to update
/// @OScop The ScopLib data structure describing the new scattering.
/// @return A map that contains for each Statement the new scattering.
StatementToIslMapTy *readScattering(Scop *S, scoplib_scop_p OScop) {
StatementToIslMapTy &NewScattering = *(new StatementToIslMapTy());
scoplib_statement_p stmt = OScop->statement;
// Check if we have dimensions for each scattering or if each row
// represents a scattering dimension.
int numScatteringDims = -1;
ScopStmt *pollyStmt = *S->begin();
if (stmt->schedule->NbColumns ==
2 + pollyStmt->getNumParams() + pollyStmt->getNumIterators()) {
numScatteringDims = maxScattering(stmt);
}
for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) {
if (!stmt) {
errs() << "Not enough statements available in ScopLib file\n";
freeStmtToIslMap(&NewScattering);
return nullptr;
}
NewScattering[*SI] =
scatteringForStmt(stmt->schedule, *SI, numScatteringDims);
stmt = stmt->next;
}
if (stmt) {
errs() << "Too many statements in ScopLib file\n";
freeStmtToIslMap(&NewScattering);
return nullptr;
}
return &NewScattering;
}
/// @brief Update the scattering in a Scop using the scoplib description of
/// the scattering.
bool ScopLib::updateScattering() {
if (!scoplib)
return false;
StatementToIslMapTy *NewScattering = readScattering(PollyScop, scoplib);
if (!NewScattering)
return false;
if (!D->isValidScattering(NewScattering)) {
freeStmtToIslMap(NewScattering);
errs() << "ScopLib file contains a scattering that changes the "
<< "dependences. Use -disable-polly-legality to continue anyways\n";
return false;
}
for (Scop::iterator SI = PollyScop->begin(), SE = PollyScop->end(); SI != SE;
++SI) {
ScopStmt *Stmt = *SI;
if (NewScattering->find(Stmt) != NewScattering->end())
Stmt->setScattering(isl_map_copy((*NewScattering)[Stmt]));
}
freeStmtToIslMap(NewScattering);
return true;
}
}
#endif

View File

@@ -1,93 +0,0 @@
//===-- ScopLibExporter.cpp - Export Scops with scoplib ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Export the Scops build by ScopInfo pass to text file.
//
//===----------------------------------------------------------------------===//
#include "polly/LinkAllPasses.h"
#ifdef SCOPLIB_FOUND
#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "polly/ScopPass.h"
#include "polly/ScopLib.h"
#include "stdio.h"
#include "isl/set.h"
#include "isl/constraint.h"
using namespace llvm;
using namespace polly;
namespace {
static cl::opt<std::string>
ExportDir("polly-export-scoplib-dir",
cl::desc("The directory to export the .scoplib files to."),
cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired,
cl::init("."), cl::cat(PollyCategory));
class ScopLibExporter : public ScopPass {
Scop *S;
std::string getFileName(Scop *S) const;
public:
static char ID;
explicit ScopLibExporter() : ScopPass(ID) {}
virtual bool runOnScop(Scop &scop);
void getAnalysisUsage(AnalysisUsage &AU) const;
};
}
char ScopLibExporter::ID = 0;
std::string ScopLibExporter::getFileName(Scop *S) const {
std::string FunctionName = S->getRegion().getEntry()->getParent()->getName();
std::string FileName = FunctionName + "___" + S->getNameStr() + ".scoplib";
return FileName;
}
bool ScopLibExporter::runOnScop(Scop &scop) {
S = &scop;
Region *R = &S->getRegion();
std::string FileName = ExportDir + "/" + getFileName(S);
FILE *F = fopen(FileName.c_str(), "w");
if (!F) {
errs() << "Cannot open file: " << FileName << "\n";
errs() << "Skipping export.\n";
return false;
}
ScopLib scoplib(S);
scoplib.print(F);
fclose(F);
std::string FunctionName = R->getEntry()->getParent()->getName();
errs() << "Writing Scop '" << R->getNameStr() << "' in function '"
<< FunctionName << "' to '" << FileName << "'.\n";
return false;
}
void ScopLibExporter::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
}
static RegisterPass<ScopLibExporter>
A("polly-export-scoplib", "Polly - Export Scops with ScopLib library"
" (Writes a .scoplib file for each Scop)");
Pass *polly::createScopLibExporterPass() { return new ScopLibExporter(); }
#endif

View File

@@ -1,116 +0,0 @@
//===-- ScopLibImporter.cpp - Import Scops with scoplib. -----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Import modified .scop files into Polly. This allows to change the schedule of
// statements.
//
//===----------------------------------------------------------------------===//
#include "polly/LinkAllPasses.h"
#ifdef SCOPLIB_FOUND
#include "polly/Dependences.h"
#include "polly/Options.h"
#include "polly/ScopInfo.h"
#include "polly/ScopLib.h"
#define SCOPLIB_INT_T_IS_MP
#include "scoplib/scop.h"
#include "isl/set.h"
#include "isl/constraint.h"
using namespace llvm;
using namespace polly;
namespace {
static cl::opt<std::string>
ImportDir("polly-import-scoplib-dir",
cl::desc("The directory to import the .scoplib files from."),
cl::Hidden, cl::value_desc("Directory path"), cl::ValueRequired,
cl::init("."), cl::cat(PollyCategory));
static cl::opt<std::string>
ImportPostfix("polly-import-scoplib-postfix",
cl::desc("Postfix to append to the import .scoplib files."),
cl::Hidden, cl::value_desc("File postfix"), cl::ValueRequired,
cl::init(""), cl::cat(PollyCategory));
struct ScopLibImporter : public RegionPass {
static char ID;
Scop *S;
Dependences *D;
explicit ScopLibImporter() : RegionPass(ID) {}
bool updateScattering(Scop *S, scoplib_scop_p OScop);
std::string getFileName(Scop *S) const;
virtual bool runOnRegion(Region *R, RGPassManager &RGM);
virtual void print(raw_ostream &OS, const Module *) const;
void getAnalysisUsage(AnalysisUsage &AU) const;
};
}
char ScopLibImporter::ID = 0;
namespace {
std::string ScopLibImporter::getFileName(Scop *S) const {
std::string FunctionName = S->getRegion().getEntry()->getParent()->getName();
std::string FileName = FunctionName + "___" + S->getNameStr() + ".scoplib";
return FileName;
}
void ScopLibImporter::print(raw_ostream &OS, const Module *) const {}
bool ScopLibImporter::runOnRegion(Region *R, RGPassManager &RGM) {
S = getAnalysis<ScopInfo>().getScop();
D = &getAnalysis<Dependences>();
if (!S)
return false;
std::string FileName = ImportDir + "/" + getFileName(S) + ImportPostfix;
FILE *F = fopen(FileName.c_str(), "r");
if (!F) {
errs() << "Cannot open file: " << FileName << "\n";
errs() << "Skipping import.\n";
return false;
}
std::string FunctionName = R->getEntry()->getParent()->getName();
errs() << "Reading Scop '" << R->getNameStr() << "' in function '"
<< FunctionName << "' from '" << FileName << "'.\n";
ScopLib scoplib(S, F, D);
bool UpdateSuccessfull = scoplib.updateScattering();
fclose(F);
if (!UpdateSuccessfull) {
errs() << "Update failed"
<< "\n";
}
return false;
}
void ScopLibImporter::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequired<ScopInfo>();
AU.addRequired<Dependences>();
}
}
static RegisterPass<ScopLibImporter>
A("polly-import-scoplib", "Polly - Import Scops with ScopLib library"
" (Reads a .scoplib file for each Scop)");
Pass *polly::createScopLibImporterPass() { return new ScopLibImporter(); }
#endif

View File

@@ -31,13 +31,6 @@ ifeq ($(PLUTO_FOUND), yes)
POLLY_PLUTO_FILES= Transform/Pluto.cpp
endif
ifeq ($(SCOPLIB_FOUND), yes)
POLLY_SCOPLIB_FILES= Exchange/ScopLib.cpp \
Exchange/ScopLibExporter.cpp \
Exchange/ScopLibImporter.cpp \
Transform/Pocc.cpp
endif
ISL_CODEGEN_FILES= CodeGen/IslAst.cpp \
CodeGen/IslExprBuilder.cpp \
CodeGen/IslCodeGeneration.cpp
@@ -74,8 +67,7 @@ SOURCES= Polly.cpp \
${ISL_CODEGEN_FILES} \
${CLOOG_FILES} \
${POLLY_JSON_FILES} \
${POLLY_PLUTO_FILES} \
${POLLY_SCOPLIB_FILES}
${POLLY_PLUTO_FILES}
#
# Include Makefile.common so we know what to do.

View File

@@ -50,9 +50,6 @@ enum OptimizerChoice {
OPTIMIZER_NONE,
#ifdef PLUTO_FOUND
OPTIMIZER_PLUTO,
#endif
#ifdef SCOPLIB_FOUND
OPTIMIZER_POCC,
#endif
OPTIMIZER_ISL
};
@@ -63,9 +60,6 @@ static cl::opt<OptimizerChoice> Optimizer(
clEnumValN(OPTIMIZER_NONE, "none", "No optimizer"),
#ifdef PLUTO_FOUND
clEnumValN(OPTIMIZER_PLUTO, "pluto", "The Pluto scheduling optimizer"),
#endif
#ifdef SCOPLIB_FOUND
clEnumValN(OPTIMIZER_POCC, "pocc", "The PoCC scheduling optimizer"),
#endif
clEnumValN(OPTIMIZER_ISL, "isl", "The isl scheduling optimizer"),
clEnumValEnd),
@@ -169,9 +163,6 @@ void initializePollyPasses(PassRegistry &Registry) {
initializeJSONImporterPass(Registry);
initializeIslAstInfoPass(Registry);
initializeIslScheduleOptimizerPass(Registry);
#ifdef SCOPLIB_FOUND
initializePoccPass(Registry);
#endif
initializePollyIndVarSimplifyPass(Registry);
initializePollyCanonicalizePass(Registry);
initializeScopDetectionPass(Registry);
@@ -198,7 +189,7 @@ void initializePollyPasses(PassRegistry &Registry) {
///
/// For certain parts of the Polly optimizer, several alternatives are provided:
///
/// As scheduling optimizer we support PoCC (http://pocc.sourceforge.net), PLUTO
/// As scheduling optimizer we support PLUTO
/// (http://pluto-compiler.sourceforge.net) as well as the isl scheduling
/// optimizer (http://freecode.com/projects/isl). The isl optimizer is the
/// default optimizer.
@@ -233,12 +224,6 @@ static void registerPollyPasses(llvm::PassManagerBase &PM) {
case OPTIMIZER_NONE:
break; /* Do nothing */
#ifdef SCOPLIB_FOUND
case OPTIMIZER_POCC:
PM.add(polly::createPoccPass());
break;
#endif
#ifdef PLUTO_FOUND
case OPTIMIZER_PLUTO:
PM.add(polly::createPlutoOptimizerPass());

View File

@@ -1,282 +0,0 @@
//===- Pocc.cpp - Pocc interface ----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Pocc[1] interface.
//
// Pocc, the polyhedral compilation collection is a collection of polyhedral
// tools. It is used as an optimizer in polly
//
// [1] http://www-roc.inria.fr/~pouchet/software/pocc/
//
//===----------------------------------------------------------------------===//
#include "polly/LinkAllPasses.h"
#ifdef SCOPLIB_FOUND
#include "polly/CodeGen/CodeGeneration.h"
#include "polly/Dependences.h"
#include "polly/Options.h"
#include "polly/ScheduleOptimizer.h"
#include "polly/ScopInfo.h"
#include "polly/ScopLib.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/ADT/SmallString.h"
#include "isl/space.h"
#include "isl/map.h"
#include "isl/constraint.h"
#include <memory>
#include <system_error>
using namespace llvm;
using namespace polly;
#define DEBUG_TYPE "polly-opt-pocc"
static cl::opt<std::string> PlutoFuse("pluto-fuse", cl::desc(""), cl::Hidden,
cl::value_desc("Set fuse mode of Pluto"),
cl::init("maxfuse"),
cl::cat(PollyCategory));
namespace {
class Pocc : public ScopPass {
SmallString<128> PlutoStderr;
SmallString<128> PlutoStdout;
std::vector<const char *> arguments;
public:
static char ID;
explicit Pocc() : ScopPass(ID) {}
std::string getFileName(Region *R) const;
virtual bool runOnScop(Scop &S);
void printScop(llvm::raw_ostream &OS) const;
void getAnalysisUsage(AnalysisUsage &AU) const;
private:
bool runTransform(Scop &S);
};
}
char Pocc::ID = 0;
bool Pocc::runTransform(Scop &S) {
Dependences *D = &getAnalysis<Dependences>();
// Create the scop file.
SmallString<128> TempDir;
SmallString<128> ScopFile;
llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/true, TempDir);
ScopFile = TempDir;
llvm::sys::path::append(ScopFile, "polly.scop");
FILE *F = fopen(ScopFile.c_str(), "w");
arguments.clear();
if (!F) {
errs() << "Cannot open file: " << TempDir.c_str() << "\n";
errs() << "Skipping export.\n";
return false;
}
ScopLib scoplib(&S);
scoplib.print(F);
fclose(F);
// Execute pocc
std::string pocc = sys::FindProgramByName("pocc");
arguments.push_back("pocc");
arguments.push_back("--read-scop");
arguments.push_back(ScopFile.c_str());
arguments.push_back("--pluto-tile-scat");
arguments.push_back("--candl-dep-isl-simp");
arguments.push_back("--cloogify-scheds");
arguments.push_back("--output-scop");
arguments.push_back("--pluto");
arguments.push_back("--pluto-bounds");
arguments.push_back("10");
arguments.push_back("--pluto-fuse");
arguments.push_back(PlutoFuse.c_str());
if (!DisablePollyTiling)
arguments.push_back("--pluto-tile");
if (PollyVectorizerChoice != VECTORIZER_NONE)
arguments.push_back("--pluto-prevector");
arguments.push_back(0);
PlutoStdout = TempDir;
llvm::sys::path::append(PlutoStdout, "pluto.stdout");
PlutoStderr = TempDir;
llvm::sys::path::append(PlutoStderr, "pluto.stderr");
std::vector<llvm::StringRef> Redirect;
Redirect.push_back(0);
Redirect.push_back(PlutoStdout.c_str());
Redirect.push_back(PlutoStderr.c_str());
sys::ExecuteAndWait(pocc, &arguments[0], 0,
(const llvm::StringRef **)&Redirect[0]);
// Read the created scop file
SmallString<128> NewScopFile;
NewScopFile = TempDir;
llvm::sys::path::append(NewScopFile, "polly.pocc.c.scop");
FILE *poccFile = fopen(NewScopFile.c_str(), "r");
ScopLib newScoplib(&S, poccFile, D);
if (!newScoplib.updateScattering()) {
errs() << "Failure when calculating the optimization with "
"the following command: ";
for (const char *Arg : arguments)
if (Arg)
errs() << " " << Arg;
errs() << "\n";
return false;
} else
fclose(poccFile);
if (PollyVectorizerChoice == VECTORIZER_NONE)
return false;
// Find the innermost dimension that is not a constant dimension. This
// dimension will be vectorized.
unsigned scatterDims = S.getScatterDim();
int lastLoop = scatterDims - 1;
while (lastLoop) {
bool isSingleValued = true;
for (ScopStmt *Stmt : S) {
isl_map *scat = Stmt->getScattering();
isl_map *projected = isl_map_project_out(scat, isl_dim_out, lastLoop,
scatterDims - lastLoop);
if (!isl_map_is_bijective(projected)) {
isSingleValued = false;
break;
}
}
if (!isSingleValued)
break;
lastLoop--;
}
// Strip mine the innermost loop.
for (ScopStmt *Stmt : S) {
isl_map *scat = Stmt->getScattering();
int scatDims = Stmt->getNumScattering();
isl_space *Space = isl_space_alloc(S.getIslCtx(), S.getNumParams(),
scatDims, scatDims + 1);
isl_basic_map *map = isl_basic_map_universe(isl_space_copy(Space));
isl_local_space *LSpace = isl_local_space_from_space(Space);
for (int i = 0; i <= lastLoop - 1; i++) {
isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace));
isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1);
isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1);
map = isl_basic_map_add_constraint(map, c);
}
for (int i = lastLoop; i < scatDims; i++) {
isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace));
isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1);
isl_constraint_set_coefficient_si(c, isl_dim_out, i + 1, -1);
map = isl_basic_map_add_constraint(map, c);
}
isl_constraint *c;
int vectorWidth = 4;
c = isl_inequality_alloc(isl_local_space_copy(LSpace));
isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop, -vectorWidth);
isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop + 1, 1);
map = isl_basic_map_add_constraint(map, c);
c = isl_inequality_alloc(LSpace);
isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop, vectorWidth);
isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop + 1, -1);
isl_constraint_set_constant_si(c, vectorWidth - 1);
map = isl_basic_map_add_constraint(map, c);
isl_map *transform = isl_map_from_basic_map(map);
transform = isl_map_set_tuple_name(transform, isl_dim_out, "scattering");
transform = isl_map_set_tuple_name(transform, isl_dim_in, "scattering");
scat = isl_map_apply_range(scat, isl_map_copy(transform));
Stmt->setScattering(scat);
}
return false;
}
bool Pocc::runOnScop(Scop &S) {
bool Result = runTransform(S);
DEBUG(printScop(dbgs()));
return Result;
}
void Pocc::printScop(raw_ostream &OS) const {
std::unique_ptr<MemoryBuffer> stdoutBuffer;
std::unique_ptr<MemoryBuffer> stderrBuffer;
OS << "Command line: ";
for (const char *Arg : arguments)
if (Arg)
OS << " " << Arg;
OS << "\n";
if (std::error_code ec =
MemoryBuffer::getFile(PlutoStdout.str(), stdoutBuffer))
OS << "Could not open pocc stdout file: " + ec.message() << "\n";
else {
OS << "pocc stdout: " << stdoutBuffer->getBufferIdentifier() << "\n";
OS << stdoutBuffer->getBuffer() << "\n";
}
if (std::error_code ec =
MemoryBuffer::getFile(PlutoStderr.str(), stderrBuffer))
OS << "Could not open pocc stderr file: " + ec.message() << "\n";
else {
OS << "pocc stderr: " << PlutoStderr << "\n";
OS << stderrBuffer->getBuffer() << "\n";
}
}
void Pocc::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
}
Pass *polly::createPoccPass() { return new Pocc(); }
INITIALIZE_PASS_BEGIN(Pocc, "polly-opt-pocc",
"Polly - Optimize the scop using pocc", false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences);
INITIALIZE_PASS_DEPENDENCY(ScopInfo);
INITIALIZE_PASS_END(Pocc, "polly-opt-pocc",
"Polly - Optimize the scop using pocc", false, false)
#endif /* SCOPLIB_FOUND */

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
<html>
@@ -29,16 +29,16 @@
<h2>Middle End</h2>
<ul>
<li><em>polly-dependences</em> Calculate the dependences in a SCoPs</li>
<li><em>polly-opt-pocc</em> Optimize the SCoP using PoCC</li>
<li><em>polly-opt-pocc</em> Optimize the SCoP using PoCC [removed after <a href="http://llvm.org/releases/download.html#3.4.2">LLVM 3.4.2</a>]</li>
<li><em>polly-opt-isl</em> Optimize the SCoP using isl</li>
<li>Import/Export
<ul>
<li><em>polly-export-cloog</em> Export the CLooG input file
(Writes a .cloog file for each SCoP)</li>
<li><em>polly-export-scoplib</em> Export SCoPs with ScopLib library
(Writes a .scoplib file for each SCoP)</li>
(Writes a .scoplib file for each SCoP) [removed after <a href="http://llvm.org/releases/download.html#3.4.2">LLVM 3.4.2</a>]</li>
<li><em>polly-import-scoplib</em> Import SCoPs with ScopLib library
(Reads a .scoplib file for each SCoP)</li>
(Reads a .scoplib file for each SCoP) [removed after <a href="http://llvm.org/releases/download.html#3.4.2">LLVM 3.4.2</a>]</li>
<li><em>polly-export-jscop</em> Export SCoPs as JSON
(Writes a .jscop file for each SCoP)</li>
<li><em>polly-import-jscop</em> Import SCoPs from JSON

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
<html>
@@ -115,8 +115,8 @@ possible to run <a
href="http://www-rocq.inria.fr/~pouchet/software/pocc/">PoCC</a> as external
optimizer. PoCC provides access to the original Pluto implementation. To use
PoCC add <b>-polly-optimizer=pocc</b> to the command line (only available if
Polly was compiled with scoplib support). To disable the
optimizer entirely use the option <b>-polly-optimizer=none</b>.
Polly was compiled with scoplib support) [removed after <a href="http://llvm.org/releases/download.html#3.4.2">LLVM 3.4.2</a>].
To disable the optimizer entirely use the option <b>-polly-optimizer=none</b>.
<h3>Disable tiling in the optimizer</h3>
By default both optimizers perform tiling, if possible. In case this is not

View File

@@ -161,7 +161,7 @@ with the location of the python2 interpreter under your system).
<h2> Optional Features </h2>
<h3> Pocc </h3>
<h3> Pocc [Supported until <a href="http://llvm.org/releases/download.html#3.4.2">LLVM 3.4.2</a>]</h3>
<p>Polly can use <a href="http://www.cse.ohio-state.edu/~pouchet/software/pocc">
PoCC</a> as an external optimizer. PoCC is a research project that provides
@@ -171,7 +171,7 @@ already a similar optimizer, such that in general PoCC is not needed. It is
only recommended for people who want to compare against a different
optimizer.</a>
<br/>
To use it install PoCC 1.0-rc3.1 (the one with Polly support) and add it to your PATH.
To use it install PoCC 1.0-rc3.1 (the one with Polly support) and add it to your PATH.
<pre>
wget <a

View File

@@ -1,4 +1,4 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
<html>
@@ -71,6 +71,17 @@
<table id="news">
<tr><td><b>2014</b></td></tr>
<tr><td width="120"><p>August</p></td>
<td>
<h4>Polly drops the support of ScopLib and the external optimizer PoCC</h4>
The support for ScopLib as an exchange format has been removed as recent
versions of clan, candl and pluto all support the OpenScop exchange format.
The support of the external optmizer PoCC has been dropped in favor of the
isl optimizer (default) and the still available pluto support.
</td>
</tr>
<tr><td><b>2014</b></td></tr>
<tr><td width="120"><p>June</p></td>
<td>
<h4>Polly can be built without GPL licensed software</h4> After Sebastian
@@ -270,7 +281,7 @@ research tool.<br \>
<tr>
<td><p>May </p></td>
<td><p><a href="http://www.grosser.es">Tobias</a>' diploma thesis and
Raghesh's master thesis. See our <a
Raghesh's master thesis. See our <a
href="publications.html">list of publications</a>.</p></td>
</tr>