From a42abb2194a6e6eec3a1df53eb1f18c4ae559965 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 17 May 2014 11:03:21 -0700 Subject: [PATCH 1/3] force handle as void_p, seems fix mac problem --- python/Makefile | 6 +++--- python/xgboost.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/Makefile b/python/Makefile index f21957a2e40c..612513a93b8b 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,6 +1,6 @@ -export CC = gcc -export CXX = g++ -export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fopenmp +export CC = clang +export CXX = clang++ +export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas # -fopenmp # specify tensor path SLIB = libxgboostpy.so diff --git a/python/xgboost.py b/python/xgboost.py index 3be5a2b066e5..f51ef7ea59fc 100644 --- a/python/xgboost.py +++ b/python/xgboost.py @@ -36,7 +36,8 @@ def ctypes2numpy( cptr, length ): class DMatrix: # constructor def __init__(self, data=None, label=None, missing=0.0, weight = None): - self.handle = xglib.XGDMatrixCreate() + # force into void_p, mac need to pass things in as void_p + self.handle = ctypes.c_void_p( xglib.XGDMatrixCreate() ) if data == None: return if isinstance(data,str): @@ -118,8 +119,8 @@ def __init__(self, params={}, cache=[]): """ constructor, param: """ for d in cache: assert isinstance(d,DMatrix) - dmats = ( ctypes.c_void_p * len(cache) )(*[ ctypes.c_void_p(d.handle) for d in cache]) - self.handle = xglib.XGBoosterCreate( dmats, len(cache) ) + dmats = ( ctypes.c_void_p * len(cache) )(*[ d.handle for d in cache]) + self.handle = ctypes.c_void_p( xglib.XGBoosterCreate( dmats, len(cache) ) ) self.set_param( params ) def __del__(self): xglib.XGBoosterFree(self.handle) @@ -154,7 +155,7 @@ def eval_set(self, evals, it = 0): for d in evals: assert isinstance(d[0], DMatrix) assert isinstance(d[1], str) - dmats = ( ctypes.c_void_p * len(evals) )(*[ ctypes.c_void_p(d[0].handle) for d in evals]) + dmats = ( ctypes.c_void_p * len(evals) )(*[ d[0].handle for d in evals]) evnames = ( ctypes.c_char_p * len(evals) )(*[ ctypes.c_char_p(d[1]) for d in evals]) xglib.XGBoosterEvalOneIter( self.handle, it, dmats, evnames, len(evals) ) def eval(self, mat, name = 'eval', it = 0 ): From 9e436f4bf3cdc9c3f3e41980394867ae9bba3191 Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 17 May 2014 11:06:36 -0700 Subject: [PATCH 2/3] use back g++ --- python/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/Makefile b/python/Makefile index 612513a93b8b..0d98f9019926 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,5 +1,5 @@ -export CC = clang -export CXX = clang++ +export CC = gcc +export CXX = g++ export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas # -fopenmp # specify tensor path From 5275b125bde3dae108b84e3b256dee8f2b5b5bcc Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 17 May 2014 11:07:12 -0700 Subject: [PATCH 3/3] add omp flag back --- python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/Makefile b/python/Makefile index 0d98f9019926..76dfdcf01302 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,6 +1,6 @@ export CC = gcc export CXX = g++ -export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas # -fopenmp +export CFLAGS = -Wall -O3 -msse2 -Wno-unknown-pragmas -fopenmp # specify tensor path SLIB = libxgboostpy.so