diff --git a/go/pserver/cclient/cclient.go b/go/pserver/cclient/cclient.go index 662e92542775ac777a035f5587a4c4c458d8e7a0..be16a143d8ec4f54b9525d8d2941d4e8307336b6 100644 --- a/go/pserver/cclient/cclient.go +++ b/go/pserver/cclient/cclient.go @@ -42,6 +42,7 @@ import ( "strings" "sync" "unsafe" + "fmt" "github.com/PaddlePaddle/Paddle/go/pserver" ) @@ -204,12 +205,14 @@ func paddle_get_params(client C.client, names **C.char, dst **C.paddle_parameter } p := ps[i] - param := *(**C.paddle_parameter)(unsafe.Pointer((uintptr(unsafe.Pointer(dst)) + uintptr(i)*unsafe.Sizeof(*dst)))) + paramPtr := (**C.paddle_parameter)(unsafe.Pointer((uintptr(unsafe.Pointer(dst)) + uintptr(i)*unsafe.Sizeof(*dst)))) + param := *paramPtr nameReady := false contentAllocated := false if unsafe.Pointer(param) == nullPtr { - param = (*C.paddle_parameter)(C.calloc(1, C.size_t(unsafe.Sizeof(*param)))) + *paramPtr = (*C.paddle_parameter)(C.calloc(1, C.size_t(unsafe.Sizeof(*param)))) + param = *paramPtr } else { if unsafe.Pointer(param.name) != nullPtr { if n := C.GoString(param.name); n != p.Name { diff --git a/go/pserver/cclient/test/main.c b/go/pserver/cclient/test/main.c index 10391393070b47f35b98977e087f82f486aef176..59cf5756fde34dd0720a919ca67450156f3f3665 100644 --- a/go/pserver/cclient/test/main.c +++ b/go/pserver/cclient/test/main.c @@ -21,7 +21,7 @@ void print_parameter(paddle_gradient* param) { for (int i = 0; i < param->content_len; ++i) { printf("0x%x ", param->content[i]); } - printf("\n"); + printf("\n\n"); } } @@ -33,17 +33,18 @@ retry: paddle_parameter param; char name_a[] = "param_a"; char name_b[] = "param_b"; - unsigned char content[] = {0x00, 0x00, 0x00}; + unsigned char content1[] = {0x01, 0x02, 0x03}; param.element_type = PADDLE_ELEMENT_TYPE_FLOAT32; param.name = name_a; - param.content = content; + param.content = content1; param.content_len = 3; if (paddle_init_param(c, param, NULL, 0) != 0) { goto retry; } + unsigned char content2[] = {0x04, 0x05, 0x06}; param.element_type = PADDLE_ELEMENT_TYPE_INT32; param.name = name_b; - param.content = content; + param.content = content2; param.content_len = 3; if (paddle_init_param(c, param, NULL, 0) != 0) { goto retry; diff --git a/go/pserver/service.go b/go/pserver/service.go index d5787b9708bb15629a6e6290ffc97ee9885bc8b8..ab814662b6bf783f9336264834781f3881e10c1e 100644 --- a/go/pserver/service.go +++ b/go/pserver/service.go @@ -29,6 +29,10 @@ type Parameter struct { Content []byte } +func (p *Parameter) toString() { + fmt.Println(p.Name, p.ElementType, p.Content) +} + // ParameterWithConfig contains the parameter and the configuration. type ParameterWithConfig struct { Param Parameter diff --git a/paddle/trainer/NewRemoteParameterUpdater.h b/paddle/trainer/NewRemoteParameterUpdater.h index ed82de3f99f06d0559b159970e59c54297334a06..1dbb3658fbe771067e8c7f6eb96b0a3d5dec65cf 100644 --- a/paddle/trainer/NewRemoteParameterUpdater.h +++ b/paddle/trainer/NewRemoteParameterUpdater.h @@ -33,8 +33,8 @@ public: const std::string pserverSpec); ~NewRemoteParameterUpdater() { LOG(INFO) << "~NewRemoteParameterUpdater in"; - releaseNewParameter(newParameters_); - releaseNewParameter(newGradients_); +// releaseNewParameter(newParameters_); +// releaseNewParameter(newGradients_); if (parameterClient_ >= 0) paddle_pserver_client_release(parameterClient_); }