Commit d4bb818a authored by Damien Leroux's avatar Damien Leroux
Browse files

Fixing compilation and SGE behaviour on cluster.

parent e96ae544
......@@ -14,13 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.0)
project(spell_qtl)
#LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
#INCLUDE(pandocology)
find_package(Boost 1.57.0 REQUIRED)
find_package(Boost 1.55.0 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE TYPE INTERNAL FORCE)
......@@ -55,7 +55,7 @@ LIST(GET VERSION 1 VERSION_MINOR)
set(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -Wno-unused-parameter -pthread -fPIC")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG -DEIGEN_NO_DEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG -DEIGEN_NO_DEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -ggdb")
add_definitions(-DEIGEN_NO_DEPRECATED_WARNING -DVERSION_MAJOR=\"${VERSION_MAJOR}\" -DVERSION_MINOR=\"${VERSION_MINOR}\" -DVERSION_PATCH=\"${VERSION_PATCH}\")
......@@ -187,4 +187,4 @@ SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_GENERATOR "DEB;STGZ")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Damien Leroux <damien.leroux@inra.fr>")
INCLUDE(CPack)
\ No newline at end of file
INCLUDE(CPack)
......@@ -69,11 +69,37 @@ struct worker_local_sge : public worker_base {
using worker_base::worker_base;
void notify_one(size_t i, bool ok)
{
FILE* fifo = fopen(m_settings->fifo_path.c_str(), "w");
MSG_INFO("Opening FIFO for notification. " << m_settings->fifo_path.c_str());
MSG_QUEUE_FLUSH();
int fifo = open(m_settings->fifo_path.c_str(), O_WRONLY | O_NONBLOCK);
if (errno) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
MSG_QUEUE_FLUSH();
} else {
MSG_INFO("Sending notification.");
MSG_QUEUE_FLUSH();
std::string msg = MESSAGE((ok ? "\fS " : "\fF ") << i << std::endl);
write(fifo, msg.c_str(), msg.size());
if (errno) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
MSG_QUEUE_FLUSH();
}
close(fifo);
}
/*
FILE* fifo = fopen(m_settings->fifo_path.c_str(), "a");
if (!fifo || errno) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
}
std::string msg = MESSAGE((ok ? "\fS " : "\fF ") << i << std::endl);
fwrite(msg.c_str(), msg.size(), 1, fifo);
if (ferror(fifo)) {
MSG_ERROR("An error occurred while trying to notify the master process: " << strerror(errno), "");
}
fflush(fifo);
fclose(fifo);
*/
MSG_INFO("Done notifying.");
}
void join() {}
};
......@@ -426,15 +452,18 @@ void reader(int)
{
#define BUFSZ 64
char buf[BUFSZ];
MSG_DEBUG("entering reader");
/*while((n = read(master_sge::fifo, buf, sizeof buf)) > 0){*/
while(fgets(buf, sizeof buf - 1, master_sge::fifo) != NULL) {
/*buf[BUFSZ - 1] = '\0';*/
buf[BUFSZ - 1] = '\0';
MSG_DEBUG("read " << buf);
if (buf[0] == '\f') {
if (buf[1] == 'F' || buf[1] == 'S') {
global_msge->notify(atoi(buf + 3), buf[1] == 'S');
}
}
}
MSG_DEBUG("exiting reader");
}
} // extern "C"
......@@ -464,9 +493,11 @@ bool do_the_job(bn_settings_t* settings, std::string job)
sighandler_t old_sigio = signal(SIGIO, reader);
mknod(settings->fifo_path.c_str(), 0666 | S_IFIFO,0);
int fd = open(settings->fifo_path.c_str(), O_RDONLY | O_NONBLOCK);
MSG_DEBUG("fd=" << fd);
fcntl(fd, F_SETOWN, getpid());
fcntl(fd, F_SETFL, O_ASYNC);
master_sge::fifo = fdopen(fd, "r");
MSG_DEBUG("fifo=" << master_sge::fifo);
master_sge msge(settings, job);
global_msge = &msge;
......
......@@ -42,6 +42,8 @@ int main(int argc, const char** argv)
if (!settings) {
print_usage();
} else {
std::vector<std::string> cli(argv, argv + argc);
MSG_INFO("Commandline: " << cli);
settings->pedigree_filename = settings->work_directory + "/" + settings->pop_name + ".cache/" + settings->pop_name + ".spell-pedigree.data";
if (!check_file(settings->pedigree_filename, false, false)) {
MSG_ERROR("Couldn'f find the spell-pedigree output file.", "Please run spell-pedigree first with the same name and work_directory parameters.");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment