compatibility issue with openmp

This commit is contained in:
tqchen 2014-03-03 15:11:41 -08:00
parent e3b7abfb47
commit 2aa1978cb6
6 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,6 @@
export CC = gcc
export CXX = g++
export CFLAGS = -Wall -O3 -msse2 -fopenmp
export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas
# specify tensor path
BIN = xgboost

View File

@ -7,9 +7,9 @@
* \author Tianqi Chen: tianqi.tchen@gmail.com
*/
// use openmp
#include <omp.h>
#include <vector>
#include "xgboost_tree_model.h"
#include "../../utils/xgboost_omp.h"
#include "../../utils/xgboost_random.h"
namespace xgboost{

View File

@ -1,9 +1,9 @@
#ifndef XGBOOST_GBMBASE_H
#define XGBOOST_GBMBASE_H
#include <omp.h>
#include <cstring>
#include "xgboost.h"
#include "../utils/xgboost_omp.h"
#include "../utils/xgboost_config.h"
/*!
* \file xgboost_gbmbase.h

View File

@ -8,9 +8,9 @@
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <omp.h>
#include "xgboost_reg_data.h"
#include "xgboost_reg_eval.h"
#include "../utils/xgboost_omp.h"
#include "../booster/xgboost_gbmbase.h"
#include "../utils/xgboost_utils.h"
#include "../utils/xgboost_stream.h"

View File

@ -5,11 +5,12 @@
* \brief evaluation metrics for regression and classification
* \author Kailong Chen: chenkl198812@gmail.com, Tianqi Chen: tianqi.tchen@gmail.com
*/
#include <omp.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include "../utils/xgboost_utils.h"
#include "../utils/xgboost_omp.h"
namespace xgboost{
namespace regression{

18
utils/xgboost_omp.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef XGBOOST_OMP_H
#define XGBOOST_OMP_H
/*!
* \file xgboost_omp.h
* \brief header to handle OpenMP compatibility issues
*
* \author Tianqi Chen: tianqi.tchen@gmail.com
*/
#if defined(_OPENMP)
#include <omp.h>
#else
#warning "OpenMP is not available, compile to single thread code"
inline int omp_get_thread_num() { return 0; }
inline int omp_get_num_threads() { return 1; }
inline void omp_set_num_threads( int nthread ) {}
#endif
#endif