summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-05-28 22:34:52 +0200
committerMatthias Braun <matze@braunis.de>2015-05-28 22:34:52 +0200
commitbff1dacaae1867e3752f2797a2560589d9eda918 (patch)
treef73b90a48b4fc6a7a4c20309002b6e325824bea9 /ir/lpp
parent86ac628189b9dd3d27fdf80869aac36a4544a96c (diff)
lpp: Remove support for using remote solvers.
This has not been used for years and the code is often causing compile problems on systems with bad posix implementations like windows.
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp.c208
-rw-r--r--ir/lpp/lpp.h3
-rw-r--r--ir/lpp/lpp_comm.c423
-rw-r--r--ir/lpp/lpp_comm.h108
-rw-r--r--ir/lpp/lpp_net.c229
-rw-r--r--ir/lpp/lpp_net.h21
-rw-r--r--ir/lpp/lpp_t.h52
7 files changed, 5 insertions, 1039 deletions
diff --git a/ir/lpp/lpp.c b/ir/lpp/lpp.c
index 1ecb129..c74c171 100644
--- a/ir/lpp/lpp.c
+++ b/ir/lpp/lpp.c
@@ -21,10 +21,7 @@
#include "sp_matrix.h"
#include "mps.h"
-#include "lpp_t.h"
-#include "lpp_comm.h"
#include "lpp_solvers.h"
-#include "lpp_net.h"
#define HASH_NAME_T(n) hash_str((n)->name)
@@ -433,207 +430,10 @@ void lpp_dump_plain(lpp_t *lpp, FILE *f)
fprintf(f, "End\n");
}
-/**
- * Serialize a lpp to a file descriptor.
- * @param comm The file descriptor.
- * @param lpp The lpp.
- */
-void lpp_serialize(lpp_comm_t *comm, const lpp_t *lpp, int with_names)
+void lpp_solve(lpp_t *lpp, const char* solver)
{
- int n, i;
-
- lpp_writel(comm, with_names);
- lpp_writel(comm, lpp->cst_next);
- lpp_writel(comm, lpp->var_next);
- lpp_writel(comm, lpp->opt_type);
- lpp_writes(comm, lpp->name);
-
- /* write options */
- lpp_writel(comm, lpp->set_bound);
- lpp_writed(comm, lpp->bound);
- lpp_writed(comm, lpp->time_limit_secs);
- lpp_writel(comm, lpp->emphasis);
-
- for(i = 0; i < lpp->cst_next; ++i) {
- lpp_name_t *name = lpp->csts[i];
- lpp_writel(comm, name->nr);
- lpp_writel(comm, name->value_kind);
- lpp_writel(comm, name->type.cst_type);
-
- if(with_names)
- lpp_writes(comm, name->name);
- }
-
- for(i = 0; i < lpp->var_next; ++i) {
- lpp_name_t *name = lpp->vars[i];
- lpp_writel(comm, name->nr);
- lpp_writel(comm, name->value_kind);
- lpp_writel(comm, name->type.var_type);
-
- if(with_names)
- lpp_writes(comm, name->name);
- }
-
- n = 0;
- matrix_foreach(lpp->m, elm)
- n++;
-
- assert(n == matrix_get_entries(lpp->m));
- lpp_writel(comm, n);
- matrix_foreach(lpp->m, elm) {
- lpp_writel(comm, elm->row);
- lpp_writel(comm, elm->col);
- lpp_writed(comm, elm->val);
- }
-}
-
-/**
- * Deserialize an lpp from a file descriptor.
- * @param comm The file descriptor.
- * @return The Problem.
- */
-lpp_t *lpp_deserialize(lpp_comm_t *comm)
-{
- int i, n;
- int with_names;
-
- lpp_t *lpp = XMALLOCZ(lpp_t);
-
- /* read general settings */
- with_names = lpp_readl(comm);
- lpp->cst_next = lpp_readl(comm);
- lpp->var_next = lpp_readl(comm);
- lpp->opt_type = (lpp_opt_t)lpp_readl(comm);
- lpp->name = lpp_reads(comm);
-
- /* read options */
- lpp->set_bound = lpp_readl(comm);
- lpp->bound = lpp_readd(comm);
- lpp->time_limit_secs = lpp_readd(comm);
- lpp->emphasis = (lpp_emphasis_t)lpp_readl(comm);
-
- lpp->cst_size = lpp->cst_next;
- lpp->var_size = lpp->var_next;
-
- lpp->cst2nr = new_set(cmp_name_t, lpp->cst_next);
- lpp->var2nr = new_set(cmp_name_t, lpp->var_next);
-
- lpp->csts = XMALLOCNZ(lpp_name_t*, lpp->cst_next);
- lpp->vars = XMALLOCNZ(lpp_name_t*, lpp->var_next);
- lpp->m = new_matrix(lpp->cst_next, lpp->var_next);
-
- for(i = 0; i < lpp->cst_next; ++i) {
- lpp_name_t name, *res;
-
- name.nr = lpp_readl(comm);
- name.value_kind = (lpp_value_kind_t)lpp_readl(comm);
- name.type.cst_type = (lpp_cst_t)lpp_readl(comm);
-
- if(with_names) {
- name.name = lpp_reads(comm);
- } else {
- char* buf = XMALLOCN(char, 32);
- snprintf(buf, 32, "c%d\n", name.nr);
- name.name = buf;
- }
-
- res = set_insert(lpp_name_t, lpp->cst2nr, &name, sizeof(name), HASH_NAME_T(&name));
- lpp->csts[name.nr] = res;
- }
-
- for(i = 0; i < lpp->var_next; ++i) {
- lpp_name_t name, *res;
-
- name.nr = lpp_readl(comm);
- name.value_kind = (lpp_value_kind_t)lpp_readl(comm);
- name.type.var_type = (lpp_var_t)lpp_readl(comm);
-
- if(with_names) {
- name.name = lpp_reads(comm);
- } else {
- char* buf = XMALLOCN(char, 32);
- snprintf(buf, 32, "v%d\n", name.nr);
- name.name = buf;
- }
-
- res = set_insert(lpp_name_t, lpp->var2nr, &name, sizeof(name), HASH_NAME_T(&name));
- lpp->vars[name.nr] = res;
- }
-
- n = lpp_readl(comm);
- for(i = 0; i < n; ++i) {
- matrix_elem_t elm;
- elm.row = lpp_readl(comm);
- elm.col = lpp_readl(comm);
- elm.val = lpp_readd(comm);
- matrix_set(lpp->m, elm.row, elm.col, elm.val);
- }
-
- return lpp;
-}
-
-void lpp_serialize_values(lpp_comm_t *comm, const lpp_t *lpp, lpp_value_kind_t value_kind)
-{
- int i, n;
-
- for(i = 0, n = 0; i < lpp->var_next; ++i)
- n += lpp->vars[i]->value_kind == value_kind;
-
- /* Write the number of values to expect */
- lpp_writel(comm, n);
-
- /* send the values */
- for(i = 0, n = lpp->var_next; i < n; ++i) {
- const lpp_name_t *name = lpp->vars[i];
- if(name->value_kind == value_kind) {
- lpp_writel(comm, name->nr);
- lpp_writed(comm, name->value);
- }
- }
-}
-
-void lpp_deserialize_values(lpp_comm_t *comm, lpp_t *lpp, lpp_value_kind_t value_kind)
-{
- int i, n;
-
- /* Get the number of values to read */
- n = lpp_readl(comm);
-
- for(i = 0; i < n; ++i) {
- int nr = lpp_readl(comm);
- lpp_name_t *name = lpp->vars[nr];
-
- name->value_kind = value_kind;
- name->value = lpp_readd(comm);
- }
-}
-
-void lpp_serialize_stats(lpp_comm_t *comm, const lpp_t *lpp)
-{
- lpp_writel(comm, lpp->sol_state);
- lpp_writel(comm, lpp->iterations);
- lpp_writed(comm, lpp->sol_time);
- lpp_writed(comm, lpp->objval);
- lpp_writed(comm, lpp->best_bound);
-}
-
-void lpp_deserialize_stats(lpp_comm_t *comm, lpp_t *lpp)
-{
- lpp->sol_state = (lpp_sol_state_t)lpp_readl(comm);
- lpp->iterations = lpp_readl(comm);
- lpp->sol_time = lpp_readd(comm);
- lpp->objval = lpp_readd(comm);
- lpp->best_bound = lpp_readd(comm);
-}
-
-void lpp_solve(lpp_t *lpp, const char* host, const char* solver)
-{
- if (host == NULL || strlen(host) == 0) {
- lpp_solver_func_t* f = lpp_find_solver(solver);
- if (f != NULL)
- f(lpp);
- } else {
- lpp_solve_net(lpp, host, solver);
- }
+ lpp_solver_func_t* f = lpp_find_solver(solver);
+ if (f != NULL)
+ f(lpp);
}
diff --git a/ir/lpp/lpp.h b/ir/lpp/lpp.h
index 96371ae..a44a83b 100644
--- a/ir/lpp/lpp.h
+++ b/ir/lpp/lpp.h
@@ -342,9 +342,8 @@ static inline void lpp_unset_bound(lpp_t *lpp)
/**
* Solve an ILP.
* @param lpp The problem.
- * @param host The host to solve on.
* @param solver The solver to use.
*/
-void lpp_solve(lpp_t *lpp, const char* host, const char* solver);
+void lpp_solve(lpp_t *lpp, const char* solver);
#endif
diff --git a/ir/lpp/lpp_comm.c b/ir/lpp/lpp_comm.c
deleted file mode 100644
index 4ea9ce2..0000000
--- a/ir/lpp/lpp_comm.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @brief Protocol stuff for lpp server
- * @author Sebastian Hack
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <winsock2.h>
-#include <BaseTsd.h>
-#ifdef _MSC_VER
-typedef SSIZE_T ssize_t;
-#endif
-#else
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#endif
-
-#include "xmalloc.h"
-#include "util.h"
-#include "debug.h"
-
-#include "lpp_comm.h"
-
-struct _lpp_comm_t {
- int fd;
- size_t buf_size;
- char *w_pos;
- char *r_pos;
- char *r_max;
- char *w_buf;
- char *r_buf;
-};
-
-#ifdef DEBUG_libfirm
-static inline firm_dbg_module_t *get_dbg_module(void)
-{
- static firm_dbg_module_t *dbg = NULL;
- if(!dbg) {
- dbg = firm_dbg_register("lpp.comm");
- }
-
- return dbg;
-}
-#define dbg get_dbg_module()
-#endif
-
-/**
- * Try to read some bytes but block until a certain amount is read.
- * @param fd The file descriptor.
- * @param buf The buffer to read into.
- * @param try_amount The amount of bytes to try to read.
- * @param at_least block until this many bytes are read.
- * @return The number of bytes read or -1 on error.
- */
-static ssize_t secure_recv(int fd, void *buf, size_t try_amount, size_t at_least)
-{
- ssize_t res;
- size_t bytes_read = 0;
- char *data = (char*)buf;
-
- do {
- res = recv(fd, &data[bytes_read], try_amount - bytes_read, 0);
- if(res <= 0) {
- if(res == 0 || errno != EAGAIN)
- return -1;
- continue;
- }
-
- bytes_read += res;
-
- } while(bytes_read < at_least);
-
- return bytes_read;
-}
-
-static ssize_t secure_send(int fd, const void *buf, size_t n)
-{
- ssize_t res;
- size_t bytes_written = 0;
- const char *data = (const char*)buf;
-
- do {
- res = send(fd, &data[bytes_written], n - bytes_written, 0);
- if(res < 0) {
- if(errno != EAGAIN)
- return -1;
- continue;
- }
-
- bytes_written += res;
-
- } while(bytes_written < n);
-
- return n;
-}
-
-static ssize_t lpp_flush_(lpp_comm_t *comm)
-{
- ssize_t res = 0;
- if(comm->w_pos - comm->w_buf > 0) {
- DBG((dbg, LEVEL_1, "flushing %d bytes\n", comm->w_pos - comm->w_buf));
- res = secure_send(comm->fd, comm->w_buf, comm->w_pos - comm->w_buf);
- if(res < 0)
- return res;
-
- comm->w_pos = comm->w_buf;
- }
- return res;
-}
-
-void lpp_flush(lpp_comm_t *comm)
-{
- lpp_flush_(comm);
-}
-
-static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
-{
- assert(comm->w_pos - comm->w_buf >= 0);
-
- DBG((dbg, LEVEL_1, "write of length %d\n", len));
- if(len > 0) {
- size_t free = (comm->w_buf + comm->buf_size) - comm->w_pos;
- size_t copy = MIN(free, len);
- size_t rest = len - copy;
- const char *pos = (const char*)buf;
-
- DBG((dbg, LEVEL_1, "\tfree = %d, copy = %d, rest = %d\n", free, copy, rest));
- if(copy > 0) {
- memcpy(comm->w_pos, pos, copy);
- comm->w_pos += copy;
- pos += copy;
- }
-
- /*
- * Not everything in buf fits into the buffer,
- * so flush the buffer and write the rest.
- */
- if(rest > 0) {
- size_t i;
- size_t n_direct = rest / comm->buf_size;
- size_t last_rest;
-
- if(lpp_flush_(comm) < 0)
- return -1;
-
- for(i = 0; i < n_direct; ++i) {
- if(secure_send(comm->fd, pos, comm->buf_size) < 0)
- return -1;
-
- pos += comm->buf_size;
- }
-
- last_rest = ((const char *) buf + len) - pos;
-
- if(last_rest > 0) {
- assert(last_rest < comm->buf_size);
- assert(comm->w_pos == comm->w_buf);
- memcpy(comm->w_pos, pos, last_rest);
- comm->w_pos += last_rest;
- }
- }
- }
-
- return len;
-}
-
-static ssize_t lpp_read(lpp_comm_t *comm, void *buf, size_t len)
-{
- DBG((dbg, LEVEL_1, "read of length %d\n", len));
- if(len > 0) {
- size_t left = comm->r_max - comm->r_pos;
- size_t copy = MIN(left, len);
- size_t rest = len - copy;
- char *pos = (char*)buf;
-
- DBG((dbg, LEVEL_1, "\tleft = %d, copy = %d, rest = %d\n", left, copy, rest));
- if(copy > 0) {
- memcpy(pos, comm->r_pos, copy);
- pos += copy;
- comm->r_pos += copy;
- }
-
- /* We want to read more than the buffer can provide. */
- if(rest > 0) {
- size_t bs = comm->buf_size;
- size_t n_direct = rest / comm->buf_size;
- size_t i;
- size_t last_rest;
-
- /*
- * The buffer is now completely read, so
- * reset the pointers.
- */
- comm->r_pos = comm->r_buf;
- comm->r_max = comm->r_buf;
-
- for(i = 0; i < n_direct; ++i) {
- if(secure_recv(comm->fd, pos, bs, bs) < 0)
- return -1;
-
- pos += comm->buf_size;
- }
-
- last_rest = ((const char *) buf + len) - pos;
-
- if(last_rest > 0) {
- ssize_t bytes_read = 0;
-
- assert(last_rest < comm->buf_size);
- assert(comm->r_pos == comm->r_buf);
-
- bytes_read = secure_recv(comm->fd, comm->r_buf, bs, last_rest);
- if(bytes_read < 0)
- return -1;
-
- memcpy(pos, comm->r_buf, last_rest);
- comm->r_pos = comm->r_buf + last_rest;
- comm->r_max = comm->r_buf + bytes_read;
- }
- }
- }
-
- return len;
-}
-
-lpp_comm_t *lpp_comm_new(int fd, size_t buf_size)
-{
- lpp_comm_t *res = XMALLOCZ(lpp_comm_t);
-
- res->fd = fd;
- res->w_buf = XMALLOCN(char, buf_size);
- res->w_pos = res->w_buf;
- res->r_buf = XMALLOCN(char, buf_size);
- res->r_pos = res->r_buf;
- res->r_max = res->r_buf;
- res->buf_size = buf_size;
-
- return res;
-}
-
-int lpp_comm_fileno(const lpp_comm_t *comm)
-{
- return comm->fd;
-}
-
-void lpp_comm_free(lpp_comm_t *comm)
-{
- free(comm->w_buf);
- free(comm->r_buf);
- free(comm);
-}
-
-void lpp_print_err(const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
-}
-
-void lpp_writel(lpp_comm_t *comm, uint32_t x)
-{
- x = htonl(x);
- ERRNO_CHECK(lpp_write(comm, &x, sizeof(x)), !=, (ssize_t)sizeof(x));
-}
-
-void lpp_writed(lpp_comm_t *comm, double dbl)
-{
- ERRNO_CHECK(lpp_write(comm, &dbl, sizeof(dbl)), !=, (ssize_t)sizeof(dbl));
-}
-
-void lpp_writes(lpp_comm_t *comm, const char *str)
-{
- size_t n = strlen(str);
- lpp_writel(comm, n);
- ERRNO_CHECK(lpp_write(comm, str, n), !=, (ssize_t) n);
-}
-
-uint32_t lpp_readl(lpp_comm_t *comm)
-{
- uint32_t res;
-
- ERRNO_CHECK(lpp_read(comm, &res, sizeof(res)), !=, (ssize_t)sizeof(res));
- return ntohl(res);
-}
-
-int lpp_read_cmd(lpp_comm_t *comm)
-{
- uint32_t res = 0;
- int retval;
-
- for(;;) {
- retval = recv(comm->fd, (char *)&res, sizeof(res), 0);
- if(retval < 0) {
- if(errno != EAGAIN)
- return -1;
- }
-
- else
- break;
- }
-
- return (int) ntohl(res);
-}
-
-double lpp_readd(lpp_comm_t *comm)
-{
- double res;
- ERRNO_CHECK(lpp_read(comm, &res, sizeof(res)), !=, (ssize_t)sizeof(res));
- return res;
-}
-
-char *lpp_reads(lpp_comm_t *comm)
-{
- size_t len = lpp_readl(comm);
- char *res = XMALLOCN(char, len+1);
-
- ERRNO_CHECK(lpp_read(comm, res, len), !=, (ssize_t) len);
- res[len] = '\0';
- return res;
-}
-
-char *lpp_readbuf(lpp_comm_t *comm, char *buf, size_t buflen)
-{
- char dummy[1024];
- size_t i;
- size_t n = buflen - 1;
- size_t len = lpp_readl(comm);
- size_t max_read = MIN(n, len);
- size_t rest = len - max_read;
-
- if(buflen > 0 && buf != NULL) {
- ERRNO_CHECK(lpp_read(comm, buf, max_read), !=, (ssize_t) max_read);
- buf[max_read] = '\0';
- }
- else
- rest = len;
-
- /* eat up data that didnt fit into the string */
- for(i = 0, n = rest / sizeof(dummy); i < n; ++i)
- ERRNO_CHECK(lpp_read(comm, dummy, sizeof(dummy)), !=, (ssize_t)sizeof(dummy));
-
- if(rest % sizeof(dummy) > 0)
- ERRNO_CHECK(lpp_read(comm, dummy, rest % sizeof(dummy)), !=,
- (ssize_t) (rest % sizeof(dummy)) );
-
- return buf;
-}
-
-int lpp_ack(lpp_comm_t *comm, char *buf, size_t buflen)
-{
- int res = 0;
- int cmd = lpp_readl(comm);
-
- switch (cmd) {
- case LPP_CMD_OK:
- res = 1;
- break;
- case LPP_CMD_BAD:
- lpp_readbuf(comm, buf, buflen);
- default:
- res = 0;
- }
-
- return res;
-}
-
-void lpp_send_res(lpp_comm_t *comm, int ok, const char *fmt, ...)
-{
- if(!ok) {
- char buf[1024];
- va_list args;
-
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
-
- lpp_writel(comm, LPP_CMD_BAD);
- lpp_writes(comm, buf);
- } else {
- lpp_writel(comm, LPP_CMD_OK);
- }
-}
-
-void lpp_send_ack(lpp_comm_t *comm)
-{
- lpp_send_res(comm, 1, "");
-}
-
-const char *lpp_get_cmd_name(int cmd)
-{
- switch (cmd) {
- case LPP_CMD_BAD: return "BAD";
- case LPP_CMD_OK: return "OK";
- case LPP_CMD_PROBLEM: return "PROBLEM";
- case LPP_CMD_SOLUTION: return "SOLUTION";
- case LPP_CMD_SOLVER: return "SOLVER";
- case LPP_CMD_BYE: return "BYE";
- case LPP_CMD_SOLVERS: return "SOLVERS";
- case LPP_CMD_SET_DEBUG: return "SET_DEBUG";
- case LPP_CMD_INFO: return "INFO";
- case LPP_CMD_LAST:
- break;
- }
-
- return "<unknown>";
-}
diff --git a/ir/lpp/lpp_comm.h b/ir/lpp/lpp_comm.h
deleted file mode 100644
index 26e8a0b..0000000
--- a/ir/lpp/lpp_comm.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @author Sebastian Hack
- */
-#ifndef LPP_LPP_COMM_H
-#define LPP_LPP_COMM_H
-
-#include <stdio.h>
-#include <stdint.h>
-
-#define LPP_PORT 2175
-#define LPP_BUFSIZE (1 << 20)
-
-enum {
- LPP_CMD_BAD,
- LPP_CMD_OK,
- LPP_CMD_PROBLEM,
- LPP_CMD_SOLUTION,
- LPP_CMD_SOLVER,
- LPP_CMD_BYE,
- LPP_CMD_SOLVERS,
- LPP_CMD_SET_DEBUG,
- LPP_CMD_INFO,
- LPP_CMD_LAST
-};
-
-#define BASIC_ERR_CHECK(expr,op,cond,fmt,last) \
-do { \
- int err_check_res; \
- if((err_check_res = (expr)) op cond) { \
- fprintf(stderr, "%s(%u): %d = %s(%d): ", \
- __FILE__, (unsigned) __LINE__, err_check_res, #expr, cond); \
- lpp_print_err fmt; \
- fprintf(stderr, "\n"); \
- last; \
- } \
-} while(0)
-
-#define BASIC_ERRNO_CHECK(expr,op,cond,last) \
-do { \
- int _basic_errno_check_res = (expr); \
- if(_basic_errno_check_res op cond) { \
- fprintf(stderr, "%s(%u): %d = %s(%d): %s\n", \
- __FILE__, (unsigned) __LINE__, _basic_errno_check_res, #expr, (int) cond, strerror(errno)); \
- last; \
- } \
-} while(0)
-
-#define ERR_CHECK_RETURN(expr, op, cond, fmt, retval) \
- BASIC_ERR_CHECK(expr, op, cond, fmt, return retval)
-
-#define ERRNO_CHECK_RETURN(expr, op, cond, retval) \
- BASIC_ERRNO_CHECK(expr, op, cond, return retval)
-
-#define ERR_CHECK_RETURN_VOID(expr, op, cond, fmt) \
- BASIC_ERR_CHECK(expr, op, cond, fmt, return)
-
-#define ERRNO_CHECK_RETURN_VOID(expr, op, cond) \
- BASIC_ERRNO_CHECK(expr, op, cond, return)
-
-#define ERR_CHECK(expr, op, cond, fmt) \
- BASIC_ERR_CHECK(expr, op, cond, fmt, (void) 0)
-
-#define ERRNO_CHECK(expr, op, cond) \
- BASIC_ERRNO_CHECK(expr, op, cond, (void) 0)
-
-typedef struct _lpp_comm_t lpp_comm_t;
-
-lpp_comm_t *lpp_comm_new(int fd, size_t buf_size);
-
-int lpp_comm_fileno(const lpp_comm_t *comm);
-
-void lpp_flush(lpp_comm_t *comm);
-
-void lpp_comm_free(lpp_comm_t *comm);
-
-void lpp_print_err(const char *fmt, ...);
-
-void lpp_writel(lpp_comm_t *comm, uint32_t x);
-
-void lpp_writed(lpp_comm_t *comm, double dbl);
-
-void lpp_writes(lpp_comm_t *comm, const char *str);
-
-uint32_t lpp_readl(lpp_comm_t *comm);
-
-int lpp_read_cmd(lpp_comm_t *comm);
-
-double lpp_readd(lpp_comm_t *comm);
-
-char *lpp_reads(lpp_comm_t *comm);
-
-char *lpp_readbuf(lpp_comm_t *comm, char *buf, size_t buflen);
-
-int lpp_ack(lpp_comm_t *comm, char *buf, size_t buflen);
-
-void lpp_send_res(lpp_comm_t *comm, int ok, const char *fmt, ...);
-
-void lpp_send_ack(lpp_comm_t *comm);
-
-const char *lpp_get_cmd_name(int cmd);
-
-#endif
diff --git a/ir/lpp/lpp_net.c b/ir/lpp/lpp_net.c
deleted file mode 100644
index e8be459..0000000
--- a/ir/lpp/lpp_net.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @brief A client for an lpp solving server.
- * @author Sebastian Hack
- */
-#ifdef _WIN32
-#include <winsock.h>
-#include <io.h>
-
-#else
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-
-/* solaris fix */
-#ifndef INADDR_NONE
-#define INADDR_NONE (in_addr_t)(-1)
-#endif
-
-#endif
-
-
-#include <signal.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "timing.h"
-
-#include "lpp_net.h"
-#include "lpp_t.h"
-#include "lpp_comm.h"
-#include "xmalloc.h"
-
-#ifdef _WIN32
-static int winsock_init(void)
-{
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
-
- wVersionRequested = MAKEWORD( 2, 2 );
-
- err = WSAStartup( wVersionRequested, &wsaData );
- if ( err != 0 ) {
- /* Tell the user that we could not find a usable */
- /* WinSock DLL. */
- return 0;
- }
-
- /* Confirm that the WinSock DLL supports 2.2.*/
- /* Note that if the DLL supports versions greater */
- /* than 2.2 in addition to 2.2, it will still return */
- /* 2.2 in wVersion since that is the version we */
- /* requested. */
-
- if ( LOBYTE( wsaData.wVersion ) != 2 ||
- HIBYTE( wsaData.wVersion ) != 2 ) {
- /* Tell the user that we could not find a usable */
- /* WinSock DLL. */
- WSACleanup( );
- return 0;
- }
- return 1;
-}
-#endif
-
-static int connect_tcp(const char *host, uint16_t port)
-{
- struct hostent *phe;
- struct protoent *ppe;
- struct sockaddr_in sin;
- int s;
-
-#ifdef _WIN32
- winsock_init();
-#endif
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_port = htons(port);
-
- if ((phe = gethostbyname(host))) {
- memcpy(&sin.sin_addr, phe->h_addr_list[0], phe->h_length);
- } else if ((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
- lpp_print_err("cannot get host entry for %s", host);
- return -1;
- }
-
- ppe = getprotobyname("tcp");
- ERRNO_CHECK_RETURN(s = socket(PF_INET, SOCK_STREAM, ppe->p_proto), <, 0, -1);
- ERRNO_CHECK_RETURN(connect(s, (struct sockaddr *) &sin, sizeof(sin)), <, 0, -1);
-
- return s;
-}
-
-char **lpp_get_solvers(const char *host)
-{
- int fd, n;
- char **res = NULL;
- lpp_comm_t *comm;
-
- ERR_CHECK_RETURN(fd = connect_tcp(host, LPP_PORT), <, 0,
- ("could not connect to %s", host), NULL);
-
- comm = lpp_comm_new(fd, LPP_BUFSIZE);
-
- lpp_writel(comm, LPP_CMD_SOLVERS);
- lpp_flush(comm);
- n = lpp_readl(comm);
- res = XMALLOCN(char*, n+1);
- res[n] = NULL;
-
- if(n > 0) {
- int i;
- for(i = 0; i < n; ++i)
- res[i] = lpp_reads(comm);
- }
-
- lpp_writel(comm, LPP_CMD_BYE);
- lpp_flush(comm);
- lpp_comm_free(comm);
- close(fd);
- return res;
-}
-
-void lpp_set_dbg(const char *host, int mask)
-{
- int fd;
- lpp_comm_t *comm;
-
- ERR_CHECK_RETURN_VOID(fd = connect_tcp(host, LPP_PORT), <, 0, ("could not connect to %s", host));
-
- comm = lpp_comm_new(fd, LPP_BUFSIZE);
-
- lpp_writel(comm, LPP_CMD_SET_DEBUG);
- lpp_writel(comm, mask);
- lpp_flush(comm);
- lpp_writel(comm, LPP_CMD_BYE);
- lpp_flush(comm);
- lpp_comm_free(comm);
- close(fd);
-}
-
-void lpp_solve_net(lpp_t *lpp, const char *host, const char *solver)
-{
- char buf[1024];
- int n, fd, ready;
- lpp_comm_t *comm;
- ir_timer_t *t_send, *t_recv;
-
- ERR_CHECK_RETURN_VOID(fd = connect_tcp(host, LPP_PORT), <, 0,
- ("could not connect to %s", host));
-
- comm = lpp_comm_new(fd, LPP_BUFSIZE);
-
- /* Set the solver */
- lpp_writel(comm, LPP_CMD_SOLVER);
- lpp_writes(comm, solver);
- lpp_flush(comm);
-
- t_send = ir_timer_new();
- t_recv = ir_timer_new();
-
- ir_timer_start(t_send);
- lpp_writel(comm, LPP_CMD_PROBLEM);
- lpp_serialize(comm, lpp, 1);
- lpp_serialize_values(comm, lpp, lpp_value_start);
- lpp_flush(comm);
- ir_timer_stop(t_send);
- lpp->send_time = ir_timer_elapsed_usec(t_send);
-
- ready = 0;
- while (! ready) {
- int cmd = lpp_readl(comm);
- switch (cmd) {
- case LPP_CMD_SOLUTION:
- ir_timer_push(t_recv);
- lpp_deserialize_stats(comm, lpp);
- lpp_deserialize_values(comm, lpp, lpp_value_solution);
- ir_timer_stop(t_recv);
- lpp->recv_time = ir_timer_elapsed_usec(t_recv);
- ready = 1;
- break;
- case LPP_CMD_INFO:
- lpp_readbuf(comm, buf, sizeof(buf));
- buf[sizeof(buf) - 1] = '\0';
-
- if(lpp->log != NULL) {
- fputs(buf, lpp->log);
- n = strlen(buf);
- if(buf[n - 1] != '\n')
- putc('\n', lpp->log);
- fflush(lpp->log);
- }
- break;
- case LPP_CMD_BAD:
- fprintf(stderr, "solver process died unexpectedly\n");
- goto end;
- default:
- fprintf(stderr, "invalid command: %s(%d)\n", lpp_get_cmd_name(cmd), cmd);
- return;
- }
- }
-
- lpp_writel(comm, LPP_CMD_BYE);
- lpp_flush(comm);
-
-end:
- lpp_comm_free(comm);
-#ifdef _WIN32
- closesocket(fd);
-#else
- close(fd);
-#endif
-}
diff --git a/ir/lpp/lpp_net.h b/ir/lpp/lpp_net.h
deleted file mode 100644
index 2bb6c52..0000000
--- a/ir/lpp/lpp_net.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @author Sebastian Hack
- */
-#ifndef LPP_LPP_NET_H
-#define LPP_LPP_NET_H
-
-#include "lpp.h"
-
-char **lpp_get_solvers(const char *host);
-
-void lpp_set_dbg(const char *host, int mask);
-
-void lpp_solve_net(lpp_t *lpp, const char *host, const char *solver);
-
-#endif
diff --git a/ir/lpp/lpp_t.h b/ir/lpp/lpp_t.h
deleted file mode 100644
index 7b32d95..0000000
--- a/ir/lpp/lpp_t.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @author Sebastian Hack
- */
-#ifndef LPP_LPP_T_H
-#define LPP_LPP_T_H
-
-#include "lpp.h"
-#include "lpp_comm.h"
-
-/**
- * Serialize a lpp to a file descriptor.
- * @param comm The file descriptor.
- * @param lpp The lpp.
- * @param with_names Also send the names of constraints/variables.
- */
-void lpp_serialize(lpp_comm_t *comm, const lpp_t *lpp, int with_names);
-
-/**
- * Deserialize an lpp from a file descriptor.
- * @param comm The file descriptor.
- * @param with_names Also receive names of constraints/variables.
- * @return The Problem.
- */
-lpp_t *lpp_deserialize(lpp_comm_t *comm);
-
-/**
- * Serialize values of the lpps for a given value kind.
- * This function only serializes values of the given kind.
- * @param fd The file descriptor to serialize to.
- * @param lpp The problem.
- * @param kind The value kind.
- */
-void lpp_serialize_values(lpp_comm_t *comm, const lpp_t *lpp, lpp_value_kind_t kind);
-
-/**
- * Desrialize values from a stream.
- * @param fd The file descriptor to read from.
- * @param lpp The problem to set the values.
- * @param kind The value kind the values shall be assigned.
- */
-void lpp_deserialize_values(lpp_comm_t *comm, lpp_t *lpp, lpp_value_kind_t kind);
-
-void lpp_serialize_stats(lpp_comm_t *comm, const lpp_t *lpp);
-void lpp_deserialize_stats(lpp_comm_t *comm, lpp_t *lpp);
-
-#endif